summaryrefslogtreecommitdiff
path: root/elm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-09-03 13:07:20 +0200
committerYorhel <git@yorhel.nl>2020-09-03 13:07:30 +0200
commitc8e5426bfa7d57e6345070d98405ea4eed81ad93 (patch)
tree4e4a8361b64b8da94f337030c4281eacc7308c31 /elm
parente9852ed38b6e57e871f2a89bfcc2f42d60f3a676 (diff)
Reviews: Hide downvoted reviews & allow moderator overruling
Seems like a better moderation tool than outright deleting reviews.
Diffstat (limited to 'elm')
-rw-r--r--elm/Reviews/Vote.elm13
1 files changed, 10 insertions, 3 deletions
diff --git a/elm/Reviews/Vote.elm b/elm/Reviews/Vote.elm
index c3d8ff9d..490a2b78 100644
--- a/elm/Reviews/Vote.elm
+++ b/elm/Reviews/Vote.elm
@@ -23,6 +23,8 @@ type alias Model =
{ state : Api.State
, id : String
, my : Maybe Bool
+ , overrule : Bool
+ , mod : Bool
}
init : GRV.Recv -> Model
@@ -30,19 +32,23 @@ init d =
{ state = Api.Normal
, id = d.id
, my = d.my
+ , overrule = d.overrule
+ , mod = d.mod
}
type Msg
= Vote Bool
+ | Overrule Bool
| Saved GApi.Response
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
+ let save m = ({ m | state = Api.Loading }, GRV.send { id = m.id, my = m.my, overrule = m.overrule } Saved)
+ in
case msg of
- Vote b ->
- let my = if model.my == Just b then Nothing else Just b
- in ({ model | my = my, state = Api.Loading }, GRV.send { id = model.id, my = my } Saved)
+ Vote b -> save { model | my = if model.my == Just b then Nothing else Just b }
+ Overrule b -> let nm = { model | overrule = b } in if isJust model.my then save nm else (nm, Cmd.none)
Saved GApi.Success -> ({ model | state = Api.Normal }, Cmd.none)
Saved e -> ({ model | state = Api.Error e }, Cmd.none)
@@ -60,4 +66,5 @@ view model =
, but True "yes"
, text " / "
, but False "no"
+ , if not model.mod then text "" else label [] [ text " / ", inputCheck "" model.overrule Overrule, text " O" ]
]