From 5827048670fab9b24663e1642c606d16223c9e0e Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Fri, 27 Sep 2024 11:43:58 -0700 Subject: [PATCH 1/4] Properly handle metadata inheritance for non uploaded nodes in edit modal. --- .../channelEdit/components/edit/EditModal.vue | 15 +++++++++++-- .../edit/InheritAncestorMetadataModal.vue | 22 ++++++++++++------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue index 3e74a3a986..ed10109255 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue @@ -534,11 +534,17 @@ return newNodeId; }); }, + resetInheritMetadataModal() { + this.$refs.inheritModal?.checkInheritance(); + }, createTopic() { this.createNode('topic', { title: '', }).then(newNodeId => { this.selected = [newNodeId]; + this.$nextTick(() => { + this.resetInheritMetadataModal(); + }); }); }, async createNodesFromUploads(fileUploads) { @@ -569,7 +575,7 @@ }) ); this.creatingNodes = false; - this.$refs.inheritModal?.resetClosed(); + this.resetInheritMetadataModal(); }, updateTitleForPage() { this.updateTabTitle(this.$store.getters.appendChannelName(this.modalTitle)); @@ -580,8 +586,13 @@ }); }, inheritMetadata(metadata) { + if (!this.createMode) { + // This shouldn't happen, but prevent this just in case. + return; + } const setMetadata = () => { - for (const nodeId of this.newNodeIds) { + const nodeIds = this.uploadMode ? this.newNodeIds : this.selected; + for (const nodeId of nodeIds) { this.updateContentNode({ id: nodeId, ...metadata, diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue index b43deb5a4d..0d893951e3 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue @@ -192,6 +192,19 @@ }, methods: { ...mapActions('contentNode', ['updateContentNode']), + /** + * @public + */ + checkInheritance() { + if (this.allFieldsDesignatedByParent || !this.parentHasInheritableMetadata) { + // If all fields have been designated by the parent, or there is nothing to inherit, + // automatically continue + this.handleContinue(); + } else { + // Wait for the data to be updated before showing the dialog + this.closed = false; + } + }, resetData() { if (this.parent) { this.dontShowAgain = false; @@ -242,14 +255,7 @@ }; }, {}); this.$nextTick(() => { - if (this.allFieldsDesignatedByParent || !this.parentHasInheritableMetadata) { - // If all fields have been designated by the parent, or there is nothing to inherit, - // automatically continue - this.handleContinue(); - } else { - // Wait for the data to be updated before showing the dialog - this.closed = false; - } + this.checkInheritance(); }); }); } From ac721447eeec349405486f8194a8be67789dd0db Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Fri, 27 Sep 2024 13:51:09 -0700 Subject: [PATCH 2/4] Cleanup and simplify API and internal implementation. --- .../edit/InheritAncestorMetadataModal.vue | 13 +------------ .../frontend/channelEdit/views/CurrentTopicView.vue | 6 ------ 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue index 0d893951e3..333d3f0eab 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue @@ -111,12 +111,7 @@ ); }, active() { - return ( - this.parent !== null && - !this.allFieldsDesignatedByParent && - !this.closed && - this.parentHasInheritableMetadata - ); + return this.parent !== null && !this.closed; }, inheritableMetadataItems() { const returnValue = {}; @@ -305,12 +300,6 @@ this.closed = true; this.$emit('inherit', {}); }, - /** - * @public - */ - resetClosed() { - this.closed = false; - }, }, $trs: { applyResourceDetailsTitle: "Apply details from the folder '{folder}'", diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue b/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue index 84f387da38..a994e1c9aa 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue @@ -931,12 +931,6 @@ this.updateContentNode({ id: nodeId, ...metadata, mergeMapFields: true }); } this.CLEAR_INHERITING_NODES(nodeIds); - this.$nextTick(() => { - // Once the inheritance is complete, reset the modal closed state. - if (!this.inheritingNodes || this.inheritingNodes.length === 0) { - this.$refs.inheritModal?.resetClosed(); - } - }); }, }, $trs: { From 3eb4bda3bdd5021bfd1578cdc8db209dc30fcd33 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Fri, 27 Sep 2024 14:18:16 -0700 Subject: [PATCH 3/4] Simplify condition for parent to ensure that inheritance is always applied. --- .../frontend/channelEdit/components/edit/EditModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue index ed10109255..68a4abb27a 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue @@ -129,7 +129,7 @@ From 603fd56af5ef1744c3c3e780914cdf3aec23425e Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Fri, 27 Sep 2024 14:56:59 -0700 Subject: [PATCH 4/4] Revert previous commit. Check if parent prop is null before uploading files. Use this to conditionalize explicit triggering of inheritance check. --- .../frontend/channelEdit/components/edit/EditModal.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue index 68a4abb27a..3ab92e6cbb 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue @@ -129,7 +129,7 @@ @@ -549,6 +549,7 @@ }, async createNodesFromUploads(fileUploads) { this.creatingNodes = true; + const parentPropDefinedForInheritModal = Boolean(this.$refs.inheritModal?.parent); this.newNodeIds = await Promise.all( fileUploads.map(async (file, index) => { let title; @@ -575,7 +576,11 @@ }) ); this.creatingNodes = false; - this.resetInheritMetadataModal(); + if (parentPropDefinedForInheritModal) { + // Only call this if the parent prop was previously defined, otherwise, + // rely on the parent prop watcher to trigger the inherit event. + this.resetInheritMetadataModal(); + } }, updateTitleForPage() { this.updateTabTitle(this.$store.getters.appendChannelName(this.modalTitle));