From f296495a912ce759df11c43e78b4552788bdbff2 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Thu, 25 Jul 2019 14:30:04 +0200 Subject: Merge the v3 branch into separate namespace + fix Docker stuff (again) I was getting tired of having to keep two branches up-to-date with the latest developments, so decided to throw v3 into the same branch - just different files (...which will get mostly rewritten again soon). The two versions aren't very different in terms of dependencies, build system and support code, so they can now properly share files. Added a section to the README to avoid confusion. This merge also makes it easier to quickly switch between the different versions, which is handy for development. It's even possible to run both at the same time, but my scripts use the same port so that needs a workaround. And it's amazing how often I break the Docker scripts. --- elm3/ProdEdit/Names.elm | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 elm3/ProdEdit/Names.elm (limited to 'elm3/ProdEdit/Names.elm') diff --git a/elm3/ProdEdit/Names.elm b/elm3/ProdEdit/Names.elm new file mode 100644 index 00000000..e28f4916 --- /dev/null +++ b/elm3/ProdEdit/Names.elm @@ -0,0 +1,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." ] + ] + ] -- cgit v1.2.3