Item quantity adjustment button now shows loading while in progress
This commit is contained in:
@@ -10,11 +10,12 @@
|
|||||||
<template #activator="{ on }">
|
<template #activator="{ on }">
|
||||||
<v-btn
|
<v-btn
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
|
:loading="loading"
|
||||||
v-on="on"
|
v-on="on"
|
||||||
@click.stop
|
@click.stop
|
||||||
>
|
>
|
||||||
<slot>
|
<slot>
|
||||||
<v-icon>mdi-plus</v-icon>
|
<v-icon>$vuetify.icons.abacus</v-icon>
|
||||||
</slot>
|
</slot>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
@@ -42,6 +43,7 @@ export default {
|
|||||||
type: Number,
|
type: Number,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
loading: Boolean,
|
||||||
},
|
},
|
||||||
data(){return {
|
data(){return {
|
||||||
open: false
|
open: false
|
||||||
|
|||||||
@@ -28,12 +28,9 @@
|
|||||||
color="primary"
|
color="primary"
|
||||||
:disabled="context.editPermission === false"
|
:disabled="context.editPermission === false"
|
||||||
:value="model.quantity"
|
:value="model.quantity"
|
||||||
|
:loading="incrementLoading"
|
||||||
@change="changeQuantity"
|
@change="changeQuantity"
|
||||||
>
|
/>
|
||||||
<v-icon>
|
|
||||||
$vuetify.icons.abacus
|
|
||||||
</v-icon>
|
|
||||||
</increment-button>
|
|
||||||
</v-list-item-action>
|
</v-list-item-action>
|
||||||
<v-list-item-action>
|
<v-list-item-action>
|
||||||
<v-icon
|
<v-icon
|
||||||
@@ -52,6 +49,7 @@ import treeNodeViewMixin from '/imports/ui/properties/treeNodeViews/treeNodeView
|
|||||||
import PROPERTIES from '/imports/constants/PROPERTIES.js';
|
import PROPERTIES from '/imports/constants/PROPERTIES.js';
|
||||||
import adjustQuantity from '/imports/api/creature/creatureProperties/methods/adjustQuantity.js';
|
import adjustQuantity from '/imports/api/creature/creatureProperties/methods/adjustQuantity.js';
|
||||||
import IncrementButton from '/imports/ui/components/IncrementButton.vue';
|
import IncrementButton from '/imports/ui/components/IncrementButton.vue';
|
||||||
|
import {snackbar} from '/imports/ui/components/snackbars/SnackbarQueue.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components:{
|
components:{
|
||||||
@@ -64,6 +62,9 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
preparingSpells: Boolean,
|
preparingSpells: Boolean,
|
||||||
},
|
},
|
||||||
|
data(){return {
|
||||||
|
incrementLoading: false,
|
||||||
|
}},
|
||||||
computed: {
|
computed: {
|
||||||
hasClickListener(){
|
hasClickListener(){
|
||||||
return this.$listeners && !!this.$listeners.click;
|
return this.$listeners && !!this.$listeners.click;
|
||||||
@@ -89,10 +90,17 @@ export default {
|
|||||||
this.$emit('click', e);
|
this.$emit('click', e);
|
||||||
},
|
},
|
||||||
changeQuantity({type, value}) {
|
changeQuantity({type, value}) {
|
||||||
|
this.incrementLoading = true;
|
||||||
adjustQuantity.call({
|
adjustQuantity.call({
|
||||||
_id: this.model._id,
|
_id: this.model._id,
|
||||||
operation: type,
|
operation: type,
|
||||||
value: value
|
value: value
|
||||||
|
}, error => {
|
||||||
|
this.incrementLoading = false;
|
||||||
|
if (error){
|
||||||
|
snackbar({text: error.reason});
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -31,12 +31,9 @@
|
|||||||
tile
|
tile
|
||||||
color="primary"
|
color="primary"
|
||||||
:value="model.value"
|
:value="model.value"
|
||||||
|
:loading="damagePropertyLoading"
|
||||||
@change="damageProperty"
|
@change="damageProperty"
|
||||||
>
|
/>
|
||||||
<v-icon>
|
|
||||||
$vuetify.icons.abacus
|
|
||||||
</v-icon>
|
|
||||||
</increment-button>
|
|
||||||
</property-field>
|
</property-field>
|
||||||
<property-field
|
<property-field
|
||||||
v-if="model.modifier !== undefined"
|
v-if="model.modifier !== undefined"
|
||||||
@@ -144,6 +141,7 @@
|
|||||||
import damageProperty from '/imports/api/creature/creatureProperties/methods/damageProperty.js';
|
import damageProperty from '/imports/api/creature/creatureProperties/methods/damageProperty.js';
|
||||||
import IncrementButton from '/imports/ui/components/IncrementButton.vue';
|
import IncrementButton from '/imports/ui/components/IncrementButton.vue';
|
||||||
import getProficiencyIcon from '/imports/ui/utility/getProficiencyIcon.js';
|
import getProficiencyIcon from '/imports/ui/utility/getProficiencyIcon.js';
|
||||||
|
import {snackbar} from '/imports/ui/components/snackbars/SnackbarQueue.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -172,6 +170,7 @@
|
|||||||
0.5: 'Half proficiency bonus rounded up',
|
0.5: 'Half proficiency bonus rounded up',
|
||||||
2: 'Double proficiency bonus',
|
2: 'Double proficiency bonus',
|
||||||
},
|
},
|
||||||
|
damagePropertyLoading: false,
|
||||||
}},
|
}},
|
||||||
computed: {
|
computed: {
|
||||||
reset(){
|
reset(){
|
||||||
@@ -197,10 +196,17 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
damageProperty({type, value}) {
|
damageProperty({type, value}) {
|
||||||
|
this.damagePropertyLoading = true;
|
||||||
damageProperty.call({
|
damageProperty.call({
|
||||||
_id: this.model._id,
|
_id: this.model._id,
|
||||||
operation: type,
|
operation: type,
|
||||||
value: value
|
value: value
|
||||||
|
}, error => {
|
||||||
|
this.damagePropertyLoading = false;
|
||||||
|
if (error){
|
||||||
|
snackbar({text: error.reason});
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,11 +15,10 @@
|
|||||||
large
|
large
|
||||||
outlined
|
outlined
|
||||||
color="primary"
|
color="primary"
|
||||||
|
:loading="incrementLoading"
|
||||||
:value="model.quantity"
|
:value="model.quantity"
|
||||||
@change="changeQuantity"
|
@change="changeQuantity"
|
||||||
>
|
/>
|
||||||
<v-icon>$vuetify.icons.abacus</v-icon>
|
|
||||||
</increment-button>
|
|
||||||
</property-field>
|
</property-field>
|
||||||
<property-field
|
<property-field
|
||||||
v-if="model.value !== undefined"
|
v-if="model.value !== undefined"
|
||||||
@@ -152,6 +151,7 @@ import CoinValue from '/imports/ui/components/CoinValue.vue';
|
|||||||
import IncrementButton from '/imports/ui/components/IncrementButton.vue';
|
import IncrementButton from '/imports/ui/components/IncrementButton.vue';
|
||||||
import adjustQuantity from '/imports/api/creature/creatureProperties/methods/adjustQuantity.js';
|
import adjustQuantity from '/imports/api/creature/creatureProperties/methods/adjustQuantity.js';
|
||||||
import stripFloatingPointOddities from '/imports/api/engine/computation/utility/stripFloatingPointOddities.js';
|
import stripFloatingPointOddities from '/imports/api/engine/computation/utility/stripFloatingPointOddities.js';
|
||||||
|
import {snackbar} from '/imports/ui/components/snackbars/SnackbarQueue.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components:{
|
components:{
|
||||||
@@ -162,6 +162,9 @@ export default {
|
|||||||
inject: {
|
inject: {
|
||||||
context: { default: {} }
|
context: { default: {} }
|
||||||
},
|
},
|
||||||
|
data(){return {
|
||||||
|
incrementLoading: false,
|
||||||
|
}},
|
||||||
computed:{
|
computed:{
|
||||||
totalValue(){
|
totalValue(){
|
||||||
return stripFloatingPointOddities(this.model.value * this.model.quantity);
|
return stripFloatingPointOddities(this.model.value * this.model.quantity);
|
||||||
@@ -182,12 +185,19 @@ export default {
|
|||||||
return SVG_ICONS[name];
|
return SVG_ICONS[name];
|
||||||
},
|
},
|
||||||
changeQuantity({type, value}) {
|
changeQuantity({type, value}) {
|
||||||
|
this.incrementLoading = true;
|
||||||
adjustQuantity.call({
|
adjustQuantity.call({
|
||||||
_id: this.model._id,
|
_id: this.model._id,
|
||||||
operation: type,
|
operation: type,
|
||||||
value: value
|
value: value
|
||||||
|
}, error => {
|
||||||
|
this.incrementLoading = false;
|
||||||
|
if (error){
|
||||||
|
snackbar({text: error.reason});
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user