summaryrefslogtreecommitdiff
path: root/elm/Lib/Editsum.elm
blob: 99a4be29f41517660fbbed0a3f388ff29e17d74f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
-- This module provides an the 'Edit summary' box, including the 'hidden' and
-- 'locked' moderation checkboxes.

module Lib.Editsum exposing (Model, Msg, new, update, view)

import Html exposing (..)
import Html.Attributes exposing (..)
import Lib.Html exposing (..)
import Lib.TextPreview as TP


type alias Model =
  { authmod  : Bool
  , locked   : Bool
  , hidden   : Bool
  , editsum  : TP.Model
  }


type Msg
  = Locked Bool
  | Hidden Bool
  | Editsum TP.Msg


new : Model
new =
  { authmod = False
  , locked  = False
  , hidden  = False
  , editsum = TP.bbcode ""
  }


update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
  case msg of
    Locked b  -> ({ model | locked  = b }, Cmd.none)
    Hidden b  -> ({ model | hidden  = b }, Cmd.none)
    Editsum m -> let (nm,nc) = TP.update m model.editsum in ({ model | editsum = nm }, Cmd.map Editsum nc)


view : Model -> Html Msg
view model =
  let
    lockhid =
      [ label []
        [ inputCheck "" model.hidden Hidden
        , text " Deleted" ]
      , label []
        [ inputCheck "" model.locked Locked
        , text " Locked" ]
      , br [] []
      , text "Note: edit summary of the last edit should indicate the reason for the deletion."
      , br [] []
      ]
  in fieldset [] <|
    (if model.authmod then lockhid else [])
    ++
    [ h2 []
      [ text "Edit summary"
      , b [class "standout"] [text " (English please!)"]
      ]
    , TP.view "" model.editsum Editsum 600 [rows 4, cols 50, minlength 2, maxlength 5000, required True]
    ]