diff options
author | Yorhel <git@yorhel.nl> | 2022-09-27 14:04:37 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2022-09-27 14:04:40 +0200 |
commit | 2c92964795a54b5e0de0b66b3c1c0bc6a4083555 (patch) | |
tree | 9b14d89609cb07f57b132df821d3a1405334e2bf /elm | |
parent | 797ddf64b5fe22e7d07ec773342ed461db0f8edf (diff) |
AdvSearch: auto-open field dropdown when adding a new field
I'm pretty sure this was requested by someone, but I can't find the
relevant post at the moment.
Diffstat (limited to 'elm')
-rw-r--r-- | elm/AdvSearch/Fields.elm | 7 | ||||
-rw-r--r-- | elm/Lib/Util.elm | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/elm/AdvSearch/Fields.elm b/elm/AdvSearch/Fields.elm index 11ecd82f..0990ac0d 100644 --- a/elm/AdvSearch/Fields.elm +++ b/elm/AdvSearch/Fields.elm @@ -80,7 +80,12 @@ nestUpdate dat msg model = in addPar (b::xs) (nestInit True b a nf ndat |> Tuple.mapSecond FMNest |> fieldCreate -1) _ -> (ndat,f) (ndat2,f2) = addPar model.addtype (fieldInit n dat) - in (ndat2, { model | addDd = DD.toggle model.addDd False, addtype = [model.qtype], fields = model.fields ++ [f2] }, Cmd.none) + nestMsg lst i = + case lst of + (a::xs) -> NField i (FSNest (nestMsg xs 0)) + _ -> NField i (FToggle True) + in (ndat2, { model | addDd = DD.toggle model.addDd False, addtype = [model.qtype], fields = model.fields ++ [f2] } + , selfCmd (nestMsg (List.drop 1 model.addtype) (List.length model.fields))) NAddType t -> (dat, { model | addtype = t }, Cmd.none) NField n FDel -> (dat, { model | fields = delidx n model.fields }, Cmd.none) NField n FMoveSub -> diff --git a/elm/Lib/Util.elm b/elm/Lib/Util.elm index 7ded22b1..e08e617b 100644 --- a/elm/Lib/Util.elm +++ b/elm/Lib/Util.elm @@ -2,6 +2,7 @@ module Lib.Util exposing (..) import Set import Task +import Process import Regex import Lib.Ffi as Ffi import Gen.Api as GApi @@ -48,8 +49,10 @@ lookup : a -> List (a,b) -> Maybe b lookup n l = List.filter (\(a,_) -> a == n) l |> List.head |> Maybe.map Tuple.second +-- Have to use Process.sleep instead of Task.succeed here, otherwise any +-- subscriptions are not updated. selfCmd : msg -> Cmd msg -selfCmd m = Task.perform (always m) (Task.succeed True) +selfCmd m = Task.perform (always m) (Process.sleep 1.0) -- Based on VNDBUtil::gtintype() |