More WIP on 0.8.x migration

This commit is contained in:
Johannes Loher 2021-06-30 03:53:52 +02:00
parent ef01698178
commit 6b39284164
16 changed files with 427 additions and 321 deletions

View file

@ -7,17 +7,16 @@
import { DS4 } from "../config";
import notifications from "../ui/notifications";
import { DS4Item } from "./item";
import { isDS4ItemDataTypePhysical } from "./item-data";
import { isDS4ItemDataTypePhysical } from "./item-data-source";
/**
* The Sheet class for DS4 Items
*/
export class DS4ItemSheet extends ItemSheet<ItemSheet.Data<DS4Item>> {
export class DS4ItemSheet extends ItemSheet {
/** @override */
static get defaultOptions(): BaseEntitySheet.Options {
static get defaultOptions(): ItemSheet.Options {
const superDefaultOptions = super.defaultOptions;
return mergeObject(superDefaultOptions, {
...superDefaultOptions,
width: 540,
height: 400,
classes: ["ds4", "sheet", "item"],
@ -45,11 +44,14 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Data<DS4Item>> {
}
/** @override */
setPosition(options: Partial<Application.Position> = {}): Application.Position & { height: number } {
setPosition(options: Partial<Application.Position> = {}): (Application.Position & { height: number }) | undefined {
const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192;
sheetBody.css("height", bodyHeight);
if (position) {
const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192;
sheetBody.css("height", bodyHeight);
}
return position;
}
@ -86,7 +88,7 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Data<DS4Item>> {
}
return effect.sheet.render(true);
case "delete": {
return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId"));
return this.item.deleteEmbeddedDocuments("ActiveEffect", [li.data("effectId")]);
}
}
}
@ -94,7 +96,7 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Data<DS4Item>> {
/**
* Create a new ActiveEffect for the item using default data.
*/
protected async _createActiveEffect(): Promise<ActiveEffect.Data> {
protected async _createActiveEffect(): Promise<ActiveEffect | undefined> {
const label = `New Effect`;
const createData = {
@ -104,7 +106,6 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Data<DS4Item>> {
transfer: true,
};
const effect = ActiveEffect.create(createData, this.item);
return effect.create({});
return ActiveEffect.create(createData, { parent: this.item });
}
}