Fix date-picker initialization in search menu

This commit is contained in:
Eike Kettner 2020-05-21 23:26:36 +02:00
parent 72f0897a3e
commit 69c46f9f1f

View File

@ -51,6 +51,7 @@ type alias Model =
, untilDueDateModel : DatePicker , untilDueDateModel : DatePicker
, untilDueDate : Maybe Int , untilDueDate : Maybe Int
, nameModel : Maybe String , nameModel : Maybe String
, datePickerInitialized : Bool
} }
@ -105,6 +106,7 @@ emptyModel =
, untilDueDateModel = Comp.DatePicker.emptyModel , untilDueDateModel = Comp.DatePicker.emptyModel
, untilDueDate = Nothing , untilDueDate = Nothing
, nameModel = Nothing , nameModel = Nothing
, datePickerInitialized = False
} }
@ -189,23 +191,36 @@ update flags msg model =
let let
( dp, dpc ) = ( dp, dpc ) =
Comp.DatePicker.init Comp.DatePicker.init
in
noChange ( mdp, cdp ) =
case model.datePickerInitialized of
True ->
( model, Cmd.none )
False ->
( { model ( { model
| untilDateModel = dp | untilDateModel = dp
, fromDateModel = dp , fromDateModel = dp
, untilDueDateModel = dp , untilDueDateModel = dp
, fromDueDateModel = dp , fromDueDateModel = dp
, datePickerInitialized = True
} }
, Cmd.batch
[ Cmd.map UntilDateMsg dpc
, Cmd.map FromDateMsg dpc
, Cmd.map UntilDueDateMsg dpc
, Cmd.map FromDueDateMsg dpc
]
)
in
noChange
( mdp
, Cmd.batch , Cmd.batch
[ Api.getTags flags "" GetTagsResp [ Api.getTags flags "" GetTagsResp
, Api.getOrgLight flags GetOrgResp , Api.getOrgLight flags GetOrgResp
, Api.getEquipments flags "" GetEquipResp , Api.getEquipments flags "" GetEquipResp
, Api.getPersonsLight flags GetPersonResp , Api.getPersonsLight flags GetPersonResp
, Cmd.map UntilDateMsg dpc , cdp
, Cmd.map FromDateMsg dpc
, Cmd.map UntilDueDateMsg dpc
, Cmd.map FromDueDateMsg dpc
] ]
) )
@ -529,13 +544,21 @@ view model =
[ label [] [ label []
[ text "From" [ text "From"
] ]
, Html.map FromDateMsg (Comp.DatePicker.viewTimeDefault model.fromDate model.fromDateModel) , Html.map FromDateMsg
(Comp.DatePicker.viewTimeDefault
model.fromDate
model.fromDateModel
)
] ]
, div [ class "field" ] , div [ class "field" ]
[ label [] [ label []
[ text "To" [ text "To"
] ]
, Html.map UntilDateMsg (Comp.DatePicker.viewTimeDefault model.untilDate model.untilDateModel) , Html.map UntilDateMsg
(Comp.DatePicker.viewTimeDefault
model.untilDate
model.untilDateModel
)
] ]
] ]
, h3 [ class "ui header" ] , h3 [ class "ui header" ]
@ -546,13 +569,21 @@ view model =
[ label [] [ label []
[ text "Due From" [ text "Due From"
] ]
, Html.map FromDueDateMsg (Comp.DatePicker.viewTimeDefault model.fromDueDate model.fromDueDateModel) , Html.map FromDueDateMsg
(Comp.DatePicker.viewTimeDefault
model.fromDueDate
model.fromDueDateModel
)
] ]
, div [ class "field" ] , div [ class "field" ]
[ label [] [ label []
[ text "Due To" [ text "Due To"
] ]
, Html.map UntilDueDateMsg (Comp.DatePicker.viewTimeDefault model.untilDueDate model.untilDueDateModel) , Html.map UntilDueDateMsg
(Comp.DatePicker.viewTimeDefault
model.untilDueDate
model.untilDueDateModel
)
] ]
] ]
] ]