Fix roll editing not requiring a non-empty ID

This commit is contained in:
pjht 2023-05-31 13:24:50 -05:00
parent dbdf6d9d8f
commit ae1dd2b771
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A

View File

@ -24,6 +24,7 @@ pub struct RollViewWindow {
edit_film: FilmKey,
editing_shot_at: bool,
edit_shot_at: Option<u32>,
show_id_req_err: bool,
show_pp_iso_err: bool,
}
@ -45,6 +46,7 @@ impl RollViewWindow {
edit_film: FilmKey::from(0),
editing_shot_at: false,
edit_shot_at: None,
show_id_req_err: false,
show_pp_iso_err: false,
}
}
@ -56,17 +58,26 @@ impl RollViewWindow {
.open(&mut close_unclicked);
window.show(ctx, |ui| {
let roll = &mut app_state.rolls[self.roll];
if self.editing_id {
if self.show_id_req_err {
ui.colored_label(Color32::DARK_RED, "Error: ID required");
}
}
ui.horizontal(|ui| {
if self.editing_id {
let label = ui.label("ID: ");
ui.text_edit_singleline(&mut self.edit_id)
.labelled_by(label.id);
if ui.button("Done").clicked() {
roll.id = self.edit_id.clone();
self.editing_id = false;
self.show_id_req_err = self.edit_id.is_empty();
if !self.show_id_req_err {
roll.id = self.edit_id.clone();
self.editing_id = false;
}
}
if ui.button("Cancel").clicked() {
self.editing_id = false;
self.show_id_req_err = false;
}
} else {
ui.label(format!("ID: {}", roll.id));
@ -221,6 +232,7 @@ impl RollViewWindow {
}
if ui.button("Cancel").clicked() {
self.editing_shot_at = false;
self.show_pp_iso_err = false;
}
} else {
ui.horizontal(|ui| {