Fixed regression: spell slot bubbles are clickable again

This commit is contained in:
Stefan Zermatten
2023-05-06 22:59:26 +02:00
parent 142072d810
commit b82061b8d4

View File

@@ -3,7 +3,6 @@
:key="model._id" :key="model._id"
class="spell-slot-list-tile" class="spell-slot-list-tile"
v-bind="$attrs" v-bind="$attrs"
:disabled="disabled"
v-on="hasClickListener ? {click} : {}" v-on="hasClickListener ? {click} : {}"
> >
<v-list-item-content> <v-list-item-content>
@@ -26,18 +25,28 @@
<div <div
v-else v-else
class="layout align-center slot-bubbles" class="layout align-center slot-bubbles"
@click.stop
> >
<v-icon <smart-btn
v-for="i in model.total" v-for="i in model.total"
:key="i" :key="i"
:disabled="disabled" :disabled="disabled(i)"
icon
single-click
@click="ack => damageProperty({
type: 'increment',
value: i <= model.value ? 1 : -1,
ack
})"
> >
{{ <v-icon>
i > model.value ? {{
'mdi-radiobox-blank' : i > model.value ?
'mdi-radiobox-marked' 'mdi-radiobox-blank' :
}} 'mdi-radiobox-marked'
</v-icon> }}
</v-icon>
</smart-btn>
</div> </div>
</v-list-item-title> </v-list-item-title>
<v-list-item-title v-else> <v-list-item-title v-else>
@@ -53,15 +62,20 @@
</template> </template>
<script lang="js"> <script lang="js">
import numberToSignedString from '../../../../../api/utility/numberToSignedString.js'; import damageProperty from '/imports/api/creature/creatureProperties/methods/damageProperty.js';
import numberToSignedString from '/imports/api/utility/numberToSignedString.js';
import { snackbar } from '/imports/client/ui/components/snackbars/SnackbarQueue.js';
export default { export default {
inject: {
context: { default: {} }
},
props: { props: {
model: { model: {
type: Object, type: Object,
required: true, required: true,
}, },
dark: Boolean, dark: Boolean,
disabled: Boolean,
}, },
computed: { computed: {
hasClickListener() { hasClickListener() {
@@ -73,6 +87,27 @@ export default {
click(e) { click(e) {
this.$emit('click', e); this.$emit('click', e);
}, },
disabled(i) {
if (!this.context.editPermission) return true;
// Use these if only the next filled or empty slot can be clicked
// if (this.model.value === i) return false;
// if (this.model.value === i - 1) return false;
// return true
return false;
},
damageProperty({type, value, ack}) {
damageProperty.call({
_id: this.model._id,
operation: type,
value: value
}, error => {
if (ack) ack(error);
if (error) {
snackbar({ text: error.reason || error.message || error.toString() });
console.error(error);
}
});
},
}, },
}; };
</script> </script>