mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
Support drag resort on features in actor setting sheets (#2023)
This commit is contained in:
parent
6f1da42735
commit
6b80a6243c
9 changed files with 52 additions and 88 deletions
|
|
@ -1,13 +1,15 @@
|
|||
import DHApplicationMixin from './application-mixin.mjs';
|
||||
const { DocumentSheetV2 } = foundry.applications.api;
|
||||
const { ActorSheetV2 } = foundry.applications.sheets;
|
||||
|
||||
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
|
||||
/**
|
||||
* @typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base settings sheet for Daggerheart actors.
|
||||
* @extends {DHApplicationMixin<DocumentSheetV2>}
|
||||
* @extends {DHApplicationMixin<ActorSheetV2>}
|
||||
*/
|
||||
export default class DHBaseActorSettings extends DHApplicationMixin(DocumentSheetV2) {
|
||||
export default class DHBaseActorSettings extends DHApplicationMixin(ActorSheetV2) {
|
||||
/**@inheritdoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ['dialog'],
|
||||
|
|
@ -34,7 +36,7 @@ export default class DHBaseActorSettings extends DHApplicationMixin(DocumentShee
|
|||
return options;
|
||||
}
|
||||
|
||||
/**@returns {foundry.documents.Actor} */
|
||||
/** @returns {foundry.documents.Actor} */
|
||||
get actor() {
|
||||
return this.document;
|
||||
}
|
||||
|
|
@ -73,4 +75,29 @@ export default class DHBaseActorSettings extends DHApplicationMixin(DocumentShee
|
|||
|
||||
return context;
|
||||
}
|
||||
|
||||
async _onDragStart(event) {
|
||||
const featureItemEl = event.currentTarget.closest('.feature-item');
|
||||
const feature = this.actor.items.get(featureItemEl?.dataset.itemId);
|
||||
if (feature && event.target.closest('.tab.features')) {
|
||||
const featureData = { ...feature.toDragData(), fromInternal: true };
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(featureData));
|
||||
event.dataTransfer.setDragImage(featureItemEl.querySelector('img'), 60, 0);
|
||||
}
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
event.stopPropagation();
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
const item = await fromUuid(data.uuid);
|
||||
if (item?.type === 'feature') {
|
||||
if (data.fromInternal && item.parent?.uuid === this.actor.uuid) {
|
||||
return super._onDrop(event);
|
||||
}
|
||||
|
||||
const itemData = item.toObject();
|
||||
delete itemData._id;
|
||||
await this.actor.createEmbeddedDocuments('Item', [itemData]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,8 +381,7 @@ export default function DHApplicationMixin(Base) {
|
|||
* @protected
|
||||
*/
|
||||
_onDrop(event) {
|
||||
// Fallback to super, but note that config sheets don't have this option
|
||||
// We still need this to avoid setting apps having issues
|
||||
// Potentially handle subclasses that dont descend from actor/item sheet.
|
||||
event.stopPropagation();
|
||||
return super._onDrop?.(event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue