summaryrefslogtreecommitdiff
path: root/elm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-11-07 15:44:55 +0100
committerYorhel <git@yorhel.nl>2021-11-07 15:45:03 +0100
commit8c1fcdb94b46373c4e9c8d533e645edf6aba6f7a (patch)
tree63a08451cec8be2741e609d82157032364881bc7 /elm
parent1ed63d7ba7b9d22300d15828dce142c2d5d1c15d (diff)
Add mod option to set deletion reason for forum posts
Diffstat (limited to 'elm')
-rw-r--r--elm/Discussions/PostEdit.elm17
1 files changed, 11 insertions, 6 deletions
diff --git a/elm/Discussions/PostEdit.elm b/elm/Discussions/PostEdit.elm
index d8de1aab..421850c1 100644
--- a/elm/Discussions/PostEdit.elm
+++ b/elm/Discussions/PostEdit.elm
@@ -25,7 +25,7 @@ type alias Model =
, id : String
, num : Int
, can_mod : Bool
- , hidden : Bool
+ , hidden : Maybe String
, nolastmod : Bool
, delete : Bool
, msg : TP.Model
@@ -56,7 +56,7 @@ encode m =
type Msg
- = Hidden Bool
+ = Hidden (Maybe String)
| Nolastmod Bool
| Delete Bool
| Content TP.Msg
@@ -67,9 +67,9 @@ type Msg
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
- Hidden b -> ({ model | hidden = b }, Cmd.none)
- Nolastmod b -> ({ model | nolastmod=b }, Cmd.none)
- Delete b -> ({ model | delete = b }, Cmd.none)
+ Hidden s -> ({ model | hidden = s }, Cmd.none)
+ Nolastmod b -> ({ model | nolastmod = b }, Cmd.none)
+ Delete b -> ({ model | delete = b }, Cmd.none)
Content m -> let (nm,nc) = TP.update m model.msg in ({ model | msg = nm }, Cmd.map Content nc)
Submit -> ({ model | state = Api.Loading }, GPE.send (encode model) Submitted)
@@ -85,7 +85,12 @@ view model =
, table [ class "formtable" ] <|
[ formField "Post" [ a [ href <| "/" ++ model.id ++ "." ++ String.fromInt model.num ] [ text <| "#" ++ String.fromInt model.num ++ " on " ++ model.id ] ]
, if model.can_mod
- then formField "" [ label [] [ inputCheck "" model.hidden Hidden, text " Hidden" ] ]
+ then formField ""
+ [ label [] [ inputCheck "" (model.hidden /= Nothing) (\b -> Hidden (if b then Just "" else Nothing)), text " Hidden" ]
+ , Maybe.withDefault (text "") <| Maybe.map (\msg ->
+ span [] [ br [] [], inputText "" msg (Just >> Hidden) [placeholder "(Optional) reason for deletion", style "width" "500px"] ]
+ ) model.hidden
+ ]
else text ""
, if model.can_mod
then formField "" [ label [] [ inputCheck "" model.nolastmod Nolastmod, text " Don't update last modification timestamp" ] ]