summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <benjamin@barenblat.name>2016-08-18 16:06:51 -0400
committerGravatar Benjamin Barenblat <benjamin@barenblat.name>2016-08-18 16:06:51 -0400
commit62023a04aa51782b66b81a2b2f7d463ddb8d65f3 (patch)
treec5dd4a1168d47db28177fe67be586ead3b99c6bc
parent37334313f0e049c31e12e1cf841de6089dfa6ed2 (diff)
Record checkbox clicks
-rw-r--r--main.ur12
-rw-r--r--prepopulate.sql10
2 files changed, 15 insertions, 7 deletions
diff --git a/main.ur b/main.ur
index cb2fe15..79e5f2b 100644
--- a/main.ur
+++ b/main.ur
@@ -15,14 +15,18 @@ specific language governing permissions and limitations under the License. *)
open Mdl
table nextAction : {
+ Id : int,
Nam : string,
Done : bool,
-}
+} PRIMARY KEY Id
(* 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>
+fun markNextActionStatus id done =
+ dml (UPDATE nextAction SET Done = {[done]} WHERE Id = {[id]})
+
fun renderNextAction action =
c <- fresh;
done <- source action.Done;
@@ -31,7 +35,11 @@ fun renderNextAction action =
<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}>
- <ccheckbox id={c} source={done} class="mdl-checkbox__input" />
+ <ccheckbox id={c} source={done} class="mdl-checkbox__input"
+ onchange={
+ b <- get done;
+ rpc (markNextActionStatus action.Id b)
+ } />
</label>
</span>
{[action.Nam]}
diff --git a/prepopulate.sql b/prepopulate.sql
index f50d17f..ffc4c79 100644
--- a/prepopulate.sql
+++ b/prepopulate.sql
@@ -12,9 +12,9 @@
-- License for the specific language governing permissions and limitations under
-- the License.
-INSERT INTO uw_Main_nextAction (uw_nam, uw_done)
+INSERT INTO uw_Main_nextAction (uw_id, uw_nam, uw_done)
VALUES
- ("Print cover for TPS report", 1),
- ("Collect information for TPS report", 0),
- ("Generate charts for TPS report", 0),
- ("Lorem ipsum dolor sit amet", 0);
+ (0, "Print cover for TPS report", 1),
+ (1, "Collect information for TPS report", 0),
+ (2, "Generate charts for TPS report", 0),
+ (3, "Lorem ipsum dolor sit amet", 0);