Emits itemEditionMessage in more contexts.

This commit is contained in:
mateuswetah 2022-03-21 11:39:44 -03:00
parent 2641608f81
commit e3edafaab9
3 changed files with 15 additions and 14 deletions

View File

@ -1337,13 +1337,14 @@ export default {
this.onPrevInSequence(); this.onPrevInSequence();
} }
} else {
parent.postMessage({
type: 'itemEditionMessage',
item: this.item
},
tainacan_plugin.admin_url);
} }
// Sends info to iframe containing item edition form and other use cases
parent.postMessage({
type: 'itemEditionMessage',
item: this.$adminOptions.itemEditionMode ? this.item : null
},
tainacan_plugin.admin_url);
}) })
.catch((errors) => { .catch((errors) => {
@ -1367,12 +1368,12 @@ export default {
onDiscard() { onDiscard() {
if (!this.$adminOptions.itemEditionMode) if (!this.$adminOptions.itemEditionMode)
this.$router.go(-1); this.$router.go(-1);
else
parent.postMessage({ parent.postMessage({
type: 'itemEditionMessage', type: 'itemEditionMessage',
item: null item: this.$adminOptions.itemEditionMode ? false : null
}, },
tainacan_plugin.admin_url); tainacan_plugin.admin_url);
}, },
createNewItem() { createNewItem() {

View File

@ -225,7 +225,7 @@
const message = event.message ? 'message' : 'data'; const message = event.message ? 'message' : 'data';
const data = event[message]; const data = event[message];
if (data.type == 'itemEditionMessage') { if (data.type == 'itemEditionMessage' && data.item !== null) {
this.editItemModal = false; this.editItemModal = false;
} }
} }

View File

@ -406,7 +406,7 @@
const message = event.message ? 'message' : 'data'; const message = event.message ? 'message' : 'data';
const data = event[message]; const data = event[message];
if (data.type == 'itemEditionMessage') { if (data.type == 'itemEditionMessage' && data.item !== null) {
this.editItemModalOpen = false; this.editItemModalOpen = false;
// An item is being edited from the modal // An item is being edited from the modal