From e55ef9fd9e9a3cd32ef5fee0726b317b3275aa32 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Wed, 8 Jul 2026 14:57:10 -0400 Subject: [PATCH] Support vaulting and unvaulting domain cards via dragdrop (#2070) --- lang/en.json | 2 +- .../applications/sheets/actors/character.mjs | 16 +++- templates/sheets/actors/character/loadout.hbs | 83 ++++++++++--------- templates/sheets/actors/character/sidebar.hbs | 11 ++- .../partials/inventory-fieldset-items-V2.hbs | 2 +- 5 files changed, 63 insertions(+), 51 deletions(-) diff --git a/lang/en.json b/lang/en.json index 6d886bc1..7863fb67 100755 --- a/lang/en.json +++ b/lang/en.json @@ -3233,7 +3233,7 @@ "beastformToManyAdvantages": "You cannot select any more advantages.", "beastformToManyFeatures": "You cannot select any more features.", "beastformEquipWeapon": "You cannot use weapons while in a Beastform.", - "loadoutMaxReached": "You've reached maximum loadout. Move atleast one domain card to the vault, or increase the limit in homebrew settings if desired.", + "loadoutMaxReached": "You've reached the maximum loadout size. To add more, move at least one domain card to the vault.", "domainMaxReached": "You've reached the maximum domains for the class. Increase the limit in homebrew settings if desired.", "insufficientResources": "You don't have enough resources to use that action.", "actionNoUsesRemaining": "That action doesn't have remaining uses.", diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index 5006e9d6..b5c04f78 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -914,7 +914,7 @@ export default class CharacterSheet extends DHBaseActorSheet { const doc = await getDocFromElement(button); const { available } = this.document.system.loadoutSlot; if (doc.system.inVault && !available && !doc.system.loadoutIgnore) { - return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.loadoutMaxReached')); + return ui.notifications.warn('DAGGERHEART.UI.Notifications.loadoutMaxReached', { localize: true }); } await doc?.update({ 'system.inVault': !doc.system.inVault }); @@ -1206,10 +1206,22 @@ export default class CharacterSheet extends DHBaseActorSheet { if (!confirmed) return; } - if (this.document.uuid === item.parent?.uuid) { + // Check for same actor drag/drop attempts + const isSameActor = this.document.uuid === item.parent?.uuid; + const loadoutFieldset = event.target.closest('[data-in-vault]'); + const vaulting = loadoutFieldset?.dataset.inVault === 'true'; + if (isSameActor && loadoutFieldset && item.type === 'domainCard' && vaulting !== item.system.inVault) { + // This is likely an attempt to vault or unvault an item + const { available } = this.document.system.loadoutSlot; + if (!vaulting && !available && !item.system.loadoutIgnore) { + return ui.notifications.warn('DAGGERHEART.UI.Notifications.loadoutMaxReached', { localize: true }); + } + return item.update({ 'system.inVault': vaulting }); + } else if (isSameActor) { return super._onDropItem(event, item); } + // Handle beastforms if (item.type === 'beastform') { if (this.document.effects.find(x => x.type === 'beastform')) { return ui.notifications.warn( diff --git a/templates/sheets/actors/character/loadout.hbs b/templates/sheets/actors/character/loadout.hbs index 9ba3fb04..41c205f1 100644 --- a/templates/sheets/actors/character/loadout.hbs +++ b/templates/sheets/actors/character/loadout.hbs @@ -1,42 +1,43 @@ -
-
- - - - - -
- -
- {{> 'daggerheart.inventory-items' - title='DAGGERHEART.GENERAL.Tabs.loadout' - type='domainCard' - isGlassy=true - cardView=cardView - collection=document.system.domainCards.loadout - canCreate=@root.editable - }} - {{> 'daggerheart.inventory-items' - title='DAGGERHEART.GENERAL.Tabs.vault' - type='domainCard' - isGlassy=true - cardView=cardView - collection=document.system.domainCards.vault - canCreate=@root.editable - inVault=true - }} -
+
+
+ + + + + +
+ +
+ {{> 'daggerheart.inventory-items' + title='DAGGERHEART.GENERAL.Tabs.loadout' + type='domainCard' + isGlassy=true + cardView=cardView + collection=document.system.domainCards.loadout + canCreate=@root.editable + inVault=false + }} + {{> 'daggerheart.inventory-items' + title='DAGGERHEART.GENERAL.Tabs.vault' + type='domainCard' + isGlassy=true + cardView=cardView + collection=document.system.domainCards.vault + canCreate=@root.editable + inVault=true + }} +
\ No newline at end of file diff --git a/templates/sheets/actors/character/sidebar.hbs b/templates/sheets/actors/character/sidebar.hbs index 6ca858bf..4e729bc5 100644 --- a/templates/sheets/actors/character/sidebar.hbs +++ b/templates/sheets/actors/character/sidebar.hbs @@ -110,7 +110,7 @@ {{/each}} -
+

{{localize "DAGGERHEART.GENERAL.loadout"}}

@@ -118,11 +118,10 @@
    {{#each document.system.domainCards.loadout as |card|}} - {{> 'daggerheart.inventory-item-compact' - item=card - type='domainCard' - }} - + {{> 'daggerheart.inventory-item-compact' + item=card + type='domainCard' + }} {{/each}}
diff --git a/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs b/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs index db2fb6b7..35a37564 100644 --- a/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs +++ b/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs @@ -26,7 +26,7 @@ Parameters: - showActions {boolean} : If true show feature's actions. --}} -
+
{{localize title}} {{#if canCreate}}