Removed drag handles from spells in spell lists
Spell lists often have spells from many sources, and dragging spells around in a UI that doesn't show what you might be breaking is a foot gun.
This commit is contained in:
@@ -4,48 +4,34 @@
|
|||||||
dense
|
dense
|
||||||
class="spell-list"
|
class="spell-list"
|
||||||
>
|
>
|
||||||
<draggable
|
<template v-for="spell in computedSpells">
|
||||||
v-model="computedSpells"
|
<v-subheader
|
||||||
style="min-height: 24px;"
|
v-if="spell.isSubheader"
|
||||||
:group="`spell-list`"
|
:key="`${spell.level}-header`"
|
||||||
ghost-class="ghost"
|
class="item"
|
||||||
draggable=".item"
|
>
|
||||||
handle=".handle"
|
{{ spell.level === 0 ? 'Cantrips' : `Level ${spell.level}` }}
|
||||||
:animation="200"
|
</v-subheader>
|
||||||
@change="change"
|
<spell-list-tile
|
||||||
>
|
v-else
|
||||||
<template v-for="spell in computedSpells">
|
:key="spell._id"
|
||||||
<v-subheader
|
class="item"
|
||||||
v-if="spell.isSubheader"
|
:disabled="context.editPermission === false"
|
||||||
:key="`${spell.level}-header`"
|
:data-id="`spell-list-tile-${spell._id}`"
|
||||||
class="item"
|
:model="spell"
|
||||||
>
|
:preparing-spells="preparingSpells"
|
||||||
{{ spell.level === 0 ? 'Cantrips' : `Level ${spell.level}` }}
|
@click="clickProperty(spell._id)"
|
||||||
</v-subheader>
|
/>
|
||||||
<spell-list-tile
|
</template>
|
||||||
v-else
|
|
||||||
:key="spell._id"
|
|
||||||
class="item"
|
|
||||||
:disabled="context.editPermission === false"
|
|
||||||
:data-id="`spell-list-tile-${spell._id}`"
|
|
||||||
:model="spell"
|
|
||||||
:preparing-spells="preparingSpells"
|
|
||||||
@click="clickProperty(spell._id)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</draggable>
|
|
||||||
</v-list>
|
</v-list>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="js">
|
<script lang="js">
|
||||||
import draggable from 'vuedraggable';
|
|
||||||
import SpellListTile from '/imports/client/ui/properties/components/spells/SpellListTile.vue';
|
import SpellListTile from '/imports/client/ui/properties/components/spells/SpellListTile.vue';
|
||||||
import { organizeDoc } from '/imports/api/parenting/organizeMethods';
|
|
||||||
import spellsWithSubheaders from '/imports/client/ui/properties/components/spells/spellsWithSubheaders';
|
import spellsWithSubheaders from '/imports/client/ui/properties/components/spells/spellsWithSubheaders';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
draggable,
|
|
||||||
SpellListTile,
|
SpellListTile,
|
||||||
},
|
},
|
||||||
inject: {
|
inject: {
|
||||||
@@ -56,39 +42,17 @@ export default {
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
parentRef: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
preparingSpells: Boolean,
|
preparingSpells: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dataSpells: [],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
levels() {
|
levels() {
|
||||||
let levels = new Set();
|
let levels = new Set();
|
||||||
this.spells.forEach(spell => levels.add(spell.level));
|
this.spells.forEach(spell => levels.add(spell.level));
|
||||||
return levels;
|
return levels;
|
||||||
},
|
},
|
||||||
computedSpells: {
|
computedSpells() {
|
||||||
get() {
|
return spellsWithSubheaders(this.spells);
|
||||||
return spellsWithSubheaders(this.dataSpells);
|
},
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
this.dataSpells = value;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
spells(value) {
|
|
||||||
this.dataSpells = spellsWithSubheaders(value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.dataSpells = spellsWithSubheaders(this.spells);
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clickProperty(_id) {
|
clickProperty(_id) {
|
||||||
@@ -98,35 +62,6 @@ export default {
|
|||||||
data: { _id },
|
data: { _id },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
change({ added, moved }) {
|
|
||||||
let event = added || moved;
|
|
||||||
if (event) {
|
|
||||||
// If this spell is now adjacent to another, set the order accordingly
|
|
||||||
let order;
|
|
||||||
let before = this.dataSpells[event.newIndex - 1];
|
|
||||||
let after = this.dataSpells[event.newIndex + 1];
|
|
||||||
if (before && before._id) {
|
|
||||||
order = before.order + 0.5;
|
|
||||||
} else if (after && after._id) {
|
|
||||||
order = after.order - 0.5;
|
|
||||||
} else {
|
|
||||||
order = -0.5;
|
|
||||||
}
|
|
||||||
let doc = event.element;
|
|
||||||
organizeDoc.callAsync({
|
|
||||||
docRef: {
|
|
||||||
id: doc._id,
|
|
||||||
collection: 'creatureProperties',
|
|
||||||
},
|
|
||||||
parentRef: this.parentRef,
|
|
||||||
order,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="css" scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -51,24 +51,8 @@
|
|||||||
<v-icon>mdi-check</v-icon>
|
<v-icon>mdi-check</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
<!-- Disabled because it changes the height of the card
|
|
||||||
<v-card-text
|
|
||||||
v-if="preparedError || preparingSpells"
|
|
||||||
:class="{'error--text' : preparedError}"
|
|
||||||
class="pb-0"
|
|
||||||
>
|
|
||||||
<div v-if="model.maxPrepared && model.maxPrepared.value">
|
|
||||||
{{ numPrepared }}/{{ model.maxPrepared.value }} spells prepared
|
|
||||||
</div>
|
|
||||||
<v-switch
|
|
||||||
v-model="preparingSpells"
|
|
||||||
label="Change prepared spells"
|
|
||||||
/>
|
|
||||||
</v-card-text>
|
|
||||||
-->
|
|
||||||
<spell-list
|
<spell-list
|
||||||
:spells="spells"
|
:spells="spells"
|
||||||
:parent-ref="{id: model._id, collection: 'creatureProperties'}"
|
|
||||||
:preparing-spells="preparingSpells"
|
:preparing-spells="preparingSpells"
|
||||||
/>
|
/>
|
||||||
</toolbar-card>
|
</toolbar-card>
|
||||||
@@ -113,7 +97,7 @@ export default {
|
|||||||
return CreatureProperties.find(filter, {
|
return CreatureProperties.find(filter, {
|
||||||
sort: {
|
sort: {
|
||||||
level: 1,
|
level: 1,
|
||||||
order: 1,
|
left: 1,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
{{ spellComponents }}
|
{{ spellComponents }}
|
||||||
</v-list-item-subtitle>
|
</v-list-item-subtitle>
|
||||||
</v-list-item-content>
|
</v-list-item-content>
|
||||||
<v-list-item-action>
|
<v-list-item-action v-if="preparingSpells || showInfoButton">
|
||||||
<smart-checkbox
|
<smart-checkbox
|
||||||
v-if="preparingSpells"
|
v-if="preparingSpells"
|
||||||
:value="model.prepared || model.alwaysPrepared"
|
:value="model.prepared || model.alwaysPrepared"
|
||||||
@@ -29,11 +29,6 @@
|
|||||||
@click.native.stop="() => {}"
|
@click.native.stop="() => {}"
|
||||||
@change="setPrepared"
|
@change="setPrepared"
|
||||||
/>
|
/>
|
||||||
<drag-handle
|
|
||||||
v-else-if="!hideHandle"
|
|
||||||
:disabled="context.editPermission === false"
|
|
||||||
style="height: 100%; width: 40px; cursor: move;"
|
|
||||||
/>
|
|
||||||
<v-btn
|
<v-btn
|
||||||
v-else-if="showInfoButton"
|
v-else-if="showInfoButton"
|
||||||
icon
|
icon
|
||||||
@@ -59,7 +54,6 @@ export default {
|
|||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
preparingSpells: Boolean,
|
preparingSpells: Boolean,
|
||||||
hideHandle: Boolean,
|
|
||||||
showInfoButton: Boolean,
|
showInfoButton: Boolean,
|
||||||
disabled: Boolean,
|
disabled: Boolean,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user