Commit e68cf17f authored by Steffen Michels's avatar Steffen Michels

add vertical layout option for dynamic editor conses

parent 7c1af90d
Pipeline #20715 passed with stage
in 4 minutes and 46 seconds
......@@ -13,7 +13,7 @@ derive class iTask DynamicEditorValue
:: DynamicEditorElement = DynamicCons !DynamicCons | DynamicConsGroup !String ![DynamicCons]
:: DynamicCons
:: DynamicConsOption = HideIfOnlyChoice | UseAsDefault
:: DynamicConsOption = HideIfOnlyChoice | UseAsDefault | LayoutVertical
(<<@@@) infixl 2 :: !DynamicCons !DynamicConsOption -> DynamicCons
(@@@>>) infixr 2 :: !DynamicConsOption !DynamicCons -> DynamicCons
......
......@@ -16,6 +16,7 @@ import Data.Functor
, builder :: !DynamicConsBuilder
, showIfOnlyChoice :: !Bool
, useAsDefault :: !Bool
, uiAttributes :: !UIAttributes
}
(<<@@@) infixl 2 :: !DynamicCons !DynamicConsOption -> DynamicCons
......@@ -27,6 +28,7 @@ import Data.Functor
tunedDynamicConsEditor :: !DynamicConsOption !DynamicCons -> DynamicCons
tunedDynamicConsEditor HideIfOnlyChoice cons = {cons & showIfOnlyChoice = False}
tunedDynamicConsEditor UseAsDefault cons = {cons & useAsDefault = True}
tunedDynamicConsEditor LayoutVertical cons = {cons & uiAttributes = 'Map'.union (directionAttr Vertical) cons.uiAttributes}
functionCons :: !String !String !a -> DynamicCons | TC a
functionCons consId label func = functionConsDyn consId label (dynamic func)
......@@ -37,6 +39,7 @@ functionConsDyn consId label func = { consId = consId
, builder = FunctionCons func
, showIfOnlyChoice = True
, useAsDefault = False
, uiAttributes = 'Map'.newMap
}
listCons :: !String !String !([a] -> b) -> DynamicCons | TC a & TC b
......@@ -48,6 +51,7 @@ listConsDyn consId label func = { consId = consId
, builder = ListCons func
, showIfOnlyChoice = True
, useAsDefault = False
, uiAttributes = 'Map'.newMap
}
customEditorCons :: !String !String !(Editor a) -> DynamicCons
......@@ -57,6 +61,7 @@ customEditorCons consId label editor = { consId = consId
, builder = CustomEditorCons editor
, showIfOnlyChoice = True
, useAsDefault = False
, uiAttributes = 'Map'.newMap
}
// TODO: don't use aborts here
......@@ -352,7 +357,7 @@ where
where
genChildEditors` [] accUi accSt vst = (Ok (accUi, accSt), vst)
genChildEditors` [(mbVal, E editor, i): children] accUi accSt vst =
case editor.Editor.genUI emptyAttr (dp ++ [i]) (maybe Enter (if viewMode View Update) mbVal) vst of
case editor.Editor.genUI cons.uiAttributes (dp ++ [i]) (maybe Enter (if viewMode View Update) mbVal) vst of
(Ok (ui, st), vst) = genChildEditors` children [ui: accUi] [st: accSt] vst
(Error e, vst) = (Error e, vst)
......@@ -364,13 +369,13 @@ where
_ = repeat Nothing
ListCons lbuilder
# listEditorMode = mapEditMode (\(DEApplication listElems) -> listElems) mode
# (mbUi, vst) = (listBuilderEditor lbuilder).Editor.genUI emptyAttr (dp ++ [0]) listEditorMode vst
# (mbUi, vst) = (listBuilderEditor lbuilder).Editor.genUI cons.uiAttributes (dp ++ [0]) listEditorMode vst
= ((\(ui, st) -> ([ui], [st])) <$> mbUi, idx, type, cons.DynamicCons.label, vst)
CustomEditorCons editor
# editorMode = mapEditMode
(\(DEJSONValue json) -> fromMaybe (abort "Invalid dynamic editor state") $ fromJSON json)
mode
# (mbUi, vst) = editor.Editor.genUI emptyAttr (dp ++ [0]) editorMode vst
# (mbUi, vst) = editor.Editor.genUI cons.uiAttributes (dp ++ [0]) editorMode vst
= ((\(ui, st) -> ([ui], [st])) <$> mbUi, idx, type, cons.DynamicCons.label, vst)
where
(cons, idx) = consWithId cid matchingConses
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment