Skip to content

Commit

Permalink
Merge pull request #4746 from AlexVelezLl/fix-suggestion-multiple-res…
Browse files Browse the repository at this point in the history
…ources

Fix selection on inherit metadata
  • Loading branch information
rtibbles committed Sep 20, 2024
2 parents cc0b008 + 7c55455 commit fbda0cb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</ToolBar>
<div ref="list">
<EditList
v-model="selected"
v-model="currentSelectedNodes"
:nodeIds="nodeIds"
@input="enableValidation(nodeIds);"
/>
Expand All @@ -96,7 +96,7 @@
<EditView
v-else
ref="editView"
:nodeIds="selected"
:nodeIds="currentSelectedNodes"
:tab="tab"
/>
</VContent>
Expand All @@ -123,8 +123,10 @@
</VLayout>
</BottomBar>
<InheritAncestorMetadataModal
ref="inheritModal"
:parent="(createMode && detailNodeIds.length) ? parent : null"
@inherit="inheritMetadata"
@updateActive="active => isInheritModalOpen = active"
/>
</VDialog>

Expand Down Expand Up @@ -252,6 +254,8 @@
listElevated: false,
storagePoll: null,
openTime: null,
isInheritModalOpen: false,
newNodeIds: [],
};
},
computed: {
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -513,30 +528,33 @@
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];
}
this.updateFile({
...file,
contentnode: newNodeId,
});
});
});
return newNodeId;
})
);
this.$refs.inheritModal?.resetClosed();
},
updateTitleForPage() {
this.updateTabTitle(this.$store.getters.appendChannelName(this.modalTitle));
Expand All @@ -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 });
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
this.resetData();
}
},
active(newValue) {
this.$emit('updateActive', newValue);
},
},
created() {
this.resetData();
Expand Down Expand Up @@ -283,6 +286,12 @@
}
this.closed = true;
},
/**
* @public
*/
resetClosed() {
this.closed = false;
},
},
$trs: {
applyResourceDetailsTitle: "Apply details from the folder '{folder}'",
Expand Down

0 comments on commit fbda0cb

Please sign in to comment.