mirror of
https://github.com/RoY7x/worldbuilding.git
synced 2025-07-15 18:56:46 -04:00
Tidy the worldbuilding system for 0.40 release
This commit is contained in:
parent
d641ff96b0
commit
6bf056b3d4
9 changed files with 72 additions and 184 deletions
|
@ -23,55 +23,22 @@ export class SimpleItemSheet extends ItemSheet {
|
|||
/** @override */
|
||||
getData() {
|
||||
const data = super.getData();
|
||||
|
||||
// Handle attribute groups.
|
||||
EntitySheetHelper.getAttributeData(data);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
async _onSubmit(event, {updateData=null, preventClose=false, preventRender=false}={}) {
|
||||
let attr = EntitySheetHelper.onSubmit(event);
|
||||
|
||||
// Submit the form if attr is true or an attr key.
|
||||
if ( attr ) {
|
||||
await super._onSubmit(event, {updateData: updateData, preventClose: preventClose, preventRender: preventRender});
|
||||
|
||||
// If attr is a key and not just true, set a very short timeout and retrigger focus after the original element is deleted and the new one is inserted.
|
||||
if ( attr !== true) {
|
||||
setTimeout(() => {
|
||||
$(`input[name="${attr}"]`).parents('.attribute').find('.attribute-value').focus();
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @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);
|
||||
|
||||
// Handle rollable attributes.
|
||||
html.find(".attributes").on("click", "a.attribute-roll", EntitySheetHelper.onAttributeRoll.bind(this));
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
// Rollable attributes
|
||||
html.find(".attributes").on("click", "a.attribute-roll", EntitySheetHelper.onAttributeRoll.bind(this));
|
||||
|
||||
// Add draggable for macros.
|
||||
html.find(".attributes a.attribute-roll").each((i, a) => {
|
||||
a.setAttribute("draggable", true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue