This commit is contained in:
WBHarry 2025-08-28 02:05:00 +02:00
parent 2487c200e5
commit 4dfc18f727
3 changed files with 12 additions and 2 deletions

View file

@ -134,6 +134,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
});
htmlElement.querySelectorAll('.inventory-item-quantity').forEach(element => {
element.addEventListener('change', this.updateItemQuantity.bind(this));
element.addEventListener('click', e => e.stopPropagation());
});
// Add listener for armor marks input
@ -679,7 +680,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
})
});
if(result) game.system.api.fields.ActionFields.CostField.execute.call(this, result);
if (result) game.system.api.fields.ActionFields.CostField.execute.call(this, result);
}
//TODO: redo toggleEquipItem method

View file

@ -28,4 +28,13 @@ export default class DHConsumable extends BaseDataItem {
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/round-potion.svg';
async _preUpdate(changes, options, userId) {
const allowed = await super._preUpdate(changes, options, userId);
if (allowed === false) return;
if (changes.system?.quantity !== undefined && Number(changes.system.quantity) === 0) {
this.parent.delete();
return;
}
}
}

View file

@ -65,7 +65,7 @@ Parameters:
{{#if (and (not hideResources) (eq item.system.resource.type 'simple'))}}
{{> "systems/daggerheart/templates/sheets/global/partials/item-resource.hbs"}}
{{/if}}
{{#if (and (not hideResources) item.system.quantity)}}
{{#if (and (not hideResources) (gte item.system.quantity 0))}}
<div class="item-resource">
<input type="number" class="inventory-item-quantity" value="{{item.system.quantity}}" min="0" />
</div>