From 4a9ab2c1beaeb9767e8ffcd83e2663232b774a7c Mon Sep 17 00:00:00 2001 From: eikek Date: Wed, 16 Jun 2021 00:14:35 +0200 Subject: [PATCH] Only update category options if the query selected all tags The tag category is a bit special (sadly). The options are retrieved by going through the tags. It must not update these, if a query selects only a subset of tags. --- modules/webapp/src/main/elm/Comp/TagManage.elm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/webapp/src/main/elm/Comp/TagManage.elm b/modules/webapp/src/main/elm/Comp/TagManage.elm index 4cc5d431..dce79931 100644 --- a/modules/webapp/src/main/elm/Comp/TagManage.elm +++ b/modules/webapp/src/main/elm/Comp/TagManage.elm @@ -66,7 +66,7 @@ type Msg = TableMsg Comp.TagTable.Msg | FormMsg Comp.TagForm.Msg | LoadTags - | TagResp (Result Http.Error TagList) + | TagResp String (Result Http.Error TagList) | SetViewMode ViewMode | InitNewTag | Submit @@ -116,9 +116,9 @@ update flags msg model = ( { model | tagFormModel = m2 }, Cmd.map FormMsg c2 ) LoadTags -> - ( { model | loading = True }, Api.getTags flags model.query TagResp ) + ( { model | loading = True }, Api.getTags flags model.query (TagResp model.query) ) - TagResp (Ok tags) -> + TagResp query (Ok tags) -> let m2 = { model | viewMode = Table, loading = False } @@ -128,11 +128,15 @@ update flags msg model = in Util.Update.andThen1 [ update flags (TableMsg (Comp.TagTable.SetTags tags.items)) - , update flags (FormMsg (Comp.TagForm.SetCategoryOptions cats)) + , if query == "" then + update flags (FormMsg (Comp.TagForm.SetCategoryOptions cats)) + + else + \m -> ( m, Cmd.none ) ] m2 - TagResp (Err _) -> + TagResp _ (Err _) -> ( { model | loading = False }, Cmd.none ) SetViewMode m -> @@ -213,7 +217,7 @@ update flags msg model = m = { model | query = str } in - ( m, Api.getTags flags str TagResp ) + ( m, Api.getTags flags str (TagResp str) )