-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.icl
169 lines (140 loc) · 5.19 KB
/
Main.icl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
module Main
import iTasks
import TableData
import iTasks.UI.Editor.Builtin
import qualified Data.Map as M
Start world = startEngine main4 world
simpleData =
[ [ 10, 20, 30 ]
, [ 11, 21, 31 ]
, [ 12, 22, 32 ]
, [ 13, 23, 33 ]
]
dataWithHeader =
( [ "A", "B", "C" ]
, [ [ 10, 20, 30 ]
, [ 11, 21, 31 ]
, [ 12, 22, 32 ]
, [ 13, 23, 33 ]
]
)
dataWithClasses :: ([String], [Maybe String], [([Int], Maybe String)])
dataWithClasses =
( [ "A", "B", "C" ]
, [Just "a", Just "b", Just "c"]
, [ ([ 1234985253, 3409583045983, 30 ], Just "ruDarkRedBg")
, ([ 1234985253, 3409583045983, 30 ], Just "ruDiepRedBg")
, ([ 1234985253, 3409583045983, 30 ], Just "ruRedBg")
, ([ 1234985253, 3409583045983, 31 ], Just "ruOrangeBg")
, ([ 1234985253, 3409583045983, 32 ], Just "ruDarkYellowBg")
, ([ 1234985253, 3409583045983, 33 ], Just "ruBlueBg")
, ([ 1234985253, 3409583045983, 33 ], Just "ruBlueBg70")
, ([ 1234985253, 3409583045983, 33 ], Just "ruPurpleBg")
, ([ 1234985253, 3409583045983, 33 ], Just "ruPurpleBg70")
, ([ 1234985253, 3409583045983, 33 ], Just "ruGreenBg")
, ([ 1234985253, 3409583045983, 33 ], Just "ruGreenBg70")
, ([ 1234985253, 3409583045983, 33 ], Just "ruPinkBg")
, ([ 1234985253, 3409583045983, 33 ], Just "ruPinkBg70")
, ([ 0, 0, 0 ], Nothing)
, ([ 1234985253, 3409583045983, 30 ], Just "ruDarkRedBg whiteText")
, ([ 1234985253, 3409583045983, 30 ], Just "ruDiepRedBg whiteText")
, ([ 1234985253, 3409583045983, 30 ], Just "ruRedBg whiteText")
, ([ 1234985253, 3409583045983, 31 ], Just "ruOrangeBg whiteText")
, ([ 1234985253, 3409583045983, 32 ], Just "ruDarkYellowBg whiteText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruBlueBg whiteText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruPurpleBg whiteText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruGreenBg whiteText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruGreenBg35 whiteText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruPinkBg whiteText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruPinkBg35 whiteText")
, ([ 0, 0, 0 ], Nothing)
, ([ 1234985253, 3409583045983, 30 ], Just "ruDarkRedText")
, ([ 1234985253, 3409583045983, 30 ], Just "ruDiepRedText")
, ([ 1234985253, 3409583045983, 30 ], Just "ruRedText")
, ([ 1234985253, 3409583045983, 31 ], Just "ruOrangeText")
, ([ 1234985253, 3409583045983, 32 ], Just "ruDarkYellowText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruBlueText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruBlueText35")
, ([ 1234985253, 3409583045983, 33 ], Just "ruPurpleText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruGreenText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruGreenText35")
, ([ 1234985253, 3409583045983, 33 ], Just "ruPinkText")
, ([ 1234985253, 3409583045983, 33 ], Just "ruPinkText35")
]
)
:: Burger =
{ bsn :: String
, address :: Address
}
:: Address =
{ postcode :: String
, huisnummer :: Int
}
derive class iTask Address, Burger
burgerData =
[ {Burger|bsn="9342857154387", address={Address|postcode="1234AB", huisnummer=17} }
, {Burger|bsn="1085034958209", address={Address|postcode="4567XY", huisnummer=182} }
, {Burger|bsn="2457260345737", address={Address|postcode="8439DC", huisnummer=65535} }
]
burgersToTable burgers =
( ["BSN", "Postcode", "Huisnummer"]
, [ [bsn, postcode, toSingleLineText huisnummer ]
\\ {bsn, address={postcode, huisnummer}} <- burgers
]
)
burgersToFancyTable burgers =
( ["BSN", "Postcode", "Huisnummer"]
, [Just "smallColumn", Nothing, Just "huisnummerCol"]
, [ ( [bsn, postcode, toSingleLineText huisnummer]
, if (huisnummer > 100 && huisnummer < 2000) (Just "ruBlueBg70") Nothing
)
\\ {bsn, address={postcode, huisnummer}} <- burgers
]
)
main :: Task ()
main = (viewAsTable "simple table" simpleData)
-&&- (viewAsTable "table with headers" dataWithHeader)
-&&- (viewAsTable "data from records" (burgersToTable burgerData))
-&&- (viewAsTable "customizable rows and columns" (burgersToFancyTable burgerData))
-&&- (viewAsTable "The Radboud Rainbow" dataWithClasses)
>>| return ()
burgers :: Shared [Burger]
burgers = sharedStore "burgers" burgerData
viewSharedStoreAsTable =
viewSharedInformation () [ViewUsing (htmlTable o burgersToFancyTable) (htmlView 'M'.newMap)] burgers
// Editing the table is not supported.
-&&- updateSharedInformation () [] burgers
// Demonstrate appending tables
simpleData1 =
[ [ 10, 20, 30 ]
, [ 11, 21, 31 ]
, [ 12, 22, 32 ]
, [ 13, 23, 33 ]
]
simpleData2 =
[ [ 30, 40 ]
, [ 30, 40 ]
, [ 30, 40 ]
, [ 30, 40 ]
]
simpleData3 = appendTable simpleData1 simpleData2
main3 = viewAsTable () simpleData3
fancyData1 :: ([String], [Maybe String], [([Int], Maybe String)])
fancyData1 =
( ["A", "B"]
, [Nothing, Nothing]
, [ ([1, 2], Just "ruRedBg")
, ([2, 3], Nothing)
, ([3, 4], Just "whiteText")
]
)
fancyData2 =
( ["C", "D"]
, [Nothing, Nothing]
, [ ([4, 5], Nothing)
, ([5, 6], Nothing)
, ([6, 7], Just "ruBlueBg") // blue background and white text are merged
, ([7, 8], Nothing) // This row is discarded
]
)
main4 = viewAsTable () (appendTable fancyData1 fancyData2)