]>
Commit | Line | Data |
---|---|---|
1de09faf | 1 | DoodleComponent subclass: DoodleApp [ |
2 | | currentView | | |
3 | ||
4 | DoodleApp class >> canBeRoot [ ^true ] | |
5 | ||
6 | initialize [ | |
7 | super initialize. | |
8 | currentView := ListPollView new. | |
9 | ] | |
10 | ||
11 | states [ ^{ self } ] | |
12 | ||
13 | children [ ^{ currentView } ] | |
14 | ||
15 | currentView: view [ | |
16 | currentView := view | |
17 | ] | |
18 | ||
19 | initialRequest: aRequest [ | |
20 | super initialRequest: aRequest. | |
21 | aRequest fields at: 'pollId' | |
22 | ifPresent: [ :value | | |
23 | self currentView: (EditPollView new). | |
24 | currentView pollId: value. | |
25 | ] | |
26 | ] | |
27 | ||
28 | renderMenuItemOn: html callback: aCallback with: aName [ | |
29 | html listItem | |
30 | class: 'pure-menu-item'; | |
31 | with: [ | |
32 | html anchor | |
33 | class: 'pure-menu-link'; | |
34 | callback: aCallback; | |
35 | with: aName | |
36 | ]. | |
37 | ] | |
38 | ||
39 | renderMenuOn: html [ | |
40 | html div | |
41 | class: 'pure-menu pure-menu-horizontal'; | |
42 | with: [ | |
43 | html unorderedList | |
44 | class: 'pure-menu-list'; | |
45 | with: [ | |
46 | self renderMenuItemOn: html | |
47 | callback: [ self currentView: (ListPollView new) ] | |
48 | with: 'Home'. | |
49 | self renderMenuItemOn: html | |
50 | callback: [ self currentView: (NewPollView new) ] | |
51 | with: 'New Poll'. | |
52 | (Seaside.WACurrentSession value user) ifNil: [ | |
53 | self renderMenuItemOn: html | |
54 | callback: [ self currentView: (LoginUserView new) ] | |
55 | with: 'Login'. | |
56 | self renderMenuItemOn: html | |
57 | callback: [ self currentView: (NewUserView new) ] | |
58 | with: 'New account'. | |
59 | ] ifNotNil: [ | |
60 | self renderMenuItemOn: html | |
61 | callback: [ self currentView: (UserAccountView new) ] | |
62 | with: 'Your account'. | |
63 | ] | |
64 | ] | |
65 | ]. | |
66 | ] | |
67 | ||
68 | updateRoot: anHtmlRoot [ | |
69 | super updateRoot: anHtmlRoot. | |
70 | anHtmlRoot stylesheet url: '/css/pure-min.css'. | |
71 | anHtmlRoot stylesheet url: '/css/font-awesome.min.css'. | |
72 | anHtmlRoot stylesheet url: '/css/doodle.css'. | |
73 | ] | |
74 | ||
75 | renderContentOn: html [ | |
76 | self renderMenuOn: html. | |
77 | html render: currentView. | |
78 | html horizontalRule. | |
79 | html text: 'Generated at: '. | |
80 | html render: (DateTime now). | |
81 | ] | |
82 | ] | |
83 | ||
84 | (DoodleApp registerAsApplication: 'doodle') | |
85 | preferenceAt: #sessionClass put: DoodleSession |