Removed floating point small decimal oddities in parts of inventory tab
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
</v-list-item-content>
|
||||
<v-list-item-action>
|
||||
<v-list-item-title>
|
||||
{{ creature.denormalizedStats.weightCarried || 0 }} lb
|
||||
{{ weightCarried }} lb
|
||||
</v-list-item-title>
|
||||
</v-list-item-action>
|
||||
</v-list-item>
|
||||
@@ -107,6 +107,7 @@ import ItemList from '/imports/ui/properties/components/inventory/ItemList.vue';
|
||||
import getParentRefByTag from '/imports/api/creature/creatureProperties/methods/getParentRefByTag.js';
|
||||
import BUILT_IN_TAGS from '/imports/constants/BUILT_IN_TAGS.js';
|
||||
import CoinValue from '/imports/ui/components/CoinValue.vue';
|
||||
import stripFloatingPointOddities from '/imports/ui/utility/stripFloatingPointOddities.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -207,6 +208,11 @@ export default {
|
||||
containerIds(){
|
||||
return this.containers.map(container => container._id);
|
||||
},
|
||||
weightCarried(){
|
||||
return stripFloatingPointOddities(
|
||||
this.creature.denormalizedStats.weightCarried || 0
|
||||
);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
clickProperty(_id){
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
>
|
||||
$vuetify.icons.weight
|
||||
</v-icon>
|
||||
{{ (model.contentsWeightless ? 0 : model.contentsWeight || 0) + (model.weight || 0) }}
|
||||
{{ weight }}
|
||||
</v-toolbar-title>
|
||||
<v-toolbar-title
|
||||
class="layout align-center"
|
||||
@@ -31,7 +31,7 @@
|
||||
$vuetify.icons.two_coins
|
||||
</v-icon>
|
||||
<coin-value
|
||||
:value="(model.contentsValue || 0) + (model.value || 0)"
|
||||
:value="value"
|
||||
/>
|
||||
</v-toolbar-title>
|
||||
</template>
|
||||
@@ -49,6 +49,7 @@ import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
|
||||
import ItemList from '/imports/ui/properties/components/inventory/ItemList.vue';
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||
import CoinValue from '/imports/ui/components/CoinValue.vue';
|
||||
import stripFloatingPointOddities from '/imports/ui/utility/stripFloatingPointOddities.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -62,6 +63,20 @@ export default {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
weight(){
|
||||
const contentWeight = this.model.contentsWeightless ?
|
||||
0 :
|
||||
this.model.contentsWeight || 0;
|
||||
const ownWeight = this.model.weight || 0;
|
||||
return stripFloatingPointOddities(contentWeight + ownWeight);
|
||||
},
|
||||
value(){
|
||||
const contentValue = this.model.contentsValue || 0;
|
||||
const ownValue = this.model.value || 0;
|
||||
return contentValue + ownValue;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickContainer(_id){
|
||||
this.$store.commit('pushDialogStack', {
|
||||
|
||||
@@ -134,6 +134,7 @@ import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyV
|
||||
import CoinValue from '/imports/ui/components/CoinValue.vue';
|
||||
import IncrementButton from '/imports/ui/components/IncrementButton.vue';
|
||||
import adjustQuantity from '/imports/api/creature/creatureProperties/methods/adjustQuantity.js';
|
||||
import stripFloatingPointOddities from '/imports/ui/utility/stripFloatingPointOddities.js';
|
||||
|
||||
export default {
|
||||
components:{
|
||||
@@ -146,10 +147,10 @@ export default {
|
||||
},
|
||||
computed:{
|
||||
totalValue(){
|
||||
return this.model.value * this.model.quantity;
|
||||
return stripFloatingPointOddities(this.model.value * this.model.quantity);
|
||||
},
|
||||
totalWeight(){
|
||||
return this.model.weight * this.model.quantity;
|
||||
return stripFloatingPointOddities(this.model.weight * this.model.quantity);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
3
app/imports/ui/utility/stripFloatingPointOddities.js
Normal file
3
app/imports/ui/utility/stripFloatingPointOddities.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function stripFloatingPointOddities(num, precision = 12){
|
||||
return +parseFloat(num.toPrecision(precision))
|
||||
}
|
||||
Reference in New Issue
Block a user