3 tiny changes for "All Done" button. (#136)
1."onAllDone" callback fixation. Because the callback deletes all tasks instead of making them done, fixed. 2.Retouching checkbox and label property. Because a checkbox didn't work and label did'nt affect the checkbox, I set the callback on checkbox, and rename label's "for" property. 3.Adding Global var "doneswitch" for convinience. I guess the button should be able to make "All Done" and "All Undone" because the checkbox is not a button. So make it done, undone button interfaced with the checkbox's display.
This commit is contained in:
parent
7440393d3a
commit
0a7136b8fc
1 changed files with 6 additions and 6 deletions
|
|
@ -9,7 +9,7 @@ var
|
|||
selectedEntry = -1
|
||||
filter: Filter
|
||||
entriesLen: int
|
||||
|
||||
doneswitch = true
|
||||
const
|
||||
contentSuffix = cstring"content"
|
||||
completedSuffix = cstring"completed"
|
||||
|
|
@ -62,9 +62,9 @@ proc toggleEntry(ev: Event; n: VNode) =
|
|||
markAsCompleted(id, not isCompleted(id))
|
||||
|
||||
proc onAllDone(ev: Event; n: VNode) =
|
||||
clear()
|
||||
selectedEntry = -1
|
||||
|
||||
for i in 0..<entriesLen:
|
||||
markAsCompleted(i, doneswitch)
|
||||
doneswitch = not doneswitch
|
||||
proc clearCompleted(ev: Event, n: VNode) =
|
||||
for i in 0..<entriesLen:
|
||||
if isCompleted(i): setEntryContent(i, nil)
|
||||
|
|
@ -124,8 +124,8 @@ proc createDom(data: RouterData): VNode =
|
|||
section(class = "todoapp"):
|
||||
makeHeader()
|
||||
section(class = "main"):
|
||||
input(class = "toggle-all", `type` = "checkbox", name = "toggle")
|
||||
label(`for` = "toggle-all", onclick = onAllDone):
|
||||
input(class = "toggle-all", `type` = "checkbox", id = "toggle", onclick = onAllDone)
|
||||
label(`for` = "toggle"):
|
||||
text "Mark all as complete"
|
||||
var entriesCount = 0
|
||||
var completedCount = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue