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
|
selectedEntry = -1
|
||||||
filter: Filter
|
filter: Filter
|
||||||
entriesLen: int
|
entriesLen: int
|
||||||
|
doneswitch = true
|
||||||
const
|
const
|
||||||
contentSuffix = cstring"content"
|
contentSuffix = cstring"content"
|
||||||
completedSuffix = cstring"completed"
|
completedSuffix = cstring"completed"
|
||||||
|
|
@ -62,9 +62,9 @@ proc toggleEntry(ev: Event; n: VNode) =
|
||||||
markAsCompleted(id, not isCompleted(id))
|
markAsCompleted(id, not isCompleted(id))
|
||||||
|
|
||||||
proc onAllDone(ev: Event; n: VNode) =
|
proc onAllDone(ev: Event; n: VNode) =
|
||||||
clear()
|
for i in 0..<entriesLen:
|
||||||
selectedEntry = -1
|
markAsCompleted(i, doneswitch)
|
||||||
|
doneswitch = not doneswitch
|
||||||
proc clearCompleted(ev: Event, n: VNode) =
|
proc clearCompleted(ev: Event, n: VNode) =
|
||||||
for i in 0..<entriesLen:
|
for i in 0..<entriesLen:
|
||||||
if isCompleted(i): setEntryContent(i, nil)
|
if isCompleted(i): setEntryContent(i, nil)
|
||||||
|
|
@ -124,8 +124,8 @@ proc createDom(data: RouterData): VNode =
|
||||||
section(class = "todoapp"):
|
section(class = "todoapp"):
|
||||||
makeHeader()
|
makeHeader()
|
||||||
section(class = "main"):
|
section(class = "main"):
|
||||||
input(class = "toggle-all", `type` = "checkbox", name = "toggle")
|
input(class = "toggle-all", `type` = "checkbox", id = "toggle", onclick = onAllDone)
|
||||||
label(`for` = "toggle-all", onclick = onAllDone):
|
label(`for` = "toggle"):
|
||||||
text "Mark all as complete"
|
text "Mark all as complete"
|
||||||
var entriesCount = 0
|
var entriesCount = 0
|
||||||
var completedCount = 0
|
var completedCount = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue