Keep form state after save

This commit is contained in:
eikek 2022-01-29 16:55:28 +01:00
parent e4527400ca
commit 040100f992
2 changed files with 20 additions and 4 deletions
modules/webapp/src/main/elm/Comp

@ -9,6 +9,7 @@ module Comp.UiSettingsForm exposing
( Model
, Msg
, init
, initData
, toggleAllTabs
, update
, view2
@ -178,6 +179,15 @@ init flags storedSettings defaults =
( initModel flags storedSettings defaults, Api.getTags flags "" Data.TagOrder.NameAsc GetTagsResp )
initData : Flags -> StoredUiSettings -> UiSettings -> Model -> ( Model, Cmd Msg )
initData flags storedSettings defaults model =
let
( m, c ) =
init flags storedSettings defaults
in
( { m | openTabs = model.openTabs }, c )
type Msg
= SearchPageSizeMsg Comp.IntField.Msg
| TagColorMsg Comp.ColorTagger.Msg

@ -211,11 +211,17 @@ update flags settings msg model =
userDefaults =
Data.UiSettings.merge coll collDefaults
( um, uc ) =
Comp.UiSettingsForm.init flags user userDefaults
( ( um, uc ), ( cm, cc ) ) =
case model.formData of
Just data ->
( Comp.UiSettingsForm.initData flags user userDefaults data.userModel
, Comp.UiSettingsForm.initData flags coll collDefaults data.collModel
)
( cm, cc ) =
Comp.UiSettingsForm.init flags coll collDefaults
Nothing ->
( Comp.UiSettingsForm.init flags user userDefaults
, Comp.UiSettingsForm.init flags coll collDefaults
)
model_ =
{ model