summaryrefslogtreecommitdiff
path: root/elm3/Lib/Editsum.elm
blob: 3ddc150657b9ef3f90be82c0dd3b6c7dd6bf59f6 (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
-- 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 (..)


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


type Msg
  = Locked Bool
  | Hidden Bool
  | Editsum String


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


update : Msg -> Model -> Model
update msg model =
  case msg of
    Locked b  -> { model | locked  = b }
    Hidden b  -> { model | hidden  = b }
    Editsum s -> { model | editsum = s }


view : Model -> Html Msg
view model =
  let
    lockhid = cardRow "Mod actions" Nothing <| formGroups
      [ [ label [ class "checkbox" ]
          [ inputCheck "" model.locked Locked
          , text " Locked" ]
        ]
      , [ label [ class "checkbox" ]
          [ inputCheck "" model.hidden Hidden
          , text " Hidden" ]
        ]
      ]
  in card_
    [ lockhid
    , cardRow "Edit summary" (Just "English please!")
      <| formGroup [ inputTextArea "" model.editsum Editsum [rows 4, minlength 2, maxlength 5000, required True] ]
    ]