diff --git a/module/applications/sheets-configs/adversary-settings.mjs b/module/applications/sheets-configs/adversary-settings.mjs index 675f07ff..e3549efc 100644 --- a/module/applications/sheets-configs/adversary-settings.mjs +++ b/module/applications/sheets-configs/adversary-settings.mjs @@ -5,6 +5,7 @@ export default class DHAdversarySettings extends HandlebarsApplicationMixin(Appl super({}); this.actor = actor; + this._dragDrop = this._createDragDropHandlers(); } get title() { @@ -30,7 +31,8 @@ export default class DHAdversarySettings extends HandlebarsApplicationMixin(Appl handler: this.updateForm, submitOnChange: true, closeOnSubmit: false - } + }, + dragDrop: [{ dragSelector: null, dropSelector: '.tab.features' }] }; static PARTS = { @@ -103,6 +105,21 @@ export default class DHAdversarySettings extends HandlebarsApplicationMixin(Appl return context; } + _attachPartListeners(partId, htmlElement, options) { + super._attachPartListeners(partId, htmlElement, options); + + this._dragDrop.forEach(d => d.bind(htmlElement)); + } + + _createDragDropHandlers() { + return this.options.dragDrop.map(d => { + d.callbacks = { + drop: this._onDrop.bind(this) + }; + return new foundry.applications.ux.DragDrop.implementation(d); + }); + } + _getTabs(tabs) { for (const v of Object.values(tabs)) { v.active = this.tabGroups[v.group] ? this.tabGroups[v.group] === v.id : v.active; @@ -152,4 +169,13 @@ export default class DHAdversarySettings extends HandlebarsApplicationMixin(Appl await this.actor.update(formData.object); this.render(); } + + async _onDrop(event) { + const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event); + const item = await fromUuid(data.uuid); + if (item.type === 'feature') { + await this.actor.createEmbeddedDocuments('Item', [item]); + this.render(); + } + } } diff --git a/module/applications/sheets-configs/environment-settings.mjs b/module/applications/sheets-configs/environment-settings.mjs index c8dd2a49..5f627ffc 100644 --- a/module/applications/sheets-configs/environment-settings.mjs +++ b/module/applications/sheets-configs/environment-settings.mjs @@ -34,7 +34,10 @@ export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(Ap submitOnChange: true, closeOnSubmit: false }, - dragDrop: [{ dragSelector: null, dropSelector: '.category-container' }] + dragDrop: [ + { dragSelector: null, dropSelector: '.category-container' }, + { dragSelector: null, dropSelector: '.tab.features' } + ] }; static PARTS = { @@ -175,7 +178,7 @@ export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(Ap async _onDrop(event) { const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event); const item = await fromUuid(data.uuid); - if (item.type === 'adversary') { + if (item.type === 'adversary' && event.target.closest('.category-container')) { const target = event.target.closest('.category-container'); const path = `system.potentialAdversaries.${target.dataset.potentialAdversary}.adversaries`; const current = foundry.utils.getProperty(this.actor, path).map(x => x.uuid); @@ -183,6 +186,9 @@ export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(Ap [path]: [...current, item.uuid] }); this.render(); + } else if (item.type === 'feature' && event.target.closest('.tab.features')) { + await this.actor.createEmbeddedDocuments('Item', [item]); + this.render(); } } diff --git a/templates/sheets/actors/environment/features.hbs b/templates/sheets/actors/environment/features.hbs index 2f8ae823..fb0d0e69 100644 --- a/templates/sheets/actors/environment/features.hbs +++ b/templates/sheets/actors/environment/features.hbs @@ -4,6 +4,6 @@ data-group='{{tabs.features.group}}' >
- {{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize tabs.actions.label) type='action'}} + {{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize tabs.features.label) type='feature'}}
\ No newline at end of file