Library Collections UI built

This commit is contained in:
Stefan Zermatten
2022-07-17 22:48:48 +02:00
parent ee89a052bc
commit bf9639ae59
19 changed files with 982 additions and 46 deletions

View File

@@ -24,6 +24,11 @@ let LibrarySchema = new SimpleSchema({
type: String,
max: STORAGE_LIMITS.name,
},
description: {
type: String,
optional: true,
max: STORAGE_LIMITS.summary,
},
});
LibrarySchema.extend(SharingSchema);
@@ -76,6 +81,29 @@ const updateLibraryName = new ValidatedMethod({
},
});
const updateLibraryDescription = new ValidatedMethod({
name: 'libraries.updateDescription',
validate: new SimpleSchema({
_id: {
type: String,
regEx: SimpleSchema.RegEx.id
},
description: {
type: String,
},
}).validator(),
mixins: [RateLimiterMixin],
rateLimit: {
numRequests: 5,
timeInterval: 5000,
},
run({_id, description}){
let library = Libraries.findOne(_id);
assertEditPermission(library, this.userId);
Libraries.update(_id, {$set: {description}});
},
});
const removeLibrary = new ValidatedMethod({
name: 'libraries.remove',
validate: new SimpleSchema({
@@ -102,4 +130,4 @@ export function removeLibaryWork(libraryId){
LibraryNodes.remove({'ancestors.id': libraryId});
}
export { LibrarySchema, insertLibrary, updateLibraryName, removeLibrary };
export { LibrarySchema, insertLibrary, updateLibraryName, updateLibraryDescription, removeLibrary };

View File

@@ -10,9 +10,9 @@ import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
/**
* LibraryCollections are groups of libraries that are subscribed together at once
*/
let LibraryCollections = new Mongo.Collection('librarycollections');
const LibraryCollections = new Mongo.Collection('libraryCollections');
let LibraryCollectionSchema = new SimpleSchema({
const LibraryCollectionSchema = new SimpleSchema({
name: {
type: String,
optional: true,
@@ -71,7 +71,14 @@ const updateLibraryCollection = new ValidatedMethod({
regEx: SimpleSchema.RegEx.Id,
},
update: {
type: LibraryCollectionSchema.pick('name', 'description', 'libraries')
type: LibraryCollectionSchema
.pick('name', 'description', 'libraries')
.extend({ //make libraries optional
libraries: {
optional: true,
defaultValue: undefined,
},
}),
}
},
rateLimit: {