mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Merge pull request #645 from eikek/equipment-description
Equipment description
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
|
||||
]
|
||||
[]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
@ -20,6 +20,7 @@ import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onInput)
|
||||
import Styles as S
|
||||
import Util.Maybe
|
||||
|
||||
|
||||
type alias Model =
|
||||
@ -28,6 +29,7 @@ type alias Model =
|
||||
, addressModel : Comp.AddressForm.Model
|
||||
, contactModel : Comp.ContactField.Model
|
||||
, notes : Maybe String
|
||||
, shortName : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -38,6 +40,7 @@ emptyModel =
|
||||
, addressModel = Comp.AddressForm.emptyModel
|
||||
, contactModel = Comp.ContactField.emptyModel
|
||||
, notes = Nothing
|
||||
, shortName = Nothing
|
||||
}
|
||||
|
||||
|
||||
@ -57,6 +60,7 @@ getOrg model =
|
||||
, address = Comp.AddressForm.getAddress model.addressModel
|
||||
, contacts = Comp.ContactField.getContacts model.contactModel
|
||||
, notes = model.notes
|
||||
, shortName = model.shortName
|
||||
}
|
||||
|
||||
|
||||
@ -66,6 +70,7 @@ type Msg
|
||||
| AddressMsg Comp.AddressForm.Msg
|
||||
| ContactMsg Comp.ContactField.Msg
|
||||
| SetNotes String
|
||||
| SetShortName String
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
@ -79,7 +84,14 @@ update flags msg model =
|
||||
( m2, c2 ) =
|
||||
update flags (ContactMsg (Comp.ContactField.SetItems t.contacts)) m1
|
||||
in
|
||||
( { m2 | org = t, name = t.name, notes = t.notes }, Cmd.batch [ c1, c2 ] )
|
||||
( { m2
|
||||
| org = t
|
||||
, name = t.name
|
||||
, notes = t.notes
|
||||
, shortName = t.shortName
|
||||
}
|
||||
, Cmd.batch [ c1, c2 ]
|
||||
)
|
||||
|
||||
AddressMsg am ->
|
||||
let
|
||||
@ -99,14 +111,12 @@ update flags msg model =
|
||||
( { model | name = n }, Cmd.none )
|
||||
|
||||
SetNotes str ->
|
||||
( { model
|
||||
| notes =
|
||||
if str == "" then
|
||||
Nothing
|
||||
( { model | notes = Util.Maybe.fromString str }
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
else
|
||||
Just str
|
||||
}
|
||||
SetShortName str ->
|
||||
( { model | shortName = Util.Maybe.fromString str }
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
@ -184,6 +194,25 @@ view2 mobile settings model =
|
||||
]
|
||||
[]
|
||||
]
|
||||
, div
|
||||
[ class "mb-4" ]
|
||||
[ label
|
||||
[ for "org-short-name"
|
||||
, class S.inputLabel
|
||||
]
|
||||
[ text "Short Name"
|
||||
]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetShortName
|
||||
, placeholder "Abbreviation"
|
||||
, Maybe.withDefault "" model.shortName
|
||||
|> value
|
||||
, name "org-short-name"
|
||||
, class S.textInput
|
||||
]
|
||||
[]
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ h3 [ class S.header3 ]
|
||||
[ text "Address"
|
||||
|
@ -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