From d63ad9ea8fd966d2e5f6a1f01aa0ee16db225818 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 3 Nov 2022 20:39:02 +0200 Subject: [PATCH] Added hide when total/value zero to attributes --- app/imports/api/properties/Attributes.js | 8 ++ .../character/characterSheetTabs/StatsTab.vue | 4 + .../attributes/HealthBarCardContainer.vue | 4 + .../ui/properties/forms/AttributeForm.vue | 88 ++++++++++++++----- 4 files changed, 84 insertions(+), 20 deletions(-) diff --git a/app/imports/api/properties/Attributes.js b/app/imports/api/properties/Attributes.js index d486d5f9..a2681d33 100644 --- a/app/imports/api/properties/Attributes.js +++ b/app/imports/api/properties/Attributes.js @@ -107,6 +107,14 @@ let AttributeSchema = createPropertySchema({ type: Boolean, optional: true, }, + hideWhenTotalZero: { + type: Boolean, + optional: true, + }, + hideWhenValueZero: { + type: Boolean, + optional: true, + }, // Automatically zero the adjustment on these conditions reset: { type: String, diff --git a/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue b/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue index e8122e32..a201c69c 100644 --- a/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue +++ b/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue @@ -365,6 +365,10 @@ const getProperties = function (creature, filter, options = { filter.removed = { $ne: true }; filter.inactive = { $ne: true }; filter.overridden = { $ne: true }; + filter.$nor = [ + { hideWhenTotalZero: true, total: 0 }, + { hideWhenValueZero: true, value: 0 }, + ]; return CreatureProperties.find(filter, options); }; diff --git a/app/imports/ui/properties/components/attributes/HealthBarCardContainer.vue b/app/imports/ui/properties/components/attributes/HealthBarCardContainer.vue index 639beee0..db3b9c66 100644 --- a/app/imports/ui/properties/components/attributes/HealthBarCardContainer.vue +++ b/app/imports/ui/properties/components/attributes/HealthBarCardContainer.vue @@ -42,6 +42,10 @@ export default { removed: { $ne: true }, inactive: { $ne: true }, overridden: { $ne: true }, + $nor: [ + { hideWhenTotalZero: true, total: 0 }, + { hideWhenValueZero: true, value: 0 }, + ], }; if (creature.settings.hideUnusedStats) { filter.hide = { $ne: true }; diff --git a/app/imports/ui/properties/forms/AttributeForm.vue b/app/imports/ui/properties/forms/AttributeForm.vue index 42814d86..4dc36f07 100644 --- a/app/imports/ui/properties/forms/AttributeForm.vue +++ b/app/imports/ui/properties/forms/AttributeForm.vue @@ -151,26 +151,74 @@ @change="change('tags', ...arguments)" />
- - - + + + + + + + + + + + + + + + + +