PageRenderTime 31ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/app/components/RootContent.io

http://github.com/pgregory/blackpool
Unknown | 67 lines | 63 code | 4 blank | 0 comment | 0 complexity | 49d5e65abb6ebc9fced51eb0e8b08a87 MD5 | raw file
  1. RootContent := Object clone do(
  2. init := method(
  3. menuComponent ::= MenuComponent clone
  4. menuComponent addEntry("All", block(self showAllTasks))
  5. menuComponent addEntry("Completed", block(self showCompletedTasks))
  6. menuComponent addEntry("Pending", block(self showPendingTasks))
  7. menuComponent addEntry("Missed", block(self showMissedTasks))
  8. listComponent ::= ListComponent clone do(
  9. renderItem := method(task, html,
  10. html tr with(
  11. html td with(html text(task deadline))
  12. html td with(html text(task taskName))
  13. html td with(html text(task taskDescription))
  14. html td with(html text(task completed))
  15. )
  16. )
  17. items append(Task clone do(
  18. deadline = Date clone copy(Date today setDay(Date today day - 1))
  19. taskName = "Missed Task"
  20. ))
  21. items append(Task clone do(
  22. deadline = Date clone copy(Date today setDay(Date today day + 2))
  23. taskName = "Pending Task"
  24. ))
  25. items append(Task clone do(
  26. deadline = Date clone copy(Date today setDay(Date today day + 1))
  27. taskName = "Already Completed"
  28. completed = true
  29. ))
  30. )
  31. taskEditor ::= TaskEditor clone
  32. taskEditor addTask := block( self addNewTask ) setIsActivatable(true)
  33. showPendingTasks
  34. debugMsg ::= Sequence clone
  35. count ::= 0
  36. )
  37. showPendingTasks := method(
  38. listComponent filterBlock = block(items, items select(v, v isPending))
  39. )
  40. showAllTasks := method(
  41. listComponent filterBlock = block(items, items)
  42. )
  43. showCompletedTasks := method(
  44. listComponent filterBlock = block(items, items select(v, v completed))
  45. )
  46. showMissedTasks := method(
  47. listComponent filterBlock = block(items, items select(v, v isMissed))
  48. )
  49. addNewTask := method(
  50. if(taskEditor task isValid,
  51. listComponent items append(
  52. taskEditor task
  53. )
  54. )
  55. )
  56. renderOn := method(html,
  57. html h1 with(html text("Todo-List"))
  58. html div with(html render(menuComponent))
  59. html div with(html render(listComponent))
  60. html div with(html render(taskEditor))
  61. html text(debugMsg)
  62. )
  63. )