Skip to content

Commit

Permalink
Refresh ElementalArea after closing popup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jianbinzhu committed Aug 13, 2023
1 parent e370d91 commit e3e67d8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
3 changes: 3 additions & 0 deletions _graphql/mutations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 11 additions & 5 deletions client/dist/js/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions client/src/components/ElementActions/MoveAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
};

Expand Down
4 changes: 1 addition & 3 deletions client/src/state/editor/moveBlockMutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});

Expand Down

0 comments on commit e3e67d8

Please sign in to comment.