From 89adda60ec489e5e754b505f0b864cbe7aa21cef Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Tue, 2 Mar 2021 13:05:38 +0200 Subject: [PATCH] Reworked single page libraries to be more in line with the library view --- app/imports/server/publications/library.js | 20 ++- app/imports/ui/library/LibraryAndNode.vue | 40 ++++++ app/imports/ui/library/LibraryBrowser.vue | 14 +- .../ui/library/LibraryContentsContainer.vue | 42 +++--- app/imports/ui/library/SingleLibrary.vue | 134 ------------------ ...lbarItems.vue => SingleLibraryToolbar.vue} | 72 +++++++--- app/imports/ui/pages/SingleLibraryPage.vue | 14 -- app/imports/ui/router.js | 7 +- 8 files changed, 145 insertions(+), 198 deletions(-) delete mode 100644 app/imports/ui/library/SingleLibrary.vue rename app/imports/ui/library/{SingleLibraryToolbarItems.vue => SingleLibraryToolbar.vue} (55%) delete mode 100644 app/imports/ui/pages/SingleLibraryPage.vue diff --git a/app/imports/server/publications/library.js b/app/imports/server/publications/library.js index ef68d79f..0a25ff59 100644 --- a/app/imports/server/publications/library.js +++ b/app/imports/server/publications/library.js @@ -25,8 +25,26 @@ Meteor.publish('libraries', function(){ {owner: this.userId}, {writers: this.userId}, {readers: this.userId}, - {_id: {$in: subs}}, + { _id: {$in: subs}, public: true }, ] + }, { + sort: {name: 1} + }); + }); +}); + +Meteor.publish('library', function(libraryId){ + if (!libraryId) return []; + libraryIdSchema.validate({libraryId}); + this.autorun(function (){ + let userId = this.userId; + let library = Libraries.findOne(libraryId); + try { assertViewPermission(library, userId) } + catch(e){ + return this.error(e); + } + return Libraries.find({ + _id: libraryId, }); }); }); diff --git a/app/imports/ui/library/LibraryAndNode.vue b/app/imports/ui/library/LibraryAndNode.vue index e2d11a61..8f8cc1e8 100644 --- a/app/imports/ui/library/LibraryAndNode.vue +++ b/app/imports/ui/library/LibraryAndNode.vue @@ -19,13 +19,27 @@ > +
+ +
@@ -48,9 +48,9 @@ small icon :disabled="!editPermission(library)" - @click="editLibrary(library._id)" + @click="$router.push(`/library/${library._id}`)" > - create + arrow_forward @@ -90,7 +90,7 @@ export default { selectedNodeId: String, }, data(){ return { - expandedLibrary: null, + expandedLibrary: [], };}, meteor: { $subscribe: { @@ -117,9 +117,7 @@ export default { }, }, methods: { - isExpanded(index){ - return this.expandedLibrary && this.expandedLibrary[index]; - }, + log: console.log, 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 3f2bca15..2b5363a5 100644 --- a/app/imports/ui/library/LibraryContentsContainer.vue +++ b/app/imports/ui/library/LibraryContentsContainer.vue @@ -1,20 +1,30 @@ - - diff --git a/app/imports/ui/library/SingleLibraryToolbarItems.vue b/app/imports/ui/library/SingleLibraryToolbar.vue similarity index 55% rename from app/imports/ui/library/SingleLibraryToolbarItems.vue rename to app/imports/ui/library/SingleLibraryToolbar.vue index 2970d7cb..0726d701 100644 --- a/app/imports/ui/library/SingleLibraryToolbarItems.vue +++ b/app/imports/ui/library/SingleLibraryToolbar.vue @@ -1,28 +1,53 @@ diff --git a/app/imports/ui/router.js b/app/imports/ui/router.js index c0175bcb..591f7045 100644 --- a/app/imports/ui/router.js +++ b/app/imports/ui/router.js @@ -6,8 +6,7 @@ import Home from '/imports/ui/pages/Home.vue'; import About from '/imports/ui/pages/About.vue'; import CharacterList from '/imports/ui/pages/CharacterList.vue'; import Library from '/imports/ui/pages/Library.vue'; -import SingleLibraryPage from '/imports/ui/pages/SingleLibraryPage.vue' -import SingleLibraryToolbarItems from '/imports/ui/library/SingleLibraryToolbarItems.vue' +import SingleLibraryToolbar from '/imports/ui/library/SingleLibraryToolbar.vue'; import CharacterSheetPage from '/imports/ui/pages/CharacterSheetPage.vue'; import CharacterSheetToolbar from '/imports/ui/creature/character/CharacterSheetToolbar.vue'; import CharacterSheetRightDrawer from '/imports/ui/creature/character/CharacterSheetRightDrawer.vue'; @@ -123,8 +122,8 @@ RouterFactory.configure(factory => { name: 'singleLibrary', path: '/library/:id', components: { - default: SingleLibraryPage, - toolbarItems: SingleLibraryToolbarItems, + default: Library, + toolbar: SingleLibraryToolbar, }, meta: { title: 'Library',