aboutsummaryrefslogtreecommitdiff
path: root/logic/database.gd
diff options
context:
space:
mode:
Diffstat (limited to 'logic/database.gd')
-rw-r--r--logic/database.gd19
1 files changed, 14 insertions, 5 deletions
diff --git a/logic/database.gd b/logic/database.gd
index 438a2dd..2285470 100644
--- a/logic/database.gd
+++ b/logic/database.gd
@@ -12,7 +12,7 @@ const ENTRY_PROTOTYPE: Dictionary = {
"date_year": 0,
"date_month": 0,
"date_day": 0,
- "anesthetic": "",
+ "anesthesia": "",
"first_assistant": "",
"type": "",
"sub_type": "",
@@ -195,6 +195,14 @@ func store_database(file_path: String = DATABASE_FILE_PATH):
file.close()
+func clear_database(save_changes: bool = false):
+ clear_selection()
+ self.clear()
+ db.resize(0)
+ if save_changes:
+ store_database()
+
+
static func instance_entry(params: Dictionary = {}) -> Dictionary:
var new_entry := ENTRY_PROTOTYPE.duplicate(true)
new_entry.process_id = params.get("process_id", "")
@@ -207,7 +215,7 @@ static func instance_entry(params: Dictionary = {}) -> Dictionary:
new_entry.date_day = params.get("date_day", today.day)
new_entry.date = params.get("date", get_entry_date(new_entry)) # @DAM We should store only one version of the date.
- new_entry.anesthetic = params.get("anesthetic", "")
+ new_entry.anesthesia = params.get("anesthesia", "")
new_entry.first_assistant = params.get("first_assistant", "")
new_entry.type = params.get("type", "")
new_entry.sub_type = params.get("sub_type", "")
@@ -234,9 +242,8 @@ static func set_entry_date(entry: Dictionary, date: String):
entry.date_day = int(date.substr(month_day_idx + 1))
-func fake_database():
- self.clear()
- db.resize(0)
+func fake_database(save_changes: bool = false):
+ clear_database()
for idx in range(500):
var date_year = 1 + int(float(idx) / 365.0)
var date_month = idx % 12
@@ -248,6 +255,8 @@ func fake_database():
})
db.append(fake_entry)
self.add_item(get_entry_view(fake_entry))
+ if save_changes:
+ store_database()
func pointer_input_handler(pointer: PointerInputSensor.PointerInputData):