Add a configurable default name for unnamed breaks
Beffroi/beffroi-tools/pipeline/head This commit looks good
Details
Beffroi/beffroi-tools/pipeline/head This commit looks good
Details
This commit is contained in:
parent
0cffbe6201
commit
14f641276b
|
|
@ -589,6 +589,11 @@ impl App {
|
|||
"Treat rows without a timing as notes",
|
||||
)
|
||||
.on_hover_text("Attach rows without a timing to the preceding event. Applied before automatic warning exclusions, so notes are retained where possible.");
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Default break name");
|
||||
ui.add(egui::TextEdit::singleline(&mut profile.default_break_name).hint_text("Break"))
|
||||
.on_hover_text("Names unnamed gaps and events created from them. Source names and individual event titles take precedence. Leave empty to keep automatic names.");
|
||||
});
|
||||
ui.small("Applied on analysis / recheck. Export requires a consistent schedule.");
|
||||
if before != serde_json::to_string(&profile).unwrap() {
|
||||
self.profile = serde_json::to_string_pretty(&profile).unwrap();
|
||||
|
|
|
|||
|
|
@ -787,6 +787,7 @@ fn schedule_settings_changed(current: &Profile, analyzed: &Profile) -> bool {
|
|||
|| current.durations != analyzed.durations
|
||||
|| current.gap_resolutions != analyzed.gap_resolutions
|
||||
|| current.gap_options != analyzed.gap_options
|
||||
|| current.default_break_name != analyzed.default_break_name
|
||||
}
|
||||
|
||||
fn preview_row_settings_changed(row: &PreviewRow, current: &Profile, analyzed: &Profile) -> bool {
|
||||
|
|
@ -799,6 +800,7 @@ fn preview_row_settings_changed(row: &PreviewRow, current: &Profile, analyzed: &
|
|||
let gap_changed = row.gap_key.as_ref().is_some_and(|key| {
|
||||
current.gap_resolutions.get(key) != analyzed.gap_resolutions.get(key)
|
||||
|| current.gap_options.get(key) != analyzed.gap_options.get(key)
|
||||
|| current.default_break_name != analyzed.default_break_name
|
||||
});
|
||||
let part_changed = row.split_part.is_some_and(|part| {
|
||||
current
|
||||
|
|
@ -1245,7 +1247,12 @@ impl App {
|
|||
let mut options = profile.gap_options.get(key).cloned().unwrap_or_default();
|
||||
if action == "create_event" {
|
||||
ui.label("Event title");
|
||||
ui.add(egui::TextEdit::singleline(&mut options.title).hint_text("Gap name, or Break"));
|
||||
let hint = if profile.default_break_name.trim().is_empty() {
|
||||
"Gap name, or Break".to_owned()
|
||||
} else {
|
||||
format!("Gap name, or {}", profile.default_break_name.trim())
|
||||
};
|
||||
ui.add(egui::TextEdit::singleline(&mut options.title).hint_text(hint));
|
||||
}
|
||||
ui.checkbox(&mut options.distribute, "Distribute across neighbours");
|
||||
if options.distribute {
|
||||
|
|
|
|||
|
|
@ -148,6 +148,8 @@ pub struct Profile {
|
|||
/// Exact gap key -> keep, extend_previous, add_to_next, or create_event.
|
||||
pub gap_resolutions: BTreeMap<String, String>,
|
||||
pub gap_options: BTreeMap<String, GapOptions>,
|
||||
/// Fallback name for unnamed breaks; source and individual names take precedence.
|
||||
pub default_break_name: String,
|
||||
}
|
||||
impl Profile {
|
||||
pub fn margin_ms(&self) -> Option<i64> {
|
||||
|
|
|
|||
|
|
@ -836,7 +836,12 @@ fn resolve_gaps(rundown: &mut Rundown, profile: &Profile) -> Vec<Diagnostic> {
|
|||
},
|
||||
)
|
||||
});
|
||||
for gap in gaps {
|
||||
for mut gap in gaps {
|
||||
if !profile.default_break_name.trim().is_empty()
|
||||
&& (gap.title.trim().is_empty() || gap.title.starts_with("Unallocated"))
|
||||
{
|
||||
gap.title = profile.default_break_name.trim().into();
|
||||
}
|
||||
let key = gap.key();
|
||||
let action = profile
|
||||
.gap_resolutions
|
||||
|
|
|
|||
|
|
@ -2002,6 +2002,41 @@ fn gap_distribution_preserves_block_bounds_and_exports_generated_timers() {
|
|||
);
|
||||
assert_eq!(e.title, "Break");
|
||||
assert_eq!(r.entries.len(), 5);
|
||||
profile.default_break_name = " Pause ".into();
|
||||
let saved = serde_json::to_string(&profile).unwrap();
|
||||
let profile_roundtrip: Profile = serde_json::from_str(&saved).unwrap();
|
||||
let renamed = analyze(&t, &profile_roundtrip).rundown.unwrap();
|
||||
assert_eq!(
|
||||
renamed
|
||||
.entries
|
||||
.iter()
|
||||
.find(|e| e.gap_origin.is_some())
|
||||
.unwrap()
|
||||
.title,
|
||||
"Pause"
|
||||
);
|
||||
profile.gap_options.insert(
|
||||
gap.key(),
|
||||
GapOptions {
|
||||
title: "Coffee".into(),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
let overridden = analyze(&t, &profile).rundown.unwrap();
|
||||
assert_eq!(
|
||||
overridden
|
||||
.entries
|
||||
.iter()
|
||||
.find(|e| e.gap_origin.is_some())
|
||||
.unwrap()
|
||||
.title,
|
||||
"Coffee"
|
||||
);
|
||||
profile.gap_resolutions.clear();
|
||||
let retained = analyze(&t, &profile).rundown.unwrap();
|
||||
assert_eq!(retained.gaps[0].title, "Pause");
|
||||
assert_eq!(retained.gaps[0].key(), gap.key());
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_value(analyze(&t, &Profile::default()).rundown.unwrap()).unwrap(),
|
||||
serde_json::to_value(baseline).unwrap()
|
||||
|
|
|
|||
|
|
@ -545,3 +545,8 @@ table structure, cell formats and representative time values when redacted.
|
|||
Private originals stay out of Git; regression fixtures are synthetic.
|
||||
|
||||
See [all tools](../README.md) and [repository development](development.md).
|
||||
|
||||
In Setup → General options, **Default break name** names unnamed gaps and the
|
||||
events created from them. Source break names and individual event titles take
|
||||
precedence. Leave it empty to retain automatic names. Apply & recheck after
|
||||
changing it; the setting is saved with resolution profiles.
|
||||
|
|
|
|||
Loading…
Reference in New Issue