summaryrefslogtreecommitdiff
path: root/elm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-10-21 11:08:24 +0200
committerYorhel <git@yorhel.nl>2021-10-21 11:08:27 +0200
commit87722345800fff269c25a045d8dd324e2997ade9 (patch)
tree3eb0c80a6f71ca8adec7f621b7ce508a0700c023 /elm
parent76805f1faa63a9b07e04bdb00f4c91a0953051b2 (diff)
AdvSearch: Allow moving the root node into a new sub
Improves the first part of https://vndb.org/t15372.102
Diffstat (limited to 'elm')
-rw-r--r--elm/AdvSearch/Fields.elm11
1 files changed, 8 insertions, 3 deletions
diff --git a/elm/AdvSearch/Fields.elm b/elm/AdvSearch/Fields.elm
index 723634fb..ff7c2004 100644
--- a/elm/AdvSearch/Fields.elm
+++ b/elm/AdvSearch/Fields.elm
@@ -512,6 +512,13 @@ fieldUpdate dat msg_ (num, dd, model) =
in (dat, (num,dd,FMNest newGrandModel), Cmd.none)
_ -> noop
+ -- Move root node to sub; for child nodes this is handled in nestUpdate, but the root node must be handled separately
+ (FMoveSub, FMNest m) ->
+ let subfields = [(num,DD.toggle dd False,model)]
+ (ndat,subm) = nestInit True m.qtype m.qtype subfields dat
+ (ndat2,subf) = fieldCreate -1 (ndat, FMNest subm)
+ in (ndat2, subf, Cmd.none)
+
(FSNest (NAnd a b), FMNest m) -> mapc FMNest FSNest (nestUpdate dat (NAnd a b) m)
(FSNest (NNeg a b), FMNest m) -> mapc FMNest FSNest (nestUpdate dat (NNeg a b) m)
(FSNest msg, FMNest m) -> mapf FMNest FSNest (nestUpdate dat msg m)
@@ -569,9 +576,7 @@ fieldViewDd dat dd lbl cont =
, if dat.level <= 1
then b [ title "Can't move this filter to parent branch" ] [ text "↰" ]
else a [ href "#", onClickD FMovePar, title "Move this filter to parent branch" ] [ text "↰" ]
- , if dat.level == 0
- then b [ title "Can't move this filter into a subbranch" ] [ text "↳" ]
- else a [ href "#", onClickD FMoveSub, title "Create new branch for this filter" ] [ text "↳" ]
+ , a [ href "#", onClickD FMoveSub, title "Create new branch for this filter" ] [ text "↳" ]
] :: cont ()
]