Allow ignoring and restoring individual split entries
This commit is contained in:
parent
5cc792a386
commit
facdf28467
|
|
@ -178,6 +178,7 @@ struct App {
|
|||
row_filter: RowFilter,
|
||||
show_issue_details: bool,
|
||||
selected_row: Option<usize>,
|
||||
selected_part: Option<usize>,
|
||||
selected_gap: Option<String>,
|
||||
jump_row: Option<usize>,
|
||||
review_scroll: Option<f32>,
|
||||
|
|
@ -239,6 +240,7 @@ impl Default for App {
|
|||
row_filter: RowFilter::Included,
|
||||
show_issue_details: false,
|
||||
selected_row: None,
|
||||
selected_part: None,
|
||||
selected_gap: None,
|
||||
jump_row: None,
|
||||
review_scroll: None,
|
||||
|
|
@ -260,6 +262,7 @@ impl App {
|
|||
self.dirty = false;
|
||||
self.issue_index = 0;
|
||||
self.selected_row = None;
|
||||
self.selected_part = None;
|
||||
self.selected_gap = None;
|
||||
self.jump_row = None;
|
||||
self.review_scroll = None;
|
||||
|
|
@ -429,6 +432,7 @@ impl App {
|
|||
self.mapping_focus_scroll = None;
|
||||
self.mapping_focus_until = None;
|
||||
self.selected_row = a.diagnostics.first().and_then(review::diagnostic_row);
|
||||
self.selected_part = None;
|
||||
self.selected_gap = None;
|
||||
self.jump_row = self.selected_row;
|
||||
self.review_view = if a.mapping.is_none() {
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ fn column_issue_advice(code: &str, duration: bool) -> (&'static str, &'static st
|
|||
|
||||
#[derive(Clone)]
|
||||
struct PreviewRow {
|
||||
split_part: Option<usize>,
|
||||
row: usize,
|
||||
start: String,
|
||||
end: String,
|
||||
|
|
@ -411,11 +412,12 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
let mut rows = Vec::new();
|
||||
let mut represented = BTreeSet::new();
|
||||
if let Some(r) = &a.rundown {
|
||||
for e in &r.entries {
|
||||
for e in r.entries.iter().chain(&r.ignored_entries) {
|
||||
if let Some(first) = e.source_rows.first() {
|
||||
represented.insert(first.row);
|
||||
}
|
||||
rows.push(PreviewRow {
|
||||
split_part: e.split_part,
|
||||
row: e.source_rows.first().map_or(0, |s| s.row),
|
||||
start: display(e.start_ms),
|
||||
end: display(e.end_ms),
|
||||
|
|
@ -434,7 +436,10 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
.diagnostics
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, d)| diagnostic_row(d) == e.source_rows.first().map(|s| s.row))
|
||||
.filter(|(_, d)| {
|
||||
e.kind != "ignored"
|
||||
&& diagnostic_row(d) == e.source_rows.first().map(|s| s.row)
|
||||
})
|
||||
.map(|(i, _)| i)
|
||||
.collect(),
|
||||
related_issues: vec![],
|
||||
|
|
@ -485,6 +490,7 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
.join(" · ")
|
||||
});
|
||||
rows.push(PreviewRow {
|
||||
split_part: None,
|
||||
row,
|
||||
start: raw(a.mapping.as_ref().map(|m| m.start)),
|
||||
end: raw(a.mapping.as_ref().and_then(|m| m.end)),
|
||||
|
|
@ -549,7 +555,7 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
}
|
||||
}
|
||||
}
|
||||
rows.sort_by_key(|r| r.row);
|
||||
rows.sort_by_key(|r| (r.row, r.split_part));
|
||||
if let Some(rundown) = &a.rundown {
|
||||
let mut gaps: Vec<_> = rundown
|
||||
.gaps
|
||||
|
|
@ -569,6 +575,7 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
})
|
||||
.unwrap_or(rows.len());
|
||||
rows.insert(position, PreviewRow {
|
||||
split_part: None,
|
||||
row: 0,
|
||||
start: gap.start_ms.map(display).unwrap_or_else(|| "?".into()),
|
||||
end: gap.end_ms.map(display).unwrap_or_else(|| "?".into()),
|
||||
|
|
@ -607,7 +614,11 @@ fn preview_rows(a: &Analysis, table: Option<&Table>) -> Vec<PreviewRow> {
|
|||
}) else {
|
||||
continue;
|
||||
};
|
||||
if let Some(row) = rows.iter_mut().find(|row| row.row == previous_row) {
|
||||
if let Some(row) = rows
|
||||
.iter_mut()
|
||||
.rev()
|
||||
.find(|row| row.row == previous_row && row.kind != "ignored")
|
||||
{
|
||||
if !row.issues.contains(&index) {
|
||||
row.issues.push(index);
|
||||
}
|
||||
|
|
@ -656,7 +667,12 @@ fn ignored_row(
|
|||
|
||||
fn modified_row(row: &PreviewRow, profile: &Profile) -> bool {
|
||||
if row.row > 0
|
||||
&& (profile.row_kinds.contains_key(&row.row)
|
||||
&& (row.split_part.is_some_and(|part| {
|
||||
profile
|
||||
.ignored_parts
|
||||
.get(&row.row)
|
||||
.is_some_and(|parts| parts.contains(&part))
|
||||
}) || profile.row_kinds.contains_key(&row.row)
|
||||
|| profile.titles.contains_key(&row.row)
|
||||
|| profile.starts.contains_key(&row.row)
|
||||
|| profile.ends.contains_key(&row.row)
|
||||
|
|
@ -724,6 +740,7 @@ fn column_settings_changed(current: &Profile, analyzed: &Profile) -> bool {
|
|||
fn schedule_settings_changed(current: &Profile, analyzed: &Profile) -> bool {
|
||||
current.untimed_as_notes != analyzed.untimed_as_notes
|
||||
|| current.ignore_warnings != analyzed.ignore_warnings
|
||||
|| current.ignored_parts != analyzed.ignored_parts
|
||||
|| current.row_kinds != analyzed.row_kinds
|
||||
|| current.titles != analyzed.titles
|
||||
|| current.starts != analyzed.starts
|
||||
|
|
@ -743,7 +760,17 @@ fn preview_row_settings_changed(row: &PreviewRow, current: &Profile, analyzed: &
|
|||
.gap_key
|
||||
.as_ref()
|
||||
.is_some_and(|key| current.gap_resolutions.get(key) != analyzed.gap_resolutions.get(key));
|
||||
row_changed || gap_changed
|
||||
let part_changed = row.split_part.is_some_and(|part| {
|
||||
current
|
||||
.ignored_parts
|
||||
.get(&row.row)
|
||||
.is_some_and(|parts| parts.contains(&part))
|
||||
!= analyzed
|
||||
.ignored_parts
|
||||
.get(&row.row)
|
||||
.is_some_and(|parts| parts.contains(&part))
|
||||
});
|
||||
row_changed || gap_changed || part_changed
|
||||
}
|
||||
|
||||
fn show_row(
|
||||
|
|
@ -756,7 +783,9 @@ fn show_row(
|
|||
match filter {
|
||||
RowFilter::All => true,
|
||||
RowFilter::Included => {
|
||||
!row.automatically_ignored && !ignored_row(row.row, table, profile, mapping)
|
||||
row.kind != "ignored"
|
||||
&& !row.automatically_ignored
|
||||
&& !ignored_row(row.row, table, profile, mapping)
|
||||
}
|
||||
RowFilter::Attention => !row.gap && !row.issues.is_empty(),
|
||||
RowFilter::Gaps => row.gap,
|
||||
|
|
@ -850,6 +879,7 @@ impl App {
|
|||
.and_then(|a| a.diagnostics.get(index))
|
||||
.and_then(diagnostic_row);
|
||||
self.selected_row = row;
|
||||
self.selected_part = None;
|
||||
self.selected_gap = None;
|
||||
self.jump_row = row;
|
||||
if let Some(row) = row {
|
||||
|
|
@ -1030,6 +1060,31 @@ impl App {
|
|||
ui.add_space(4.0);
|
||||
}
|
||||
|
||||
fn split_part_control(ui: &mut egui::Ui, profile: &mut Profile, row: usize, part: usize) {
|
||||
let mut ignored = profile
|
||||
.ignored_parts
|
||||
.get(&row)
|
||||
.is_some_and(|parts| parts.contains(&part));
|
||||
let before = ignored;
|
||||
egui::ComboBox::from_id_salt(("split_part", row, part))
|
||||
.width(90.0)
|
||||
.selected_text(if ignored { "Ignore" } else { "Auto (Event)" })
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut ignored, false, "Auto (Event)");
|
||||
ui.selectable_value(&mut ignored, true, "Ignore");
|
||||
}).response.on_hover_text("Affects only this split entry. Ignoring removes its duration and margin; remaining entries are recalculated after Apply & recheck. Restore it under All rows.");
|
||||
if ignored != before {
|
||||
if ignored {
|
||||
profile.ignored_parts.entry(row).or_default().insert(part);
|
||||
} else if let Some(parts) = profile.ignored_parts.get_mut(&row) {
|
||||
parts.remove(&part);
|
||||
if parts.is_empty() {
|
||||
profile.ignored_parts.remove(&row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn row_kind_control(
|
||||
ui: &mut egui::Ui,
|
||||
profile: &mut Profile,
|
||||
|
|
@ -1172,9 +1227,12 @@ impl App {
|
|||
.unwrap_or(1)
|
||||
.max(1);
|
||||
let preview = self.analysis.as_ref().and_then(|a| {
|
||||
preview_rows(a, Some(table))
|
||||
.into_iter()
|
||||
.find(|r| r.row == row)
|
||||
preview_rows(a, Some(table)).into_iter().find(|r| {
|
||||
r.row == row
|
||||
&& self
|
||||
.selected_part
|
||||
.is_none_or(|part| r.split_part == Some(part))
|
||||
})
|
||||
});
|
||||
let row_pending = preview.as_ref().is_some_and(|preview| {
|
||||
self.analyzed_profile
|
||||
|
|
@ -1222,8 +1280,15 @@ impl App {
|
|||
kind if kind.starts_with("Note") => Some("Note"),
|
||||
kind if kind.starts_with("Gap") => Some("Gap"), _ => None,
|
||||
};
|
||||
Self::row_kind_control(ui, &mut profile, row, if self.dirty { None } else { detected });
|
||||
if let Some(part) = preview.split_part {
|
||||
Self::split_part_control(ui, &mut profile, row, part);
|
||||
} else {
|
||||
Self::row_kind_control(ui, &mut profile, row, if self.dirty { None } else { detected });
|
||||
}
|
||||
});
|
||||
if preview.split_part.is_some() {
|
||||
ui.weak("Ignore affects only this split entry. Title and timing corrections below apply to the source row.");
|
||||
}
|
||||
ui.label("Title");
|
||||
let mut title = profile.titles.get(&row).cloned().unwrap_or_default();
|
||||
if ui
|
||||
|
|
@ -2158,7 +2223,7 @@ impl App {
|
|||
if row.row == 0 {
|
||||
row.gap_key.as_ref() == self.selected_gap.as_ref()
|
||||
} else {
|
||||
self.selected_row == Some(row.row)
|
||||
self.selected_row == Some(row.row) && self.selected_part == row.split_part
|
||||
}
|
||||
}))
|
||||
.collect();
|
||||
|
|
@ -2172,7 +2237,8 @@ impl App {
|
|||
.chain(rows.iter().map(|row| {
|
||||
if preview_row_settings_changed(row, &profile, &analyzed_profile) {
|
||||
Some(Color32::from_rgb(43, 36, 70))
|
||||
} else if row.automatically_ignored
|
||||
} else if row.kind == "ignored"
|
||||
|| row.automatically_ignored
|
||||
|| ignored_row(row.row, table, &analyzed_profile, a.mapping.as_ref())
|
||||
{
|
||||
Some(Color32::from_rgb(34, 35, 39))
|
||||
|
|
@ -2226,7 +2292,7 @@ impl App {
|
|||
for (row_index, row) in rows.iter().enumerate() {
|
||||
let pending = pending_rows[row_index + 1];
|
||||
let row_top = ui.cursor().min;
|
||||
let ignored = row.automatically_ignored
|
||||
let ignored = row.kind == "ignored" || row.automatically_ignored
|
||||
|| ignored_row(
|
||||
row.row,
|
||||
table,
|
||||
|
|
@ -2316,7 +2382,7 @@ impl App {
|
|||
};
|
||||
if response.double_clicked() {
|
||||
if row.row > 0 {
|
||||
details = Some(row.row);
|
||||
details = Some((row.row, row.split_part));
|
||||
} else {
|
||||
gap_details = row.gap_key.clone();
|
||||
}
|
||||
|
|
@ -2391,14 +2457,18 @@ impl App {
|
|||
let mut title_double_clicked = false;
|
||||
let mut issue_controls = |ui: &mut egui::Ui| {
|
||||
if can_ignore && ui.small_button("Ignore")
|
||||
.on_hover_text("Ignore this source row. Apply & recheck to update the schedule; restore it under All rows.")
|
||||
.on_hover_text("Ignore this entry (only this part when split). Apply & recheck to update the schedule; restore it under All rows.")
|
||||
.clicked() {
|
||||
profile.row_kinds.insert(row.row, "ignore".into());
|
||||
if let Some(part) = row.split_part {
|
||||
profile.ignored_parts.entry(row.row).or_default().insert(part);
|
||||
} else {
|
||||
profile.row_kinds.insert(row.row, "ignore".into());
|
||||
}
|
||||
}
|
||||
if let (Some(index), Some(label)) = (issue_index, &issue_button)
|
||||
&& ui.small_button(RichText::new(label).color(color))
|
||||
.on_hover_text(&explanation).clicked() {
|
||||
if row.row > 0 { details = Some(row.row); }
|
||||
if row.row > 0 { details = Some((row.row, row.split_part)); }
|
||||
else if let Some(key) = &row.gap_key { gap_details = Some(key.clone()); }
|
||||
else { resolve = Some(index); }
|
||||
}
|
||||
|
|
@ -2424,7 +2494,7 @@ impl App {
|
|||
}
|
||||
if title_double_clicked {
|
||||
if row.row > 0 {
|
||||
details = Some(row.row);
|
||||
details = Some((row.row, row.split_part));
|
||||
} else {
|
||||
gap_details = row.gap_key.clone();
|
||||
}
|
||||
|
|
@ -2450,7 +2520,11 @@ impl App {
|
|||
_ => None,
|
||||
}
|
||||
};
|
||||
Self::row_kind_control(ui, &mut profile, row.row, detected)
|
||||
if let Some(part) = row.split_part {
|
||||
Self::split_part_control(ui, &mut profile, row.row, part);
|
||||
} else {
|
||||
Self::row_kind_control(ui, &mut profile, row.row, detected);
|
||||
}
|
||||
});
|
||||
}
|
||||
if pending {
|
||||
|
|
@ -2466,6 +2540,7 @@ impl App {
|
|||
if ui.input(|i| i.pointer.primary_clicked()) {
|
||||
if row.row > 0 {
|
||||
self.selected_row = Some(row.row);
|
||||
self.selected_part = row.split_part;
|
||||
self.selected_gap = None;
|
||||
} else {
|
||||
self.selected_row = None;
|
||||
|
|
@ -2476,7 +2551,7 @@ impl App {
|
|||
if !ui.rect_contains_pointer(controls.response.rect)
|
||||
&& ui.input(|i| i.pointer.button_double_clicked(egui::PointerButton::Primary)) {
|
||||
if row.row > 0 {
|
||||
details = Some(row.row);
|
||||
details = Some((row.row, row.split_part));
|
||||
} else {
|
||||
gap_details = row.gap_key.clone();
|
||||
}
|
||||
|
|
@ -2496,8 +2571,9 @@ impl App {
|
|||
self.choose_issue(index);
|
||||
self.show_issue_details = true;
|
||||
}
|
||||
if let Some(row) = details {
|
||||
if let Some((row, part)) = details {
|
||||
self.selected_row = Some(row);
|
||||
self.selected_part = part;
|
||||
self.selected_gap = None;
|
||||
self.row_details = true;
|
||||
}
|
||||
|
|
@ -3312,6 +3388,67 @@ mod tests {
|
|||
.iter()
|
||||
.any(|(text, _)| text.contains("use of widget ID"))
|
||||
);
|
||||
let ignore = labels
|
||||
.iter()
|
||||
.rev()
|
||||
.find(|(text, _)| text == "Ignore")
|
||||
.unwrap()
|
||||
.1
|
||||
.center();
|
||||
click_size(&mut app, &ctx, ignore, size);
|
||||
let profile: Profile = serde_json::from_str(&app.profile).unwrap();
|
||||
assert_eq!(profile.ignored_parts[&2], [2].into_iter().collect());
|
||||
assert!(!profile.row_kinds.contains_key(&2));
|
||||
let pending = preview_rows(app.analysis.as_ref().unwrap(), Some(&app.tables[0]));
|
||||
assert!(!preview_row_settings_changed(
|
||||
&pending[0],
|
||||
&profile,
|
||||
app.analyzed_profile.as_ref().unwrap()
|
||||
));
|
||||
assert!(preview_row_settings_changed(
|
||||
&pending[1],
|
||||
&profile,
|
||||
app.analyzed_profile.as_ref().unwrap()
|
||||
));
|
||||
app.analysis = Some(pipeline::analyze(
|
||||
&app.tables[0],
|
||||
&profile,
|
||||
&AtomicBool::new(false),
|
||||
|_, _| {},
|
||||
));
|
||||
app.analyzed_profile = Some(profile.clone());
|
||||
app.dirty = false;
|
||||
let rows = preview_rows(app.analysis.as_ref().unwrap(), Some(&app.tables[0]));
|
||||
assert_eq!(rows.len(), 2);
|
||||
assert_eq!(rows[1].kind, "ignored");
|
||||
assert!(!show_row(
|
||||
&rows[1],
|
||||
RowFilter::Included,
|
||||
Some(&app.tables[0]),
|
||||
&profile,
|
||||
app.analysis.as_ref().unwrap().mapping.as_ref()
|
||||
));
|
||||
app.row_filter = RowFilter::All;
|
||||
render(&mut app, &ctx, size, vec![]);
|
||||
let labels = render(&mut app, &ctx, size, vec![]);
|
||||
let restore = labels
|
||||
.iter()
|
||||
.find(|(text, _)| text == "Ignore")
|
||||
.unwrap()
|
||||
.1
|
||||
.center();
|
||||
click_size(&mut app, &ctx, restore, size);
|
||||
let labels = render(&mut app, &ctx, size, vec![]);
|
||||
let option = labels
|
||||
.iter()
|
||||
.rev()
|
||||
.find(|(text, _)| text == "Auto (Event)")
|
||||
.unwrap()
|
||||
.1
|
||||
.center();
|
||||
click_size(&mut app, &ctx, option, size);
|
||||
let profile: Profile = serde_json::from_str(&app.profile).unwrap();
|
||||
assert!(profile.ignored_parts.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ pub struct Profile {
|
|||
pub ignore_warnings: bool,
|
||||
/// One-based source row -> event, gap, marker, note, or ignore.
|
||||
pub row_kinds: BTreeMap<usize, String>,
|
||||
/// One-based source row -> one-based split parts excluded independently.
|
||||
#[serde(default)]
|
||||
pub ignored_parts: BTreeMap<usize, std::collections::BTreeSet<usize>>,
|
||||
/// Explicit title overrides; original source cells remain in the IR.
|
||||
pub titles: BTreeMap<usize, String>,
|
||||
/// Explicit start clock overrides (e.g. 09:30 or 09:30:00).
|
||||
|
|
@ -159,6 +162,9 @@ pub struct SourceRow {
|
|||
}
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct Entry {
|
||||
/// One-based position in the source duration split, stable when siblings are ignored.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub split_part: Option<usize>,
|
||||
pub id: String,
|
||||
pub kind: String,
|
||||
pub title: String,
|
||||
|
|
@ -197,6 +203,9 @@ pub struct Rundown {
|
|||
pub title: String,
|
||||
pub mapping: Mapping,
|
||||
pub entries: Vec<Entry>,
|
||||
/// Excluded virtual entries retained for review and restoration, never exported.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub ignored_entries: Vec<Entry>,
|
||||
pub gaps: Vec<Gap>,
|
||||
/// Original intervals absorbed into event timing, retained for review/undo.
|
||||
#[serde(default)]
|
||||
|
|
|
|||
|
|
@ -68,12 +68,39 @@ fn duration_plan(
|
|||
})
|
||||
}
|
||||
}
|
||||
fn selected_total(
|
||||
plan: &SelectedDurations,
|
||||
row: usize,
|
||||
profile: &Profile,
|
||||
include_margin: bool,
|
||||
) -> i64 {
|
||||
if plan.events.len() <= 1 {
|
||||
return plan.events.iter().sum::<i64>() + if include_margin { plan.margin } else { 0 };
|
||||
}
|
||||
plan.events
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(part, _)| {
|
||||
!profile
|
||||
.ignored_parts
|
||||
.get(&(row + 1))
|
||||
.is_some_and(|parts| parts.contains(&(part + 1)))
|
||||
})
|
||||
.map(|(part, duration)| {
|
||||
duration
|
||||
+ if include_margin {
|
||||
plan.margins.get(part).copied().unwrap_or(0)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
})
|
||||
.sum()
|
||||
}
|
||||
fn supplied_duration(table: &Table, row: usize, map: &Mapping, profile: &Profile) -> Option<i64> {
|
||||
duration_plan(table, row, map, profile).map(|plan| plan.events.iter().sum())
|
||||
duration_plan(table, row, map, profile).map(|plan| selected_total(&plan, row, profile, false))
|
||||
}
|
||||
fn supplied_span(table: &Table, row: usize, map: &Mapping, profile: &Profile) -> Option<i64> {
|
||||
duration_plan(table, row, map, profile)
|
||||
.map(|plan| plan.events.iter().sum::<i64>() + plan.margin)
|
||||
duration_plan(table, row, map, profile).map(|plan| selected_total(&plan, row, profile, true))
|
||||
}
|
||||
fn supplied_title(table: &Table, row: usize, map: &Mapping, profile: &Profile) -> String {
|
||||
if let Some(title) = profile.titles.get(&(row + 1)) {
|
||||
|
|
@ -267,6 +294,7 @@ fn entry(
|
|||
|part| format!("rundown/{}/{row}/part/{part}", table.name),
|
||||
);
|
||||
Entry {
|
||||
split_part: virtual_part.map(|part| part + 1),
|
||||
id: Uuid::new_v5(&Uuid::NAMESPACE_URL, identity.as_bytes())
|
||||
.simple()
|
||||
.to_string(),
|
||||
|
|
@ -294,11 +322,31 @@ pub fn construct(
|
|||
title: table.name.clone(),
|
||||
mapping: map.clone(),
|
||||
entries: vec![],
|
||||
ignored_entries: vec![],
|
||||
gaps: vec![],
|
||||
resolved_gaps: vec![],
|
||||
decisions: vec![],
|
||||
};
|
||||
let mut errors = vec![];
|
||||
for (&source, parts) in &profile.ignored_parts {
|
||||
if parts.is_empty()
|
||||
|| profile
|
||||
.row_kinds
|
||||
.get(&source)
|
||||
.is_some_and(|kind| kind == "ignore")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let count = source
|
||||
.checked_sub(1)
|
||||
.filter(|row| *row >= map.header_row && *row < table.rows.len())
|
||||
.and_then(|row| duration_plan(table, row, &map, profile))
|
||||
.map_or(0, |plan| plan.events.len());
|
||||
if count < 2 || parts.iter().any(|part| *part == 0 || *part > count) {
|
||||
errors.push(Diagnostic::new(3, "INVALID_SPLIT_RESOLUTION", format!("{}!row {source}", table.name),
|
||||
"An ignored split entry no longer exists. Restore the original split settings or remove this row from ignored_parts in the resolution profile."));
|
||||
}
|
||||
}
|
||||
let mut row = map.header_row;
|
||||
let mut group: Option<(usize, i64, i64)> = None;
|
||||
let mut cursor: Option<i64> = None;
|
||||
|
|
@ -492,7 +540,7 @@ pub fn construct(
|
|||
}
|
||||
let plan = duration_plan.as_ref().expect("checked above");
|
||||
if let Some(end) = given_end {
|
||||
let selected: i64 = plan.events.iter().sum::<i64>() + plan.margin;
|
||||
let selected = selected_total(plan, r, profile, true);
|
||||
if start + selected > end {
|
||||
errors.push(Diagnostic::new(
|
||||
4,
|
||||
|
|
@ -515,7 +563,7 @@ pub fn construct(
|
|||
start: part_start,
|
||||
end: part_end,
|
||||
duration,
|
||||
explicit_start: part == 0 && given_start.is_some(),
|
||||
explicit_start: part_start == start && given_start.is_some(),
|
||||
inferred_end: true,
|
||||
inferred_duration: false,
|
||||
},
|
||||
|
|
@ -526,10 +574,19 @@ pub fn construct(
|
|||
part + 1,
|
||||
count
|
||||
));
|
||||
if part > 0 {
|
||||
if part_start > start {
|
||||
e.decisions
|
||||
.push("Start derived from the preceding virtual entry".into());
|
||||
}
|
||||
if profile
|
||||
.ignored_parts
|
||||
.get(&(r + 1))
|
||||
.is_some_and(|parts| parts.contains(&(part + 1)))
|
||||
{
|
||||
e.kind = "ignored".into();
|
||||
result.ignored_entries.push(e);
|
||||
continue;
|
||||
}
|
||||
result.entries.push(e);
|
||||
let margin = plan.margins.get(part).copied().unwrap_or(0);
|
||||
if margin > 0 {
|
||||
|
|
@ -941,6 +998,7 @@ pub fn analyze(
|
|||
*row > 0
|
||||
&& *row <= table.rows.len()
|
||||
&& !effective.row_kinds.contains_key(row)
|
||||
&& !profile.ignored_parts.contains_key(row)
|
||||
&& !profile.titles.contains_key(row)
|
||||
&& !profile.starts.contains_key(row)
|
||||
&& !profile.ends.contains_key(row)
|
||||
|
|
|
|||
|
|
@ -1771,3 +1771,62 @@ fn upper_median_is_applied_per_split_entry_with_independent_fixed_margins() {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignoring_a_split_part_retains_its_sibling_and_recalculates_timing() {
|
||||
let t = table(&[
|
||||
&["Start", "Duration", "Title"],
|
||||
&["15:30", "30min\n25min + 5 min QR", "Talk"],
|
||||
&["16:00", "30 min", "Break"],
|
||||
]);
|
||||
let base = Profile {
|
||||
duration_split: true,
|
||||
duration_mode: Some("median".into()),
|
||||
..Profile::default()
|
||||
};
|
||||
let original = analyze(&t, &base).rundown.unwrap();
|
||||
for ignored in [1, 2] {
|
||||
let mut profile = base.clone();
|
||||
profile
|
||||
.ignored_parts
|
||||
.insert(2, [ignored].into_iter().collect());
|
||||
let profile: Profile =
|
||||
serde_json::from_str(&serde_json::to_string(&profile).unwrap()).unwrap();
|
||||
let a = analyze(&t, &profile);
|
||||
assert!(a.diagnostics.is_empty(), "{:?}", a.diagnostics);
|
||||
let r = a.rundown.unwrap();
|
||||
assert_eq!(r.entries.len(), 2);
|
||||
assert_eq!(r.ignored_entries.len(), 1);
|
||||
let remaining = if ignored == 1 { 2 } else { 1 };
|
||||
assert_eq!(r.entries[0].split_part, Some(remaining));
|
||||
assert_eq!(r.entries[0].id, original.entries[remaining - 1].id);
|
||||
assert_eq!(r.entries[0].start_ms, 55_800_000);
|
||||
assert!(r.entries[0].explicit_start);
|
||||
assert_eq!(
|
||||
r.entries[0].duration_ms,
|
||||
if ignored == 1 { 1_500_000 } else { 1_800_000 }
|
||||
);
|
||||
let json = export::ontime(&r).unwrap();
|
||||
let entries = json["rundowns"]["default"]["entries"].as_object().unwrap();
|
||||
assert!(!entries.contains_key(&r.ignored_entries[0].id));
|
||||
assert!(entries.contains_key(&r.entries[0].id));
|
||||
}
|
||||
let mut margin = base.clone();
|
||||
margin.duration_add_margin = true;
|
||||
margin.duration_margin = Some("5 min".into());
|
||||
margin.ignored_parts.insert(2, [1].into_iter().collect());
|
||||
// The next source row also has a margin, but the excluded part does not.
|
||||
let a = analyze(&t, &margin);
|
||||
assert!(a.diagnostics.is_empty(), "{:?}", a.diagnostics);
|
||||
let r = a.rundown.unwrap();
|
||||
assert_eq!(r.entries[0].start_ms, 55_800_000);
|
||||
assert_eq!(r.entries[0].end_ms, 57_300_000);
|
||||
assert_eq!(r.gaps.iter().filter(|g| g.after_row == Some(2)).count(), 1);
|
||||
margin.duration_split = false;
|
||||
assert!(
|
||||
analyze(&t, &margin)
|
||||
.diagnostics
|
||||
.iter()
|
||||
.any(|d| d.code == "INVALID_SPLIT_RESOLUTION")
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,6 +160,12 @@ visually distinct from labels and ordinary actions; the active tab uses the stro
|
|||
`20 min + 5 min` and `10 min + 2 min` on separate lines produce 25-minute
|
||||
and 12-minute entries with Split + Sum. Selecting one duration column explicitly resolves
|
||||
duplicate TIMER headers.
|
||||
Each split entry has its own **Ignore** choice in the preview and editor.
|
||||
After **Apply & recheck**, only that entry and its margin are removed; remaining
|
||||
entries are recalculated from the source start. **All rows** retains excluded
|
||||
entries with an **Auto (Event)** choice to restore them. Title and timing edits
|
||||
still apply to the source row. If the source row was previously ignored as a
|
||||
whole, restore it and recheck first to see its individual split entries.
|
||||
**Secondary title** selects another title source with a nested handling menu:
|
||||
**Either** uses the main title when present and the secondary when it is empty;
|
||||
**Merge** joins both nonempty titles with an em dash; **Notes** adds the secondary
|
||||
|
|
@ -366,6 +372,10 @@ detailed multi-value line is treated as an alternative expression, avoiding doub
|
|||
counting. Legacy `duration_mode: "margin"` profiles remain supported; new GUI
|
||||
choices use Maximum with the Add margin toggle. Legacy profiles using `duration_mode: "split"` are read as Sum with
|
||||
splitting enabled.
|
||||
`ignored_parts: {"20": [2]}` excludes only the second split entry of source row
|
||||
20. Both numbers are one-based; original split indices remain stable when other
|
||||
parts are excluded. If a saved index no longer fits the split settings, analysis
|
||||
reports an error instead of silently applying it to another entry.
|
||||
|
||||
`column_usage` maps column letters to `notes`, `metadata` or `ignore`. Every choice
|
||||
prevents that column from being inferred as a start, start–end, end, duration or
|
||||
|
|
|
|||
Loading…
Reference in New Issue