mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-09 14:18:10 +02:00
Added drag/drop for features onto adversary/environment settings
This commit is contained in:
parent
c3b8def6b1
commit
424335a3f2
3 changed files with 36 additions and 4 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue