fix list.selected behavior

master
itwrx 1 year ago
parent 372a2076f4
commit 1dd810c6b3
  1. 14
      views/routine_list.nim

@ -4,7 +4,7 @@ EZ-Bkup is released under the General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]#
import owlkettle
import std/osproc, std/os, std/logging
import osproc, os, logging, sequtils
import edit_routine_dialog
import "../models/routine", "../shared"
@ -13,15 +13,10 @@ viewable RoutineList:
runStatus: string
selected: seq[RoutineId]
# hey, hook.
hooks:
# yes, you, the build hook.
build:
# i love you. :)
state.selected = selectedPreload()
proc changed(state: bool)
var thread: Thread[RoutineListState]
proc rsyncThread(list: RoutineListState) {.thread.} =
@ -116,7 +111,7 @@ method view(list: RoutineListState): Widget =
margin = 6
spacing = 6
Switch {.expand: false, vAlign: AlignCenter.}:
state = routine.selByDef
state = sequtils.any(list.selected, proc (id: RoutineId): bool = id == routine.id)
tooltip = "Enable/Disable this Routine for the current Bkup run."
proc changed(state: bool) =
if state == true:
@ -125,9 +120,6 @@ method view(list: RoutineListState): Widget =
let index = list.selected.find(routine.id)
if index != -1:
list.selected.delete(index)
if not list.changed.isNil:
list.changed.callback(true)
Label:
text = "<span size=\"large\">" & routine.name & "</span>"
xAlign = 0
@ -146,12 +138,14 @@ method view(list: RoutineListState): Widget =
if res.kind == DialogAccept:
# The "Update" button was clicked
list.routineModel.update(EditRoutineDialogState(state).routine)
list.selected = selectedPreload()
# Delete Button
Button {.expand: false.}:
icon = "user-trash-symbolic"
tooltip = "Delete this Routine. Warning: will not ask you to confirm."
proc clicked() =
list.routineModel.delete(routine.id)
list.selected = selectedPreload()
if routine.id in list.selected:
Box:
orient = OrientY

Loading…
Cancel
Save