summaryrefslogtreecommitdiff
path: root/main.ur
diff options
context:
space:
mode:
Diffstat (limited to 'main.ur')
-rw-r--r--main.ur27
1 files changed, 21 insertions, 6 deletions
diff --git a/main.ur b/main.ur
index dd43f47..b9b5699 100644
--- a/main.ur
+++ b/main.ur
@@ -20,6 +20,8 @@ table nextAction : {
Done : bool,
} PRIMARY KEY Id
+sequence nextActionId
+
(* Forces JavaScript to be enabled on the given page, so as to pull in external
scripts specified in the .urp file. *)
val forceJavaScript = <xml><script code={return ()} /></xml>
@@ -34,7 +36,7 @@ fun renderNextAction action =
<li class="mdl-list__item">
<span class="mdl-list__item-primary-content">
<span class="mdl-list__item-icon">
- <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for={c}>
+ <label class="mdl-checkbox" for={c}>
<ccheckbox id={c} source={done} class="mdl-checkbox__input"
onchange={
b <- get done;
@@ -47,6 +49,14 @@ fun renderNextAction action =
</li>
</xml>
+val renderNextActions =
+ queryX1' (SELECT * FROM nextAction WHERE nextAction.Done = FALSE) renderNextAction
+
+fun newNextAction name =
+ id <- nextval nextActionId;
+ dml (INSERT INTO nextAction (Id, Nam, Done) VALUES ({[4 + id]}, {[name]}, FALSE));
+ renderNextActions
+
style hidden
style visible
@@ -54,8 +64,7 @@ style visible
datatype mode = NextActions | NewNextAction
val main =
- actionItems <- queryX1' (SELECT * FROM nextAction) renderNextAction;
- setHeader (blessResponseHeader "X-UA-Compatible") "IE=edge";
+ actionItems <- bind renderNextActions source;
mode <- source NextActions;
newNextActionDescription <- Mdl.Textbox.make "Description";
return <xml>
@@ -95,11 +104,17 @@ val main =
<div class="mdl-layout__header-row">
<span class="mdl-layout-title">New action</span>
<div class="mdl-layout-spacer" />
- (* <button class="mdl-button mdl-js-button" value="Save" /> *)
+ <button class="mdl-button mdl-js-button" value="Save" onclick={fn _ =>
+ name <- get newNextActionDescription.Source;
+ bind (rpc (newNextAction name)) (set actionItems);
+ sleep 0;
+ set mode NextActions;
+ set newNextActionDescription.Source ""
+ } />
</div>
</header>
<div class="mdl-layout__content">
- {newNextActionDescription}
+ {newNextActionDescription.Xml}
</div>
</div>
</div>
@@ -117,7 +132,7 @@ val main =
</div>
<div class="mdl-layout__content">
<ul class="mdl-list">
- {actionItems}
+ <dyn signal={signal actionItems} />
</ul>
<button class="mdl-button mdl-js-button mdl-button--fab mdl-button--colored" onclick={fn _ => set mode NewNextAction}>
<i class="material-icons">add</i>