Added spells tab

This commit is contained in:
Stefan Zermatten
2020-03-13 12:02:57 +02:00
parent c1aacb9ebe
commit 24725381d7
6 changed files with 167 additions and 27 deletions

View File

@@ -24,6 +24,9 @@ const allowedParenting = {
const allParentTypes = new Set(flatten(Object.values(allowedParenting)));
export function canBeParent(type){
return true;
//TODO until there is a good reason to disallow certain parenting options,
// this should just let the user do whatever
return type && allParentTypes.has(type);
}

View File

@@ -48,6 +48,9 @@
Inventory
</v-tab>
<v-tab>
Spells
</v-tab>
<v-tab>
Tree
</v-tab>
</v-tabs>
@@ -63,6 +66,9 @@
<v-tab-item>
<inventory-tab :creature-id="creatureId"/>
</v-tab-item>
<v-tab-item>
<spells-tab :creature-id="creatureId"/>
</v-tab-item>
<v-tab-item>
<tree-tab :creature-id="creatureId"/>
</v-tab-item>
@@ -83,6 +89,7 @@
import StatsTab from '/imports/ui/creature/character/characterSheetTabs/StatsTab.vue';
import FeaturesTab from '/imports/ui/creature/character/characterSheetTabs/FeaturesTab.vue';
import InventoryTab from '/imports/ui/creature/character/characterSheetTabs/InventoryTab.vue';
import SpellsTab from '/imports/ui/creature/character/characterSheetTabs/SpellsTab.vue';
import TreeTab from '/imports/ui/creature/character/characterSheetTabs/TreeTab.vue';
import { recomputeCreature } from '/imports/api/creature/creatureComputation.js';
@@ -95,6 +102,7 @@
StatsTab,
FeaturesTab,
InventoryTab,
SpellsTab,
TreeTab,
},
data(){return {

View File

@@ -0,0 +1,103 @@
<template lang="html">
<div class="spells">
<column-layout>
<v-card>
<v-card-actions>
<v-switch v-model="organize" label="Organize"/>
</v-card-actions>
<!-- Equipping things isn't implemented yet
<creature-properties-tree
:root="{collection: 'creatures', id: creatureId}"
:filter="{
equipped: true,
type: 'spell',
'ancestors.id': {$nin: spellListIds}
}"
@selected="e => clickProperty(e)"
:organize="organize"
group="spells"
/>
<v-divider/>
-->
<creature-properties-tree
:root="{collection: 'creatures', id: creatureId}"
:filter="{
equipped: {$ne: true},
type: 'spell',
'ancestors.id': {$nin: spellListIds}
}"
@selected="e => clickProperty(e)"
:organize="organize"
group="spells"
/>
</v-card>
<div v-for="spellList in spellListsWithoutAncestorSpellLists" :key="spellList._id">
<spellList-card
:model="spellList"
:organize="organize"
/>
</div>
</column-layout>
</div>
</template>
<script>
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
import ColumnLayout from '/imports/ui/components/ColumnLayout.vue';
import CreaturePropertiesTree from '/imports/ui/creature/creatureProperties/CreaturePropertiesTree.vue';
import SpellListCard from '/imports/ui/properties/components/spells/SpellListCard.vue';
export default {
props: {
creatureId: String,
},
data(){ return {
organize: false,
}},
components: {
ColumnLayout,
CreaturePropertiesTree,
SpellListCard,
},
meteor: {
spellLists(){
return CreatureProperties.find({
'ancestors.id': this.creatureId,
type: 'spellList',
removed: {$ne: true},
}, {
sort: {order: 1},
});
},
spellListsWithoutAncestorSpellLists(){
return CreatureProperties.find({
'ancestors.id': {
$eq: this.creatureId,
$nin: this.spellListIds
},
type: 'spellList',
removed: {$ne: true},
}, {
sort: {order: 1},
});
},
},
computed: {
spellListIds(){
return this.spellLists.map(spellList => spellList._id);
},
},
methods: {
clickProperty(_id){
this.$store.commit('pushDialogStack', {
component: 'creature-property-dialog',
elementId: `tree-node-${_id}`,
data: {_id},
});
},
},
}
</script>
<style lang="css" scoped>
</style>

View File

@@ -19,7 +19,6 @@
<script>
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
import ItemListTile from '/imports/ui/properties/components/inventory/ItemListTile.vue';
import CreaturePropertiesTree from '/imports/ui/creature/creatureProperties/CreaturePropertiesTree.vue';
export default {
@@ -29,7 +28,6 @@ export default {
},
components: {
ToolbarCard,
ItemListTile,
CreaturePropertiesTree,
},
methods: {

View File

@@ -1,25 +0,0 @@
<template lang="html">
<v-list-tile class="skill-list-tile" height="32px" v-on="hasClickListener ? {click: () => $emit('click')} : {}">
<v-list-tile-content>
<v-list-tile-title>
{{model.name}}
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</template>
<script>
export default {
props: {
model: Object,
},
computed: {
hasClickListener(){
return this.$listeners && !!this.$listeners.click
},
}
}
</script>
<style lang="css" scoped>
</style>

View File

@@ -0,0 +1,53 @@
<template lang="html">
<toolbar-card :color="model.color" @toolbarclick="clickSpellList(model._id)" :data-id="model._id">
<template slot="toolbar">
<span>
{{model.name}}
</span>
<v-spacer/>
</template>
<creature-properties-tree
:root="{collection: 'creatureProperties', id: model._id}"
:filter="{type: {$in: ['spellList', 'spell', 'folder']}}"
@selected="e => clickProperty(e)"
:organize="organize"
group="spells"
/>
</toolbar-card>
</template>
<script>
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
import CreaturePropertiesTree from '/imports/ui/creature/creatureProperties/CreaturePropertiesTree.vue';
export default {
props: {
model: Object,
organize: Boolean,
},
components: {
ToolbarCard,
CreaturePropertiesTree,
},
methods: {
clickSpellList(_id){
this.$store.commit('pushDialogStack', {
component: 'creature-property-dialog',
elementId: `${_id}`,
data: {_id},
});
},
clickProperty(_id){
this.$store.commit('pushDialogStack', {
component: 'creature-property-dialog',
elementId: `tree-node-${_id}`,
data: {_id},
});
},
}
};
</script>
<style lang="css" scoped>
</style>