Commit 22473c7f authored by Bas Lijnse's avatar Bas Lijnse

Fixed comparison of UI's in dynamic editor

parent a5896c2b
Pipeline #48315 passed with stages
in 9 minutes and 56 seconds
......@@ -5,7 +5,7 @@ import Data.Func, Data.Functor, Data.Tuple
import qualified Data.Map as Map
import Text, Text.GenPrint, Text.HTML
import iTasks, iTasks.UI.Editor.Common
from Data.List import intersperse, zip4
from Data.List import intersperse, zip4, zipWith
dynamicEditor :: !(DynamicEditor a) -> Editor (DynamicEditorValue a) (?(DynamicEditorValue a)) | TC a
dynamicEditor dynEditor = compoundEditorToEditor $ dynamicCompoundEditor dynEditor
......@@ -37,7 +37,9 @@ where
# (uiForNewP, vst) = (dynamicCompoundEditor $ editor p).CompoundEditor.onReset 'Map'.newMap (?Just new) vst
| isError uiForNewP = (liftError uiForNewP, vst)
# (uiForNewP, newSt, newChildSts, newMbW) = fromOk uiForNewP
| uiForOldP === uiForNewP =
//Because the generated UI's each have a fresh unique editorId generated during onReset
//We must ignore all 'editorId' attributes during the comparison
| isEqualExceptEditorId uiForOldP uiForNewP =
appFst
(fmap \(change,st,cst,mbw) -> (change,(p,st),cst,fmap (fmap (\w -> (p,w))) mbw))
((dynamicCompoundEditor $ editor p).CompoundEditor.onRefresh new mbSt childSts vst)
......@@ -47,6 +49,12 @@ where
Ok res = Ok $ mapMaybe (\val -> (p, val)) res
Error e = Error e
isEqualExceptEditorId (UI t1 a1 i1) (UI t2 a2 i2)
= t1 === t2
&& 'Map'.del "editorId" a1 === 'Map'.del "editorId" a2
&& length i1 == length i2
&& (and $ zipWith isEqualExceptEditorId i1 i2)
// Bool part of result indicates whether the type is correct, i.e. the child types are matching
dynamicCompoundEditor :: !(DynamicEditor a) -> CompoundEditor
(?(!DynamicConsId, !ConsType, !Bool)) (DynamicEditorValue a) (?(DynamicEditorValue a)) | TC a
......
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