From 8136e74c83e95de944b27849c2485cc0e041fb2f Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Wed, 25 Sep 2024 08:55:44 -0700 Subject: [PATCH 1/4] Explicitly check undefined when the desired value can be `false`. --- .../components/edit/InheritAncestorMetadataModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue index 87d6bbb7d6..42b1b95639 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue @@ -204,7 +204,7 @@ for (const field of inheritableFields) { if ( this.parent.extra_fields.inherited_metadata && - this.parent.extra_fields.inherited_metadata[field] + !isUndefined(this.parent.extra_fields.inherited_metadata[field]) ) { this.checks[field] = this.parent.extra_fields.inherited_metadata[field]; } From 51eaa8fa02cd66472718a4dc632d2fdd589b4374 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Wed, 25 Sep 2024 12:59:35 -0700 Subject: [PATCH 2/4] Defer metadata setting if nodes are still being created from uploads. Disable upload more button while nodes are still being created, for simplicity. --- .../channelEdit/components/edit/EditModal.vue | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) 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(); + } + }); } }, }, From 89ef2c3111a2eb8e85dea200c5c4a8ec1a40f8da Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Wed, 25 Sep 2024 13:03:15 -0700 Subject: [PATCH 3/4] Emit empty inheritance payload on cancel to ensure consistent behaviour. --- .../components/edit/InheritAncestorMetadataModal.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue index 42b1b95639..31998babe9 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" >
@@ -291,6 +291,10 @@ } this.closed = true; }, + handleCancel() { + this.closed = true; + this.$emit({}); + }, /** * @public */ From 87c6fd128e7ca1a67f5a8952c8bed37cb16d2d7c Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Thu, 26 Sep 2024 12:19:00 -0700 Subject: [PATCH 4/4] Add some defensive programming checks. Ensure we actually emit the inherit method. --- .../components/edit/InheritAncestorMetadataModal.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue index 31998babe9..b43deb5a4d 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue @@ -201,9 +201,13 @@ } 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 && !isUndefined(this.parent.extra_fields.inherited_metadata[field]) ) { this.checks[field] = this.parent.extra_fields.inherited_metadata[field]; @@ -293,7 +297,7 @@ }, handleCancel() { this.closed = true; - this.$emit({}); + this.$emit('inherit', {}); }, /** * @public