Added delete icon to inventory

This commit is contained in:
WBHarry 2025-11-07 16:43:21 +01:00
parent c96cd2beac
commit a23061a8be
7 changed files with 115 additions and 77 deletions

View file

@ -2679,7 +2679,8 @@
"remainingUses": "Uses refresh on {type}", "remainingUses": "Uses refresh on {type}",
"rightClickExtand": "Right-Click to extand", "rightClickExtand": "Right-Click to extand",
"companionPartnerLevelBlock": "The companion needs an assigned partner to level up.", "companionPartnerLevelBlock": "The companion needs an assigned partner to level up.",
"configureAttribution": "Configure Attribution" "configureAttribution": "Configure Attribution",
"deleteItem": "Delete Item"
} }
} }
} }

View file

@ -26,6 +26,7 @@ export default class Party extends DHBaseActorSheet {
}, },
actions: { actions: {
deletePartyMember: Party.#deletePartyMember, deletePartyMember: Party.#deletePartyMember,
deleteItem: Party.#deleteItem,
toggleHope: Party.#toggleHope, toggleHope: Party.#toggleHope,
toggleHitPoints: Party.#toggleHitPoints, toggleHitPoints: Party.#toggleHitPoints,
toggleStress: Party.#toggleStress, toggleStress: Party.#toggleStress,
@ -468,23 +469,44 @@ export default class Party extends DHBaseActorSheet {
} }
} }
static async #deletePartyMember(_event, target) { static async #deletePartyMember(event, target) {
const doc = await getDocFromElement(target.closest('.inventory-item')); const doc = await getDocFromElement(target.closest('.inventory-item'));
const confirmed = await foundry.applications.api.DialogV2.confirm({ if (!event.shiftKey) {
window: { const confirmed = await foundry.applications.api.DialogV2.confirm({
title: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.title', { window: {
type: game.i18n.localize('TYPES.Actor.adversary'), title: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.title', {
name: doc.name type: game.i18n.localize('TYPES.Actor.adversary'),
}) name: doc.name
}, })
content: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.text', { name: doc.name }) },
}); content: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.text', { name: doc.name })
});
if (!confirmed) return; if (!confirmed) return;
}
const currentMembers = this.document.system.partyMembers.map(x => x.uuid); const currentMembers = this.document.system.partyMembers.map(x => x.uuid);
const newMemberdList = currentMembers.filter(uuid => uuid !== doc.uuid); const newMemberdList = currentMembers.filter(uuid => uuid !== doc.uuid);
await this.document.update({ 'system.partyMembers': newMemberdList }); await this.document.update({ 'system.partyMembers': newMemberdList });
} }
static async #deleteItem(event, target) {
const doc = await getDocFromElement(target.closest('.inventory-item'));
if (!event.shiftKey) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.title', {
type: game.i18n.localize('TYPES.Actor.party'),
name: doc.name
})
},
content: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.text', { name: doc.name })
});
if (!confirmed) return;
}
this.document.deleteEmbeddedDocuments('Item', [doc.id]);
}
} }

View file

@ -27,10 +27,10 @@ export default class DhParty extends BaseDataActor {
prepareBaseData() { prepareBaseData() {
super.prepareBaseData(); super.prepareBaseData();
this.partyMembers = this.partyMembers.filter((p) => !!p); this.partyMembers = this.partyMembers.filter(p => !!p);
// Register this party to all members // Register this party to all members
if (fromUuidSync(this.parent.uuid) === this.parent) { if (game.actors.get(this.parent.id) === this.parent) {
for (const member of this.partyMembers) { for (const member of this.partyMembers) {
member.parties?.add(this.parent); member.parties?.add(this.parent);
} }

View file

@ -76,7 +76,7 @@ export default class DhpActor extends Actor {
// Configure prototype token settings // Configure prototype token settings
const prototypeToken = {}; const prototypeToken = {};
if (['character', 'companion'].includes(this.type)) if (['character', 'companion', 'party'].includes(this.type))
Object.assign(prototypeToken, { Object.assign(prototypeToken, {
sight: { enabled: true }, sight: { enabled: true },
actorLink: true, actorLink: true,

View file

@ -43,36 +43,40 @@
{{> 'daggerheart.inventory-items' {{> 'daggerheart.inventory-items'
title='TYPES.Item.weapon' title='TYPES.Item.weapon'
type='weapon' type='weapon'
actorType='party'
collection=document.itemTypes.weapon collection=document.itemTypes.weapon
isGlassy=true isGlassy=true
canCreate=true canCreate=true
hideResources=true hideResources=true
hideControls=true hideContextMenu=true
}} }}
{{> 'daggerheart.inventory-items' {{> 'daggerheart.inventory-items'
title='TYPES.Item.armor' title='TYPES.Item.armor'
type='armor' type='armor'
actorType='party'
collection=document.itemTypes.armor collection=document.itemTypes.armor
isGlassy=true isGlassy=true
canCreate=true canCreate=true
hideResources=true hideResources=true
hideControls=true hideContextMenu=true
}} }}
{{> 'daggerheart.inventory-items' {{> 'daggerheart.inventory-items'
title='TYPES.Item.consumable' title='TYPES.Item.consumable'
type='consumable' type='consumable'
actorType='party'
collection=document.itemTypes.consumable collection=document.itemTypes.consumable
isGlassy=true isGlassy=true
canCreate=true canCreate=true
hideControls=true hideContextMenu=true
}} }}
{{> 'daggerheart.inventory-items' {{> 'daggerheart.inventory-items'
title='TYPES.Item.loot' title='TYPES.Item.loot'
type='loot' type='loot'
actorType='party'
collection=document.itemTypes.loot collection=document.itemTypes.loot
isGlassy=true isGlassy=true
canCreate=true canCreate=true
hideControls=true hideContextMenu=true
}} }}
</div> </div>
</section> </section>

View file

@ -10,6 +10,7 @@ Parameters:
- isGlassy {boolean} : If true, applies the 'glassy' class to the fieldset. - isGlassy {boolean} : If true, applies the 'glassy' class to the fieldset.
- cardView {boolean} : If true and type is 'domainCard', renders using domain card layout. - cardView {boolean} : If true and type is 'domainCard', renders using domain card layout.
- isActor {boolean} : Passed through to inventory-item partials. - isActor {boolean} : Passed through to inventory-item partials.
- actorType {boolean} : The actor type of the parent actor
- canCreate {boolean} : If true, show createDoc anchor on legend - canCreate {boolean} : If true, show createDoc anchor on legend
- inVault {boolean} : If true, the domainCard is created with inVault=true - inVault {boolean} : If true, the domainCard is created with inVault=true
- disabled {boolean}: If true, the ActiveEffect is created with disabled=true; - disabled {boolean}: If true, the ActiveEffect is created with disabled=true;
@ -17,6 +18,7 @@ Parameters:
- showLabels {boolean} : If true, show label-tags else show simple tags. - showLabels {boolean} : If true, show label-tags else show simple tags.
- hideTooltip {boolean} : If true, disables the tooltip on the item image. - hideTooltip {boolean} : If true, disables the tooltip on the item image.
- hideControls {boolean} : If true, hides the controls inside inventory-item partials. - hideControls {boolean} : If true, hides the controls inside inventory-item partials.
- simpleDelete {boolean} : if true, uses only a delete button for controls.
- hideDescription {boolean} : If true, hides the item's description. - hideDescription {boolean} : If true, hides the item's description.
- hideResources {boolean} : If true, hides the item's resources. - hideResources {boolean} : If true, hides the item's resources.
- showActions {boolean} : If true show feature's actions. - showActions {boolean} : If true show feature's actions.
@ -54,6 +56,7 @@ Parameters:
{{> 'daggerheart.inventory-item' {{> 'daggerheart.inventory-item'
item=item item=item
type=../type type=../type
actorType=../actorType
hideControls=../hideControls hideControls=../hideControls
hideContextMenu=../hideContextMenu hideContextMenu=../hideContextMenu
isActor=../isActor isActor=../isActor

View file

@ -4,6 +4,7 @@
Parameters: Parameters:
- type {string} : The type of items in the list - type {string} : The type of items in the list
- isActor {boolean} : Passed through to inventory-item partials. - isActor {boolean} : Passed through to inventory-item partials.
- actorType {boolean} : The actor type of the parent actor
- categoryAdversary {string} : Category adversary id. - categoryAdversary {string} : Category adversary id.
- noExtensible {boolean} : If true, the inventory-item-content would be collapsable/extendible else it always be showed - noExtensible {boolean} : If true, the inventory-item-content would be collapsable/extendible else it always be showed
- hideLabels {boolean} : If true, hide label-tags else show label-tags. - hideLabels {boolean} : If true, hide label-tags else show label-tags.
@ -95,17 +96,24 @@ Parameters:
</a> </a>
{{/if}} {{/if}}
{{else}} {{else}}
{{#if (eq type 'weapon')}} {{#unless (eq actorType 'party')}}
<a class="{{#unless item.system.equipped}}unequipped{{/unless}}" data-action="toggleEquipItem" {{#if (eq type 'weapon')}}
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.equipped 'unequip' 'equip' }}"> <a class="{{#unless item.system.equipped}}unequipped{{/unless}}" data-action="toggleEquipItem"
<i class="fa-solid fa-hands"></i> data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.equipped 'unequip' 'equip' }}">
</a> <i class="fa-solid fa-hands"></i>
{{else if (eq type 'armor')}} </a>
<a class="{{#unless item.system.equipped}}unequipped{{/unless}}" data-action="toggleEquipItem" {{else if (eq type 'armor')}}
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.equipped 'unequip' 'equip' }}"> <a class="{{#unless item.system.equipped}}unequipped{{/unless}}" data-action="toggleEquipItem"
<i class="fa-solid fa-shield"></i> data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.equipped 'unequip' 'equip' }}">
</a> <i class="fa-solid fa-shield"></i>
{{else if (eq type 'domainCard')}} </a>
{{/if}}
{{else}}
<a data-action="deleteItem" data-tooltip="DAGGERHEART.UI.Tooltip.deleteItem">
<i class="fa-solid fa-trash"></i>
</a>
{{/unless}}
{{#if (eq type 'domainCard')}}
<a data-action="toggleVault" <a data-action="toggleVault"
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.inVault 'sendToLoadout' 'sendToVault' }}"> data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.inVault 'sendToLoadout' 'sendToVault' }}">
<i class="fa-solid {{ifThen item.system.inVault 'fa-arrow-up' 'fa-arrow-down'}}"></i> <i class="fa-solid {{ifThen item.system.inVault 'fa-arrow-up' 'fa-arrow-down'}}"></i>
@ -116,7 +124,7 @@ Parameters:
<i class="{{ifThen item.disabled 'fa-solid fa-toggle-off' 'fa-solid fa-toggle-on'}}"></i> <i class="{{ifThen item.disabled 'fa-solid fa-toggle-off' 'fa-solid fa-toggle-on'}}"></i>
</a> </a>
{{/if}} {{/if}}
{{#if (hasProperty item "toChat")}} {{#if (and (hasProperty item "toChat") (not (eq actorType 'party')))}}
<a data-action="toChat" data-tooltip="DAGGERHEART.UI.Tooltip.sendToChat"> <a data-action="toChat" data-tooltip="DAGGERHEART.UI.Tooltip.sendToChat">
<i class="fa-regular fa-message"></i> <i class="fa-regular fa-message"></i>
</a> </a>