summaryrefslogtreecommitdiff
path: root/elm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-11-06 16:11:56 +0100
committerYorhel <git@yorhel.nl>2019-11-10 12:44:55 +0100
commit194d9d43593937d835cca00719a2b0639213ebb3 (patch)
tree18cffaa4032c44f2069e11cc0388990f088cdf77 /elm
parent27b1c8315c58e0f37baad991283e66b92e033a94 (diff)
ulist: Dynamically update releases summary on change
Diffstat (limited to 'elm')
-rw-r--r--elm/UList/Opt.elm8
-rw-r--r--elm/UList/Opt.js7
2 files changed, 12 insertions, 3 deletions
diff --git a/elm/UList/Opt.elm b/elm/UList/Opt.elm
index fb33faac..46ac6acd 100644
--- a/elm/UList/Opt.elm
+++ b/elm/UList/Opt.elm
@@ -29,6 +29,7 @@ main = Browser.element
port ulistVNDeleted : Bool -> Cmd msg
port ulistNotesChanged : String -> Cmd msg
+port ulistRelChanged : (Int, Int) -> Cmd msg
type alias Rel =
{ nfo : GVO.RecvRels
@@ -113,9 +114,10 @@ update msg model =
( { model | rels = modrel rid (\r -> { r | dd = DD.toggle r.dd False, status = st, state = Api.Loading }) model.rels }
, Api.post "/u/ulist/rstatus.json" (GRS.encode { uid = model.flags.uid, rid = rid, status = st }) (RelSaved rid st) )
RelSaved rid st GApi.Success ->
- ( { model | rels = if st == -1 then List.filter (\r -> r.nfo.id /= rid) model.rels
- else modrel rid (\r -> { r | state = Api.Normal }) model.rels }
- , Cmd.none)
+ let nr = if st == -1 then List.filter (\r -> r.nfo.id /= rid) model.rels
+ else modrel rid (\r -> { r | state = Api.Normal }) model.rels
+ in ( { model | rels = nr }
+ , ulistRelChanged (List.length <| List.filter (\r -> r.status == 2) nr, List.length nr) )
RelSaved rid _ e -> ({ model | rels = modrel rid (\r -> { r | state = Api.Error e }) model.rels }, Cmd.none)
diff --git a/elm/UList/Opt.js b/elm/UList/Opt.js
index 41bd1ce2..11ac9419 100644
--- a/elm/UList/Opt.js
+++ b/elm/UList/Opt.js
@@ -18,4 +18,11 @@ Elm.UList.Opt.init = function(opt) {
document.getElementById('ulist_notes_'+opt.flags.vid).innerText = n;
document.getElementById('ulist_noteflag_'+opt.flags.vid).classList.toggle('blurred', n.length == 0);
});
+
+ app.ports.ulistRelChanged.subscribe(function(rels) {
+ var e = document.getElementById('ulist_relsum_'+opt.flags.vid);
+ e.classList.toggle('todo', rels[0] != rels[1]);
+ e.classList.toggle('done', rels[1] > 0 && rels[0] == rels[1]);
+ e.innerText = rels[0] + '/' + rels[1];
+ });
};