comparison demo/more/grid.ur @ 951:103ac1792c41

Make filter argument to render, not create
author Adam Chlipala <adamc@hcoop.net>
date Thu, 17 Sep 2009 14:27:00 -0400
parents da3ec6014d2f
children 07569af40069
comparison
equal deleted inserted replaced
950:5be3d19b59f3 951:103ac1792c41
78 filters <- Monad.mapR2 [colMeta M.row] [fst3] [thd3] 78 filters <- Monad.mapR2 [colMeta M.row] [fst3] [thd3]
79 (fn [nm :: Name] [p :: (Type * Type * Type)] meta state => 79 (fn [nm :: Name] [p :: (Type * Type * Type)] meta state =>
80 (meta.Handlers state).CreateFilter) 80 (meta.Handlers state).CreateFilter)
81 [_] M.folder M.cols cols; 81 [_] M.folder M.cols cols;
82 82
83 rows <- Dlist.create {Filter = fn all => 83 rows <- Dlist.create;
84 row <- signal all.Row;
85 foldR3 [colMeta M.row] [fst3] [thd3] [fn _ => M.row -> signal bool]
86 (fn [nm :: Name] [p :: (Type * Type * Type)]
87 [rest :: {(Type * Type * Type)}] [[nm] ~ rest]
88 meta state filter combinedFilter row =>
89 previous <- combinedFilter row;
90 this <- (meta.Handlers state).Filter filter row;
91 return (previous && this))
92 (fn _ => return True)
93 [_] M.folder M.cols cols filters row};
94 sel <- source False; 84 sel <- source False;
95 return {Cols = cols, Rows = rows, Selection = sel, Filters = filters} 85
86 return {Cols = cols,
87 Rows = rows,
88 Selection = sel,
89 Filters = filters}
96 90
97 fun sync {Cols = cols, Rows = rows, ...} = 91 fun sync {Cols = cols, Rows = rows, ...} =
98 Dlist.clear rows; 92 Dlist.clear rows;
99 init <- rpc M.list; 93 init <- rpc M.list;
100 List.app (addRow cols rows) init 94 List.app (addRow cols rows) init
205 else 199 else
206 return <xml/>}/> 200 return <xml/>}/>
207 </td></xml>) 201 </td></xml>)
208 [_] M.folder grid.Cols M.cols cols)}/> 202 [_] M.folder grid.Cols M.cols cols)}/>
209 </tr></xml> 203 </tr></xml>
210 end) grid.Rows} 204 end)
205 {Filter = fn all =>
206 row <- signal all.Row;
207 foldR3 [colMeta M.row] [fst3] [thd3] [fn _ => M.row -> signal bool]
208 (fn [nm :: Name] [p :: (Type * Type * Type)]
209 [rest :: {(Type * Type * Type)}] [[nm] ~ rest]
210 meta state filter combinedFilter row =>
211 previous <- combinedFilter row;
212 this <- (meta.Handlers state).Filter filter row;
213 return (previous && this))
214 (fn _ => return True)
215 [_] M.folder M.cols grid.Cols grid.Filters row}
216 grid.Rows}
211 217
212 <dyn signal={rows <- Dlist.foldl (fn row => Monad.mapR2 [aggregateMeta M.row] [id] [id] 218 <dyn signal={rows <- Dlist.foldl (fn row => Monad.mapR2 [aggregateMeta M.row] [id] [id]
213 (fn [nm :: Name] [t :: Type] meta acc => 219 (fn [nm :: Name] [t :: Type] meta acc =>
214 Monad.mp (fn v => meta.Step v acc) 220 Monad.mp (fn v => meta.Step v acc)
215 (signal row.Row)) 221 (signal row.Row))