diff --git a/module/Apps/ItemSheets/AllItemSheetV1.mjs b/module/Apps/ItemSheets/AllItemSheetV1.mjs index e8c2e03..83aa9eb 100644 --- a/module/Apps/ItemSheets/AllItemSheetV1.mjs +++ b/module/Apps/ItemSheets/AllItemSheetV1.mjs @@ -38,7 +38,7 @@ export class AllItemSheetV1 extends GenericAppMixin(HandlebarsApplicationMixin(I // #region Lifecycle async _preparePartContext(partId, ctx, opts) { ctx = await super._preparePartContext(partId, ctx, opts); - ctx.actor = this.document; + ctx.item = this.document; Logger.debug(`Context:`, ctx); return ctx; diff --git a/module/data/Item/Weapon.mjs b/module/data/Item/Weapon.mjs index 2e42e35..1c16aa9 100644 --- a/module/data/Item/Weapon.mjs +++ b/module/data/Item/Weapon.mjs @@ -55,4 +55,23 @@ export class WeaponData extends foundry.abstract.TypeDataModel { return String(this.range.short ?? this.range.long ?? ``); } // #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 }; diff --git a/module/handlebarHelpers/_index.mjs b/module/handlebarHelpers/_index.mjs index 1603faf..9c8587d 100644 --- a/module/handlebarHelpers/_index.mjs +++ b/module/handlebarHelpers/_index.mjs @@ -1,8 +1,10 @@ import { handlebarsLocalizer, localizer } from "../utils/Localizer.mjs"; +import { formFields } from "./inputs/formFields.mjs"; import { options } from "./options.mjs"; export default { // #region Complex + "rc-formFields": formFields, "rc-i18n": handlebarsLocalizer, "rc-options": options, diff --git a/module/handlebarHelpers/inputs/formFields.mjs b/module/handlebarHelpers/inputs/formFields.mjs new file mode 100644 index 0000000..0ddd6b5 --- /dev/null +++ b/module/handlebarHelpers/inputs/formFields.mjs @@ -0,0 +1,20 @@ +const inputTypes = { + set: displayOnly, + integer: displayOnly, + bar: displayOnly, + dropdown: displayOnly, + boolean: displayOnly, +}; + +function displayOnly(input) { + return `
${input.label}
`; +}; + +export function formFields(inputs) { + let htmlString = ``; + for (const input of inputs) { + if (inputTypes[input.type] == null) { continue }; + htmlString += inputTypes[input.type](input); + }; + return htmlString; +}; diff --git a/templates/Apps/AllItemSheetV1/content.hbs b/templates/Apps/AllItemSheetV1/content.hbs index 43a098c..3d48a8e 100644 --- a/templates/Apps/AllItemSheetV1/content.hbs +++ b/templates/Apps/AllItemSheetV1/content.hbs @@ -1,3 +1,3 @@
- All Item Sheet V1 + {{{ rc-formFields item.system.formFields }}}