EZ-Bkup/views/edit_routine_dialog.nim
2023-07-01 13:33:28 -05:00

42 lines
1.3 KiB
Nim

#[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 =
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