add toggleEquipped action

This commit is contained in:
jalensailin
2025-07-18 22:48:02 -04:00
parent 05a38c9616
commit e80430ddaf
2 changed files with 21 additions and 28 deletions
+7 -16
View File
@@ -28,6 +28,7 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
clearBondDamage: DeltaGreenActorSheet._clearBondDamage,
toggleItemSortMode: DeltaGreenActorSheet._toggleItemSortMode,
toggleShowUntrained: DeltaGreenActorSheet._toggleShowUntrained,
toggleEquipped: DeltaGreenActorSheet._toggleEquipped,
},
});
@@ -783,10 +784,6 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
/** @override */
activateListeners(html) {
html
.find(".equipped-item")
.mousedown(this._onEquippedStatusChange.bind(this));
// Drag events for macros.
if (this.actor.isOwner) {
const handler = (ev) => this._onDragStart(ev);
@@ -1339,20 +1336,14 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
this.actor.update({ system: updatedData });
}
_onEquippedStatusChange(event) {
static _toggleEquipped(event, target) {
event.preventDefault();
const element = event.currentTarget;
const { dataset } = element;
const { id } = target.dataset;
const item = this.actor.items.get(id);
try {
// const item = this.actor.getOwnedItem(dataset.id);
const item = this.actor.items.get(dataset.id);
let isEquipped = item.system.equipped;
isEquipped = !isEquipped;
item.update({ system: { equipped: isEquipped } });
} catch (ex) {
console.log(ex);
}
const targetProp = "system.equipped";
const currentVal = foundry.utils.getProperty(item, targetProp);
item.update({ [targetProp]: !currentVal });
}
// For any skills a user has checked off as failed, roll the improvement and update the agent's skills to their new values
+14 -12
View File
@@ -174,15 +174,16 @@
<span class="centered-item-property">{{item.system.protection}}</span>
<span class="equipped-item centered-item-property"
data-id="{{item._id}}"
title="{{localize 'DG.Tooltip.ToggleEquippedState'}}">
<a class="centered-item-property"
data-action="toggleEquipped"
data-id="{{item._id}}"
title="{{localize 'DG.Tooltip.ToggleEquippedState'}}">
{{#if item.system.equipped }}
<span class="fas fa-check"></span>
<i class="fas fa-check"></i>
{{else}}
<span class="fas fa-times"></span>
<i class="fas fa-times"></i>
{{/if}}
</span>
</a>
<div class="item-controls">
<a class="item-control"
@@ -247,15 +248,16 @@
<h4 style="word-wrap: break-word; min-width: 55%;" class="item-name">{{item.name}}</h4>
<span class="equipped-item centered-item-property"
data-id="{{item._id}}"
title="{{localize 'DG.Tooltip.ToggleEquippedState'}}">
<a class="centered-item-property"
data-action="toggleEquipped"
data-id="{{item._id}}"
title="{{localize 'DG.Tooltip.ToggleEquippedState'}}">
{{#if item.system.equipped }}
<span class="fas fa-check"></span>
<i class="fas fa-check"></i>
{{else}}
<span class="fas fa-times"></span>
<i class="fas fa-times"></i>
{{/if}}
</span>
</a>
<div class="item-controls">
<a class="item-control"