PageRenderTime 198ms CodeModel.GetById 100ms app.highlight 12ms RepoModel.GetById 79ms app.codeStats 0ms

/app/components/TaskEditor.io

http://github.com/pgregory/blackpool
Unknown | 50 lines | 43 code | 7 blank | 0 comment | 0 complexity | 4545259b23298fc110256a6cc2363acf MD5 | raw file
 1TaskEditor := Object clone do(
 2  init := method(
 3    task ::= Task clone
 4  )
 5
 6  renderOn := method(html,
 7    html div with(
 8      html form with(
 9        html table with(
10          html tr with(self renderNameInputOn(html))
11          html tr with(self renderDescriptionInputOn(html))
12          html tr with(self renderDateInputOn(html))
13          html tr with(self renderCompletedSelectionOn(html))
14          html tr with(self renderButtonsOn(html))
15        )
16      )
17    )
18  )
19
20  renderNameInputOn := method(html,
21    html td with(html label addAttribute("for", "name") with(html text("Name:")))
22    html td with(html inputText callback(block(value, task taskName = value)) with())
23  )
24
25  renderDescriptionInputOn := method(html,
26    html td with(html label addAttribute("for", "description") with(html text("Description:")))
27    html td with(html inputText callback(block(value, task taskDescription = value)) with())
28  )
29
30  renderDateInputOn := method(html,
31    html td with(html label addAttribute("for", "date") with(html text("Date:")))
32    html td with(html inputDate callback(block(value, task deadline fromString(value, "%Y-%m-%d"))) with())
33  )
34
35  renderCompletedSelectionOn := method(html,
36    html td with(html label addAttribute("for", "completed") with(html text("Completed:")))
37    html td with(html select with(
38        html option addAttribute("value", "yes") with(html text("yes"))
39        html option addAttribute("value", "no") addAttribute("selected", "selected") with(html text("no"))
40      )
41    )
42  )
43
44  renderButtonsOn := method(html,
45    html td with(html space)
46    html td with(html button("Save", block(self addTask))  
47            html button("Cancel", block()))
48  )
49)
50