foundryvtt-reve-de-dragon/module/item-sheet.js

69 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-05-21 21:48:20 +02:00
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
*/
2020-05-22 00:48:43 +02:00
export class RdDItemSheet extends ItemSheet {
2020-05-21 21:48:20 +02:00
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
2020-05-22 19:28:01 +02:00
classes: ["foundryvtt-reve-de-dragon", "sheet", "item"],
template: "systems/foundryvtt-reve-de-dragon/templates/item-sheet.html",
2020-05-21 21:48:20 +02:00
width: 520,
2020-05-22 19:28:01 +02:00
height: 480
//tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
2020-05-21 21:48:20 +02:00
});
}
/* -------------------------------------------- */
/** @override */
setPosition(options={}) {
const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192;
sheetBody.css("height", bodyHeight);
return position;
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
super.activateListeners(html);
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
2020-05-22 19:28:01 +02:00
// Select competence categorie
html.find("#categorie").on("click", this._onClickSelectCategorie.bind(this) );
2020-05-21 21:48:20 +02:00
}
2020-05-22 19:28:01 +02:00
2020-05-21 21:48:20 +02:00
/* -------------------------------------------- */
2020-05-22 19:28:01 +02:00
async _onClickSelectCategorie(event) {
2020-05-21 21:48:20 +02:00
event.preventDefault();
2020-05-22 19:28:01 +02:00
const category = event.currentTarget.value;
let level = CONFIG.RDD.level_category[category];
this.object.data.data.base = level;
$("#base").val( level );
}
2020-05-21 21:48:20 +02:00
2020-05-22 19:28:01 +02:00
/* -------------------------------------------- */
2020-05-21 21:48:20 +02:00
2020-05-22 19:28:01 +02:00
get template()
{
let type = this.item.type;
return `systems/foundryvtt-reve-de-dragon/templates/item-${type}-sheet.html`;
2020-05-21 21:48:20 +02:00
}
/* -------------------------------------------- */
/** @override */
_updateObject(event, formData) {
return this.object.update(formData);
}
}