cleanup
This commit is contained in:
parent
26233d61ea
commit
05933af152
10 changed files with 22 additions and 15 deletions
|
@ -102,7 +102,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
|||
html.find(".item-edit").on("click", (ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const id = li.data("itemId");
|
||||
const item = this.actor.getEmbeddedDocument("Item", id) as DS4Item; // TODO: Improve in upstream
|
||||
const item = this.actor.items.get(id);
|
||||
if (!item) {
|
||||
throw new Error(getGame().i18n.format("DS4.ErrorActorDoesNotHaveItem", { id, actor: this.actor.name }));
|
||||
}
|
||||
|
@ -157,7 +157,10 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
|||
ev.preventDefault();
|
||||
const el: HTMLFormElement = $(ev.currentTarget).get(0);
|
||||
const id = $(ev.currentTarget).parents(".item").data("itemId");
|
||||
const item = this.actor.getEmbeddedDocument("Item", id) as DS4Item; // TODO: Improve in upstream
|
||||
const item = this.actor.items.get(id);
|
||||
if (!item) {
|
||||
throw new Error(getGame().i18n.format("DS4.ErrorActorDoesNotHaveItem", { id, actor: this.actor.name }));
|
||||
}
|
||||
const itemObject = item.toObject();
|
||||
const property: string | undefined = $(ev.currentTarget).data("property");
|
||||
|
||||
|
@ -172,7 +175,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
|||
// Set new value
|
||||
const newValue = this.getValue(el);
|
||||
foundry.utils.setProperty(itemObject, property, newValue);
|
||||
this.actor.updateEmbeddedDocuments("Item", [{ ...itemObject }]); // TODO: Improve in upstream
|
||||
item.update({ ...itemObject });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -237,7 +240,10 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
|||
protected onRollItem(event: JQuery.ClickEvent): void {
|
||||
event.preventDefault();
|
||||
const id = $(event.currentTarget).parents(".item").data("itemId");
|
||||
const item = this.actor.getEmbeddedDocument("Item", id, { strict: true }) as DS4Item; // TODO: improve in upstream types
|
||||
const item = this.actor.items.get(id);
|
||||
if (!item) {
|
||||
throw new Error(getGame().i18n.format("DS4.ErrorActorDoesNotHaveItem", { id, actor: this.actor.name }));
|
||||
}
|
||||
item.roll().catch((e) => notifications.error(e, { log: true }));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue