Characters can now be deleted
This commit is contained in:
@@ -4,6 +4,8 @@ import ColorSchema from '/imports/api/properties/subSchemas/ColorSchema.js';
|
||||
import SharingSchema from '/imports/api/sharing/SharingSchema.js';
|
||||
import {assertEditPermission, assertOwnership} from '/imports/api/sharing/sharingPermissions.js';
|
||||
|
||||
import '/imports/api/creature/removeCreature.js';
|
||||
|
||||
//set up the collection for creatures
|
||||
Creatures = new Mongo.Collection('creatures');
|
||||
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
import creatureCollections from '/imports/api/creature/creatureCollections.js';
|
||||
import CreatureProperties from '/imports/api/creature/CreatureProperties.js'
|
||||
import { assertOwnership } from '/imports/api/creature/creaturePermissions.js';
|
||||
|
||||
function removeRelatedDocuments(charId){
|
||||
creatureCollections.forEach(collection => {
|
||||
collection.remove({charId}, error => {
|
||||
if (error) console.error(error);
|
||||
});
|
||||
});
|
||||
CreatureProperties.remove({'ancestors.id': charId});
|
||||
};
|
||||
|
||||
const removeCreature = new ValidatedMethod({
|
||||
|
||||
@@ -22,7 +22,7 @@ export function assertOwnership(doc, userId){
|
||||
return true;
|
||||
} else {
|
||||
throw new Meteor.Error("Permission denied",
|
||||
`You are not the owner of this doc`);
|
||||
`You are not the owner of this document`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Meteor.publish("user", function(){
|
||||
});
|
||||
|
||||
Meteor.publish("userPublicProfiles", function(ids){
|
||||
if (!this.userId || !ids) return [];
|
||||
if (!this.userId || !Array.isArray(ids)) return [];
|
||||
return Meteor.users.find({
|
||||
_id: {$in: ids}
|
||||
},{
|
||||
|
||||
66
app/imports/ui/creature/character/CharacterDeleteDialog.vue
Normal file
66
app/imports/ui/creature/character/CharacterDeleteDialog.vue
Normal file
@@ -0,0 +1,66 @@
|
||||
<template lang="html">
|
||||
<dialog-base>
|
||||
<div slot="toolbar">
|
||||
Delete Character
|
||||
</div>
|
||||
<div>
|
||||
<p v-if="name">
|
||||
Type "{{name}}" to permanenetly delete the character
|
||||
</p>
|
||||
<v-text-field v-if="name" v-model="inputName"/>
|
||||
<v-btn v-show="nameMatch" class="primary" @click="remove">Delete forever</v-btn>
|
||||
</div>
|
||||
<v-spacer slot="actions"/>
|
||||
<v-btn
|
||||
slot="actions"
|
||||
flat
|
||||
@click="$store.dispatch('popDialogStack')"
|
||||
>Cancel</v-btn>
|
||||
</dialog-base>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||
import removeCreature from '/imports/api/creature/removeCreature.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
DialogBase,
|
||||
},
|
||||
props: {
|
||||
id: String,
|
||||
},
|
||||
data(){return {
|
||||
inputName: undefined,
|
||||
}},
|
||||
computed: {
|
||||
nameMatch(){
|
||||
if (!this.name) return true;
|
||||
let uppername = this.name.toUpperCase();
|
||||
let upperInputName = this.inputName && this.inputName.toUpperCase();
|
||||
return uppername === upperInputName;
|
||||
},
|
||||
},
|
||||
meteor: {
|
||||
name(){
|
||||
let creature = Creatures.findOne(this.id);
|
||||
return creature && creature.name;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
remove(){
|
||||
removeCreature.call({charId: this.id}, (error, result) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
} else {
|
||||
this.$router.push('/characterList');
|
||||
this.$store.dispatch('popDialogStack');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
</style>
|
||||
@@ -121,7 +121,13 @@
|
||||
});
|
||||
},
|
||||
deleteCharacter(){
|
||||
console.log('todo');
|
||||
this.$store.commit('pushDialogStack', {
|
||||
component: 'character-delete-dialog',
|
||||
elementId: 'creature-menu',
|
||||
data: {
|
||||
id: this.creatureId,
|
||||
},
|
||||
});
|
||||
},
|
||||
isDarkColor,
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@ import AttributeDialog from '/imports/ui/properties/attributes/AttributeDialog.v
|
||||
import AttributeDialogContainer from '/imports/ui/properties/attributes/AttributeDialogContainer.vue';
|
||||
import AttributeCreationDialog from '/imports/ui/properties/attributes/AttributeCreationDialog.vue';
|
||||
import CreatureFormDialog from '/imports/ui/creature/CreatureFormDialog.vue';
|
||||
import CharacterDeleteDialog from '/imports/ui/creature/character/CharacterDeleteDialog.vue';
|
||||
import CreaturePropertyCreationDialog from '/imports/ui/creature/creatureProperties/CreaturePropertyCreationDialog.vue';
|
||||
import CreaturePropertyDialog from '/imports/ui/creature/creatureProperties/CreaturePropertyDialog.vue'
|
||||
import CreaturePropertyFromLibraryDialog from '/imports/ui/creature/creatureProperties/CreaturePropertyFromLibraryDialog.vue'
|
||||
@@ -18,6 +19,7 @@ export default {
|
||||
AttributeDialogContainer,
|
||||
AttributeCreationDialog,
|
||||
CreatureFormDialog,
|
||||
CharacterDeleteDialog,
|
||||
CreaturePropertyCreationDialog,
|
||||
CreaturePropertyDialog,
|
||||
CreaturePropertyFromLibraryDialog,
|
||||
|
||||
@@ -41,6 +41,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<v-btn
|
||||
slot="actions"
|
||||
flat
|
||||
@click="$store.dispatch('popDialogStack')"
|
||||
>Done</v-btn>
|
||||
</dialog-base>
|
||||
</template>
|
||||
|
||||
@@ -105,7 +110,6 @@ export default {
|
||||
model(){
|
||||
if (!this.docRef || !this.docRef.id) return;
|
||||
let model = fetchDocByRef(this.docRef);
|
||||
console.log({model})
|
||||
return model;
|
||||
},
|
||||
readers(){
|
||||
|
||||
Reference in New Issue
Block a user