Iterated on library nodes
This commit is contained in:
@@ -1,10 +1,17 @@
|
|||||||
import schema from '/imports/api/schema.js';
|
import schema from '/imports/api/schema.js';
|
||||||
import SharingSchema from '/imports/api/sharing/SharingSchema.js';
|
|
||||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||||
import librarySchemas from '/imports/api/library/librarySchemas.js';
|
import librarySchemas from '/imports/api/library/librarySchemas.js';
|
||||||
|
|
||||||
let LibraryNodes = new Mongo.Collection('libraryNodes');
|
let LibraryNodes = new Mongo.Collection('libraryNodes');
|
||||||
|
|
||||||
|
const RefSchema = new SimpleSchema({
|
||||||
|
id: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
index: 1
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
let LibraryNodeSchema = schema({
|
let LibraryNodeSchema = schema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -13,6 +20,21 @@ let LibraryNodeSchema = schema({
|
|||||||
libraryNodeType: {
|
libraryNodeType: {
|
||||||
type: String,
|
type: String,
|
||||||
allowedValues: Object.keys(librarySchemas),
|
allowedValues: Object.keys(librarySchemas),
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
type: SimpleSchema.Integer,
|
||||||
|
index: true,
|
||||||
|
},
|
||||||
|
parent: {
|
||||||
|
type: RefSchema,
|
||||||
|
},
|
||||||
|
// ancestors[0] should be the library to check for permission
|
||||||
|
ancestors: {
|
||||||
|
type: Array,
|
||||||
|
defaultValue: [],
|
||||||
|
},
|
||||||
|
'ancestors.$': {
|
||||||
|
type: RefSchema,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -21,9 +43,6 @@ for (let key in librarySchemas){
|
|||||||
schema.extend(librarySchemas[key]);
|
schema.extend(librarySchemas[key]);
|
||||||
schema.extend(LibraryNodeSchema);
|
schema.extend(LibraryNodeSchema);
|
||||||
schema.extend(ChildSchema);
|
schema.extend(ChildSchema);
|
||||||
if (key === 'folder'){
|
|
||||||
schema.extend(SharingSchema);
|
|
||||||
}
|
|
||||||
LibraryNodes.attachSchema(schema, {
|
LibraryNodes.attachSchema(schema, {
|
||||||
selector: {libraryNodeType: key}
|
selector: {libraryNodeType: key}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user