You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.4 KiB
42 lines
1.4 KiB
1 year ago
|
#[Copyright 2023 ITwrx.
|
||
|
This file is part of EZ-Bkup.
|
||
|
EZ-Bkup is released under the General Public License 3.0.
|
||
|
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||
|
|
||
|
import owlkettle
|
||
|
import ../models/routine
|
||
|
import routine_editor
|
||
|
|
||
|
type EditRoutineDialogMode* = enum
|
||
|
EditRoutineCreate = "Create"
|
||
|
EditRoutineUpdate = "Update"
|
||
|
|
||
|
viewable EditRoutineDialog:
|
||
|
## A dialog for editing a routine. We use the same dialog for creating and updating
|
||
|
## a routine. Since we want to use different titles and labels for the buttons in each case,
|
||
|
## the EditRoutineDialog.mode field specifies the purpose of the dialog.
|
||
|
|
||
|
routine: Routine ## The routine being edited
|
||
|
mode: EditRoutineDialogMode ## Purpose of the dialog (create/update)
|
||
|
|
||
|
method view(dialog: EditRoutineDialogState): Widget {.locks: "unknown".} =
|
||
|
result = gui:
|
||
|
Dialog:
|
||
|
title = $dialog.mode & " Routine"
|
||
|
defaultSize = (800, 600)
|
||
|
DialogButton {.addButton.}:
|
||
|
# Create / Update Button
|
||
|
text = $dialog.mode
|
||
|
style = [ButtonSuggested]
|
||
|
res = DialogAccept
|
||
|
DialogButton {.addButton.}:
|
||
|
text = "Cancel"
|
||
|
res = DialogCancel
|
||
|
# Content
|
||
|
RoutineEditor:
|
||
|
routine = dialog.routine
|
||
|
proc changed(routine: Routine) =
|
||
|
dialog.routine = routine
|
||
|
|
||
|
export EditRoutineDialog, EditRoutineDialogState
|