Commit e55ca5b3 authored by Bas Lijnse's avatar Bas Lijnse

Removed update flag from genUI in gEditor, will be replaced by edit mode in VSt

parent 1b48c63e
......@@ -89,8 +89,8 @@ where
= makeEditor (Display (defaultViewFun status),newFieldMask) taskId iworld
makeEditor value=:(v,vmask) taskId iworld
# vst = {VSt| selectedConsIndex = -1, optional = False, disabled = False, taskId = toString taskId, iworld = iworld}
# (editUI,vst=:{VSt|iworld}) = gEditor{|*|}.Editor.genUI [] v True vst
# vst = {VSt| selectedConsIndex = -1, mode = View, optional = False, disabled = False, taskId = toString taskId, iworld = iworld}
# (editUI,vst=:{VSt|iworld}) = gEditor{|*|}.Editor.genUI [] v vst
= (editUI,iworld)
//By default show a progress bar
......
......@@ -120,17 +120,17 @@ matchAndApplyEvent_ _ matchId evalOpts mbEditor taskTime (v,m) ts desc iworld
updateValueAndMask_ :: TaskId DataPath (Maybe (Editor v)) JSONNode (Masked v) *IWorld -> *(!Masked v,*IWorld) | iTask v
updateValueAndMask_ taskId path mbEditor diff (v,m) iworld
# editor = fromMaybe gEditor{|*|} mbEditor
# (nv,nm,vst=:{VSt|iworld}) = editor.Editor.onEdit path diff v m {VSt|selectedConsIndex= -1, taskId=toString taskId,optional=False,disabled=False,iworld=iworld}
# (nv,nm,vst=:{VSt|iworld}) = editor.Editor.onEdit path diff v m {VSt|selectedConsIndex= -1, taskId=toString taskId, mode = Enter, optional=False,disabled=False,iworld=iworld}
= ((nv,nm),iworld)
visualizeView_ :: TaskId TaskEvalOpts (Maybe (Editor v)) Event (Masked v) (Masked v) d *IWorld -> *(!MaybeErrorString UIChange,!Bool,!*IWorld) | iTask v & toPrompt d
visualizeView_ taskId evalOpts mbEditor event old=:(v,m) new=:(nv,nm) desc iworld
# editor = fromMaybe gEditor{|*|} mbEditor
# valid = not (containsInvalidFields nm)
# vst = {VSt| selectedConsIndex = -1, optional = False, disabled = False, taskId = toString taskId, iworld = iworld}
# vst = {VSt| selectedConsIndex = -1, mode = Enter, optional = False, disabled = False, taskId = toString taskId, iworld = iworld}
# (change,vst=:{VSt|iworld}) = case event of
ResetEvent //(re)generate the initial UI
= case editor.Editor.genUI [] nv True vst of
= case editor.Editor.genUI [] nv vst of
(Ok (editUI,nm),vst)
# promptUI = toPrompt desc
# change = ReplaceUI (uic UIInteract [promptUI,editUI])
......
......@@ -7,7 +7,7 @@ from Data.Map import :: Map (..)
from Data.List import instance Functor []
import qualified Data.List as DL
import qualified Data.Map as DM
import iTasks.UI.Definition, iTasks.UI.Editor, iTasks.UI.Editor.Builtin, iTasks.UI.Editor.Combinators
import iTasks.UI.Definition, iTasks.UI.Editor, iTasks.UI.Editor.Builtin, iTasks.UI.Editor.Combinators, iTasks.UI.Editor.Common
import iTasks.UI.Prompt
import iTasks._Framework.Generic.Visualization
import iTasks._Framework.Task, iTasks._Framework.TaskState, iTasks._Framework.Util
......@@ -470,7 +470,7 @@ gEditor {|Document|} = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
typeDesc = "document"
genUI dp val update vst=:{VSt|taskId,optional,disabled}
genUI dp val vst=:{VSt|taskId,optional,disabled}
# mask = newFieldMask
| disabled
# value = checkMask mask val
......@@ -544,7 +544,7 @@ gText{|Scale|} _ _ = [""]
gEditor{|Scale|} = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val upd vst=:{VSt|taskId,optional,disabled}
genUI dp val vst=:{VSt|taskId,optional,disabled}
# sliderAttr = 'DM'.unions [minValueAttr val.Scale.min, maxValueAttr val.Scale.max]
# mask = newFieldMask
| disabled
......@@ -571,7 +571,7 @@ gText{|Progress|} _ val = [maybe "" (\{Progress|description} -> description) va
gEditor{|Progress|} = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val mask vst=:{VSt|taskId}
genUI dp val vst=:{VSt|taskId}
# attr = 'DM'.unions [textAttr (text val),valueAttr (toJSON (value val))]
= (Ok (uia UIViewProgress attr,newFieldMask), vst)
where
......@@ -604,7 +604,7 @@ gText{|HtmlInclude|} _ _ = [""]
gEditor{|HtmlInclude|} = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp (HtmlInclude path) update vst
genUI dp (HtmlInclude path) vst
# attr = 'DM'.fromList [("value",JSONString (toString (IframeTag [SrcAttr path] [])))]
= (Ok (uia UIViewHtml attr,newFieldMask),vst)
......@@ -620,7 +620,7 @@ gText{|FormButton|} _ val = [maybe "" (\v -> v.FormButton.label) val]
gEditor{|FormButton|} = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val update vst=:{VSt|taskId,disabled}
genUI dp val vst=:{VSt|taskId,disabled}
# text = val.FormButton.label
# iconCls = val.FormButton.icon
# attr = 'DM'.unions [textAttr text,iconClsAttr iconCls,enabledAttr True,editAttrs taskId (editorId dp) (Just (JSONString "pressed"))]
......@@ -653,7 +653,7 @@ gText{|Table|} _ _ = ["<Table>"]
gEditor{|Table|} = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val mask vst=:{VSt|taskId,disabled}
genUI dp val vst=:{VSt|taskId,disabled}
# attr = 'DM'.unions [choiceAttrs taskId (editorId dp) (value val) (options val),columnsAttr (columns val)]
= (Ok (uia UIGrid attr,newFieldMask),vst)
where
......@@ -664,7 +664,7 @@ where
updUI dp old om new nm vst
| old === new
= (Ok NoChange,vst)
= case genUI dp new True vst of
= case genUI dp new vst of
(Ok (ui,mask),vst) = (Ok (ReplaceUI ui),vst)
(Error e,vst) = (Error e,vst)
......@@ -707,7 +707,7 @@ gText{|ComboChoice|} fv mode _ = [""]
gEditor{|ComboChoice|} fx gx _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val mask vst=:{VSt|taskId,optional,disabled}
genUI dp val vst=:{VSt|taskId,optional,disabled}
| disabled
= (Ok (uia UIViewString (vvalue val),newFieldMask), vst)
| otherwise
......@@ -724,7 +724,7 @@ where
updUI dp old om new nm vst
| options old === options new && evalue old === evalue new
= (Ok NoChange,vst)
= case genUI dp new True vst of
= case genUI dp new vst of
(Ok (ui,mask),vst) = (Ok (ReplaceUI ui),vst)
(Error e,vst) = (Error e,vst)
......@@ -744,7 +744,7 @@ gText{|RadioChoice|} fv _ _ = [""]
gEditor{|RadioChoice|} _ gx _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val update vst=:{VSt|taskId,optional,disabled}
genUI dp val vst=:{VSt|taskId,optional,disabled}
| disabled
# attr = 'DM'.unions [optionalAttr optional,vvalue val]
= (Ok (uia UIViewString attr,newFieldMask),vst)
......@@ -763,7 +763,7 @@ where
updUI dp old om new nm vst
| options old === options new && evalue old === evalue new
= (Ok NoChange,vst)
= case genUI dp new True vst of
= case genUI dp new vst of
(Ok (ui,mask),vst) = (Ok (ReplaceUI ui),vst)
(Error e,vst) = (Error e,vst)
......@@ -782,7 +782,7 @@ gText{|ListChoice|} fv _ _ = [""]
gEditor{|ListChoice|} _ gx _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val mask vst=:{VSt|taskId,disabled}
genUI dp val vst=:{VSt|taskId,disabled}
| disabled
= (Ok (uia UIViewString (vvalue val),newFieldMask), vst)
| otherwise
......@@ -798,7 +798,7 @@ where
updUI dp old om new nm vst
| options old === options new && evalue old === evalue new
= (Ok NoChange,vst)
= case genUI dp new True vst of
= case genUI dp new vst of
(Ok (ui,mask),vst) = (Ok (ReplaceUI ui),vst)
(Error e,vst) = (Error e,vst)
......@@ -818,7 +818,7 @@ gText{|TreeChoice|} fv _ _ = [""]
gEditor{|TreeChoice|} _ gx _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val mask vst=:{VSt|taskId,disabled}
genUI dp val vst=:{VSt|taskId,disabled}
# attr = choiceAttrs taskId (editorId dp) (value val) (options gx val)
= (Ok (uia UITree attr,newFieldMask),vst)
......@@ -845,7 +845,7 @@ where
updUI dp old om new nm vst
| options gx old === options gx new && value old === value new
= (Ok NoChange,vst)
= case genUI dp new True vst of
= case genUI dp new vst of
(Ok (ui,mask),vst) = (Ok (ReplaceUI ui),vst)
(Error e,vst) = (Error e,vst)
......@@ -868,7 +868,7 @@ gText{|GridChoice|} fv _ _ = [""]
gEditor{|GridChoice|} _ gx _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val mask vst=:{VSt|taskId,disabled}
genUI dp val vst=:{VSt|taskId,disabled}
# attr = 'DM'.unions [choiceAttrs taskId (editorId dp) (value val) (options val),columnsAttr columns]
= (Ok (uia UIGrid attr,newFieldMask),vst)
......@@ -879,7 +879,7 @@ where
updUI dp old om new nm vst
| options old === options new && value old === value new
= (Ok NoChange,vst)
= case genUI dp new True vst of
= case genUI dp new vst of
(Ok (ui,mask),vst) = (Ok (ReplaceUI ui),vst)
(Error e,vst) = (Error e,vst)
......@@ -903,11 +903,11 @@ gText{|DynamicChoice|} fv _ _ = [""]
gEditor{|DynamicChoice|} f1 f2 f3 f4 f5 = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp (DCCombo val) mask vst = (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.genUI dp val mask vst
genUI dp (DCRadio val) mask vst = (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.genUI dp val mask vst
genUI dp (DCList val) mask vst = (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.genUI dp val mask vst
genUI dp (DCTree val) mask vst = (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.genUI dp val mask vst
genUI dp (DCGrid val) mask vst = (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.genUI dp val mask vst
genUI dp (DCCombo val) vst = (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.genUI dp val vst
genUI dp (DCRadio val) vst = (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.genUI dp val vst
genUI dp (DCList val) vst = (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.genUI dp val vst
genUI dp (DCTree val) vst = (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.genUI dp val vst
genUI dp (DCGrid val) vst = (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.genUI dp val vst
updUI dp (DCCombo old) om (DCCombo new) nm vst
= (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.updUI dp old om new nm vst
......@@ -919,7 +919,7 @@ where
= (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.updUI dp old om new nm vst
updUI dp (DCGrid old) om (DCGrid new) nm vst
= (gEditor{|*->*|} f1 f2 f3 f4 f5).Editor.updUI dp old om new nm vst
updUI dp old om new nm vst = case genUI dp new True vst of
updUI dp old om new nm vst = case genUI dp new vst of
(Ok (ui,mask),vst) = (Ok (ReplaceUI ui),vst)
(Error e,vst) = (Error e,vst)
onEdit dp e (DCCombo val) mask ust
......@@ -971,7 +971,7 @@ gText{|CheckMultiChoice|} fv _ _ _ = [""]
gEditor{|CheckMultiChoice|} _ gx _ _ _ _ _ _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val ipd vst=:{VSt|taskId,optional,disabled}
genUI dp val vst=:{VSt|taskId,optional,disabled}
| disabled
# attr = 'DM'.unions [optionalAttr optional,vvalue val]
= (Ok (uia UIViewString attr,newFieldMask),vst)
......@@ -987,7 +987,7 @@ where
updUI dp old om new nm vst
| options old === options new && evalue old === evalue new
= (Ok NoChange,vst)
= case genUI dp new True vst of
= case genUI dp new vst of
(Ok (ui,mask),vst) = (Ok (ReplaceUI ui),vst)
(Error e,vst) = (Error e,vst)
......@@ -1142,10 +1142,10 @@ gText{|VisualizationHint|} fx _ _ = [""]
gEditor{|VisualizationHint|} fx gx dx jex jdx = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val mask vst = case val of
VHHidden x = (gEditor{|* -> *|} fx gx dx jex jdx).Editor.genUI dp (Hidden x) mask vst
VHDisplay x = (gEditor{|* -> *|} fx gx dx jex jdx).Editor.genUI dp (Display x) mask vst
VHEditable x = (gEditor{|* -> *|} fx gx dx jex jdx).Editor.genUI dp (Editable x) mask vst
genUI dp val vst = case val of
VHHidden x = (gEditor{|* -> *|} fx gx dx jex jdx).Editor.genUI dp (Hidden x) vst
VHDisplay x = (gEditor{|* -> *|} fx gx dx jex jdx).Editor.genUI dp (Display x) vst
VHEditable x = (gEditor{|* -> *|} fx gx dx jex jdx).Editor.genUI dp (Editable x) vst
updUI dp (VHEditable old) om (VHEditable new) nm vst = (gEditor{|* -> *|} fx gx dx jex jdx).Editor.updUI dp (Editable old) om (Editable new) nm vst
updUI dp (VHDisplay old) om (VHDisplay new) nm vst = (gEditor{|* -> *|} fx gx dx jex jdx).Editor.updUI dp (Display old) om (Display new) nm vst
......@@ -1166,11 +1166,7 @@ toVisualizationHint a = (VHEditable a)
gText{|Hidden|} _ _ _ = []
gEditor{|Hidden|} fx _ _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val upd vst = (Ok (ui UIEmpty,CompoundMask []),vst)
updUI dp old om new nm vst = (Ok NoChange,vst)
onEdit dp e val mask ust = (val,mask,ust)
gEditor{|Hidden|} fx _ _ _ _ = emptyEditor
fromHidden :: !(Hidden .a) -> .a
fromHidden (Hidden x) = x
......@@ -1183,8 +1179,8 @@ gText{|Display|} fx mode Nothing = fx mode Nothing
gEditor{|Display|} ex j _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp (Display val) mask vst=:{VSt|disabled}
# (def,vst) = ex.Editor.genUI dp val mask {VSt|vst & disabled = True}
genUI dp (Display val) vst=:{VSt|disabled}
# (def,vst) = ex.Editor.genUI dp val {VSt|vst & disabled = True}
= (def,{VSt|vst & disabled = disabled})
updUI dp (Display old) om (Display new) nm vst=:{VSt|disabled}
......@@ -1204,8 +1200,8 @@ gText{|Editable|} fx mode Nothing = fx mode Nothing
gEditor{|Editable|} ex _ _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val mask vst=:{VSt|disabled}
# (def,vst) = ex.Editor.genUI dp (fromEditable val) mask {VSt | vst & disabled = False}
genUI dp val vst=:{VSt|disabled}
# (def,vst) = ex.Editor.genUI dp (fromEditable val) {VSt | vst & disabled = False}
= (def,{VSt | vst & disabled = disabled})
updUI dp (Editable old) om (Editable new) nm vst
......@@ -1224,8 +1220,8 @@ gText{|Row|} gVizx mode Nothing = gVizx mode Nothing
gEditor{|Row|} ex _ _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp (Row val) update vst
= case ex.Editor.genUI dp val update vst of
genUI dp (Row val) vst
= case ex.Editor.genUI dp val vst of
(Ok (ui,mask),vst) = (Ok (setHorizontal ui,mask),vst)
(Error e,vst) = (Error e,vst)
where
......@@ -1240,8 +1236,8 @@ gText{|Col|} gVizx mode Nothing = gVizx mode Nothing
gEditor{|Col|} ex _ _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp (Col val) update vst
= case ex.Editor.genUI dp val update vst of
genUI dp (Col val) vst
= case ex.Editor.genUI dp val vst of
(Ok (ui,mask),vst) = (Ok (setVertical ui,mask),vst)
(Error e,vst) = (Error e,vst)
where
......@@ -1367,7 +1363,7 @@ derive gText Icon
gEditor{|Icon|} = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI _ (Icon icon) mask vst = (Ok (uia UIIcon (iconClsAttr ("icon-"+++icon)),newFieldMask), vst)
genUI _ (Icon icon) vst = (Ok (uia UIIcon (iconClsAttr ("icon-"+++icon)),newFieldMask), vst)
updUI _ (Icon old) om (Icon new) nm vst
= (Ok (if (old === new) NoChange (ChangeUI [SetAttribute "iconCls" (encodeUI ("icon-"+++new))] [])),vst)
......@@ -1394,7 +1390,7 @@ gEq{|Dynamic|} _ _ = False // dynamics are never equal
gDefault{|{}|} _ = undef
gEditor{|{}|} _ _ _ _ _ = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI _ _ _ vst = (Ok (ui UIEmpty,newCompoundMask),vst)
genUI _ _ vst = (Ok (ui UIEmpty,newCompoundMask),vst)
updUI _ _ _ _ _ vst = (Ok NoChange,vst)
onEdit _ _ val mask ust = (val,mask,ust)
......
......@@ -25,7 +25,7 @@ analogClockEditlet
,onEdit = onEdit
}
where
genUI dp (AnalogClock {Time|hour,min,sec}) mask world
genUI dp (AnalogClock {Time|hour,min,sec}) world
# attr = 'DM'.unions [sizeAttr (ExactSize 100) (ExactSize 100),valueAttr (JSONString (toString (svgClock hour min sec)))]
= (Ok (uia UIViewHtml attr,newFieldMask), world)
where
......
......@@ -21,7 +21,7 @@ controlLightEditlet
,onEdit = \_ _ a m ust -> (a,m,ust)
}
where
genUI dp val upd world
genUI dp val world
# attr = 'DM'.unions [sizeAttr (ExactSize 20) (ExactSize 20),valueAttr (JSONString (toString (svgLight (color val))))]
= (Ok (uia UIViewHtml attr,newFieldMask), world)
......
......@@ -65,7 +65,7 @@ googleMapEditlet
, onEdit = onEdit
}
where
genUI dp val upd world
genUI dp val world
# attr = 'DM'.unions [sizeAttr (ExactSize 500) (ExactSize 200), valueAttr (toJSON val)]
= (Ok (uia UIComponent attr,newFieldMask),world)
......
......@@ -134,7 +134,7 @@ leafletEditlet
, onEdit = onEdit
}
where
genUI dp val mask world
genUI dp val world
# attr = sizeAttr (ExactSize 500) (ExactSize 150)
= (Ok (uia UIViewHtml attr,newFieldMask), world)
......
......@@ -76,7 +76,7 @@ svgRenderer svglet=:{initView,renderImage,updView,updModel}
, onEdit = onEdit
}
where
genUI dp val upd world
genUI dp val world
# attr = 'DM'.unions [sizeAttr FlexSize FlexSize, valueAttr (toJSON val)]
= (Ok (uia UIComponent attr,newFieldMask), world)
......
......@@ -17,17 +17,19 @@ from Text.JSON import :: JSONNode, generic JSONEncode, generic JSONDecode
from GenEq import generic gEq
/*
* Standard editor
* Definition of an editor editor
*/
:: Editor a =
{ genUI :: DataPath a Bool *VSt -> *(!MaybeErrorString (!UI, !EditMask),!*VSt)
{ genUI :: DataPath a *VSt -> *(!MaybeErrorString (!UI, !EditMask),!*VSt)
, updUI :: DataPath a EditMask a EditMask *VSt -> *(!MaybeErrorString UIChange, !*VSt)
, onEdit :: DataPath JSONNode a EditMask *VSt -> *(!a, !EditMask, !*VSt)
, onEdit :: DataPath JSONNode a EditMask *VSt -> *(!a, !EditMask, !*VSt)
}
//* Datapaths identify sub structures in a composite structure
:: DataPath :== [Int]
:: EditMode = Enter | Update | View
/** Edit masks contain information about a value as it is being edited in an interactive task.
* During editing, values can be in an inconsistent, or even untypable state
*/
......@@ -45,7 +47,8 @@ from GenEq import generic gEq
:: Masked a :== (a,EditMask)
:: *VSt =
{ selectedConsIndex :: !Int // Index of the selected constructor in an Object
{ selectedConsIndex :: !Int // Index of the selected constructor in an OBJECT
, mode :: !EditMode // If we are entering, updating or viewing the data
, optional :: !Bool // Create optional form fields
, disabled :: !Bool // If true the editor is not editable
, taskId :: !String // The id of the task the visualisation belongs to
......@@ -85,7 +88,7 @@ basicEditSimple :: !DataPath !JSONNode !a !EditMask !*VSt -> *(!a,!EditMask,!*VS
//****************************************************************************//
:: Editlet a
=
{ genUI :: DataPath a Bool *VSt -> *(!MaybeErrorString (!UI,!EditMask), !*VSt)
{ genUI :: DataPath a *VSt -> *(!MaybeErrorString (!UI,!EditMask), !*VSt)
, initUI :: (JSObj ()) *JSWorld -> *JSWorld
, updUI :: DataPath a EditMask a EditMask *VSt -> *(!MaybeErrorString UIChange, !*VSt)
, onEdit :: DataPath JSONNode a EditMask *VSt -> *(!a, !EditMask, !*VSt)
......
......@@ -15,7 +15,7 @@ derive gEq EditMask, FieldMask
emptyEditor :: Editor a
emptyEditor = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI _ _ _ vst = (Ok (ui UIEmpty,newFieldMask),vst)
genUI _ _ vst = (Ok (ui UIEmpty,newFieldMask),vst)
updUI _ _ _ _ _ vst = (Ok NoChange,vst)
onEdit _ _ val mask ust = (val,mask,ust)
......@@ -108,8 +108,8 @@ basicEditSimple target upd val mask iworld = basicEdit (\json _ -> fromJSON json
fromEditlet :: (Editlet a) -> (Editor a) | JSONEncode{|*|} a & JSONDecode{|*|} a & gDefault{|*|} a
fromEditlet editlet=:{Editlet|genUI,initUI,updUI,onEdit} = {Editor|genUI=genUI`,updUI=updUI,onEdit=onEdit}
where
genUI` dp val upd vst=:{VSt|taskId}
= case genUI dp val upd vst of
genUI` dp val vst=:{VSt|taskId}
= case genUI dp val vst of
(Ok (UI type attr items,mask),vst=:{VSt|iworld}) = case editletLinker initUI iworld of
(Ok (saplDeps, saplInit),iworld)
# editletAttr = 'DM'.fromList [("taskId",JSONString taskId)
......
......@@ -44,9 +44,9 @@ icon = simpleComponent toJSON UIIcon
//Simple components for which simply knowing the UI type is sufficient
simpleComponent toValue type = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val upd vst=:{VSt|taskId,optional}
genUI dp val vst=:{VSt|taskId,mode,optional}
# mask = newFieldMask
# val = if upd (toValue val) JSONNull
# val = if (mode =: Enter) JSONNull (toValue val)
# attr = 'DM'.unions [optionalAttr optional, taskIdAttr taskId, editorIdAttr (editorId dp), valueAttr val]
= (Ok (uia type attr,mask),vst)
......
......@@ -7,8 +7,8 @@ import qualified Data.Map as DM
withHintAttributes :: String (Editor a) -> Editor a
withHintAttributes typeDesc editor = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val upd vst=:{VSt|taskId,optional}
= case editor.Editor.genUI dp val upd vst of
genUI dp val vst=:{VSt|taskId,optional}
= case editor.Editor.genUI dp val vst of
(Ok (UI type attr items,mask),vst)
//Add hint attributes
# attr = 'DM'.union (stdAttributes typeDesc optional mask) attr
......@@ -27,9 +27,9 @@ where
whenDisabled :: (Editor a) (Editor a) -> Editor a
whenDisabled disabledEditor enabledEditor = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val mask vst=:{VSt|taskId,disabled}
| disabled = disabledEditor.Editor.genUI dp val mask vst
= enabledEditor.Editor.genUI dp val mask vst
genUI dp val vst=:{VSt|taskId,disabled}
| disabled = disabledEditor.Editor.genUI dp val vst
= enabledEditor.Editor.genUI dp val vst
updUI dp ov om nv nm vst=:{VSt|optional,disabled}
| disabled = disabledEditor.Editor.updUI dp ov om nv nm vst
......@@ -41,7 +41,7 @@ where
liftEditor :: (b -> a) (a -> b) (Editor a) -> Editor b
liftEditor tof fromf editor = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val upd vst = editor.Editor.genUI dp (tof val) upd vst
genUI dp val vst = editor.Editor.genUI dp (tof val) vst
updUI dp ov om nv nm vst = editor.Editor.updUI dp (tof ov) om (tof nv) nm vst
onEdit dp e val mask ust
# (val,mask,ust) = editor.Editor.onEdit dp e (tof val) mask ust
......@@ -50,7 +50,7 @@ where
liftEditorAsymmetric :: (b -> a) (a -> MaybeErrorString b) (Editor a) -> Editor b
liftEditorAsymmetric tof fromf editor = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val upd vst = editor.Editor.genUI dp (tof val) upd vst
genUI dp val vst = editor.Editor.genUI dp (tof val) vst
updUI dp ov om nv nm vst = editor.Editor.updUI dp (tof ov) om (tof nv) nm vst
onEdit dp e old mask ust
......@@ -62,7 +62,7 @@ where
constEditor :: a (Editor a) -> (Editor a)
constEditor val editor = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp _ upd vst = editor.Editor.genUI dp val upd vst
genUI dp _ vst = editor.Editor.genUI dp val vst
updUI dp _ _ _ _ vst = (Ok NoChange,vst)
onEdit dp _ val mask ust = (val,mask,ust)
......@@ -8,14 +8,14 @@ import qualified Data.Map as DM
emptyEditor :: Editor a
emptyEditor = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI _ _ _ vst = (Ok (ui UIEmpty,newFieldMask),vst)
genUI _ _ vst = (Ok (ui UIEmpty,newFieldMask),vst)
updUI _ _ _ _ _ vst = (Ok NoChange,vst)
onEdit _ _ val mask ust = (val,mask,ust)
listEditor :: (Maybe ([a] -> a)) Bool Bool (Maybe ([a] -> String)) (Editor a) -> Editor [a]
listEditor add remove reorder count itemEditor = {Editor|genUI=genUI,updUI=updUI,onEdit=onEdit}
where
genUI dp val upd vst=:{VSt|taskId} = case genChildUIs dp 0 val [] vst of
genUI dp val vst=:{VSt|taskId} = case genChildUIs dp 0 val [] vst of
(Ok (items,masks),vst)
//Add list structure editing buttons
# items = [listItemControl (length val) idx dx \\ dx <- items & idx <- [0..]]
......@@ -25,7 +25,7 @@ where
(Error e,vst) = (Error e,vst)
where
genChildUIs dp _ [] us vst = (Ok (unzip (reverse us)), vst)
genChildUIs dp i [c:cs] us vst = case itemEditor.Editor.genUI (dp++[i]) c upd vst of
genChildUIs dp i [c:cs] us vst = case itemEditor.Editor.genUI (dp++[i]) c vst of
(Ok (u,m),vst) = genChildUIs dp (i+1) cs [(u,m):us] vst
(Error e,vst) = (Error e,vst)
......@@ -46,7 +46,7 @@ where
# attr = 'DM'.unions [halignAttr AlignRight,heightAttr WrapSize,directionAttr Horizontal]
= uiac UIContainer attr (if (reorder || remove) ([item] ++ buttons) [item])
updUI dp ov om nv nm vst = case genUI dp nv True vst of
updUI dp ov om nv nm vst = case genUI dp nv vst of
(Ok (ui,mask),vst) = (Ok (ReplaceUI ui),vst)
(Error e,vst) = (Error e,vst)
......