Skip to content

Commit 161a0b4

Browse files
authored
Merge pull request #4849 from bjester/no-mo-modal
Inherit modal does not appear when sorting items in a folder with metadata
2 parents b3c96fe + 5be153e commit 161a0b4

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@
533533
},
534534
inheritanceParent() {
535535
const firstNode = this.currentInheritingNodes[0];
536+
536537
if (!firstNode) {
537538
return;
538539
}
@@ -726,6 +727,7 @@
726727
handleDragDrop(drop) {
727728
const { data } = drop;
728729
const { identity, section, relative } = data.target;
730+
const targetMetadata = identity.metadata || {};
729731
const isTargetTree =
730732
drop.target && drop.target.region && drop.target.region.id === DraggableRegions.TREE;
731733
@@ -742,7 +744,7 @@
742744
position = this.relativePosition(relative > DraggableFlags.NONE ? relative : section);
743745
} else {
744746
// Safety check
745-
const { kind } = identity.metadata || {};
747+
const { kind } = targetMetadata;
746748
if (kind && kind !== ContentKindsNames.TOPIC) {
747749
return Promise.reject('Cannot set child of non-topic');
748750
}
@@ -756,7 +758,7 @@
756758
const sources = drop.sources || [];
757759
const sourceRegion = sources.length > 0 ? sources[0].region : null;
758760
const payload = {
759-
target: identity.metadata.id,
761+
target: targetMetadata.id,
760762
position,
761763
};
762764
@@ -765,7 +767,7 @@
765767
// `excluded_descendants` by accessing the copy trees through the clipboard node ID
766768
if (sourceRegion && sourceRegion.id === DraggableRegions.CLIPBOARD) {
767769
return Promise.all(
768-
data.sources.map(source => {
770+
sources.map(source => {
769771
// Using `getCopyTrees` we can access the `excluded_descendants` for the node, such
770772
// that we make sure to skip copying nodes that aren't intended to be copied
771773
const trees = this.getCopyTrees(source.metadata.clipboardNodeId, true);
@@ -789,10 +791,27 @@
789791
);
790792
}
791793
794+
// We want to avoid launching the inherit modal when the move operation is a prepend or
795+
// append move, and target is the current parent. When the move operation is relative to
796+
// the target, that is left or right, we want only launch the modal if the parent is
797+
// changing
798+
let inherit = false;
799+
if (
800+
position === RELATIVE_TREE_POSITIONS.FIRST_CHILD ||
801+
position === RELATIVE_TREE_POSITIONS.LAST_CHILD
802+
) {
803+
inherit = !sources.some(s => s.metadata.parent === targetMetadata.id);
804+
} else if (
805+
position === RELATIVE_TREE_POSITIONS.LEFT ||
806+
position === RELATIVE_TREE_POSITIONS.RIGHT
807+
) {
808+
inherit = !sources.some(s => s.metadata.parent === targetMetadata.parent);
809+
}
810+
792811
return this.moveContentNodes({
793812
...payload,
794-
id__in: data.sources.map(s => s.metadata.id),
795-
inherit: !data.sources.some(s => s.metadata.parent === payload.target),
813+
id__in: sources.map(s => s.metadata.id),
814+
inherit,
796815
});
797816
}
798817
},

0 commit comments

Comments
 (0)