mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Fixed drag/drop of features for environments (#1488)
This commit is contained in:
parent
c070c6cc2d
commit
f6bd1430e3
6 changed files with 52 additions and 7 deletions
|
|
@ -51,6 +51,19 @@ export default class DHAdversarySettings extends DHBaseActorSettings {
|
|||
}
|
||||
};
|
||||
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
|
||||
const featureForms = ['passive', 'action', 'reaction'];
|
||||
context.features = context.document.system.features.sort((a, b) =>
|
||||
a.system.featureForm !== b.system.featureForm
|
||||
? featureForms.indexOf(a.system.featureForm) - featureForms.indexOf(b.system.featureForm)
|
||||
: a.sort - b.sort
|
||||
);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
|
|
@ -98,16 +111,16 @@ export default class DHAdversarySettings extends DHBaseActorSettings {
|
|||
|
||||
async _onDrop(event) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
const itemData = item.toObject();
|
||||
delete itemData._id;
|
||||
|
||||
|
||||
await this.actor.createEmbeddedDocuments('Item', [itemData]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,19 @@ export default class DHEnvironmentSettings extends DHBaseActorSettings {
|
|||
}
|
||||
};
|
||||
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
|
||||
const featureForms = ['passive', 'action', 'reaction'];
|
||||
context.features = context.document.system.features.sort((a, b) =>
|
||||
a.system.featureForm !== b.system.featureForm
|
||||
? featureForms.indexOf(a.system.featureForm) - featureForms.indexOf(b.system.featureForm)
|
||||
: a.sort - b.sort
|
||||
);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new category entry to the actor.
|
||||
* @type {ApplicationClickAction}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
|
||||
dropSelector: null
|
||||
}
|
||||
],
|
||||
]
|
||||
};
|
||||
|
||||
/**@override */
|
||||
|
|
@ -79,6 +79,9 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
case 'header':
|
||||
await this._prepareHeaderContext(context, options);
|
||||
|
||||
break;
|
||||
case 'features':
|
||||
await this._prepareFeaturesContext(context, options);
|
||||
break;
|
||||
case 'notes':
|
||||
await this._prepareNotesContext(context, options);
|
||||
|
|
@ -115,6 +118,22 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare render context for the features part.
|
||||
* @param {ApplicationRenderContext} context
|
||||
* @param {ApplicationRenderOptions} options
|
||||
* @returns {Promise<void>}
|
||||
* @protected
|
||||
*/
|
||||
async _prepareFeaturesContext(context, _options) {
|
||||
const featureForms = ['passive', 'action', 'reaction'];
|
||||
context.features = this.document.system.features.sort((a, b) =>
|
||||
a.system.featureForm !== b.system.featureForm
|
||||
? featureForms.indexOf(a.system.featureForm) - featureForms.indexOf(b.system.featureForm)
|
||||
: a.sort - b.sort
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare render context for the Header part.
|
||||
* @param {ApplicationRenderContext} context
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<fieldset>
|
||||
<legend>{{localize tabs.features.label}}</legend>
|
||||
<ul class="feature-list">
|
||||
{{#each document.system.features as |feature|}}
|
||||
{{#each @root.features as |feature|}}
|
||||
<li class="feature-item" id="{{feature.id}}" draggable="true">
|
||||
<img src="{{feature.img}}" alt="">
|
||||
<div class="label">
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<fieldset>
|
||||
<legend>{{localize tabs.features.label}}</legend>
|
||||
<ul class="feature-list">
|
||||
{{#each document.system.features as |feature|}}
|
||||
{{#each @root.features as |feature|}}
|
||||
<li class="feature-item" id="{{feature.id}}">
|
||||
<img src="{{feature.img}}" alt="">
|
||||
<div class="label">
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
{{> 'daggerheart.inventory-items'
|
||||
title=tabs.features.label
|
||||
type='feature'
|
||||
collection=document.system.features
|
||||
collection=@root.features
|
||||
hideContextMenu=true
|
||||
canCreate=true
|
||||
showActions=true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue