comparison demo/more/decision.ur @ 1032:5d9f47124c4c

Saving paper decisions
author Adam Chlipala <adamc@hcoop.net>
date Sat, 07 Nov 2009 11:06:38 -0500
parents 5dccff15fa62
children
comparison
equal deleted inserted replaced
1031:5dccff15fa62 1032:5d9f47124c4c
10 con paperOther :: {Type} 10 con paperOther :: {Type}
11 constraint [Id, Decision] ~ paperOther 11 constraint [Id, Decision] ~ paperOther
12 include Conference.INPUT 12 include Conference.INPUT
13 where con paper = [Decision = option bool] ++ paperOther 13 where con paper = [Decision = option bool] ++ paperOther
14 14
15 val status : ctx ::: {Unit} -> [[Body] ~ ctx] => $paperOther -> xml ([Body] ++ ctx) [] [] 15 val status : ctx ::: {Unit} -> [[Body] ~ ctx] => $([Id = paperId] ++ paperOther)
16 -> transaction (xml ([Body] ++ ctx) [] [])
16 end) = struct 17 end) = struct
17 open M 18 open M
18 19
19 val linksForChair = 20 val linksForChair =
20 let 21 let
21 fun makeDecisions () = 22 fun makeDecisions () =
22 ps <- queryX (SELECT paper.Id, paper.Decision, paper.{{M.paperOther}} 23 ps <- queryX' (SELECT paper.Id, paper.Decision, paper.{{M.paperOther}}
23 FROM paper 24 FROM paper
24 ORDER BY paper.Id) 25 ORDER BY paper.Id)
25 (fn r => <xml><tr> 26 (fn r => st <- status (r.Paper -- #Decision);
26 <td>{useMore (summarizePaper (r.Paper -- #Id))}</td> 27 return <xml><tr>
27 <td>{useMore (status (r.Paper -- #Id -- #Decision))}</td> 28 <td>{useMore (summarizePaper (r.Paper -- #Id))}</td>
28 <td><entry> 29 <td>{useMore st}</td>
29 <hidden{#Paper} value={show r.Paper.Id}/> 30 <td><entry>
30 <select{#Decision}> 31 <hidden{#Paper} value={show r.Paper.Id}/>
31 <option selected={r.Paper.Decision = None}>?</option> 32 <select{#Decision}>
32 <option selected={r.Paper.Decision = Some True}>Accept</option> 33 <option selected={r.Paper.Decision = None}>?</option>
33 <option selected={r.Paper.Decision = Some False}>Reject</option> 34 <option selected={r.Paper.Decision = Some True}>Accept</option>
34 </select></entry></td> 35 <option selected={r.Paper.Decision = Some False}>Reject</option>
35 </tr></xml>); 36 </select></entry></td>
37 </tr></xml>);
36 return <xml><body> 38 return <xml><body>
37 <h1>Make acceptance decisions</h1> 39 <h1>Make acceptance decisions</h1>
38 40
39 <form><subforms{#Papers}> 41 <form>
40 <table> 42 <subforms{#Papers}>
41 <tr> <th>Paper</th> <th>Status</th> <th>Decision</th> </tr> 43 <table>
42 {ps} 44 <tr> <th>Paper</th> <th>Status</th> <th>Decision</th> </tr>
43 </table> 45 {ps}
44 </subforms></form> 46 </table>
47 </subforms>
48 <submit value="Save" action={saveDecisions}/>
49 </form>
45 </body></xml> 50 </body></xml>
51
52 and saveDecisions r =
53 List.app (fn {Paper = pid, Decision = dec} =>
54 dml (UPDATE paper
55 SET Decision = {[case dec of
56 "?" => None
57 | "Accept" => Some True
58 | "Reject" => Some False
59 | _ => error <xml>Invalid decision code</xml>]}
60 WHERE Id = {[readError pid]})) r.Papers;
61 makeDecisions ()
46 in 62 in
47 <xml> 63 <xml>
48 <li><a link={makeDecisions ()}>Make acceptance decisions</a></li> 64 <li><a link={makeDecisions ()}>Make acceptance decisions</a></li>
49 </xml> 65 </xml>
50 end 66 end