From e3e67d861c82fd098df737125f9dbc373159243e Mon Sep 17 00:00:00 2001 From: James Zhu Date: Mon, 14 Aug 2023 11:54:32 +1200 Subject: [PATCH] Refresh ElementalArea after closing popup --- _graphql/mutations.yml | 3 +++ client/dist/js/bundle.js | 16 +++++++++++----- .../src/components/ElementActions/MoveAction.js | 11 ++++++++--- client/src/state/editor/moveBlockMutation.js | 4 +--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/_graphql/mutations.yml b/_graphql/mutations.yml index 48ecba4d..f2d44911 100644 --- a/_graphql/mutations.yml +++ b/_graphql/mutations.yml @@ -7,3 +7,6 @@ 'sortBlock(id: ID!, afterBlockID: ID!)': model: DNADesign\Elemental\Models\BaseElement description: Changes the sort position of an element +'moveBlock(id: ID!)': + model: DNADesign\Elemental\Models\BaseElement + description: Move an element to another page diff --git a/client/dist/js/bundle.js b/client/dist/js/bundle.js index 4aea05f3..0ebd992e 100644 --- a/client/dist/js/bundle.js +++ b/client/dist/js/bundle.js @@ -561,7 +561,8 @@ var MoveAction = function MoveAction(MenuComponent) { modalOpen = _useState2[0], setModalOpen = _useState2[1]; - var id = props.element.id; + var id = props.element.id, + handleMoveBlock = props.actions.handleMoveBlock; var handleClick = function handleClick(event) { @@ -571,6 +572,13 @@ var MoveAction = function MoveAction(MenuComponent) { }; var closeModal = function closeModal() { + if (handleMoveBlock) { + handleMoveBlock(id).then(function () { + var preview = window.jQuery('.cms-preview'); + preview.entwine('ss.preview')._loadUrl(preview.find('iframe').attr('src')); + }); + } + setModalOpen(false); }; @@ -4096,12 +4104,10 @@ var config = { var mutate = _ref.mutate, actions = _ref.ownProps.actions; - var handleMoveBlock = function handleMoveBlock(blockId, fromPageId, toPageId) { + var handleMoveBlock = function handleMoveBlock(blockId) { return mutate({ variables: { - blockId: blockId, - fromPageId: fromPageId, - toPageId: toPageId + blockId: blockId } }); }; diff --git a/client/src/components/ElementActions/MoveAction.js b/client/src/components/ElementActions/MoveAction.js index 3a718f58..b4ac2e14 100644 --- a/client/src/components/ElementActions/MoveAction.js +++ b/client/src/components/ElementActions/MoveAction.js @@ -13,8 +13,7 @@ import i18n from 'i18n'; const MoveAction = (MenuComponent) => (props) => { const FormBuilderModal = loadComponent('FormBuilderModal'); const [modalOpen, setModalOpen] = useState(false); - // const { element: { id }, isPublished, actions: { handleMoveBlock } } = props; - const { element: { id } } = props; + const { element: { id }, actions: { handleMoveBlock } } = props; const handleClick = (event) => { event.stopPropagation(); @@ -23,7 +22,13 @@ const MoveAction = (MenuComponent) => (props) => { }; const closeModal = () => { - // TODO: refetch the elemental list when the modal is closed + if (handleMoveBlock) { + handleMoveBlock(id).then(() => { + const preview = window.jQuery('.cms-preview'); + preview.entwine('ss.preview')._loadUrl(preview.find('iframe').attr('src')); + }); + } + setModalOpen(false); }; diff --git a/client/src/state/editor/moveBlockMutation.js b/client/src/state/editor/moveBlockMutation.js index 243081f2..4d98cbc0 100644 --- a/client/src/state/editor/moveBlockMutation.js +++ b/client/src/state/editor/moveBlockMutation.js @@ -15,11 +15,9 @@ mutation MoveBlock($blockId:ID!) { const config = { props: ({ mutate, ownProps: { actions } }) => { - const handleMoveBlock = (blockId, fromPageId, toPageId) => mutate({ + const handleMoveBlock = (blockId) => mutate({ variables: { blockId, - fromPageId, - toPageId, }, });