Separate manual header mapping from advanced settings

This commit is contained in:
Dandaedre 2026-11-03 15:40:31 +01:00
parent 6d82edca99
commit 6481333a48
3 changed files with 49 additions and 4 deletions

View File

@ -49,6 +49,7 @@ struct App {
neutral: bool,
completed: Option<PathBuf>,
settings: bool,
advanced_settings: bool,
review_view: ReviewView,
dirty: bool,
issue_index: usize,
@ -82,6 +83,7 @@ impl Default for App {
neutral: false,
completed: None,
settings: false,
advanced_settings: false,
review_view: ReviewView::Rows,
dirty: false,
issue_index: 0,
@ -274,7 +276,6 @@ impl App {
}
fn mapping_controls(&mut self, ui: &mut egui::Ui) {
ui.heading("Remap columns, header and units / advanced profile");
self.mapping_fields(ui);
}
fn mapping_fields(&mut self, ui: &mut egui::Ui) {
@ -348,6 +349,18 @@ impl App {
}
}
});
if before != serde_json::to_string(&profile).unwrap() {
self.profile = serde_json::to_string_pretty(&profile).unwrap();
self.decisions_changed();
}
} else {
ui.label("Read and select a sheet first. If the profile JSON is invalid, fix it in Advanced settings.");
}
}
fn advanced_controls(&mut self, ui: &mut egui::Ui) {
if let Ok(mut profile) = serde_json::from_str::<Profile>(&self.profile) {
let before = serde_json::to_string(&profile).unwrap();
let mut unit = profile.duration_unit.clone().unwrap_or_default();
egui::ComboBox::from_label("Duration unit")
.selected_text(if unit.is_empty() {
@ -588,12 +601,19 @@ impl App {
});
ui.checkbox(&mut self.overwrite, "Replace existing output");
ui.separator();
if ui.button("Mapping and clarification settings…").clicked() {
if ui.button("Manual header mapping").clicked() {
self.settings = !self.settings;
}
if self.settings {
self.mapping_controls(ui);
}
ui.separator();
if ui.button("Advanced settings").clicked() {
self.advanced_settings = !self.advanced_settings;
}
if self.advanced_settings {
self.advanced_controls(ui);
}
}
Tab::Review => self.review(ui),
Tab::Details => {

View File

@ -1911,6 +1911,31 @@ mod tests {
assert_eq!(app.profile, profile);
assert!(!app.dirty);
assert!(app.analysis.is_some());
assert!(!app.advanced_settings);
assert!(!labels.iter().any(|(s, _)| s == "Duration unit"));
let size = [860.0, 900.0];
let labels = render(&mut app, &ctx, size, vec![]);
let mapping = labels
.iter()
.find(|(s, _)| s == "Manual header mapping")
.unwrap()
.1
.center();
click_size(&mut app, &ctx, mapping, size);
let labels = render(&mut app, &ctx, size, vec![]);
let advanced = labels
.iter()
.find(|(s, _)| s == "Advanced settings")
.unwrap()
.1
.center();
click_size(&mut app, &ctx, advanced, size);
let labels = render(&mut app, &ctx, size, vec![]);
assert!(app.advanced_settings);
assert!(!app.settings);
assert!(labels.iter().any(|(s, _)| s == "Duration unit"));
assert!(!labels.iter().any(|(s, _)| s == "Header row"));
assert_eq!(app.profile, profile);
}
#[test]

View File

@ -100,8 +100,8 @@ Review has two views:
as timing or titles; **Ignore** excludes it from inference and Ontime output.
Several columns can be metadata or ignored. **Auto** restores inference; other
columns remain included as metadata by default. **Remap columns in Setup →**
opens Setup with mapping settings expanded for header row, duration units and
advanced JSON settings.
opens **Manual header mapping** in Setup for the header row and column choices.
The separate **Advanced settings** section contains duration units and profile JSON.
The row type selector shows the detected type in parentheses, such as **Auto (Event)**.
**Auto (?)** means unresolved or awaiting recheck.