adamc@1004: open Meta
adamc@1004: 
adamc@1004: functor Make(M : sig
adamc@1004:                  con keyName :: Name
adamc@1004:                  con keyType :: Type
adamc@1004:                  val showKey : show keyType
adamc@1005:                  val readKey : read keyType
adamc@1005:                  val injKey : sql_injectable keyType
adamc@1004: 
adamc@1004:                  con visible :: {(Type * Type)}
adamc@1004:                  constraint [keyName] ~ visible
adamc@1004:                  val folder : folder visible
adamc@1004:                  val visible : $(map Meta.meta visible)
adamc@1004: 
adamc@1004:                  con invisible :: {Type}
adamc@1004:                  constraint [keyName] ~ invisible
adamc@1004:                  constraint visible ~ invisible
adamc@1004: 
adamc@1004:                  val title : string
adamc@1004:                  val isAllowed : transaction bool
adamc@1004:                  table t : ([keyName = keyType] ++ map fst visible ++ invisible)
adamc@1004:              end) = struct
adamc@1004: 
adamc@1004:     open M
adamc@1004: 
adamc@1004:     fun main () =
adamc@1004:         items <- queryX (SELECT t.{keyName}, t.{{map fst visible}} FROM t)
adamc@1004:                  (fn r => <xml><entry><tr>
adamc@1004:                    <hidden{keyName} value={show r.T.keyName}/>
adamc@1008:                    {useMore (allPopulatedTr visible (r.T -- keyName) folder)}
adamc@1004:                  </tr></entry></xml>);
adamc@1004:         
adamc@1004:         return <xml><body>
adamc@1004:           <h1>{[title]}</h1>
adamc@1004: 
adamc@1004:           <form><table>
adamc@1004:             <tr>{foldRX [meta] [_]
adamc@1004:                  (fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest] m =>
adamc@1004:                      <xml><th>{[m.Nam]}</th></xml>) [_] folder visible}</tr>
adamc@1004:             <subforms{#Users}>{items}</subforms>
adamc@1005:             <tr> <td><submit value="Save" action={save}/></td> </tr>
adamc@1004:           </table></form>
adamc@1004:         </body></xml>
adamc@1004: 
adamc@1005:     and save r =
adamc@1005:         List.app (fn user => dml (update [map fst visible] !
adamc@1008:                                   (ensql visible (user -- keyName) folder)
adamc@1005:                                   t
adamc@1005:                                   (WHERE t.{keyName} = {[readError user.keyName]}))) r.Users;
adamc@1005:         main ()
adamc@1005: 
adamc@1004: end