From 469822d4d7e0387a1a9b6116cb4019c1a2bee97e Mon Sep 17 00:00:00 2001 From: Thaum Rystra Date: Mon, 25 May 2020 18:33:38 +0200 Subject: [PATCH] In organize mode, new library properties get placed under the selected node --- app/imports/ui/library/LibraryBrowser.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/imports/ui/library/LibraryBrowser.vue b/app/imports/ui/library/LibraryBrowser.vue index ab9cee45..8c9c069d 100644 --- a/app/imports/ui/library/LibraryBrowser.vue +++ b/app/imports/ui/library/LibraryBrowser.vue @@ -76,6 +76,7 @@ import LibraryNodes, { insertNode } from '/imports/api/library/LibraryNodes.js'; import Libraries, { insertLibrary } from '/imports/api/library/Libraries.js'; import { getUserTier } from '/imports/api/users/patreon/tiers.js'; import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js'; +import { getAncestry } from '/imports/api/parenting/parenting.js'; export default { components: { @@ -139,13 +140,20 @@ export default { }, insertLibraryNode(libraryId){ if (this.paidBenefits){ + let parentRef; + if (this.organizeMode && this.selectedNodeId){ + parentRef = {collection: 'libraryNodes', id: this.selectedNodeId} + } else { + parentRef = {collection: 'libraries', id: libraryId}; + } + let {ancestors} = getAncestry({parentRef}); this.$store.commit('pushDialogStack', { component: 'library-node-creation-dialog', elementId: `insert-node-${libraryId}`, callback(libraryNode){ if (!libraryNode) return; - libraryNode.parent = {collection: 'libraries', id: libraryId}; - libraryNode.ancestors = [ {collection: 'libraries', id: libraryId}]; + libraryNode.parent = parentRef; + libraryNode.ancestors = ancestors; setDocToLastOrder({collection: LibraryNodes, doc: libraryNode}); let libraryNodeId = insertNode.call(libraryNode); return `tree-node-${libraryNodeId}`;