Uppdate DS4ItemSheet#getData

This commit is contained in:
Johannes Loher 2021-06-30 13:26:15 +02:00
parent 5bf9ee534d
commit d85d335799

View file

@ -6,13 +6,12 @@
import { DS4 } from "../config";
import notifications from "../ui/notifications";
import { DS4Item } from "./item";
import { isDS4ItemDataTypePhysical } from "./item-data-source";
/**
* The Sheet class for DS4 Items
*/
export class DS4ItemSheet extends ItemSheet {
export class DS4ItemSheet extends ItemSheet<ItemSheet.Options, DS4ItemSheetData> {
/** @override */
static get defaultOptions(): ItemSheet.Options {
// TODO: Improve
@ -32,17 +31,18 @@ export class DS4ItemSheet extends ItemSheet {
const basePath = "systems/ds4/templates/sheets/item";
return `${basePath}/${this.item.data.type}-sheet.hbs`;
}
// /** @override */
// async getData(): Promise<ItemSheet.Data<DS4Item>> {
// const data = {
// ...(await super.getData()),
// config: DS4,
// isOwned: this.item.isOwned,
// actor: this.item.actor,
// isPhysical: isDS4ItemDataTypePhysical(this.item.data.data),
// };
// return data;
// }
/** @override */
async getData(): Promise<DS4ItemSheetData> {
return {
...(await super.getData()),
config: DS4,
isOwned: this.item.isOwned,
actor: this.item.actor,
isPhysical: isDS4ItemDataTypePhysical(this.item.data.data),
};
}
/** @override */
setPosition(options: Partial<Application.Position> = {}): (Application.Position & { height: number }) | undefined {
const position = super.setPosition(options);
@ -109,3 +109,10 @@ export class DS4ItemSheet extends ItemSheet {
return ActiveEffect.create(createData, { parent: this.item });
}
}
interface DS4ItemSheetData extends ItemSheet.Data<ItemSheet.Options> {
config: typeof DS4;
isOwned: boolean;
actor: DS4ItemSheet["item"]["actor"];
isPhysical: boolean;
}