mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fixed drag/drop of features for environments
This commit is contained in:
parent
f11b018bd7
commit
d788eaa6b7
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) {
|
async _onDrop(event) {
|
||||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||||
|
|
||||||
const item = await fromUuid(data.uuid);
|
const item = await fromUuid(data.uuid);
|
||||||
if (item?.type === 'feature') {
|
if (item?.type === 'feature') {
|
||||||
if (data.fromInternal && item.parent?.uuid === this.actor.uuid) {
|
if (data.fromInternal && item.parent?.uuid === this.actor.uuid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const itemData = item.toObject();
|
const itemData = item.toObject();
|
||||||
delete itemData._id;
|
delete itemData._id;
|
||||||
|
|
||||||
await this.actor.createEmbeddedDocuments('Item', [itemData]);
|
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.
|
* Adds a new category entry to the actor.
|
||||||
* @type {ApplicationClickAction}
|
* @type {ApplicationClickAction}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
||||||
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
|
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
|
||||||
dropSelector: null
|
dropSelector: null
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
/**@override */
|
/**@override */
|
||||||
|
|
@ -79,6 +79,9 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
||||||
case 'header':
|
case 'header':
|
||||||
await this._prepareHeaderContext(context, options);
|
await this._prepareHeaderContext(context, options);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'features':
|
||||||
|
await this._prepareFeaturesContext(context, options);
|
||||||
break;
|
break;
|
||||||
case 'notes':
|
case 'notes':
|
||||||
await this._prepareNotesContext(context, options);
|
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.
|
* Prepare render context for the Header part.
|
||||||
* @param {ApplicationRenderContext} context
|
* @param {ApplicationRenderContext} context
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{{localize tabs.features.label}}</legend>
|
<legend>{{localize tabs.features.label}}</legend>
|
||||||
<ul class="feature-list">
|
<ul class="feature-list">
|
||||||
{{#each document.system.features as |feature|}}
|
{{#each @root.features as |feature|}}
|
||||||
<li class="feature-item" id="{{feature.id}}" draggable="true">
|
<li class="feature-item" id="{{feature.id}}" draggable="true">
|
||||||
<img src="{{feature.img}}" alt="">
|
<img src="{{feature.img}}" alt="">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{{localize tabs.features.label}}</legend>
|
<legend>{{localize tabs.features.label}}</legend>
|
||||||
<ul class="feature-list">
|
<ul class="feature-list">
|
||||||
{{#each document.system.features as |feature|}}
|
{{#each @root.features as |feature|}}
|
||||||
<li class="feature-item" id="{{feature.id}}">
|
<li class="feature-item" id="{{feature.id}}">
|
||||||
<img src="{{feature.img}}" alt="">
|
<img src="{{feature.img}}" alt="">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
{{> 'daggerheart.inventory-items'
|
{{> 'daggerheart.inventory-items'
|
||||||
title=tabs.features.label
|
title=tabs.features.label
|
||||||
type='feature'
|
type='feature'
|
||||||
collection=document.system.features
|
collection=@root.features
|
||||||
hideContextMenu=true
|
hideContextMenu=true
|
||||||
canCreate=true
|
canCreate=true
|
||||||
showActions=true
|
showActions=true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue