PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 36ms app.codeStats 1ms

/app/components/RootContent.io

http://github.com/pgregory/blackpool
Unknown | 67 lines | 63 code | 4 blank | 0 comment | 0 complexity | 49d5e65abb6ebc9fced51eb0e8b08a87 MD5 | raw file
 1RootContent := 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  
38  showPendingTasks := method(
39    listComponent filterBlock = block(items, items select(v, v isPending))
40  )
41  showAllTasks := method(
42    listComponent filterBlock = block(items, items)
43  )
44  showCompletedTasks := method(
45    listComponent filterBlock = block(items, items select(v, v completed))
46  )
47  showMissedTasks := method(
48    listComponent filterBlock = block(items, items select(v, v isMissed))
49  )
50  addNewTask := method(
51    if(taskEditor task isValid,
52      listComponent items append(
53        taskEditor task
54      )
55    )
56  )
57
58  renderOn := method(html,
59    html h1 with(html text("Todo-List"))
60    html div with(html render(menuComponent))
61    html div with(html render(listComponent))
62    html div with(html render(taskEditor))
63    html text(debugMsg)
64  )
65)
66
67