store method for save page or screen (context dependant)

This commit is contained in:
Michael Shanks 2020-02-20 17:08:17 +00:00
parent 1d2f079914
commit 21461645cc
1 changed files with 12 additions and 17 deletions

View File

@ -749,7 +749,7 @@ const addTemplatedComponent = store => props => {
props props
) )
_savePage(state) _saveCurrentPreviewItem(state)
return state return state
}) })
@ -792,9 +792,7 @@ const setComponentStyle = store => (type, name, value) => {
]) ])
// save without messing with the store // save without messing with the store
s.currentFrontEndType === "page" _saveCurrentPreviewItem(s)
? _savePage(s)
: _saveScreenApi(s.currentPreviewItem, s)
return s return s
}) })
} }
@ -843,9 +841,7 @@ const deleteComponent = store => component => {
parent._children = parent._children.filter(c => c !== component) parent._children = parent._children.filter(c => c !== component)
} }
s.currentFrontEndType === "page" _saveCurrentPreviewItem(s)
? _savePage(s)
: _saveScreenApi(s.currentPreviewItem, s)
return s return s
}) })
@ -864,9 +860,7 @@ const moveUpComponent = store => component => {
parent._children = newChildren parent._children = newChildren
} }
s.currentComponentInfo = component s.currentComponentInfo = component
s.currentFrontEndType === "page" _saveCurrentPreviewItem(s)
? _savePage(s)
: _saveScreenApi(s.currentPreviewItem, s)
return s return s
}) })
@ -885,9 +879,7 @@ const moveDownComponent = store => component => {
parent._children = newChildren parent._children = newChildren
} }
s.currentComponentInfo = component s.currentComponentInfo = component
s.currentFrontEndType === "page" _saveCurrentPreviewItem(s)
? _savePage(s)
: _saveScreenApi(s.currentPreviewItem, s)
return s return s
}) })
@ -902,9 +894,7 @@ const copyComponent = store => component => {
}) })
parent._children = [...parent._children, copiedComponent] parent._children = [...parent._children, copiedComponent]
s.curren s.curren
s.currentFrontEndType === "page" _saveCurrentPreviewItem(s)
? _savePage(s)
: _saveScreenApi(s.currentPreviewItem, s)
s.currentComponentInfo = copiedComponent s.currentComponentInfo = copiedComponent
return s return s
}) })
@ -913,7 +903,7 @@ const copyComponent = store => component => {
const getParent = (rootProps, child) => { const getParent = (rootProps, child) => {
let parent let parent
walkProps(rootProps, (p, breakWalk) => { walkProps(rootProps, (p, breakWalk) => {
if (p._children.includes(child)) { if (p._children && p._children.includes(child)) {
parent = p parent = p
breakWalk() breakWalk()
} }
@ -934,3 +924,8 @@ const walkProps = (props, action, cancelToken = null) => {
} }
} }
} }
const _saveCurrentPreviewItem = s =>
s.currentFrontEndType === "page"
? _savePage(s)
: _saveScreenApi(s.currentPreviewItem, s)