Skip to content

Commit

Permalink
Merge pull request #4769 from rtibbles/folders_and_exercises
Browse files Browse the repository at this point in the history
Properly handle metadata inheritance for non uploaded nodes in edit modal
  • Loading branch information
rtibbles authored Sep 27, 2024
2 parents 0a6da56 + 603fd56 commit 73cbda7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -534,15 +534,22 @@
return newNodeId;
});
},
resetInheritMetadataModal() {
this.$refs.inheritModal?.checkInheritance();
},
createTopic() {
this.createNode('topic', {
title: '',
}).then(newNodeId => {
this.selected = [newNodeId];
this.$nextTick(() => {
this.resetInheritMetadataModal();
});
});
},
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;
Expand All @@ -569,7 +576,11 @@
})
);
this.creatingNodes = false;
this.$refs.inheritModal?.resetClosed();
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));
Expand All @@ -580,8 +591,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,7 @@
);
},
active() {
return (
this.parent !== null &&
!this.allFieldsDesignatedByParent &&
!this.closed &&
this.parentHasInheritableMetadata
);
return this.parent !== null && !this.closed;
},
inheritableMetadataItems() {
const returnValue = {};
Expand Down Expand Up @@ -192,6 +187,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;
Expand Down Expand Up @@ -242,14 +250,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();
});
});
}
Expand Down Expand Up @@ -299,12 +300,6 @@
this.closed = true;
this.$emit('inherit', {});
},
/**
* @public
*/
resetClosed() {
this.closed = false;
},
},
$trs: {
applyResourceDetailsTitle: "Apply details from the folder '{folder}'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 73cbda7

Please sign in to comment.