Merge branch '024-not-possible-to-manage-active-effects-on-owned-items' into 'master'
prevent error when trying to manage active effects on an owned item Closes #24 See merge request dungeonslayers/ds4!32
This commit is contained in:
commit
52074cff5a
3 changed files with 31 additions and 21 deletions
|
@ -109,5 +109,6 @@
|
||||||
"DS4.ProfilHairColor": "Hair Color",
|
"DS4.ProfilHairColor": "Hair Color",
|
||||||
"DS4.ProfileWeight": "Weight",
|
"DS4.ProfileWeight": "Weight",
|
||||||
"DS4.ProfileEyeColor": "Eye Color",
|
"DS4.ProfileEyeColor": "Eye Color",
|
||||||
"DS4.ProfileSpecialCharacteristics": "Special Characteristics"
|
"DS4.ProfileSpecialCharacteristics": "Special Characteristics",
|
||||||
|
"DS4.WarningManageActiveEffectOnOwnedItem": "Managing Active Effects within an Owned Item is not currently supported and will be added in a subsequent update."
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,29 +60,38 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
|
||||||
|
|
||||||
if (!this.options.editable) return;
|
if (!this.options.editable) return;
|
||||||
|
|
||||||
html.find(".effect-create").on("click", this._onEffectCreate.bind(this));
|
html.find(".effect-control").on("click", this._onManageActiveEffect.bind(this));
|
||||||
|
|
||||||
html.find(".effect-edit").on("click", (ev) => {
|
|
||||||
const li = $(ev.currentTarget).parents(".effect");
|
|
||||||
console.log(li.data("effectId"));
|
|
||||||
const effect = this.item.effects.get(li.data("effectId"));
|
|
||||||
effect.sheet.render(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
html.find(".effect-delete").on("click", async (ev) => {
|
|
||||||
const li = $(ev.currentTarget).parents(".effect");
|
|
||||||
await this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId"));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle creating a new ActiveEffect for the item using initial data defined in the HTML dataset
|
* Handle management of ActiveEffects.
|
||||||
* @param {Event} event The originating click event
|
* @param {Event} event The originating click event
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
private async _onEffectCreate(event: JQuery.ClickEvent): Promise<unknown> {
|
private async _onManageActiveEffect(event: JQuery.ClickEvent): Promise<unknown> {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
if (this.item.isOwned) {
|
||||||
|
return ui.notifications.warn(game.i18n.localize("DS4.WarningManageActiveEffectOnOwnedItem"));
|
||||||
|
}
|
||||||
|
const a = event.currentTarget;
|
||||||
|
const li = $(a).parents(".effect");
|
||||||
|
|
||||||
|
switch (a.dataset["action"]) {
|
||||||
|
case "create":
|
||||||
|
return this._createActiveEffect();
|
||||||
|
case "edit":
|
||||||
|
const effect = this.item.effects.get(li.data("effectId"));
|
||||||
|
return effect.sheet.render(true);
|
||||||
|
case "delete": {
|
||||||
|
return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ActiveEffect for the item using default data.
|
||||||
|
*/
|
||||||
|
private async _createActiveEffect(): Promise<unknown> {
|
||||||
const label = `New Effect`;
|
const label = `New Effect`;
|
||||||
|
|
||||||
const createData = {
|
const createData = {
|
||||||
|
|
|
@ -5,16 +5,16 @@
|
||||||
<div class="effect-image"></div>
|
<div class="effect-image"></div>
|
||||||
<div class="effect-name">Name</div>
|
<div class="effect-name">Name</div>
|
||||||
<div class="effect-controls">
|
<div class="effect-controls">
|
||||||
<a class="effect-control effect-create" title="Create Effect"><i
|
<a class="effect-control" data-action="create" title="Create Effect"><i class="fas fa-plus"></i> Add
|
||||||
class="fas fa-plus"></i> Add effect</a>
|
effect</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{{#each item.effects as |effect id|}}
|
{{#each item.effects as |effect id|}}
|
||||||
<li class="effect flexrow" data-effect-id="{{effect._id}}">
|
<li class="effect flexrow" data-effect-id="{{effect._id}}">
|
||||||
<h4 class="effect-name">{{effect.label}}</h4>
|
<h4 class="effect-name">{{effect.label}}</h4>
|
||||||
<div class="effect-controls">
|
<div class="effect-controls">
|
||||||
<a class="effect-control effect-edit" title="Edit Effect"><i class="fas fa-edit"></i></a>
|
<a class="effect-control" data-action="edit" title="Edit Effect"><i class="fas fa-edit"></i></a>
|
||||||
<a class="effect-control effect-delete" title="Delete Effect"><i class="fas fa-trash"></i></a>
|
<a class="effect-control" data-action="delete" title="Delete Effect"><i class="fas fa-trash"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
Loading…
Reference in a new issue