Added Character sheet
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import Effects from "/imports/api/creature/properties/Effects.js"
|
||||
import deathSaveSchema from "/imports/api/creature/subSchemas/DeathSavesSchema.js"
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
|
||||
//Methods
|
||||
import '/imports/api/creature/insertCreature.js';
|
||||
import '/imports/api/creature/removeCreature.js';
|
||||
|
||||
//set up the collection for creatures
|
||||
Creatures = new Mongo.Collection("creatures");
|
||||
@@ -62,27 +62,8 @@ let creatureSchema = new SimpleSchema({
|
||||
Creatures.attachSchema(creatureSchema);
|
||||
Creatures.attachSchema(ColorSchema);
|
||||
|
||||
//clean up all data related to that creature before removing it
|
||||
//Keep the urlName up to date
|
||||
if (Meteor.isServer){
|
||||
Creatures.after.remove(function(userId, creature) {
|
||||
let charId = creature._id;
|
||||
Actions .remove({charId});
|
||||
Attacks .remove({charId});
|
||||
Attributes .remove({charId});
|
||||
Buffs .remove({charId});
|
||||
Classes .remove({charId});
|
||||
CustomBuffs .remove({charId});
|
||||
DamageMultipliers.remove({charId});
|
||||
Effects .remove({charId});
|
||||
Experiences .remove({charId});
|
||||
Features .remove({charId});
|
||||
Notes .remove({charId});
|
||||
Proficiencies .remove({charId});
|
||||
Skills .remove({charId});
|
||||
SpellLists .remove({charId});
|
||||
Items .remove({charId});
|
||||
Containers .remove({charId});
|
||||
});
|
||||
Creatures.after.update(function(userId, doc, fieldNames, modifier, options) {
|
||||
if (_.contains(fieldNames, "name")){
|
||||
var urlName = getSlug(doc.name, {maintainCase: true}) || "-";
|
||||
|
||||
@@ -19,7 +19,7 @@ const addDefaultDocs = function(docs){
|
||||
|
||||
const insertCreature = new ValidatedMethod({
|
||||
|
||||
name: "Creatures.methods.insertCharacter", // DDP method name
|
||||
name: "Creatures.methods.insertCreature",
|
||||
|
||||
validate: null,
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SimpleSchema from "simpl-schema";
|
||||
|
||||
let Bundle = new Mongo.Collection("bundle");
|
||||
let Bundles = new Mongo.Collection("bundle");
|
||||
|
||||
let attributeSchema = new SimpleSchema({
|
||||
name: String,
|
||||
|
||||
@@ -24,3 +24,5 @@ let experienceSchema = new SimpleSchema({
|
||||
Experiences.attachSchema(experienceSchema);
|
||||
|
||||
//Experiences.attachBehaviour("softRemovable");
|
||||
|
||||
export default Experiences;
|
||||
|
||||
@@ -34,3 +34,5 @@ Proficiencies.attachSchema(proficiencySchema);
|
||||
|
||||
// Proficiencies.attachBehaviour("softRemovable");
|
||||
makeChild(Proficiencies, ["enabled"]);
|
||||
|
||||
export default Proficiencies;
|
||||
|
||||
76
app/imports/api/creature/removeCreature.js
Normal file
76
app/imports/api/creature/removeCreature.js
Normal file
@@ -0,0 +1,76 @@
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
import Actions from '/imports/api/creature/properties/Actions.js';
|
||||
import Attacks from '/imports/api/creature/properties/Attacks.js';
|
||||
import Attributes from '/imports/api/creature/properties/Attributes.js';
|
||||
import Buffs from '/imports/api/creature/properties/Buffs.js';
|
||||
import Bundles from '/imports/api/creature/properties/Bundles.js';
|
||||
import Classes from '/imports/api/creature/properties/Classes.js';
|
||||
import Conditions from '/imports/api/creature/properties/Conditions.js';
|
||||
import CustomBuffs from '/imports/api/creature/properties/CustomBuffs.js';
|
||||
import DamageMultipliers from '/imports/api/creature/properties/DamageMultipliers.js';
|
||||
import Effects from '/imports/api/creature/properties/Effects.js';
|
||||
import Experiences from '/imports/api/creature/properties/Experiences.js';
|
||||
import Features from '/imports/api/creature/properties/Features.js';
|
||||
import Notes from '/imports/api/creature/properties/Notes.js';
|
||||
import Proficiencies from '/imports/api/creature/properties/Proficiencies.js';
|
||||
import Skills from '/imports/api/creature/properties/Skills.js';
|
||||
import SpellLists from '/imports/api/creature/properties/SpellLists.js';
|
||||
import Spells from '/imports/api/creature/properties/Spells.js';
|
||||
import Items from '/imports/api/inventory/Items.js';
|
||||
import Containers from '/imports/api/inventory/Containers.js';
|
||||
|
||||
const checkRemovePermissions = function(userId, charId, creature){
|
||||
// Must be logged in
|
||||
if (!userId) {
|
||||
throw new Meteor.Error("Creatures.methods.removeCreature.denied",
|
||||
"You need to be logged in to remove a creature");
|
||||
}
|
||||
|
||||
// Creature must exist
|
||||
if (!creature) {
|
||||
throw new Meteor.Error("Creatures.methods.removeCreature.denied",
|
||||
`No creature exists with the given id: ${charId}`);
|
||||
}
|
||||
|
||||
// Must be creatures owner
|
||||
if (creature.owner !== userId){
|
||||
throw new Meteor.Error("Creatures.methods.removeCreature.denied",
|
||||
"Only the owner is allowed to remove a creature, you are not the owner");
|
||||
}
|
||||
}
|
||||
|
||||
const removeRelatedDocuments = function(charId){
|
||||
Actions .remove({charId});
|
||||
Attacks .remove({charId});
|
||||
Attributes .remove({charId});
|
||||
Buffs .remove({charId});
|
||||
Bundles .remove({charId});
|
||||
Classes .remove({charId});
|
||||
Conditions .remove({charId});
|
||||
CustomBuffs .remove({charId});
|
||||
DamageMultipliers.remove({charId});
|
||||
Effects .remove({charId});
|
||||
Experiences .remove({charId});
|
||||
Features .remove({charId});
|
||||
Notes .remove({charId});
|
||||
Proficiencies .remove({charId});
|
||||
Skills .remove({charId});
|
||||
SpellLists .remove({charId});
|
||||
Spells .remove({charId});
|
||||
Items .remove({charId});
|
||||
Containers .remove({charId});
|
||||
};
|
||||
|
||||
const removeCreature = new ValidatedMethod({
|
||||
name: "Creatures.methods.removeCreature", // DDP method name
|
||||
validate: null,
|
||||
run(charId) {
|
||||
let creature = Creatures.findOne(charId);
|
||||
checkRemovePermissions(this.userId, charId, creature);
|
||||
Creatures.remove(charId);
|
||||
this.unblock();
|
||||
removeRelatedDocuments(charId);
|
||||
},
|
||||
});
|
||||
|
||||
export default removeCreature;
|
||||
45
app/imports/ui/character/CharacterSheet.vue
Normal file
45
app/imports/ui/character/CharacterSheet.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-toolbar app color="primary" dark>
|
||||
<v-btn v-if="showMenuButton" flat icon @click="toggleDrawer">
|
||||
<v-icon>menu</v-icon>
|
||||
</v-btn>
|
||||
<span>{{character.name}}</span>
|
||||
</v-toolbar>
|
||||
<v-content v-if="$subReady.singleCharacter">
|
||||
{{character}}
|
||||
</v-content>
|
||||
<v-content v-else>
|
||||
<v-progress-circular indeterminate />
|
||||
</v-content>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
import { mapMutations } from "vuex";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
showMenuButton: Boolean,
|
||||
charId: String,
|
||||
},
|
||||
methods: {
|
||||
...mapMutations([
|
||||
"toggleDrawer",
|
||||
]),
|
||||
},
|
||||
meteor: {
|
||||
$subscribe: {
|
||||
'singleCharacter': [this.charId],
|
||||
},
|
||||
character(){
|
||||
return Creatures.findOne(this.charId);
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -13,9 +13,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapMutations } from "vuex"
|
||||
import { mapMutations } from "vuex";
|
||||
export default {
|
||||
methods:{
|
||||
methods: {
|
||||
...mapMutations([
|
||||
"toggleDrawer",
|
||||
]),
|
||||
|
||||
12
app/imports/ui/pages/CharacterSheetPage.vue
Normal file
12
app/imports/ui/pages/CharacterSheetPage.vue
Normal file
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<character-sheet show-menu-button :char-id="$route.params.id" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CharacterSheet from '/imports/ui/character/CharacterSheet.vue';
|
||||
export default {
|
||||
components: {
|
||||
CharacterSheet,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -4,10 +4,11 @@ import Vue from "vue";
|
||||
// Components
|
||||
import Home from '/imports/ui/pages/Home.vue';
|
||||
import CharacterList from "/imports/ui/pages/CharacterList.vue";
|
||||
import CharacterSheetPage from "/imports/ui/pages/CharacterSheetPage.vue";
|
||||
import SignIn from "/imports/ui/pages/SignIn.vue" ;
|
||||
import Register from "/imports/ui/pages/Register.vue" ;
|
||||
import Account from "/imports/ui/pages/Account.vue" ;
|
||||
import TestDialog from "/imports/ui/dialogStack/TestDialog.vue"
|
||||
import TestDialog from "/imports/ui/dialogStack/TestDialog.vue";
|
||||
|
||||
// Not found
|
||||
import NotFound from '/imports/ui/pages/NotFound.vue';
|
||||
@@ -30,6 +31,12 @@ RouterFactory.configure(factory => {
|
||||
},{
|
||||
path: "/characterList",
|
||||
component: CharacterList,
|
||||
},{
|
||||
path: "/character/:id/:urlName",
|
||||
component: CharacterSheetPage,
|
||||
},{
|
||||
path: "/character/:id",
|
||||
component: CharacterSheetPage,
|
||||
},{
|
||||
path: "/sign-in",
|
||||
component: SignIn,
|
||||
|
||||
78
app/package-lock.json
generated
78
app/package-lock.json
generated
@@ -105,7 +105,7 @@
|
||||
},
|
||||
"block-stream": {
|
||||
"version": "0.0.9",
|
||||
"resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=",
|
||||
"requires": {
|
||||
"inherits": "~2.0.0"
|
||||
@@ -453,7 +453,7 @@
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
},
|
||||
"ini": {
|
||||
@@ -1394,37 +1394,6 @@
|
||||
"requires": {
|
||||
"inherits": "~2.0.1",
|
||||
"readable-stream": "^2.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"readable-stream": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
}
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"stream-http": {
|
||||
@@ -1437,37 +1406,6 @@
|
||||
"readable-stream": "^2.3.3",
|
||||
"to-arraybuffer": "^1.0.0",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"readable-stream": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
}
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
@@ -1685,7 +1623,7 @@
|
||||
},
|
||||
"os-homedir": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
|
||||
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
|
||||
},
|
||||
"os-locale": {
|
||||
@@ -1700,7 +1638,7 @@
|
||||
},
|
||||
"os-tmpdir": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
||||
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
|
||||
},
|
||||
"osenv": {
|
||||
@@ -1753,7 +1691,7 @@
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
},
|
||||
"path-key": {
|
||||
@@ -1841,7 +1779,7 @@
|
||||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
|
||||
}
|
||||
}
|
||||
@@ -2058,7 +1996,7 @@
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
@@ -2089,7 +2027,7 @@
|
||||
},
|
||||
"tar": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz",
|
||||
"integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=",
|
||||
"requires": {
|
||||
"block-stream": "*",
|
||||
|
||||
Reference in New Issue
Block a user