diff options
Diffstat (limited to 'logic/stage.gd')
| -rw-r--r-- | logic/stage.gd | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/logic/stage.gd b/logic/stage.gd index 1352816..6f46489 100644 --- a/logic/stage.gd +++ b/logic/stage.gd @@ -19,8 +19,10 @@ const OPTION_SETS_TREE_STRUCTURE := { } } +var staged_entry_hash: int var option_sets: Dictionary +onready var confirm_action := get_node("/root/main/confirm_action") as ConfirmationDialog onready var process_id := get_node("controls/process_id") as LineEdit onready var surgery_id := get_node("controls/surgery_id") as LineEdit onready var date := get_node("controls/date_picker") as DatePicker @@ -65,8 +67,8 @@ func _ready(): "intervention": intervention } for key in option_sets_map: - var button := option_sets_map[key].get_node("auto") as Button - button.connect("pressed", self, "auto_populate", [key]) + var button := option_sets_map[key].get_node("option_set") as Button + button.connect("pressed", self, "show_option_sets", [key]) func get_option_sets(field: String): @@ -86,13 +88,13 @@ func get_option_sets(field: String): return options -func auto_populate(field: String): +func show_option_sets(field: String): var stage_options = get_node("/root/main/popup_list") as Popup - stage_options.connect("item_selected", self, "auto_selected", [field], CONNECT_ONESHOT) + stage_options.connect("item_selected", self, "option_set_selected", [field], CONNECT_ONESHOT) stage_options.popup_options(get_option_sets(field)) -func auto_selected(index: int, field: String): +func option_set_selected(index: int, field: String): var field_input: LineEdit = self[field] field_input.text = get_option_sets(field)[index] field_input.caret_position = field_input.text.length() @@ -107,11 +109,22 @@ func save_action(): func discard_action(): + if get_stage().hash() != staged_entry_hash: + confirm_action.window_title = "DISCARD ENTRY" + confirm_action.dialog_text = "Do you want to discard the changes made?" + confirm_action.connect("confirmed", self, "discard_action_confirmed", [], CONNECT_ONESHOT) + confirm_action.show_modal(true) + else: + discard_action_confirmed() + + +func discard_action_confirmed(): self.visible = false emit_signal("discard") func set_stage(entry: Dictionary): + staged_entry_hash = entry.hash() process_id.text = entry.process_id surgery_id.text = entry.surgery_id date.set_date(entry.date_year, entry.date_month, entry.date_day) @@ -225,8 +238,8 @@ func pointer_input_on_click_handler(pointer: PointerInputSensor.PointerInputData var button: Button if target is Button: button = target - elif target.get_node("auto") is Button: - button = target.get_node("auto") + elif target.get_node("option_set") is Button: + button = target.get_node("option_set") if button != null && button.get_global_rect().has_point(pointer.current_position): if button is CheckBox || button is CheckButton: |
