Simplify resolutions dialog around save and reuse actions
This commit is contained in:
parent
31b94943f6
commit
6d82edca99
|
|
@ -433,7 +433,43 @@ impl App {
|
|||
}
|
||||
|
||||
fn resolution_controls(&mut self, ui: &mut egui::Ui) {
|
||||
ui.label("Save and reuse clarification decisions. Original documents remain unchanged.");
|
||||
ui.label("Remember the decisions for this sheet, then reuse them next time.");
|
||||
let ready = !self.dirty
|
||||
&& self
|
||||
.analysis
|
||||
.as_ref()
|
||||
.is_some_and(|a| a.completed_stage == 4 && a.diagnostics.is_empty());
|
||||
let memory = self.memory_path().ok();
|
||||
let path = memory.clone().filter(|p| p.exists());
|
||||
let size = egui::vec2(ui.available_width(), 48.0);
|
||||
if ui.add_enabled(ready && memory.is_some(), egui::Button::new("Save resolution").min_size(size))
|
||||
.on_hover_text("Save or update the remembered resolution for this exact sheet. Original documents remain unchanged.").clicked()
|
||||
&& let Err(e) = self.remember() {
|
||||
self.error = Some(e.to_string());
|
||||
}
|
||||
if !ready {
|
||||
ui.small("Apply & recheck and resolve remaining issues before saving. Advanced offers Save as for unfinished work.");
|
||||
} else if memory.is_none() {
|
||||
ui.small("Automatic storage is unavailable. Use Save as under Advanced.");
|
||||
}
|
||||
if ui
|
||||
.add_enabled(
|
||||
path.is_some(),
|
||||
egui::Button::new("Reuse remembered resolution").min_size(size),
|
||||
)
|
||||
.on_hover_text("Load the decisions saved for this exact sheet, then apply & recheck.")
|
||||
.clicked()
|
||||
&& let Err(e) = self.load_profile(path.clone().unwrap())
|
||||
{
|
||||
self.error = Some(e.to_string());
|
||||
}
|
||||
ui.small(if path.is_some() {
|
||||
"A saved resolution is available for this sheet. Reuse requires Apply & recheck."
|
||||
} else {
|
||||
"No remembered resolution for this sheet yet."
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
ui.collapsing("Advanced", |ui| {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
if ui.button("Load resolution…").clicked()
|
||||
&& let Some(path) = rfd::FileDialog::new()
|
||||
|
|
@ -475,30 +511,6 @@ impl App {
|
|||
if let Some(path) = &self.profile_path {
|
||||
ui.label(format!("Resolution: {}", path.display()));
|
||||
}
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
let ready = !self.dirty
|
||||
&& self
|
||||
.analysis
|
||||
.as_ref()
|
||||
.is_some_and(|a| a.completed_stage == 4 && a.diagnostics.is_empty());
|
||||
if ui
|
||||
.add_enabled(ready, egui::Button::new("Remember resolution"))
|
||||
.clicked()
|
||||
&& let Err(e) = self.remember()
|
||||
{
|
||||
self.error = Some(e.to_string());
|
||||
}
|
||||
let path = self.memory_path().ok().filter(|p| p.exists());
|
||||
if ui
|
||||
.add_enabled(
|
||||
path.is_some(),
|
||||
egui::Button::new("Reuse remembered resolution"),
|
||||
)
|
||||
.clicked()
|
||||
&& let Err(e) = self.load_profile(path.clone().unwrap())
|
||||
{
|
||||
self.error = Some(e.to_string());
|
||||
}
|
||||
if ui
|
||||
.add_enabled(path.is_some(), egui::Button::new("Forget"))
|
||||
.clicked()
|
||||
|
|
@ -508,8 +520,9 @@ impl App {
|
|||
Err(e) => self.error = Some(e.to_string()),
|
||||
}
|
||||
}
|
||||
if let Some(memory) = &memory { ui.small(format!("Remembered file: {}", memory.display())); }
|
||||
ui.small("Remembered decisions match the complete sheet, including row order and timing formats.");
|
||||
});
|
||||
ui.small("Remembered decisions match the complete sheet, including row order and timing formats. Reuse always requires validation.");
|
||||
}
|
||||
|
||||
fn pane(&mut self, ui: &mut egui::Ui) {
|
||||
|
|
|
|||
|
|
@ -1381,6 +1381,69 @@ mod tests {
|
|||
assert_eq!(app.selected_row, Some(3));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolutions_window_prioritizes_save_and_reuse() {
|
||||
let mut app = sample();
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let source = dir.path().join("show.csv");
|
||||
std::fs::write(&source, "source document").unwrap();
|
||||
app.input = source.display().to_string();
|
||||
app.resolution_dir = Some(dir.path().join("remembered"));
|
||||
let profile = Profile {
|
||||
untimed_as_notes: true,
|
||||
..Default::default()
|
||||
};
|
||||
app.profile = serde_json::to_string(&profile).unwrap();
|
||||
app.analysis = Some(pipeline::analyze(
|
||||
&app.tables[0],
|
||||
&profile,
|
||||
&AtomicBool::new(false),
|
||||
|_, _| {},
|
||||
));
|
||||
app.resolutions_open = true;
|
||||
let ctx = egui::Context::default();
|
||||
configure_style(&ctx);
|
||||
let size = [860.0, 900.0];
|
||||
render(&mut app, &ctx, size, vec![]);
|
||||
let labels = render(&mut app, &ctx, size, vec![]);
|
||||
assert!(!labels.iter().any(|(s, _)| s == "Save resolution as…"));
|
||||
let save = labels
|
||||
.iter()
|
||||
.find(|(s, _)| s == "Save resolution")
|
||||
.unwrap()
|
||||
.1
|
||||
.center();
|
||||
click_size(&mut app, &ctx, save, size);
|
||||
assert!(app.memory_path().unwrap().exists());
|
||||
assert!(app.error.is_none(), "{:?}", app.error);
|
||||
app.profile = "{}".into();
|
||||
app.decisions_changed();
|
||||
let labels = render(&mut app, &ctx, size, vec![]);
|
||||
let reuse = labels
|
||||
.iter()
|
||||
.find(|(s, _)| s == "Reuse remembered resolution")
|
||||
.unwrap()
|
||||
.1
|
||||
.center();
|
||||
click_size(&mut app, &ctx, reuse, size);
|
||||
assert!(
|
||||
serde_json::from_str::<Profile>(&app.profile)
|
||||
.unwrap()
|
||||
.untimed_as_notes
|
||||
);
|
||||
assert!(app.dirty);
|
||||
let labels = render(&mut app, &ctx, size, vec![]);
|
||||
let advanced = labels
|
||||
.iter()
|
||||
.find(|(s, _)| s == "Advanced")
|
||||
.unwrap()
|
||||
.1
|
||||
.center();
|
||||
click_size(&mut app, &ctx, advanced, size);
|
||||
let labels = render(&mut app, &ctx, size, vec![]);
|
||||
assert!(labels.iter().any(|(s, _)| s == "Save resolution as…"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn global_options_are_visible_and_automatic_exclusions_remain_reviewable() {
|
||||
let mut app = sample();
|
||||
|
|
|
|||
|
|
@ -253,7 +253,11 @@ timers. An ignored row is recorded as an explicit exclusion. Duration overrides
|
|||
retain original cell values and the fact that a correction was requested. Use
|
||||
`expected_headers` to guard reusable profiles against changed layouts.
|
||||
|
||||
**Save resolution as…** writes a portable profile JSON, usable with CLI
|
||||
Under **Resolutions…**, the two main actions are **Save resolution** and
|
||||
**Reuse remembered resolution**. **Advanced** contains file management, reset,
|
||||
and forget controls.
|
||||
|
||||
**Save resolution as…** (under Advanced) writes a portable profile JSON, usable with CLI
|
||||
`--profile`. **Save (overwrite resolution)** replaces the loaded/saved profile;
|
||||
Save as refuses existing files unless its replacement checkbox is enabled.
|
||||
These actions save decisions, not a rewritten spreadsheet or an Ontime export.
|
||||
|
|
@ -261,7 +265,7 @@ Profiles may contain unfinished decisions; loading one always requires a fresh
|
|||
analysis. Explicitly loaded profiles use worksheet row numbers, so review their
|
||||
applicability when the document has changed.
|
||||
|
||||
**Remember resolution** stores a validated profile in the platform's user
|
||||
**Save resolution** stores a validated profile in the platform's user
|
||||
configuration directory, under `rundown-converter/resolutions` (on Linux,
|
||||
`$XDG_CONFIG_HOME/rundown-converter/resolutions`, normally
|
||||
`~/.config/rundown-converter/resolutions`). The status displays the exact path.
|
||||
|
|
|
|||
Loading…
Reference in New Issue