Added drag/drop for features onto adversary/environment settings

This commit is contained in:
WBHarry 2025-07-05 03:01:43 +02:00
parent c3b8def6b1
commit 424335a3f2
3 changed files with 36 additions and 4 deletions

View file

@ -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();
}
}