diff --git a/app/imports/api/creature/CreatureProperties.js b/app/imports/api/creature/CreatureProperties.js index 3105f367..2d9b865b 100644 --- a/app/imports/api/creature/CreatureProperties.js +++ b/app/imports/api/creature/CreatureProperties.js @@ -18,6 +18,13 @@ let CreaturePropertySchema = new SimpleSchema({ type: String, allowedValues: Object.keys(propertySchemasIndex), }, + tags: { + type: Array, + defaultValue: [], + }, + 'tags.$': { + type: String, + }, }); for (let key in propertySchemasIndex){ diff --git a/app/imports/api/creature/insertCreature.js b/app/imports/api/creature/insertCreature.js index fc225123..119ac2d2 100644 --- a/app/imports/api/creature/insertCreature.js +++ b/app/imports/api/creature/insertCreature.js @@ -21,7 +21,7 @@ const insertCreature = new ValidatedMethod({ validate: null, - run(characterFormData) { + run() { if (!this.userId) { throw new Meteor.Error("Creatures.methods.insert.denied", "You need to be logged in to insert a creature"); @@ -29,18 +29,9 @@ const insertCreature = new ValidatedMethod({ // Create the creature document let charId = Creatures.insert({ - name: characterFormData.name, owner: this.userId, - alignment: characterFormData.alignment, - gender: characterFormData.gender, - race: characterFormData.race, }); this.unblock(); - if (Meteor.isServer){ - //Add all the required attributes to it - let docs = getDefaultCharacterDocs(charId, characterFormData); - addDefaultDocs(docs); - } return charId; }, diff --git a/app/imports/api/library/Libraries.js b/app/imports/api/library/Libraries.js index b7c75200..bb410028 100644 --- a/app/imports/api/library/Libraries.js +++ b/app/imports/api/library/Libraries.js @@ -17,6 +17,10 @@ let LibrarySchema = new SimpleSchema({ name: { type: String, }, + isDefault: { + type: Boolean, + optional: true, + }, }); LibrarySchema.extend(SharingSchema); @@ -30,11 +34,30 @@ const insertLibrary = new ValidatedMethod({ mixins: [ simpleSchemaMixin, ], - schema: LibrarySchema.omit('owner'), + schema: LibrarySchema.omit('owner', 'isDefault'), run(library) { library.owner = this.userId; return Libraries.insert(library); }, }); -export { LibrarySchema, insertLibrary }; +const setLibraryDefault = new ValidatedMethod({ + name: 'Libraries.methods.makeLibraryDefault', + validate: new SimpleSchema({ + _id: { + type: String, + regEx: SimpleSchema.RegEx.id + }, + isDefault: { + type: Boolean, + }, + }).validator(), + run({_id, isDefault}) { + if (!Meteor.users.isAdmin()){ + throw new Meteor.Error('Permission denied', 'User must be admin to set libraries as default'); + } + return Libraries.update(_id, {$set: {isDefault}}); + }, +}); + +export { LibrarySchema, insertLibrary, setLibraryDefault }; diff --git a/app/imports/api/library/LibraryNodes.js b/app/imports/api/library/LibraryNodes.js index 1651f57c..8b8af182 100644 --- a/app/imports/api/library/LibraryNodes.js +++ b/app/imports/api/library/LibraryNodes.js @@ -13,6 +13,13 @@ let LibraryNodeSchema = new SimpleSchema({ type: String, allowedValues: Object.keys(propertySchemasIndex), }, + tags: { + type: Array, + defaultValue: [], + }, + 'tags.$': { + type: String, + }, }); for (let key in propertySchemasIndex){ diff --git a/app/imports/api/parenting/parenting.js b/app/imports/api/parenting/parenting.js index 33ea860d..875ba525 100644 --- a/app/imports/api/parenting/parenting.js +++ b/app/imports/api/parenting/parenting.js @@ -107,7 +107,6 @@ export function setLineageOfDocs({docArray, oldParent, newAncestry}){ }); } - /** * Give documents new random ids and transform their references. * Transform collections of re-IDed docs according to the collection map diff --git a/app/imports/api/properties/ClassLevels.js b/app/imports/api/properties/ClassLevels.js index 5af2190d..86e3654f 100644 --- a/app/imports/api/properties/ClassLevels.js +++ b/app/imports/api/properties/ClassLevels.js @@ -21,6 +21,13 @@ let ClassLevelSchema = new SimpleSchema({ type: SimpleSchema.Integer, defaultValue: 1, }, + nextLevelTags: { + type: Array, + defaultValue: [], + }, + 'nextLevelTags.$': { + type: String, + }, }); export { ClassLevelSchema }; diff --git a/app/imports/api/properties/Slots.js b/app/imports/api/properties/Slots.js new file mode 100644 index 00000000..949330d0 --- /dev/null +++ b/app/imports/api/properties/Slots.js @@ -0,0 +1,13 @@ +import SimpleSchema from 'simpl-schema'; + +let SlotSchema = new SimpleSchema({ + slotTags: { + type: Array, + defaultValue: [], + }, + 'slotTags.$': { + type: String, + }, +}); + +export { SlotSchema }; diff --git a/app/imports/api/properties/propertySchemasIndex.js b/app/imports/api/properties/propertySchemasIndex.js index 62e853fa..85e30b5e 100644 --- a/app/imports/api/properties/propertySchemasIndex.js +++ b/app/imports/api/properties/propertySchemasIndex.js @@ -12,8 +12,9 @@ import { FolderSchema } from '/imports/api/properties/Folders.js'; import { NoteSchema } from '/imports/api/properties/Notes.js'; import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js'; import { RollSchema } from '/imports/api/properties/Rolls.js'; -import { SkillSchema } from '/imports/api/properties/Skills.js'; import { SavingThrowSchema } from '/imports/api/properties/SavingThrows.js'; +import { SkillSchema } from '/imports/api/properties/Skills.js'; +import { SlotSchema } from '/imports/api/properties/Slots.js'; import { SpellListSchema } from '/imports/api/properties/SpellLists.js'; import { SpellSchema } from '/imports/api/properties/Spells.js'; import { ContainerSchema } from '/imports/api/properties/Containers.js'; @@ -35,6 +36,7 @@ const propertySchemasIndex = { roll: RollSchema, savingThrow: SavingThrowSchema, skill: SkillSchema, + slot: SlotSchema, spellList: SpellListSchema, spell: SpellSchema, container: ContainerSchema, diff --git a/app/imports/api/users/Users.js b/app/imports/api/users/Users.js index 03a24902..158f2181 100644 --- a/app/imports/api/users/Users.js +++ b/app/imports/api/users/Users.js @@ -105,7 +105,7 @@ Meteor.users.sendVerificationEmail = new ValidatedMethod({ }).validator(), run(userId, address){ userId = this.userId || userId; - let user = Meteor.users.findOne(); + let user = Meteor.users.findOne(userId); if (!user) { throw new Meteor.Error('User not found', 'Can\'t send a validation email to a user that does not exist'); @@ -114,6 +114,12 @@ Meteor.users.sendVerificationEmail = new ValidatedMethod({ throw new Meteor.Error('Email address not found', 'The specified email address wasn\'t found on this user account'); } - Accounts.sendVerificationEmail(this.userId, address); + Accounts.sendVerificationEmail(userId, address); } }); + +Meteor.users.isAdmin = function(userId){ + userId = this.userId || userId; + let user = Meteor.users.findOne(userId); + return user && user.roles.includes('admin'); +} diff --git a/app/imports/ui/creature/character/CharacterSheet.vue b/app/imports/ui/creature/character/CharacterSheet.vue index 1cddf8b8..4cf970a5 100644 --- a/app/imports/ui/creature/character/CharacterSheet.vue +++ b/app/imports/ui/creature/character/CharacterSheet.vue @@ -1,5 +1,5 @@