From 04040203351851f875b1dc988dc5fb83ec9db79d Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Wed, 24 Feb 2021 14:07:20 +0200 Subject: [PATCH] Added weights and content weight to containers UI --- .../denormalise/recomputeInventory.js | 3 + app/imports/api/parenting/organizeMethods.js | 10 ++- .../characterSheetTabs/InventoryTab.vue | 2 +- .../components/inventory/ContainerCard.vue | 27 ++++++++ .../ui/properties/viewers/ContainerViewer.vue | 61 +++++++++++++++++-- 5 files changed, 94 insertions(+), 9 deletions(-) diff --git a/app/imports/api/creature/denormalise/recomputeInventory.js b/app/imports/api/creature/denormalise/recomputeInventory.js index fbdaf935..b5754330 100644 --- a/app/imports/api/creature/denormalise/recomputeInventory.js +++ b/app/imports/api/creature/denormalise/recomputeInventory.js @@ -88,6 +88,9 @@ function getInventoryData(tree, containersToWrite){ data.weightCarried = 0; data.valueCarried = 0; } + if (node.contentsWeightless){ + data.weightCarried = node.weight; + } return data } diff --git a/app/imports/api/parenting/organizeMethods.js b/app/imports/api/parenting/organizeMethods.js index 93263848..624a2525 100644 --- a/app/imports/api/parenting/organizeMethods.js +++ b/app/imports/api/parenting/organizeMethods.js @@ -10,7 +10,7 @@ import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js'; import getCollectionByName from '/imports/api/parenting/getCollectionByName.js'; import { recomputeCreatureById } from '/imports/api/creature/computation/methods/recomputeCreature.js'; import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js'; - +import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js'; const organizeDoc = new ValidatedMethod({ name: 'organize.organizeDoc', validate: new SimpleSchema({ @@ -20,7 +20,10 @@ const organizeDoc = new ValidatedMethod({ type: Number, // Should end in 0.5 to place it reliably between two existing documents }, - skipRecompute: Boolean, + skipRecompute: { + type: Boolean, + optional: true, + }, }).validator(), mixins: [RateLimiterMixin], rateLimit: { @@ -60,6 +63,9 @@ const organizeDoc = new ValidatedMethod({ // The active status of some properties might change due to a change in // ancestry recomputeInactiveProperties(id); + if (doc.type === 'container' || doc.type === 'item'){ + recomputeInventory(id); + } // Some Dependencies depend on ancestry, so a full recompute is needed recomputeCreatureById(id); }); diff --git a/app/imports/ui/creature/character/characterSheetTabs/InventoryTab.vue b/app/imports/ui/creature/character/characterSheetTabs/InventoryTab.vue index 80359410..b16cf9c5 100644 --- a/app/imports/ui/creature/character/characterSheetTabs/InventoryTab.vue +++ b/app/imports/ui/creature/character/characterSheetTabs/InventoryTab.vue @@ -15,7 +15,7 @@ - {{ creature.denormalizedStats.weightCarried || 0 }} lbs + {{ creature.denormalizedStats.weightCarried || 0 }} lb diff --git a/app/imports/ui/properties/components/inventory/ContainerCard.vue b/app/imports/ui/properties/components/inventory/ContainerCard.vue index 3fada354..bf68a64f 100644 --- a/app/imports/ui/properties/components/inventory/ContainerCard.vue +++ b/app/imports/ui/properties/components/inventory/ContainerCard.vue @@ -9,6 +9,31 @@ {{ model.name }} + + + $vuetify.icons.weight + + {{ (model.contentsWeight || 0) + (model.weight || 0) }} + + + + $vuetify.icons.two_coins + + +
-
-
+ + $vuetify.icons.cash + + + + contents + + +
+
+ {{ model.weight }} lb @@ -41,6 +61,35 @@ $vuetify.icons.weight + + + + + $vuetify.icons.injustice + +