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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
module ProdEdit.Names exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Dict
import Lib.Html exposing (..)
import Lib.Gen exposing (ProdEdit)
import Lib.Util exposing (..)
type alias Model =
{ name : String
, original : String
, alias : String
, aliasList : List String
, aliasDuplicates : Bool
}
init : ProdEdit -> Model
init d =
{ name = d.name
, original = d.original
, alias = d.alias
, aliasList = splitLn d.alias
, aliasDuplicates = False
}
new : Model
new =
{ name = ""
, original = ""
, alias = ""
, aliasList = []
, aliasDuplicates = False
}
type Msg
= Name String
| Original String
| Alias String
update : Msg -> Model -> Model
update msg model =
case msg of
Name s -> { model | name = s }
Original s -> { model | original = s }
Alias s ->
{ model
| alias = s
, aliasList = splitLn s
, aliasDuplicates = hasDuplicates (model.name :: model.original :: splitLn s)
}
view : Model -> List (Html Msg)
view model =
[ cardRow "Name" Nothing <| formGroups
[ [ label [for "name"] [text "Name (romaji)"]
, inputText "name" model.name Name [required True, maxlength 200]
]
, [ label [for "original"] [text "Original"]
, inputText "original" model.original Original [maxlength 200]
, div [class "form-group__help"] [text "The original name of this producer, leave blank if it already is in the Latin alphabet."]
]
]
, cardRow "Aliases" Nothing <| formGroup
[ inputTextArea "aliases" model.alias Alias
[ rows 4, maxlength 500
, classList [("is-invalid", model.aliasDuplicates)]
]
, if model.aliasDuplicates
then div [class "invalid-feedback"]
[ text "There are duplicate aliases." ]
else text ""
, div [class "form-group__help"] [ text "(Un)official aliases, separated by a newline." ]
]
]
|