From 8c3710cda330f74281b3ed125164c6644c161246 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Tue, 2 Mar 2021 00:24:54 +0200 Subject: [PATCH] Started work on single page libraries --- app/imports/server/publications/library.js | 24 +-- app/imports/ui/library/LibraryBrowser.vue | 17 +- .../ui/library/LibraryContentsContainer.vue | 35 ++++ app/imports/ui/library/SingleLibrary.vue | 165 ++++++++++-------- app/imports/ui/pages/SingleLibraryPage.vue | 8 +- 5 files changed, 141 insertions(+), 108 deletions(-) diff --git a/app/imports/server/publications/library.js b/app/imports/server/publications/library.js index 271df4a8..ef68d79f 100644 --- a/app/imports/server/publications/library.js +++ b/app/imports/server/publications/library.js @@ -32,31 +32,25 @@ Meteor.publish('libraries', function(){ }); let libraryIdSchema = new SimpleSchema({ - libraryIds: { - type: Array, - }, - 'libraryIds.$':{ + libraryId:{ type: String, regEx: SimpleSchema.RegEx.Id, }, }); -Meteor.publish('libraryNodes', function(libraryIds){ - libraryIdSchema.validate({libraryIds}); - if (!libraryIds.length) return []; +Meteor.publish('libraryNodes', function(libraryId){ + if (!libraryId) return []; + libraryIdSchema.validate({libraryId}); this.autorun(function (){ let userId = this.userId; - for (let i in libraryIds){ - let libraryId = libraryIds[i]; - let library = Libraries.findOne(libraryId); - try { assertViewPermission(library, userId) } - catch(e){ - return this.error(e); - } + let library = Libraries.findOne(libraryId); + try { assertViewPermission(library, userId) } + catch(e){ + return this.error(e); } return [ LibraryNodes.find({ - 'ancestors.id': {$in: libraryIds}, + 'ancestors.id': libraryId, }, { sort: {order: 1}, }), diff --git a/app/imports/ui/library/LibraryBrowser.vue b/app/imports/ui/library/LibraryBrowser.vue index b1f9238c..5bc60287 100644 --- a/app/imports/ui/library/LibraryBrowser.vue +++ b/app/imports/ui/library/LibraryBrowser.vue @@ -11,7 +11,7 @@ expand > @@ -94,17 +95,6 @@ export default { meteor: { $subscribe: { 'libraries': [], - 'libraryNodes'(){ - if (!this.expandedLibrary) return [[]]; - let libraryIds = []; - this.expandedLibrary.forEach((expanded, index) => { - if (expanded){ - let library = this.libraries[index]; - if (library) libraryIds.push(library._id) - } - }); - return [libraryIds]; - } }, libraries(){ return Libraries.find({}, { @@ -127,6 +117,9 @@ export default { }, }, methods: { + isExpanded(index){ + return this.expandedLibrary && this.expandedLibrary[index]; + }, insertLibrary(){ if (this.paidBenefits){ this.$store.commit('pushDialogStack', { diff --git a/app/imports/ui/library/LibraryContentsContainer.vue b/app/imports/ui/library/LibraryContentsContainer.vue index 114cae5b..3f2bca15 100644 --- a/app/imports/ui/library/LibraryContentsContainer.vue +++ b/app/imports/ui/library/LibraryContentsContainer.vue @@ -1,5 +1,6 @@ diff --git a/app/imports/ui/pages/SingleLibraryPage.vue b/app/imports/ui/pages/SingleLibraryPage.vue index dc15640e..77134ee8 100644 --- a/app/imports/ui/pages/SingleLibraryPage.vue +++ b/app/imports/ui/pages/SingleLibraryPage.vue @@ -1,9 +1,7 @@