mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Add a notes field to equipments
This commit is contained in:
@ -16,11 +16,13 @@ import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onInput)
|
||||
import Styles as S
|
||||
import Util.Maybe
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ equipment : Equipment
|
||||
, name : String
|
||||
, notes : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +30,7 @@ emptyModel : Model
|
||||
emptyModel =
|
||||
{ equipment = Api.Model.Equipment.empty
|
||||
, name = ""
|
||||
, notes = Nothing
|
||||
}
|
||||
|
||||
|
||||
@ -38,23 +41,37 @@ isValid model =
|
||||
|
||||
getEquipment : Model -> Equipment
|
||||
getEquipment model =
|
||||
Equipment model.equipment.id model.name model.equipment.created
|
||||
{ id = model.equipment.id
|
||||
, name = model.name
|
||||
, created = model.equipment.created
|
||||
, notes = model.notes
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= SetName String
|
||||
| SetEquipment Equipment
|
||||
| SetNotes String
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update _ msg model =
|
||||
case msg of
|
||||
SetEquipment t ->
|
||||
( { model | equipment = t, name = t.name }, Cmd.none )
|
||||
( { model
|
||||
| equipment = t
|
||||
, name = t.name
|
||||
, notes = t.notes
|
||||
}
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
SetName n ->
|
||||
( { model | name = n }, Cmd.none )
|
||||
|
||||
SetNotes str ->
|
||||
( { model | notes = Util.Maybe.fromString str }, Cmd.none )
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
@ -84,9 +101,7 @@ view model =
|
||||
view2 : Model -> Html Msg
|
||||
view2 model =
|
||||
div [ class "flex flex-col" ]
|
||||
[ div
|
||||
[ class "mb-4"
|
||||
]
|
||||
[ div [ class "mb-4" ]
|
||||
[ label
|
||||
[ for "equipname"
|
||||
, class S.inputLabel
|
||||
@ -109,4 +124,17 @@ view2 model =
|
||||
]
|
||||
[]
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ h3 [ class S.header3 ]
|
||||
[ text "Notes"
|
||||
]
|
||||
, div [ class "" ]
|
||||
[ textarea
|
||||
[ onInput SetNotes
|
||||
, Maybe.withDefault "" model.notes |> value
|
||||
, class S.textAreaInput
|
||||
]
|
||||
[]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
@ -479,7 +479,7 @@ updateDrop ddm flags settings msg model =
|
||||
SetConcEquip id ->
|
||||
let
|
||||
equip =
|
||||
Equipment id.id id.name 0
|
||||
Equipment id.id id.name 0 Nothing
|
||||
in
|
||||
resetAndSet (ConcEquipmentMsg (Comp.Dropdown.SetSelection [ equip ]))
|
||||
|
||||
|
Reference in New Issue
Block a user