RC-92 | Datamodel Defined Input Definition
This commit is contained in:
parent
94c89f72e1
commit
4b423a0729
5 changed files with 43 additions and 2 deletions
|
|
@ -38,7 +38,7 @@ export class AllItemSheetV1 extends GenericAppMixin(HandlebarsApplicationMixin(I
|
||||||
// #region Lifecycle
|
// #region Lifecycle
|
||||||
async _preparePartContext(partId, ctx, opts) {
|
async _preparePartContext(partId, ctx, opts) {
|
||||||
ctx = await super._preparePartContext(partId, ctx, opts);
|
ctx = await super._preparePartContext(partId, ctx, opts);
|
||||||
ctx.actor = this.document;
|
ctx.item = this.document;
|
||||||
|
|
||||||
Logger.debug(`Context:`, ctx);
|
Logger.debug(`Context:`, ctx);
|
||||||
return ctx;
|
return ctx;
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,23 @@ export class WeaponData extends foundry.abstract.TypeDataModel {
|
||||||
return String(this.range.short ?? this.range.long ?? ``);
|
return String(this.range.short ?? this.range.long ?? ``);
|
||||||
}
|
}
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
// #region Sheet Data
|
||||||
|
get formFields() {
|
||||||
|
const fields = [
|
||||||
|
{ type: `set`, label: `Traits` },
|
||||||
|
{ type: `integer`, label: `Short Range` },
|
||||||
|
{ type: `integer`, label: `Long Range` },
|
||||||
|
{ type: `integer`, label: `Damage` },
|
||||||
|
{ type: `bar`, label: `Wear` },
|
||||||
|
{ type: `dropdown`, label: `Access` },
|
||||||
|
];
|
||||||
|
|
||||||
|
if (this.parent.isEmbedded) {
|
||||||
|
fields.push({ type: `boolean`, label: `Equipped` });
|
||||||
|
};
|
||||||
|
|
||||||
|
return fields;
|
||||||
|
};
|
||||||
|
// #endregion
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import { handlebarsLocalizer, localizer } from "../utils/Localizer.mjs";
|
import { handlebarsLocalizer, localizer } from "../utils/Localizer.mjs";
|
||||||
|
import { formFields } from "./inputs/formFields.mjs";
|
||||||
import { options } from "./options.mjs";
|
import { options } from "./options.mjs";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// #region Complex
|
// #region Complex
|
||||||
|
"rc-formFields": formFields,
|
||||||
"rc-i18n": handlebarsLocalizer,
|
"rc-i18n": handlebarsLocalizer,
|
||||||
"rc-options": options,
|
"rc-options": options,
|
||||||
|
|
||||||
|
|
|
||||||
20
module/handlebarHelpers/inputs/formFields.mjs
Normal file
20
module/handlebarHelpers/inputs/formFields.mjs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
const inputTypes = {
|
||||||
|
set: displayOnly,
|
||||||
|
integer: displayOnly,
|
||||||
|
bar: displayOnly,
|
||||||
|
dropdown: displayOnly,
|
||||||
|
boolean: displayOnly,
|
||||||
|
};
|
||||||
|
|
||||||
|
function displayOnly(input) {
|
||||||
|
return `<div data-input-type="${input.type}">${input.label}</div>`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function formFields(inputs) {
|
||||||
|
let htmlString = ``;
|
||||||
|
for (const input of inputs) {
|
||||||
|
if (inputTypes[input.type] == null) { continue };
|
||||||
|
htmlString += inputTypes[input.type](input);
|
||||||
|
};
|
||||||
|
return htmlString;
|
||||||
|
};
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
<div class="AllItemSheetV1">
|
<div class="AllItemSheetV1">
|
||||||
All Item Sheet V1
|
{{{ rc-formFields item.system.formFields }}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue