aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2022-02-09 00:21:59 +0000
committerdam <dam@gudinoff>2022-02-09 00:21:59 +0000
commitcc3f6e5ea29bfe006576a35b5fa24d029a07cf7c (patch)
tree05a9671dde552fbebadd326df0fbc9d2b58b1b60
parent9478682f845d5518ca1c6a4552a8b710d1a2b238 (diff)
downloadsurgery-log-cc3f6e5ea29bfe006576a35b5fa24d029a07cf7c.tar.zst
surgery-log-cc3f6e5ea29bfe006576a35b5fa24d029a07cf7c.zip
Add confirmation dialog to entry destructive actions.
-rw-r--r--logic/database.gd8
-rw-r--r--logic/stage.gd27
-rw-r--r--main.gd32
-rw-r--r--main.tscn18
-rw-r--r--menu/menu.gd10
-rw-r--r--readme.md4
6 files changed, 61 insertions, 38 deletions
diff --git a/logic/database.gd b/logic/database.gd
index 3c2d6b7..1518490 100644
--- a/logic/database.gd
+++ b/logic/database.gd
@@ -7,6 +7,7 @@ var db: Array
var selected_idx: int
var staged_idx: int
+onready var confirm_action := get_node("/root/main/confirm_action") as ConfirmationDialog
onready var stage := get_node("/root/main/stage") as Stage
onready var delete_button := get_node("actions/delete") as Button
onready var edit_button := get_node("actions/edit") as Button
@@ -65,6 +66,13 @@ func delete_action():
if selected_idx < 0:
return
+ confirm_action.window_title = "DELETE ENTRY"
+ confirm_action.dialog_text = "Do you want to delete entry with process ID '%s' from the database?" % db[selected_idx].process_id
+ confirm_action.connect("confirmed", self, "delete_action_confirmed", [], CONNECT_ONESHOT)
+ confirm_action.show_modal(true)
+
+
+func delete_action_confirmed():
db.remove(selected_idx)
self.remove_item(selected_idx)
selected_idx = -1
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:
diff --git a/main.gd b/main.gd
index a1b9aca..bf31aa0 100644
--- a/main.gd
+++ b/main.gd
@@ -1,11 +1,13 @@
extends Control
-var timeout: float
+var power_throttle_timeout: float
-onready var controls_sensible_to_keyboard: Array = [
+onready var file_picker := get_node("/root/main/file_picker") as FileDialog
+onready var confirm_action := get_node("/root/main/confirm_action") as ConfirmationDialog
+onready var controls_sensible_to_keyboard := [
self,
- get_node("/root/main/file_picker"),
- get_node("/root/main/confirm_action"),
+ file_picker,
+ confirm_action,
]
@@ -14,27 +16,35 @@ func _init():
PhysicsServer.set_active(false)
+func _ready():
+ confirm_action.get_cancel().connect("pressed", self, "dialog_cancelled", ["confirmed"])
+ file_picker.get_cancel().connect("pressed", self, "dialog_cancelled", ["file_selected"])
+
+
func _process(delta: float):
var keyboard_height: int = OS.get_virtual_keyboard_height()
for it in controls_sensible_to_keyboard:
it.margin_bottom = -keyboard_height
- # @DAM Debug information.
-# $debug.text = "%s" % Engine.get_frames_per_second()
-# $debug.text = "%s" % timeout
- if timeout > 0.0:
- timeout -= delta
+ if power_throttle_timeout > 0.0:
+ power_throttle_timeout -= delta
else:
Engine.target_fps = 10
func _input(event: InputEvent):
Engine.target_fps = 0
- timeout = 3.5
+ power_throttle_timeout = 3.5
func _unhandled_input(event: InputEvent):
Engine.target_fps = 0
- timeout = 3.5
+ power_throttle_timeout = 3.5
+
+
+func dialog_cancelled(confirmation_signal_name: String):
+ var confirmation_handlers = confirm_action.get_signal_connection_list(confirmation_signal_name)
+ for it in confirmation_handlers:
+ confirm_action.disconnect(it.signal, it.target, it.method)
diff --git a/main.tscn b/main.tscn
index a6abf1b..ead511e 100644
--- a/main.tscn
+++ b/main.tscn
@@ -110,7 +110,7 @@ placeholder_text = "Local"
caret_blink = true
caret_blink_speed = 0.5
-[node name="auto" type="Button" parent="stage/controls/place"]
+[node name="option_set" type="Button" parent="stage/controls/place"]
anchor_left = 0.85
anchor_right = 1.0
anchor_bottom = 1.0
@@ -127,7 +127,7 @@ placeholder_text = "Anestesia"
caret_blink = true
caret_blink_speed = 0.5
-[node name="auto" type="Button" parent="stage/controls/anesthesia"]
+[node name="option_set" type="Button" parent="stage/controls/anesthesia"]
anchor_left = 0.85
anchor_right = 1.0
anchor_bottom = 1.0
@@ -144,7 +144,7 @@ placeholder_text = "1º Ajudante"
caret_blink = true
caret_blink_speed = 0.5
-[node name="auto" type="Button" parent="stage/controls/first_assistant"]
+[node name="option_set" type="Button" parent="stage/controls/first_assistant"]
anchor_left = 0.85
anchor_right = 1.0
anchor_bottom = 1.0
@@ -161,7 +161,7 @@ placeholder_text = "Tipo"
caret_blink = true
caret_blink_speed = 0.5
-[node name="auto" type="Button" parent="stage/controls/type"]
+[node name="option_set" type="Button" parent="stage/controls/type"]
anchor_left = 0.85
anchor_right = 1.0
anchor_bottom = 1.0
@@ -178,7 +178,7 @@ placeholder_text = "Subtipo"
caret_blink = true
caret_blink_speed = 0.5
-[node name="auto" type="Button" parent="stage/controls/sub_type"]
+[node name="option_set" type="Button" parent="stage/controls/sub_type"]
anchor_left = 0.85
anchor_right = 1.0
anchor_bottom = 1.0
@@ -195,7 +195,7 @@ placeholder_text = "Sub-Subtipo"
caret_blink = true
caret_blink_speed = 0.5
-[node name="auto" type="Button" parent="stage/controls/sub_sub_type"]
+[node name="option_set" type="Button" parent="stage/controls/sub_sub_type"]
anchor_left = 0.85
anchor_right = 1.0
anchor_bottom = 1.0
@@ -212,7 +212,7 @@ placeholder_text = "Patologia"
caret_blink = true
caret_blink_speed = 0.5
-[node name="auto" type="Button" parent="stage/controls/pathology"]
+[node name="option_set" type="Button" parent="stage/controls/pathology"]
anchor_left = 0.85
anchor_right = 1.0
anchor_bottom = 1.0
@@ -229,7 +229,7 @@ placeholder_text = "Intervenção"
caret_blink = true
caret_blink_speed = 0.5
-[node name="auto" type="Button" parent="stage/controls/intervention"]
+[node name="option_set" type="Button" parent="stage/controls/intervention"]
anchor_left = 0.85
anchor_right = 1.0
anchor_bottom = 1.0
@@ -308,7 +308,7 @@ anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
window_title = "CONFIRM ACTION"
-dialog_text = "Are you sure you want to delete all filters?"
+dialog_text = "Do you confirm this action?"
dialog_autowrap = true
[node name="popup_list" type="Popup" parent="."]
diff --git a/menu/menu.gd b/menu/menu.gd
index 1df6f28..5847d5b 100644
--- a/menu/menu.gd
+++ b/menu/menu.gd
@@ -23,20 +23,12 @@ func _ready():
for idx in range(menu_items.size()):
popup.add_item(menu_items[idx].label, idx)
popup.connect("id_pressed", self, "id_pressed")
- file_picker.get_cancel().connect("pressed", self, "dialog_cancelled", ["file_selected"])
- confirm_action.get_cancel().connect("pressed", self, "dialog_cancelled", ["confirmed"])
func id_pressed(id: int):
self.call_deferred(menu_items[id].action)
-func dialog_cancelled(confirmation_signal_name: String):
- var confirmation_handlers = confirm_action.get_signal_connection_list(confirmation_signal_name)
- for it in confirmation_handlers:
- confirm_action.disconnect(it.signal, it.target, it.method)
-
-
func _menu_import_option_sets_action():
file_picker.window_title = "IMPORT OPTION SETS"
file_picker.mode = FileDialog.MODE_OPEN_FILE
@@ -85,7 +77,7 @@ func _menu_clear_data_action():
func _menu_about_action():
- confirm_action.window_title = "FAKE DB"
+ confirm_action.window_title = "ABOUT"
confirm_action.dialog_text = "About text here!"
confirm_action.show_modal(true)
diff --git a/readme.md b/readme.md
index ad0ec8f..7aed207 100644
--- a/readme.md
+++ b/readme.md
@@ -24,8 +24,8 @@ Surgery Log
- should show a pop-up with multiple options filtered according to current filters;
- allow options to be scrolled by dragging;
- selecting option puts that text on the associated LineEdit;
-- [ ] add pop-up asking if changes are to be discarded once the stage screen's discard button is pressed;
-- [ ] add pop-up confirming delete-entry action; (pressing back should cancel the action);
+- [x] add pop-up asking if changes are to be discarded once the stage screen's discard button is pressed;
+- [x] add pop-up confirming delete-entry action;
- [ ] edit and delete action buttons should be faded-out when no entry is selected;
- [ ] Implement file access permission check on Android:
```py