diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/Channel.vue b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/Channel.vue
index c079012be4..318ecaf90a 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/Channel.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/Channel.vue
@@ -38,18 +38,18 @@
-
+
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/ContentNode.vue b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/ContentNode.vue
index 0aa632158b..d580aacf9c 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/ContentNode.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/ContentNode.vue
@@ -3,6 +3,7 @@
-
+
-
-
+
+
@@ -76,16 +77,18 @@
ContextMenu,
},
mixins: [clipboardMixin],
- props: {
- sourceId: {
- type: String,
- required: true,
- },
- },
computed: {
thumbnailAttrs() {
- const { title, kind, thumbnail_src: src, thumbnail_encoding: encoding } = this.contentNode;
- return { title, kind, src, encoding };
+ if (this.contentNode) {
+ const {
+ title,
+ kind,
+ thumbnail_src: src,
+ thumbnail_encoding: encoding,
+ } = this.contentNode;
+ return { title, kind, src, encoding };
+ }
+ return {};
},
},
$trs: {},
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/ContentNodeOptions.vue b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/ContentNodeOptions.vue
index 48e5ae44ee..1e984e3d07 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/ContentNodeOptions.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/ContentNodeOptions.vue
@@ -7,7 +7,7 @@
{{ $tr('makeACopy') }}
-
+
{{ $tr('moveTo') }}
@@ -22,7 +22,6 @@
import { mapActions, mapGetters, mapMutations } from 'vuex';
import { RouterNames } from '../../constants';
import { withChangeTracker } from 'shared/data/changes';
- import { ContentKindsNames } from 'shared/leUtils/ContentKinds';
export default {
name: 'ContentNodeOptions',
@@ -31,44 +30,41 @@
type: String,
required: true,
},
- sourceId: {
+ ancestorId: {
type: String,
- required: true,
+ default: null,
},
},
computed: {
...mapGetters('channel', ['getChannel']),
- ...mapGetters('contentNode', ['getContentNode', 'getTreeNode']),
- treeNode() {
- return this.getTreeNode(this.sourceId);
- },
+ ...mapGetters('clipboard', ['getClipboardNodeForRender', 'getCopyTrees']),
node() {
- return this.getContentNode(this.sourceId);
+ return this.getClipboardNodeForRender(this.nodeId);
},
channelId() {
- return this.treeNode.channel_id;
+ return this.node.channel_id;
},
viewLink() {
return {
name: RouterNames.TREE_VIEW,
params: {
- nodeId: this.treeNode.parent,
- detailNodeId: this.sourceId,
+ nodeId: this.node.parent,
+ detailNodeId: this.node.id,
},
};
},
canEdit() {
return this.getChannel(this.channelId) && this.getChannel(this.channelId).edit;
},
- isTopic() {
- return this.node.kind === ContentKindsNames.TOPIC;
- },
},
methods: {
...mapActions(['showSnackbar']),
- ...mapActions('clipboard', ['copy']),
- ...mapActions('contentNode', ['deleteContentNodes']),
- ...mapMutations('contentNode', { setMoveNodes: 'SET_MOVE_NODES' }),
+ ...mapActions('clipboard', ['copy', 'deleteClipboardNode']),
+ ...mapMutations('clipboard', { setCopyNodes: 'SET_CLIPBOARD_MOVE_NODES' }),
+ moveNode() {
+ const copyTrees = this.getCopyTrees(this.nodeId, null, this.ancestorId, true);
+ this.setCopyNodes(copyTrees);
+ },
removeNode: withChangeTracker(function(changeTracker) {
this.showSnackbar({
duration: null,
@@ -77,7 +73,10 @@
actionCallback: () => changeTracker.revert(),
});
- return this.deleteContentNodes([this.nodeId]).then(() => {
+ return this.deleteClipboardNode({
+ clipboardNodeId: this.nodeId,
+ ancestorId: this.ancestorId,
+ }).then(() => {
return this.showSnackbar({
text: this.$tr('removedFromClipboard'),
actionText: this.$tr('undo'),
@@ -94,8 +93,8 @@
});
return this.copy({
- id: this.sourceId,
- deep: this.isTopic,
+ node_id: this.node.node_id,
+ channel_id: this.node.channel_id,
}).then(() => {
return this.showSnackbar({
text: this.$tr('copiedItemsToClipboard'),
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/TopicNode.vue b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/TopicNode.vue
index 9149898c1c..2139965c33 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/TopicNode.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/TopicNode.vue
@@ -10,12 +10,12 @@
- {{ descendantCount }}
+ {{ contentNode.resource_count }}
{{ contentNode.title }}
@@ -34,18 +34,20 @@
-
+
@@ -65,9 +67,9 @@
},
mixins: [clipboardMixin, parentMixin],
props: {
- sourceId: {
+ ancestorId: {
type: String,
- required: true,
+ default: null,
},
},
data() {
@@ -75,6 +77,18 @@
open: false,
};
},
+ computed: {
+ childAncestorId() {
+ return this.isClipboardNode(this.nodeId) ? this.nodeId : this.ancestorId;
+ },
+ },
+ mounted() {
+ // Prefetch content node data. Since we're using `lazy` with the
+ // nested VListGroup, this prefetches one level at a time!
+ if (this.contentNode.total_count > 0) {
+ this.loadClipboardNodes({ parent: this.nodeId, ancestorId: this.childAncestorId });
+ }
+ },
};
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/index.vue b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/index.vue
index 53103acbcc..b260a5b74b 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/index.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/index.vue
@@ -139,7 +139,7 @@
'getCopyTrees',
]),
selectedNodeIds() {
- return this.selectedNodes.map(n => n.id);
+ return this.selectedNodes.map(([sid]) => sid);
},
canEdit() {
return !this.selectedChannels.find(channel => !channel.edit);
@@ -166,9 +166,8 @@
},
methods: {
...mapActions(['showSnackbar']),
- ...mapMutations('contentNode', { setMoveNodes: 'SET_MOVE_NODES' }),
- ...mapActions('clipboard', ['loadChannels', 'copy']),
- ...mapActions('contentNode', ['deleteContentNodes']),
+ ...mapMutations('clipboard', { setCopyNodes: 'SET_CLIPBOARD_MOVE_NODES' }),
+ ...mapActions('clipboard', ['loadChannels', 'copy', 'deleteClipboardNodes']),
refresh() {
if (this.refreshing) {
return;
@@ -181,14 +180,15 @@
this.elevated = this.$refs.nodeList.scrollTop > 0;
},
moveNodes() {
- if (!this.selectedNodeIds.length) {
+ const trees = this.getCopyTrees(this.clipboardRootId);
+ if (!trees.length) {
return;
}
- this.setMoveNodes(this.selectedNodes.map(n => n.source_id));
+ this.setCopyNodes(trees);
},
duplicateNodes: withChangeTracker(function(changeTracker) {
- const trees = this.getCopyTrees(this.clipboardRootId);
+ const trees = this.getCopyTrees(this.clipboardRootId, this.clipboardRootId);
if (!trees.length) {
return Promise.resolve([]);
@@ -213,9 +213,9 @@
});
}),
removeNodes: withChangeTracker(function(changeTracker) {
- const id__in = this.selectedNodeIds;
+ const selectionIds = this.selectedNodeIds;
- if (!id__in.length) {
+ if (!selectionIds.length) {
return Promise.resolve([]);
}
@@ -226,7 +226,7 @@
actionCallback: () => changeTracker.revert(),
});
- return this.deleteContentNodes(id__in).then(() => {
+ return this.deleteClipboardNodes(selectionIds).then(() => {
return this.showSnackbar({
text: this.$tr('removedFromClipboard'),
actionText: this.$tr('undo'),
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/mixins.js b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/mixins.js
index 9b1c3c304b..5a4d5d3b32 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/mixins.js
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/Clipboard/mixins.js
@@ -1,5 +1,4 @@
import { mapActions, mapGetters } from 'vuex';
-import uniq from 'lodash/uniq';
import { SelectionFlags } from 'frontend/channelEdit/vuex/clipboard/constants';
export default {
@@ -8,32 +7,33 @@ export default {
type: String,
required: true,
},
- sourceId: {
+ ancestorId: {
type: String,
+ default: null,
+ },
+ level: {
+ type: Number,
+ default: 0,
},
},
computed: {
- ...mapGetters('contentNode', ['getContentNode', 'getTreeNode']),
...mapGetters('clipboard', [
- 'currentSelectionState',
+ 'getClipboardNodeForRender',
+ 'getSelectionState',
'getNextSelectionState',
'getClipboardChildren',
]),
- treeNode() {
- return this.getTreeNode(this.nodeId);
- },
contentNode() {
- return this.sourceId ? this.getContentNode(this.sourceId) : null;
+ return this.nodeId ? this.getClipboardNodeForRender(this.nodeId) : null;
},
indentPadding() {
- const level = this.treeNode.level || 0;
- return `${level * 32}px`;
+ return `${this.level * 32}px`;
},
selectionState() {
- return this.currentSelectionState(this.nodeId);
+ return this.getSelectionState(this.nodeId, this.ancestorId);
},
nextSelectionState() {
- return this.getNextSelectionState(this.nodeId);
+ return this.getNextSelectionState(this.nodeId, this.ancestorId);
},
selected() {
return Boolean(this.selectionState & SelectionFlags.SELECTED);
@@ -45,39 +45,42 @@ export default {
methods: {
...mapActions('clipboard', ['setSelectionState', 'resetSelectionState']),
goNextSelectionState() {
- this.setSelectionState({ id: this.nodeId, selectionState: this.nextSelectionState });
+ this.setSelectionState({
+ id: this.nodeId,
+ selectionState: this.nextSelectionState,
+ ancestorId: this.ancestorId,
+ });
},
},
};
export const parentMixin = {
- computed: {
- ...mapGetters('contentNode', [
- 'hasChildren',
- 'getTreeNodeChildren',
- 'countTreeNodeDescendants',
- ]),
- ...mapGetters('clipboard', ['channelIds', 'getClipboardChildren']),
- treeChildren() {
- return this.getClipboardChildren(this.nodeId);
+ props: {
+ nodeId: {
+ type: String,
+ required: true,
},
- childrenSourceIds() {
- return this.treeChildren.map(child => child.source_id);
+ ancestorId: {
+ type: String,
+ default: null,
},
- descendantCount() {
- return this.countTreeNodeDescendants(this.nodeId);
+ level: {
+ type: Number,
+ default: 0,
},
},
- mounted() {
- const id__in = uniq(this.childrenSourceIds);
-
- // Prefetch content node data. Since we're using `lazy` with the
- // nested VListGroup, this prefetches one level at a time!
- if (id__in.length) {
- this.$nextTick(() => this.loadContentNodes({ id__in }));
- }
+ computed: {
+ ...mapGetters('clipboard', [
+ 'channelIds',
+ 'getClipboardChildren',
+ 'hasClipboardChildren',
+ 'isClipboardNode',
+ ]),
+ children() {
+ return this.getClipboardChildren(this.nodeId, this.ancestorId);
+ },
},
methods: {
- ...mapActions('contentNode', ['loadContentNodes']),
+ ...mapActions('clipboard', ['loadClipboardNodes']),
},
};
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeOptions.vue b/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeOptions.vue
index e7f01c8450..e1369137d7 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeOptions.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeOptions.vue
@@ -48,7 +48,7 @@
},
computed: {
...mapGetters('currentChannel', ['canEdit', 'trashId']),
- ...mapGetters('contentNode', ['getContentNode', 'getTreeNode']),
+ ...mapGetters('contentNode', ['getContentNode']),
node() {
return this.getContentNode(this.nodeId);
},
@@ -73,9 +73,6 @@
},
};
},
- treeNode() {
- return this.getTreeNode(this.nodeId);
- },
},
methods: {
...mapActions(['showSnackbar']),
@@ -115,13 +112,15 @@
actionCallback: () => changeTracker.revert(),
});
- return this.copy({ id: this.nodeId }).then(() => {
- return this.showSnackbar({
- text: this.$tr('copiedToClipboardSnackbar'),
- actionText: this.$tr('undo'),
- actionCallback: () => changeTracker.revert(),
- });
- });
+ return this.copy({ node_id: this.node.node_id, channel_id: this.node.channel_id }).then(
+ () => {
+ return this.showSnackbar({
+ text: this.$tr('copiedToClipboardSnackbar'),
+ actionText: this.$tr('undo'),
+ actionCallback: () => changeTracker.revert(),
+ });
+ }
+ );
}),
duplicateNode: withChangeTracker(function(changeTracker) {
this.showSnackbar({
@@ -130,7 +129,7 @@
actionText: this.$tr('cancel'),
actionCallback: () => changeTracker.revert(),
});
- const target = this.treeNode.parent;
+ const target = this.node.parent;
return this.copyContentNode({ id: this.nodeId, target, deep: true }).then(() => {
return this.showSnackbar({
text: this.$tr('copiedSnackbar'),
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/NodeTreeNavigation.vue b/contentcuration/contentcuration/frontend/channelEdit/components/NodeTreeNavigation.vue
index b7686c46ee..27499f4527 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/NodeTreeNavigation.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/NodeTreeNavigation.vue
@@ -45,10 +45,6 @@
event: 'updateSelectedNodeId',
},
props: {
- treeId: {
- type: String,
- required: true,
- },
selectedNodeId: {
type: String,
required: true,
@@ -107,7 +103,6 @@
this.loadContentNode(nodeId),
this.loadAncestors({
id: nodeId,
- includeSelf: true,
}),
];
@@ -115,7 +110,6 @@
promises.push(
this.loadChildren({
parent: nodeId,
- tree_id: this.treeId,
})
);
}
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/StudioTree/StudioTree.spec.js b/contentcuration/contentcuration/frontend/channelEdit/components/StudioTree/StudioTree.spec.js
index 27bd13914f..aa77ed91e7 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/StudioTree/StudioTree.spec.js
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/StudioTree/StudioTree.spec.js
@@ -7,7 +7,7 @@ import { ContentKindsNames } from 'shared/leUtils/ContentKinds';
const localVue = createLocalVue();
localVue.use(Vuex);
-const TREE_ID = 'tree-id';
+const ROOT_ID = 'tree-id';
const NODE_ID = 'node-id';
const initWrapper = ({ getters = {}, mutations = {}, actions = {}, propsData = {} } = {}) => {
@@ -46,7 +46,7 @@ const initWrapper = ({ getters = {}, mutations = {}, actions = {}, propsData = {
return mount(StudioTree, {
propsData: {
- treeId: TREE_ID,
+ treeId: ROOT_ID,
nodeId: NODE_ID,
onNodeClick: jest.fn(),
...propsData,
@@ -172,7 +172,7 @@ describe('StudioTree', () => {
});
expect(mockLoadChildren).toHaveBeenCalledTimes(1);
- expect(mockLoadChildren.mock.calls[0][1]).toEqual({ parent: NODE_ID, tree_id: TREE_ID });
+ expect(mockLoadChildren.mock.calls[0][1]).toEqual({ parent: NODE_ID });
});
it("doesn't dispatch load children action if node has no resources", () => {
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/StudioTree/StudioTree.vue b/contentcuration/contentcuration/frontend/channelEdit/components/StudioTree/StudioTree.vue
index 12b5d5f710..99c0b8de86 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/StudioTree/StudioTree.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/StudioTree/StudioTree.vue
@@ -85,7 +85,6 @@
{
+ data() {
return {
ContentKindsNames,
loading: false,
- loaded: false,
+ loaded: this.dataPreloaded,
};
},
computed: {
@@ -153,12 +152,11 @@
node() {
return this.getContentNode(this.nodeId);
},
+ children() {
+ return this.getContentNodeChildren(this.nodeId) || [];
+ },
subtopics() {
- const children = this.getContentNodeChildren(this.nodeId);
- if (!children) {
- return [];
- }
- return children.filter(child => child.kind === this.ContentKindsNames.TOPIC);
+ return this.children.filter(child => child.kind === this.ContentKindsNames.TOPIC);
},
showExpansion() {
return this.node && this.node.total_count > this.node.resource_count;
@@ -198,7 +196,6 @@
this.loading = true;
return this.loadChildren({
parent: this.nodeId,
- tree_id: this.treeId,
}).then(() => {
this.loading = false;
this.loaded = true;
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/move/MoveModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/move/MoveModal.vue
index d2443793aa..8b6e2ca9b3 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/move/MoveModal.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/move/MoveModal.vue
@@ -162,21 +162,22 @@
},
computed: {
...mapState('contentNode', { moveNodeIds: 'moveNodes' }),
+ ...mapState('clipboard', { copyNodes: 'clipboardMoveNodes' }),
...mapGetters('currentChannel', ['currentChannel', 'rootId']),
...mapGetters('contentNode', [
'getContentNode',
'getContentNodeChildren',
- 'getTreeNode',
'getContentNodeAncestors',
'getTopicAndResourceCounts',
]),
dialog: {
get() {
- return Boolean(this.moveNodeIds.length);
+ return Boolean(this.moveNodeIds.length || this.copyNodes.length);
},
set(value) {
if (!value) {
this.setMoveNodes([]);
+ this.setCopyNodes([]);
}
},
},
@@ -184,8 +185,8 @@
return this.$tr('moveItems', this.getTopicAndResourceCounts(this.moveNodeIds));
},
currentLocationId() {
- let treeNode = this.getTreeNode(this.moveNodeIds[0]);
- return treeNode && treeNode.parent;
+ const contentNode = this.getContentNode(this.moveNodeIds[0]);
+ return contentNode && contentNode.parent;
},
currentNode() {
return this.getContentNode(this.targetNodeId);
@@ -209,8 +210,15 @@
this.targetNodeId = this.currentLocationId || this.rootId;
},
methods: {
- ...mapActions('contentNode', ['createContentNode', 'loadChildren', 'moveContentNodes']),
+ ...mapActions('contentNode', [
+ 'createContentNode',
+ 'loadChildren',
+ 'moveContentNodes',
+ 'copyContentNode',
+ ]),
+ ...mapActions('clipboard', ['deleteClipboardNodes']),
...mapMutations('contentNode', { setMoveNodes: 'SET_MOVE_NODES' }),
+ ...mapMutations('clipboard', { setCopyNodes: 'SET_CLIPBOARD_MOVE_NODES' }),
isDisabled(node) {
return this.moveNodeIds.includes(node.id);
},
@@ -234,7 +242,7 @@
this.loading = true;
return this.loadChildren({
parent: this.targetNodeId,
- tree_id: this.rootId,
+ root_id: this.rootId,
}).then(() => {
this.loading = false;
});
@@ -249,7 +257,24 @@
});
},
moveNodes() {
- this.moveContentNodes({ id__in: this.moveNodeIds, parent: this.targetNodeId }).then(() => {
+ let promise;
+ if (this.moveNodeIds.length) {
+ promise = this.moveContentNodes({ id__in: this.moveNodeIds, parent: this.targetNodeId });
+ } else if (this.copyNodes.length) {
+ promise = Promise.all(
+ this.copyNodes.map(copyNode =>
+ this.copyContentNode({
+ id: copyNode.id,
+ deep: copyNode.deep,
+ target: this.targetNodeId,
+ children: copyNode.children,
+ })
+ )
+ ).then(() =>
+ this.deleteClipboardNodes(this.copyNodes.map(copyNode => copyNode.selectionId))
+ );
+ }
+ promise.then(() => {
this.dialog = false;
this.$store.dispatch('showSnackbar', {
text: this.$tr('movedMessage', { title: this.currentNode.title }),
diff --git a/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.spec.js b/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.spec.js
index 8e469dfdb5..df4c6b5d4d 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.spec.js
+++ b/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.spec.js
@@ -13,21 +13,20 @@ localVue.use(Vuex);
localVue.use(VueRouter);
const NODE_ID = 'id-reading';
-const ROOT_TREE_ID = 'channel-root-tree';
+const ROOT_ID = 'channel-root-tree';
const GETTERS = {
global: {
isCompactViewMode: jest.fn(),
},
currentChannel: {
- rootId: () => ROOT_TREE_ID,
+ rootId: () => ROOT_ID,
currentChannel: () => jest.fn(),
stagingId: jest.fn(),
hasStagingTree: jest.fn(),
getCurrentChannelStagingDiff: jest.fn(),
},
contentNode: {
- getTreeNodeChildren: () => jest.fn(),
getContentNodeChildren: () => jest.fn(),
getContentNodeAncestors: () => jest.fn(),
getContentNode: () => jest.fn(),
@@ -174,7 +173,7 @@ describe('StagingTreePage', () => {
const wrapper = initWrapper();
const link = wrapper.find({ name: 'ToolBar' }).find('[data-test="root-tree-link"]');
- expect(link.attributes().href).toBe(`#/${ROOT_TREE_ID}`);
+ expect(link.attributes().href).toBe(`#/${ROOT_ID}`);
});
it('renders no resources found message if a channel has no staging tree', () => {
@@ -211,9 +210,6 @@ describe('StagingTreePage', () => {
},
};
};
- getters.contentNode.getTreeNodeChildren = () => () => {
- return [{ id: 'id-topic' }, { id: 'id-document' }, { id: 'id-exercise' }];
- };
getters.contentNode.getContentNodeChildren = () => () => {
return [
{ id: 'id-topic', title: 'Topic', kind: ContentKindsNames.TOPIC },
@@ -425,7 +421,7 @@ describe('StagingTreePage', () => {
expect(wrapper.vm.$router.currentRoute.name).toBe(RouterNames.TREE_VIEW);
expect(wrapper.vm.$router.currentRoute.params).toEqual({
- nodeId: ROOT_TREE_ID,
+ nodeId: ROOT_ID,
});
});
});
diff --git a/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.vue b/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.vue
index 226aa3c6e5..bc223703e6 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/pages/StagingTreePage/index.vue
@@ -323,13 +323,9 @@
'hasStagingTree',
'getCurrentChannelStagingDiff',
]),
- ...mapGetters('contentNode', [
- 'getTreeNodeChildren',
- 'getContentNodeChildren',
- 'getContentNodeAncestors',
- ]),
+ ...mapGetters('contentNode', ['getContentNodeChildren', 'getContentNodeAncestors']),
isEmpty() {
- return !this.hasStagingTree || !this.getTreeNodeChildren(this.stagingId);
+ return !this.hasStagingTree || !this.getContentNodeChildren(this.stagingId);
},
rootTreeRoute() {
return {
@@ -405,8 +401,8 @@
},
watch: {
nodeId(newNodeId) {
- this.loadAncestors({ id: newNodeId, includeSelf: true });
- this.loadChildren({ parent: newNodeId, tree_id: this.stagingId });
+ this.loadAncestors({ id: newNodeId });
+ this.loadChildren({ parent: newNodeId, root_id: this.stagingId });
},
detailNodeId(newDetailNodeId) {
if (!newDetailNodeId) {
@@ -424,18 +420,13 @@
},
created() {
return this.loadCurrentChannel({ staging: true })
- .then(channel => {
- if (channel.staging_root_id) {
- return this.loadTree({ tree_id: channel.staging_root_id });
- }
- })
.then(() => {
if (!this.hasStagingTree) {
return;
}
Promise.all([
- this.loadAncestors({ id: this.nodeId, includeSelf: true }),
- this.loadChildren({ parent: this.nodeId, tree_id: this.stagingId }),
+ this.loadAncestors({ id: this.nodeId }),
+ this.loadChildren({ parent: this.nodeId, root_id: this.stagingId }),
]).then(() => {
this.isLoading = false;
this.loadCurrentChannelStagingDiff();
@@ -450,7 +441,7 @@
...mapActions('channel', ['loadChannel']),
...mapActions('currentChannel', ['loadCurrentChannelStagingDiff', 'deployCurrentChannel']),
...mapActions('currentChannel', { loadCurrentChannel: 'loadChannel' }),
- ...mapActions('contentNode', ['loadAncestors', 'loadChildren', 'loadTree']),
+ ...mapActions('contentNode', ['loadAncestors', 'loadChildren']),
...mapMutations('contentNode', {
collapseAll: 'COLLAPSE_ALL_EXPANDED',
setExpanded: 'SET_EXPANSION',
diff --git a/contentcuration/contentcuration/frontend/channelEdit/router.js b/contentcuration/contentcuration/frontend/channelEdit/router.js
index f6f5b48abe..1604fb755f 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/router.js
+++ b/contentcuration/contentcuration/frontend/channelEdit/router.js
@@ -23,13 +23,9 @@ const router = new VueRouter({
component: Sandbox,
beforeEnter: (to, from, next) => {
const channelPromise = store.dispatch('currentChannel/loadChannel');
- const treePromise = store.dispatch(
- 'contentNode/loadTree',
- store.state.currentChannel.currentChannelId
- );
const nodePromise = store.dispatch('contentNode/loadContentNode', to.params.nodeId);
// api call to get ancestors if nodeId is a child descendant???
- return Promise.all([channelPromise, treePromise, nodePromise])
+ return Promise.all([channelPromise, nodePromise])
.then(() => next())
.catch(() => {});
},
@@ -80,10 +76,9 @@ const router = new VueRouter({
props: true,
component: AddPreviousStepsPage,
beforeEnter: (to, from, next) => {
- const { currentChannelId } = store.state.currentChannel;
const { targetNodeId } = to.params;
const promises = [
- store.dispatch('channel/loadChannel', currentChannelId),
+ store.dispatch('currentChannel/loadChannel'),
store.dispatch('contentNode/loadRelatedResources', targetNodeId),
];
@@ -100,10 +95,9 @@ const router = new VueRouter({
props: true,
component: AddNextStepsPage,
beforeEnter: (to, from, next) => {
- const { currentChannelId } = store.state.currentChannel;
const { targetNodeId } = to.params;
const promises = [
- store.dispatch('channel/loadChannel', currentChannelId),
+ store.dispatch('currentChannel/loadChannel'),
store.dispatch('contentNode/loadRelatedResources', targetNodeId),
];
@@ -218,13 +212,8 @@ const router = new VueRouter({
props: true,
component: TreeView,
beforeEnter: (to, from, next) => {
- const { currentChannelId } = store.state.currentChannel;
-
return store
.dispatch('currentChannel/loadChannel')
- .then(() => {
- return store.dispatch('contentNode/loadChannelTree', currentChannelId);
- })
.catch(error => {
throw new Error(error);
})
diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue b/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue
index a14438e939..49357510d5 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue
@@ -227,17 +227,18 @@
...mapGetters('currentChannel', ['canEdit', 'currentChannel', 'trashId']),
...mapGetters('contentNode', [
'getContentNode',
+ 'getContentNodes',
'getContentNodeAncestors',
- 'getTreeNodeChildren',
'getTopicAndResourceCounts',
+ 'getContentNodeChildren',
]),
selectAll: {
get() {
- return this.selected.length === this.treeChildren.length;
+ return this.selected.length === this.children.length;
},
set(value) {
if (value) {
- this.selected = this.treeChildren.map(node => node.id);
+ this.selected = this.children.map(node => node.id);
} else {
this.selected = [];
}
@@ -256,8 +257,8 @@
};
});
},
- treeChildren() {
- return this.getTreeNodeChildren(this.topicId);
+ children() {
+ return this.getContentNodeChildren(this.topicId);
},
uploadFilesLink() {
return { name: RouterNames.UPLOAD_FILES };
@@ -288,7 +289,7 @@
this.selected = [];
this.loadingAncestors = true;
- this.loadAncestors({ id: this.topicId, includeSelf: true }).then(() => {
+ this.loadAncestors({ id: this.topicId }).then(() => {
this.loadingAncestors = false;
});
},
@@ -305,12 +306,6 @@
}
},
},
- created() {
- this.loadingAncestors = true;
- this.loadAncestors({ id: this.topicId, includeSelf: true }).then(() => {
- this.loadingAncestors = false;
- });
- },
methods: {
...mapActions(['showSnackbar']),
...mapActions(['setViewMode', 'addViewModeOverride', 'removeViewModeOverride']),
@@ -379,7 +374,8 @@
});
});
}),
- copyToClipboard: withChangeTracker(function(id__in, changeTracker) {
+ copyToClipboard: withChangeTracker(function(ids, changeTracker) {
+ const nodes = this.getContentNodes(ids);
this.showSnackbar({
duration: null,
text: this.$tr('creatingClipboardCopies'),
@@ -387,7 +383,7 @@
actionCallback: () => changeTracker.revert(),
});
- return this.copyAll({ id__in, deep: true }).then(() => {
+ return this.copyAll({ nodes }).then(() => {
this.selectAll = false;
return this.showSnackbar({
text: this.$tr('copiedItemsToClipboard'),
diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/ContentTreeList.vue b/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/ContentTreeList.vue
index ff9545f60a..9f11e0b6c4 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/ContentTreeList.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/ContentTreeList.vue
@@ -85,7 +85,7 @@
};
},
computed: {
- ...mapGetters('contentNode', ['getContentNodeAncestors', 'getTreeNode']),
+ ...mapGetters('contentNode', ['getContentNodeAncestors']),
selectAll: {
get() {
return this.ancestorIsSelected || !differenceBy(this.nodes, this.selected, 'id').length;
@@ -94,9 +94,6 @@
this.$emit('change_selected', { isSelected, nodes: this.nodes });
},
},
- topicNode() {
- return this.getTreeNode(this.topicId);
- },
isSelected() {
return function(node) {
if (this.ancestorIsSelected) {
@@ -141,7 +138,6 @@
this.loading = true;
return this.loadChildren({
parent,
- tree_id: this.topicNode.tree_id,
}).then(nodes => {
this.nodes = nodes;
this.loading = false;
@@ -150,18 +146,16 @@
},
mounted() {
this.loading = true;
- return this.loadChannelTree(this.$route.params.channelId).then(nodes => {
- return Promise.all([
- this.loadChildren({ parent: this.topicId, tree_id: nodes[0].tree_id }),
- this.loadAncestors({ id: this.topicId, includeSelf: true }),
- ]).then(([nodes]) => {
- this.nodes = nodes;
- this.loading = false;
- });
+ return Promise.all([
+ this.loadChildren({ parent: this.topicId }),
+ this.loadAncestors({ id: this.topicId }),
+ ]).then(([nodes]) => {
+ this.nodes = nodes;
+ this.loading = false;
});
},
methods: {
- ...mapActions('contentNode', ['loadChildren', 'loadAncestors', 'loadChannelTree']),
+ ...mapActions('contentNode', ['loadChildren', 'loadAncestors']),
// @public
scrollToNode(nodeId) {
const ref = this.$refs[nodeId];
diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/SearchOrBrowseWindow.vue b/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/SearchOrBrowseWindow.vue
index 50b69f0eb7..2014cf597d 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/SearchOrBrowseWindow.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/SearchOrBrowseWindow.vue
@@ -155,7 +155,7 @@
actionText: this.$tr('cancel'),
actionCallback: () => changeTracker.revert(),
});
- return this.copy({ id: this.copyNode.id })
+ return this.copy({ node_id: this.copyNode.node_id, channel_id: this.copyNode.channel_id })
.then(() => {
return this.$store.dispatch('showSnackbar', {
text: this.$tr('copiedToClipboard'),
diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/NodePanel.vue b/contentcuration/contentcuration/frontend/channelEdit/views/NodePanel.vue
index 217313167a..210404663e 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/views/NodePanel.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/views/NodePanel.vue
@@ -94,10 +94,10 @@
return this.rootId === this.parentId;
},
},
- mounted() {
+ created() {
if (this.node && this.node.total_count && !this.children.length) {
this.loading = true;
- this.loadChildren({ parent: this.parentId, tree_id: this.rootId }).then(() => {
+ this.loadChildren({ parent: this.parentId }).then(() => {
this.loading = false;
});
}
diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/TreeViewBase.vue b/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/TreeViewBase.vue
index 7d834ae820..af080d901e 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/TreeViewBase.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/TreeViewBase.vue
@@ -119,7 +119,7 @@
-
+
@@ -149,7 +149,7 @@