Mercurial > urweb
comparison demo/more/grid.ur @ 1784:e6bc6bbd7a32
Update demo code for key/mouse handler change
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 21 Jul 2012 10:12:35 -0400 |
parents | 9253765d7724 |
children | be0c4e2e488a |
comparison
equal
deleted
inserted
replaced
1783:5bc4fbf9c0fe | 1784:e6bc6bbd7a32 |
---|---|
122 M.folder M.cols grid.Cols grid.Filters row | 122 M.folder M.cols grid.Cols grid.Filters row |
123 | 123 |
124 fun render (grid : grid) = <xml> | 124 fun render (grid : grid) = <xml> |
125 <table class={tabl}> | 125 <table class={tabl}> |
126 <tr class={tr}> | 126 <tr class={tr}> |
127 <th/> <th/> <th><button value="No sort" onclick={set grid.Sort None}/></th> | 127 <th/> <th/> <th><button value="No sort" onclick={fn _ => set grid.Sort None}/></th> |
128 {@mapX2 [fst3] [colMeta M.row] [tr] | 128 {@mapX2 [fst3] [colMeta M.row] [tr] |
129 (fn [nm :: Name] [p :: (Type * Type * Type)] [rest :: {(Type * Type * Type)}] [[nm] ~ rest] | 129 (fn [nm :: Name] [p :: (Type * Type * Type)] [rest :: {(Type * Type * Type)}] [[nm] ~ rest] |
130 data (meta : colMeta M.row p) => | 130 data (meta : colMeta M.row p) => |
131 <xml><th class={th}> | 131 <xml><th class={th}> |
132 {case (meta.Handlers data).Sort of | 132 {case (meta.Handlers data).Sort of |
133 None => txt (meta.Handlers data).Header | 133 None => txt (meta.Handlers data).Header |
134 | sort => <xml><button value={(meta.Handlers data).Header} | 134 | sort => <xml><button value={(meta.Handlers data).Header} |
135 onclick={set grid.Sort sort}/></xml>} | 135 onclick={fn _ => set grid.Sort sort}/></xml>} |
136 </th></xml>) | 136 </th></xml>) |
137 M.folder grid.Cols M.cols} | 137 M.folder grid.Cols M.cols} |
138 </tr> | 138 </tr> |
139 | 139 |
140 {Dlist.render (fn {Row = rowS, Cols = colsS, Updating = ud, Selected = sd} pos => | 140 {Dlist.render (fn {Row = rowS, Cols = colsS, Updating = ud, Selected = sd} pos => |
195 </td> | 195 </td> |
196 | 196 |
197 <td> | 197 <td> |
198 <dyn signal={b <- signal ud; | 198 <dyn signal={b <- signal ud; |
199 return (if b then | 199 return (if b then |
200 <xml><button value="Save" onclick={save}/></xml> | 200 <xml><button value="Save" onclick={fn _ => save}/></xml> |
201 else | 201 else |
202 <xml><button value="Update" onclick={update}/></xml>)}/> | 202 <xml><button value="Update" onclick={fn _ => update}/></xml>)}/> |
203 </td> | 203 </td> |
204 | 204 |
205 <td><dyn signal={b <- signal ud; | 205 <td><dyn signal={b <- signal ud; |
206 return (if b then | 206 return (if b then |
207 <xml><button value="Cancel" onclick={cancel}/></xml> | 207 <xml><button value="Cancel" onclick={fn _ => cancel}/></xml> |
208 else | 208 else |
209 <xml><button value="Delete" onclick={delete}/></xml>)}/> | 209 <xml><button value="Delete" onclick={fn _ => delete}/></xml>)}/> |
210 </td> | 210 </td> |
211 | 211 |
212 <dyn signal={cols <- signal colsS; | 212 <dyn signal={cols <- signal colsS; |
213 return (@mapX3 [fst3] [colMeta M.row] [snd3] [_] | 213 return (@mapX3 [fst3] [colMeta M.row] [snd3] [_] |
214 (fn [nm :: Name] [t :: (Type * Type * Type)] | 214 (fn [nm :: Name] [t :: (Type * Type * Type)] |
300 return (if n * plen = pos then | 300 return (if n * plen = pos then |
301 <xml><b>{[n + 1]}</b></xml> | 301 <xml><b>{[n + 1]}</b></xml> |
302 else | 302 else |
303 <xml> | 303 <xml> |
304 <button value={show (n + 1)} | 304 <button value={show (n + 1)} |
305 onclick={set grid.Position | 305 onclick={fn _ => set grid.Position |
306 (n * plen) | 306 (n * plen) |
307 }/></xml>)}/> | 307 }/></xml>)}/> |
308 {if (n + 1) * plen >= avail then <xml/> else <xml>|</xml>} | 308 {if (n + 1) * plen >= avail then <xml/> else <xml>|</xml>} |
309 {pages (n + 1)} | 309 {pages (n + 1)} |
310 </xml> | 310 </xml> |
311 in | 311 in |
312 <xml><p><b>Pages:</b> {pages 0}</p></xml> | 312 <xml><p><b>Pages:</b> {pages 0}</p></xml> |
313 end)}/> | 313 end)}/> |
314 </xml>} | 314 </xml>} |
315 | 315 |
316 <button value="New row" onclick={row <- rpc M.new; | 316 <button value="New row" onclick={fn _ => row <- rpc M.new; |
317 addRow grid.Cols grid.Rows row}/> | 317 addRow grid.Cols grid.Rows row}/> |
318 <button value="Refresh" onclick={sync grid}/> | 318 <button value="Refresh" onclick={fn _ => sync grid}/> |
319 </xml> | 319 </xml> |
320 | 320 |
321 fun showSelection grid = grid.Selection | 321 fun showSelection grid = grid.Selection |
322 | 322 |
323 fun selection grid = Dlist.foldl (fn {Row = rowS, Selected = sd, ...} ls => | 323 fun selection grid = Dlist.foldl (fn {Row = rowS, Selected = sd, ...} ls => |