summaryrefslogtreecommitdiff
path: root/demo/more/decision.ur
diff options
context:
space:
mode:
Diffstat (limited to 'demo/more/decision.ur')
-rw-r--r--demo/more/decision.ur58
1 files changed, 37 insertions, 21 deletions
diff --git a/demo/more/decision.ur b/demo/more/decision.ur
index b93658ee..efd1b9c7 100644
--- a/demo/more/decision.ur
+++ b/demo/more/decision.ur
@@ -12,37 +12,53 @@ functor Make(M : sig
include Conference.INPUT
where con paper = [Decision = option bool] ++ paperOther
- val status : ctx ::: {Unit} -> [[Body] ~ ctx] => $paperOther -> xml ([Body] ++ ctx) [] []
+ val status : ctx ::: {Unit} -> [[Body] ~ ctx] => $([Id = paperId] ++ paperOther)
+ -> transaction (xml ([Body] ++ ctx) [] [])
end) = struct
open M
val linksForChair =
let
fun makeDecisions () =
- ps <- queryX (SELECT paper.Id, paper.Decision, paper.{{M.paperOther}}
- FROM paper
- ORDER BY paper.Id)
- (fn r => <xml><tr>
- <td>{useMore (summarizePaper (r.Paper -- #Id))}</td>
- <td>{useMore (status (r.Paper -- #Id -- #Decision))}</td>
- <td><entry>
- <hidden{#Paper} value={show r.Paper.Id}/>
- <select{#Decision}>
- <option selected={r.Paper.Decision = None}>?</option>
- <option selected={r.Paper.Decision = Some True}>Accept</option>
- <option selected={r.Paper.Decision = Some False}>Reject</option>
- </select></entry></td>
- </tr></xml>);
+ ps <- queryX' (SELECT paper.Id, paper.Decision, paper.{{M.paperOther}}
+ FROM paper
+ ORDER BY paper.Id)
+ (fn r => st <- status (r.Paper -- #Decision);
+ return <xml><tr>
+ <td>{useMore (summarizePaper (r.Paper -- #Id))}</td>
+ <td>{useMore st}</td>
+ <td><entry>
+ <hidden{#Paper} value={show r.Paper.Id}/>
+ <select{#Decision}>
+ <option selected={r.Paper.Decision = None}>?</option>
+ <option selected={r.Paper.Decision = Some True}>Accept</option>
+ <option selected={r.Paper.Decision = Some False}>Reject</option>
+ </select></entry></td>
+ </tr></xml>);
return <xml><body>
<h1>Make acceptance decisions</h1>
- <form><subforms{#Papers}>
- <table>
- <tr> <th>Paper</th> <th>Status</th> <th>Decision</th> </tr>
- {ps}
- </table>
- </subforms></form>
+ <form>
+ <subforms{#Papers}>
+ <table>
+ <tr> <th>Paper</th> <th>Status</th> <th>Decision</th> </tr>
+ {ps}
+ </table>
+ </subforms>
+ <submit value="Save" action={saveDecisions}/>
+ </form>
</body></xml>
+
+ and saveDecisions r =
+ List.app (fn {Paper = pid, Decision = dec} =>
+ dml (UPDATE paper
+ SET Decision = {[case dec of
+ "?" => None
+ | "Accept" => Some True
+ | "Reject" => Some False
+ | _ => error <xml>Invalid decision code</xml>]}
+ WHERE Id = {[readError pid]})) r.Papers;
+ makeDecisions ()
in
<xml>
<li><a link={makeDecisions ()}>Make acceptance decisions</a></li>