PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 1ms 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
  1. TaskEditor := Object clone do(
  2. init := method(
  3. task ::= Task clone
  4. )
  5. renderOn := method(html,
  6. html div with(
  7. html form with(
  8. html table with(
  9. html tr with(self renderNameInputOn(html))
  10. html tr with(self renderDescriptionInputOn(html))
  11. html tr with(self renderDateInputOn(html))
  12. html tr with(self renderCompletedSelectionOn(html))
  13. html tr with(self renderButtonsOn(html))
  14. )
  15. )
  16. )
  17. )
  18. renderNameInputOn := method(html,
  19. html td with(html label addAttribute("for", "name") with(html text("Name:")))
  20. html td with(html inputText callback(block(value, task taskName = value)) with())
  21. )
  22. renderDescriptionInputOn := method(html,
  23. html td with(html label addAttribute("for", "description") with(html text("Description:")))
  24. html td with(html inputText callback(block(value, task taskDescription = value)) with())
  25. )
  26. renderDateInputOn := method(html,
  27. html td with(html label addAttribute("for", "date") with(html text("Date:")))
  28. html td with(html inputDate callback(block(value, task deadline fromString(value, "%Y-%m-%d"))) with())
  29. )
  30. renderCompletedSelectionOn := method(html,
  31. html td with(html label addAttribute("for", "completed") with(html text("Completed:")))
  32. html td with(html select with(
  33. html option addAttribute("value", "yes") with(html text("yes"))
  34. html option addAttribute("value", "no") addAttribute("selected", "selected") with(html text("no"))
  35. )
  36. )
  37. )
  38. renderButtonsOn := method(html,
  39. html td with(html space)
  40. html td with(html button("Save", block(self addTask))
  41. html button("Cancel", block()))
  42. )
  43. )