diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue index 6c5d676a5b..de914ef971 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue @@ -64,7 +64,12 @@ {{ $tr('addTopic') }} - + {{ $tr('uploadButton') }} @@ -256,6 +261,7 @@ openTime: null, isInheritModalOpen: false, newNodeIds: [], + creatingNodes: false, }; }, computed: { @@ -532,6 +538,7 @@ }); }, async createNodesFromUploads(fileUploads) { + this.creatingNodes = true; this.newNodeIds = await Promise.all( fileUploads.map(async (file, index) => { let title; @@ -557,6 +564,7 @@ return newNodeId; }) ); + this.creatingNodes = false; this.$refs.inheritModal?.resetClosed(); }, updateTitleForPage() { @@ -568,8 +576,21 @@ }); }, inheritMetadata(metadata) { - for (const nodeId of this.currentSelectedNodes) { - this.updateContentNode({ id: nodeId, ...metadata, mergeMapFields: true }); + const setMetadata = () => { + for (const nodeId of this.newNodeIds) { + this.updateContentNode({ id: nodeId, ...metadata, mergeMapFields: true }); + } + this.newNodeIds = []; + }; + if (!this.creatingNodes) { + setMetadata(); + } else { + const unwatch = this.$watch('creatingNodes', creatingNodes => { + if (!creatingNodes) { + unwatch(); + setMetadata(); + } + }); } }, }, diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue index 87d6bbb7d6..b43deb5a4d 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue @@ -7,7 +7,7 @@ :submitText="$tr('continueAction')" :cancelText="$tr('cancelAction')" @submit="handleContinue" - @cancel="closed = true" + @cancel="handleCancel" >
@@ -201,10 +201,14 @@ } this.checks = checks; ContentNode.getAncestors(this.parent.id).then(ancestors => { + if (!this.parent) { + // If the parent has been removed before the data is fetched, return + return; + } for (const field of inheritableFields) { if ( - this.parent.extra_fields.inherited_metadata && - this.parent.extra_fields.inherited_metadata[field] + this.parent.extra_fields?.inherited_metadata && + !isUndefined(this.parent.extra_fields.inherited_metadata[field]) ) { this.checks[field] = this.parent.extra_fields.inherited_metadata[field]; } @@ -291,6 +295,10 @@ } this.closed = true; }, + handleCancel() { + this.closed = true; + this.$emit('inherit', {}); + }, /** * @public */