Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix selection on inherit metadata #4746

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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