Fix remembering selection when going to detail view

This commit is contained in:
Eike Kettner 2020-08-08 17:24:27 +02:00
parent 27439530f0
commit 5810eac899
3 changed files with 27 additions and 11 deletions

View File

@ -24,10 +24,10 @@ type alias Model =
} }
init : List FolderItem -> Model init : Maybe FolderItem -> List FolderItem -> Model
init all = init selected all =
{ all = List.sortBy .name all { all = List.sortBy .name all
, selected = Nothing , selected = Maybe.map .id selected
, expanded = False , expanded = False
} }

View File

@ -71,7 +71,7 @@ type alias Model =
init : Model init : Model
init = init =
{ tagSelectModel = Comp.TagSelect.init [] { tagSelectModel = Comp.TagSelect.init Comp.TagSelect.emptySelection []
, tagSelection = Comp.TagSelect.emptySelection , tagSelection = Comp.TagSelect.emptySelection
, directionModel = , directionModel =
Comp.Dropdown.makeSingleList Comp.Dropdown.makeSingleList
@ -111,7 +111,7 @@ init =
, labelColor = \_ -> \_ -> "" , labelColor = \_ -> \_ -> ""
, placeholder = "Choose an equipment" , placeholder = "Choose an equipment"
} }
, folderList = Comp.FolderSelect.init [] , folderList = Comp.FolderSelect.init Nothing []
, selectedFolder = Nothing , selectedFolder = Nothing
, inboxCheckbox = False , inboxCheckbox = False
, fromDateModel = Comp.DatePicker.emptyModel , fromDateModel = Comp.DatePicker.emptyModel
@ -288,7 +288,7 @@ updateDrop ddm flags settings msg model =
selectModel = selectModel =
List.sortBy .count tags.items List.sortBy .count tags.items
|> List.reverse |> List.reverse
|> Comp.TagSelect.init |> Comp.TagSelect.init model.tagSelection
model_ = model_ =
{ model | tagSelectModel = selectModel } { model | tagSelectModel = selectModel }
@ -571,7 +571,7 @@ updateDrop ddm flags settings msg model =
{ model { model
| folderList = | folderList =
Util.Folder.onlyVisible flags fs.items Util.Folder.onlyVisible flags fs.items
|> Comp.FolderSelect.init |> Comp.FolderSelect.init model.selectedFolder
} }
in in
{ model = model_ { model = model_

View File

@ -41,12 +41,28 @@ type alias Category =
} }
init : List TagCount -> Model init : Selection -> List TagCount -> Model
init tags = init sel tags =
let
tagId t =
t.tag.id
constDict mkId flag list =
List.map (\e -> ( mkId e, flag )) list
|> Dict.fromList
selTag =
constDict tagId True sel.includeTags
|> Dict.union (constDict tagId False sel.excludeTags)
selCat =
constDict .name True sel.includeCats
|> Dict.union (constDict .name False sel.excludeCats)
in
{ all = tags { all = tags
, categories = sumCategories tags , categories = sumCategories tags
, selectedTags = Dict.empty , selectedTags = selTag
, selectedCats = Dict.empty , selectedCats = selCat
, expandedTags = False , expandedTags = False
, expandedCats = False , expandedCats = False
} }