From 7c55455cfc1575411d218c0ed44f5af9ae3aa27c Mon Sep 17 00:00:00 2001 From: Alex Velez Date: Thu, 19 Sep 2024 15:39:39 -0500 Subject: [PATCH] Fix selection on inherit metadata --- .../channelEdit/components/edit/EditModal.vue | 58 ++++++++++++------- .../edit/InheritAncestorMetadataModal.vue | 9 +++ 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue index 2dba69cc0f..ad498da058 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/EditModal.vue @@ -70,7 +70,7 @@
@@ -96,7 +96,7 @@ @@ -123,8 +123,10 @@ @@ -252,6 +254,8 @@ listElevated: false, storagePoll: null, openTime: null, + isInheritModalOpen: false, + newNodeIds: [], }; }, computed: { @@ -315,6 +319,17 @@ invalidNodes() { return this.nodeIds.filter(id => !this.getContentNodeIsValid(id)); }, + currentSelectedNodes: { + get() { + if (this.isInheritModalOpen && this.newNodeIds.length) { + return this.newNodeIds; + } + return this.selected; + }, + set(value) { + this.selected = value; + }, + }, }, beforeRouteEnter(to, from, next) { if ( @@ -513,21 +528,22 @@ this.selected = [newNodeId]; }); }, - createNodesFromUploads(fileUploads) { - fileUploads.forEach((file, index) => { - let title; - if (file.metadata.title) { - title = file.metadata.title; - } else { - title = file.original_filename - .split('.') - .slice(0, -1) - .join('.'); - } - this.createNode( - FormatPresets.has(file.preset) && FormatPresets.get(file.preset).kind_id, - { title, ...file.metadata } - ).then(newNodeId => { + async createNodesFromUploads(fileUploads) { + this.newNodeIds = await Promise.all( + fileUploads.map(async (file, index) => { + let title; + if (file.metadata.title) { + title = file.metadata.title; + } else { + title = file.original_filename + .split('.') + .slice(0, -1) + .join('.'); + } + const newNodeId = await this.createNode( + FormatPresets.has(file.preset) && FormatPresets.get(file.preset).kind_id, + { title, ...file.metadata } + ); if (index === 0) { this.selected = [newNodeId]; } @@ -535,8 +551,10 @@ ...file, contentnode: newNodeId, }); - }); - }); + return newNodeId; + }) + ); + this.$refs.inheritModal?.resetClosed(); }, updateTitleForPage() { this.updateTabTitle(this.$store.getters.appendChannelName(this.modalTitle)); @@ -547,7 +565,7 @@ }); }, inheritMetadata(metadata) { - for (const nodeId of this.nodeIds) { + for (const nodeId of this.currentSelectedNodes) { this.updateContentNode({ id: nodeId, ...metadata, mergeMapFields: true }); } }, diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue index 6c0a42fda7..4147ab63e5 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/edit/InheritAncestorMetadataModal.vue @@ -178,6 +178,9 @@ this.resetData(); } }, + active(newValue) { + this.$emit('updateActive', newValue); + }, }, created() { this.resetData(); @@ -283,6 +286,12 @@ } this.closed = true; }, + /** + * @public + */ + resetClosed() { + this.closed = false; + }, }, $trs: { applyResourceDetailsTitle: "Apply details from the folder '{folder}'",