Groundwork for default libraries and slots
This commit is contained in:
@@ -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){
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,6 +21,13 @@ let ClassLevelSchema = new SimpleSchema({
|
||||
type: SimpleSchema.Integer,
|
||||
defaultValue: 1,
|
||||
},
|
||||
nextLevelTags: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'nextLevelTags.$': {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
export { ClassLevelSchema };
|
||||
|
||||
13
app/imports/api/properties/Slots.js
Normal file
13
app/imports/api/properties/Slots.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
|
||||
let SlotSchema = new SimpleSchema({
|
||||
slotTags: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'slotTags.$': {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
export { SlotSchema };
|
||||
@@ -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,
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="character-sheet">
|
||||
<div class="character-sheet layout column">
|
||||
<v-toolbar app :color="character.color || 'secondary'" :dark="isDarkColor(character.color || theme.primary)">
|
||||
<v-btn v-if="showMenuButton" flat icon @click="toggleDrawer">
|
||||
<v-icon>menu</v-icon>
|
||||
@@ -14,12 +14,36 @@
|
||||
centered
|
||||
>
|
||||
<v-tab>
|
||||
Stats
|
||||
</v-tab>
|
||||
<v-tab>
|
||||
Features
|
||||
</v-tab>
|
||||
<v-tab>
|
||||
Tree
|
||||
</v-tab>
|
||||
</v-tabs>
|
||||
</v-toolbar>
|
||||
<v-content v-if="$subReady.singleCharacter">
|
||||
<v-content class="flex" v-if="$subReady.singleCharacter">
|
||||
<v-tabs-items v-model="tab">
|
||||
<v-tab-item>
|
||||
<!--<stats-tab/>-->
|
||||
<v-alert
|
||||
:value="true"
|
||||
type="info"
|
||||
>
|
||||
This tab is not available in this version of the alpha.
|
||||
</v-alert>
|
||||
</v-tab-item>
|
||||
<v-tab-item>
|
||||
<!--<features-tab/>-->
|
||||
<v-alert
|
||||
:value="true"
|
||||
type="info"
|
||||
>
|
||||
This tab is not available in this version of the alpha.
|
||||
</v-alert>
|
||||
</v-tab-item>
|
||||
<v-tab-item>
|
||||
<tree-tab :creature-id="creatureId"/>
|
||||
</v-tab-item>
|
||||
@@ -37,6 +61,8 @@
|
||||
import { mapMutations } from "vuex";
|
||||
import { theme } from '/imports/ui/theme.js';
|
||||
import TreeTab from '/imports/ui/creature/character/TreeTab.vue';
|
||||
import StatsTab from '/imports/ui/creature/character/StatsTab.vue';
|
||||
import FeaturesTab from '/imports/ui/creature/character/FeaturesTab.vue';
|
||||
import { recomputeCreature } from '/imports/api/creature/creatureComputation.js'
|
||||
|
||||
export default {
|
||||
@@ -73,5 +99,14 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
<style>
|
||||
.v-tabs__bar {
|
||||
background: none !important;
|
||||
}
|
||||
.v-window-item, .v-window, .v-window__container {
|
||||
height: 100%;
|
||||
}
|
||||
.v-window-item {
|
||||
padding: 0.1px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<v-btn
|
||||
slot="activator"
|
||||
color="primary"
|
||||
small fab
|
||||
small fab disabled
|
||||
@click="insertCreatureProperty"
|
||||
>
|
||||
<v-icon>edit</v-icon>
|
||||
@@ -127,12 +127,11 @@
|
||||
component: 'creature-property-from-library-dialog',
|
||||
elementId: 'insert-creature-property-fab',
|
||||
callback(libraryNode){
|
||||
console.log({libraryNode});
|
||||
if (!libraryNode) return;
|
||||
let propertyId = insertPropertyFromLibraryNode.call({
|
||||
nodeId: libraryNode._id,
|
||||
parentRef: {collection: 'creatures', id: that.creatureId},
|
||||
});
|
||||
console.log({propertyId});
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -124,7 +124,10 @@
|
||||
},
|
||||
methods: {
|
||||
insertCharacter(){
|
||||
store.commit("pushDialogStack", {
|
||||
insertCreature.call(result);
|
||||
|
||||
/*
|
||||
store.commit("pushDialogStack", {
|
||||
component: CharacterCreationDialog,
|
||||
data: {},
|
||||
element: undefined,
|
||||
@@ -134,6 +137,7 @@
|
||||
insertCreature.call(result);
|
||||
},
|
||||
});
|
||||
*/
|
||||
},
|
||||
},
|
||||
components: {
|
||||
|
||||
Reference in New Issue
Block a user