switch to using TypeScript
This commit is contained in:
parent
1d120b273a
commit
d163fd27fe
53 changed files with 2875 additions and 1614 deletions
85
src/module/item/item-sheet.ts
Normal file
85
src/module/item/item-sheet.ts
Normal file
|
@ -0,0 +1,85 @@
|
|||
/**
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
* @extends {ItemSheet}
|
||||
*/
|
||||
export class DS4ItemSheet extends ItemSheet {
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
width: 530,
|
||||
height: 400,
|
||||
classes: ["ds4", "sheet", "item"],
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }],
|
||||
});
|
||||
}
|
||||
|
||||
/** @override */
|
||||
get template() {
|
||||
const path = "systems/ds4/templates/item";
|
||||
return `${path}/${this.item.data.type}-sheet.hbs`;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
getData() {
|
||||
const data = { ...super.getData(), config: CONFIG.DS4 };
|
||||
console.log(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
setPosition(options = {}) {
|
||||
const position = super.setPosition(options);
|
||||
const sheetBody = (this.element as JQuery).find(".sheet-body"); // TODO: Why is the cast necessary?
|
||||
const bodyHeight = position.height - 192;
|
||||
//sheetBody.css("height", bodyHeight);
|
||||
return position;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
if (!this.options.editable) return;
|
||||
|
||||
html.find(".effect-create").click(this._onEffectCreate.bind(this));
|
||||
|
||||
html.find(".effect-edit").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").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
|
||||
* @param {Event} event The originating click event
|
||||
* @private
|
||||
*/
|
||||
async _onEffectCreate(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const label = `New Effect`;
|
||||
|
||||
const createData = {
|
||||
label: label,
|
||||
changes: [],
|
||||
duration: {},
|
||||
transfer: true,
|
||||
};
|
||||
|
||||
const effect = await ActiveEffect.create(createData, this.item);
|
||||
return effect.create({});
|
||||
}
|
||||
}
|
17
src/module/item/item.ts
Normal file
17
src/module/item/item.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* Extend the basic Item with some very simple modifications.
|
||||
* @extends {Item}
|
||||
*/
|
||||
export class DS4Item extends Item {
|
||||
/**
|
||||
* Augment the basic Item data model with additional dynamic data.
|
||||
*/
|
||||
prepareData() {
|
||||
super.prepareData();
|
||||
|
||||
// Get the Item's data
|
||||
const itemData = this.data;
|
||||
const actorData = this.actor ? this.actor.data : {};
|
||||
const data = itemData.data;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue