Fix some compile errors

This commit is contained in:
eraden 2021-10-14 22:42:42 +02:00
parent dc977891de
commit fd4e04647e
9 changed files with 75 additions and 40 deletions

View File

@ -34,7 +34,7 @@ pub fn view(model: &model::Model, modal: &Model) -> Node<Msg> {
}
fn warning(model: &model::Model, modal: &Model) -> Node<Msg> {
let issues: Vec<Node<Msg>> = modal
let issues = modal
.related_issues
.iter()
.flat_map(|id| model.issues_by_id.get(id))
@ -48,12 +48,11 @@ fn warning(model: &model::Model, modal: &Model) -> Node<Msg> {
issue.title.as_str()
]
]]
})
.collect();
});
let close = StyledButton {
text: Some("Close"),
on_click: Some(mouse_ev("click", move |ev| {
on_click: Some(mouse_ev(Ev::Click, move |ev| {
ev.stop_propagation();
ev.prevent_default();
Msg::ModalDropped

View File

@ -27,14 +27,14 @@ impl Model {
};
let related_issues = model
.issues()
.issue_ids
.iter()
.filter_map(|issue| {
if issue.epic_id == Some(epic_id) {
Some(issue.id)
} else {
None
}
.filter_map(|id| {
model
.issues_by_id
.get(id)
.filter(|issue| issue.epic_id == Some(epic_id))
.map(|issue| issue.id)
})
.collect();
Self {

View File

@ -16,8 +16,12 @@ impl EpicsPage {
}
pub fn build_issues_per_epic(model: &Model) -> HashMap<EpicId, Vec<IssueId>> {
model.issues().iter().fold(
HashMap::with_capacity(model.issues().len()),
model
.issue_ids
.iter()
.filter_map(|id| model.issues_by_id.get(id))
.fold(
HashMap::with_capacity(model.issue_ids.len()),
|mut h, issue| {
if let Some(epic_id) = issue.epic_id.as_ref() {
h.entry(*epic_id).or_default().push(issue.id);

View File

@ -20,8 +20,14 @@ pub struct IssuesAndFiltersPage {
impl IssuesAndFiltersPage {
pub fn new(model: &model::Model) -> Self {
let jql = Jql::default();
let visible_issues = Self::visible_issues(model.issues(), &jql);
let active_id = model.issues().first().as_ref().map(|issue| issue.id);
let visible_issues = Self::visible_issues(
model
.issue_ids
.iter()
.filter_map(|id| model.issues_by_id.get(id)),
&jql,
);
let active_id = model.issue_ids.first().copied();
Self {
visible_issues,
@ -34,9 +40,11 @@ impl IssuesAndFiltersPage {
}
}
pub fn visible_issues(issues: &[Issue], jql: &Jql) -> Vec<IssueId> {
pub fn visible_issues<'l, IssueStream>(issues: IssueStream, jql: &Jql) -> Vec<IssueId>
where
IssueStream: std::iter::Iterator<Item = &'l Issue>,
{
issues
.iter()
.filter(|issue| jql.is_visible(issue))
.map(|issue| issue.id)
.collect()

View File

@ -37,15 +37,24 @@ pub fn update(msg: Msg, model: &mut crate::model::Model, orders: &mut impl Order
.jql
.remove_from(idx);
let issues = super::IssuesAndFiltersPage::visible_issues(
model.issues(),
model
.issue_ids
.iter()
.filter_map(|id| model.issues_by_id.get(id)),
&crate::match_page!(model, IssuesAndFilters).jql,
);
crate::match_page_mut!(model, IssuesAndFilters).visible_issues = issues;
}
Msg::ResourceChanged(ResourceKind::Issue, OperationKind::ListLoaded, _) => {
let jql = &match_page!(model, IssuesAndFilters).jql;
let issues = super::IssuesAndFiltersPage::visible_issues(model.issues(), jql);
let first_id = model.issues().first().as_ref().map(|issue| issue.id);
let issues = super::IssuesAndFiltersPage::visible_issues(
model
.issue_ids
.iter()
.filter_map(|id| model.issues_by_id.get(id)),
jql,
);
let first_id = model.issue_ids.first().copied();
let page = crate::match_page_mut!(model, IssuesAndFilters);
if page.active_id.is_none() {
page.active_id = first_id;
@ -56,7 +65,7 @@ pub fn update(msg: Msg, model: &mut crate::model::Model, orders: &mut impl Order
crate::match_page_mut!(model, IssuesAndFilters).active_id = Some(id);
}
Msg::SetActiveIssue(None) => {
let first_id = model.issues().first().as_ref().map(|issue| issue.id);
let first_id = model.issue_ids.first().copied();
crate::match_page_mut!(model, IssuesAndFilters).active_id = first_id;
}
Msg::StyledSelectChanged(
@ -114,7 +123,10 @@ pub fn update(msg: Msg, model: &mut crate::model::Model, orders: &mut impl Order
page.current_jql_part.reset();
page.current_jql_part.opened = true;
let issues = super::IssuesAndFiltersPage::visible_issues(
model.issues(),
model
.issue_ids
.iter()
.filter_map(|id| model.issues_by_id.get(id)),
&crate::match_page!(model, IssuesAndFilters).jql,
);
crate::match_page_mut!(model, IssuesAndFilters).visible_issues = issues;

View File

@ -120,7 +120,10 @@ pub fn update(msg: Msg, model: &mut crate::model::Model, orders: &mut impl Order
crate::match_page!(model, Project),
model.epics(),
model.issue_statuses(),
model.issues(),
model
.issue_ids
.iter()
.filter_map(|id| model.issues_by_id.get(id)),
model.user(),
);
crate::match_page_mut!(model, Project).visible_issues = visible_issues;

View File

@ -1,11 +1,9 @@
use std::collections::HashMap;
use seed::*;
use seed::prelude::*;
use jirs_data::{IssueStatus, ProjectCategory, TimeTracking};
use seed::prelude::*;
use seed::*;
use crate::{FieldId, Msg, ProjectFieldId};
use crate::components::styled_button::{ButtonVariant, StyledButton};
use crate::components::styled_checkbox::{ChildBuilder, StyledCheckbox, StyledCheckboxState};
use crate::components::styled_editor::render_styled_editor;
@ -19,6 +17,7 @@ use crate::components::styled_textarea::StyledTextarea;
use crate::model::{self, Model, PageContent};
use crate::pages::project_settings_page::{events, ProjectSettingsPage};
use crate::shared::inner_layout;
use crate::{FieldId, Msg, ProjectFieldId};
static TIME_TRACKING_FIBONACCI: &str = include_str!("./time_tracking_fibonacci.txt");
static TIME_TRACKING_HOURLY: &str = include_str!("./time_tracking_hourly.txt");
@ -206,10 +205,18 @@ fn category_select_option<'l>(pc: ProjectCategory) -> StyledSelectOption<'l> {
fn columns_section(model: &Model, page: &ProjectSettingsPage) -> Node<Msg> {
let width = 100f64 / (model.issue_statuses.len() + 1) as f64;
let column_style = format!("width: calc({width}% - 10px)", width = width);
let per_column_issue_count = model.issues().iter().fold(HashMap::new(), |mut h, issue| {
let per_column_issue_count = model
.issue_ids
.iter()
.filter_map(|id| model.issues_by_id.get(id))
.iter()
.fold(
HashMap::with_capacity(model.issue_statuses_by_id.len()),
|mut h, issue| {
*h.entry(issue.issue_status_id).or_insert(0) += 1;
h
});
},
);
let columns: Vec<Node<Msg>> = model
.issue_statuses
.iter()

View File

@ -240,8 +240,9 @@ fn issue_list(page: &ReportsPage, project_name: &str, this_month_updated: &[&Iss
fn this_month_updated<'a>(model: &'a Model, page: &ReportsPage) -> Vec<&'a Issue> {
model
.issues()
.issue_ids
.iter()
.filter_map(|id| model.issues_by_id.get(id))
.filter(|issue| {
issue.updated_at.date() >= page.first_day && issue.updated_at.date() <= page.last_day
})

View File

@ -30,8 +30,9 @@ pub fn change_position(below_id: EpicId, model: &mut Model) {
}
let (issue_status_id, epic_id) = model
.issues()
.issue_ids
.iter()
.filter_map(|id| model.issues_by_id.get(id))
.find_map(|issue| {
if issue.id == dragged_id {
Some((issue.issue_status_id, issue.epic_id))