diff --git a/module/Apps/ItemSheets/ArmourSheet.mjs b/module/Apps/ItemSheets/ArmourSheet.mjs
index 990771a..453f4c4 100644
--- a/module/Apps/ItemSheets/ArmourSheet.mjs
+++ b/module/Apps/ItemSheets/ArmourSheet.mjs
@@ -5,6 +5,7 @@ import { Logger } from "../../utils/Logger.mjs";
const { HandlebarsApplicationMixin } = foundry.applications.api;
const { ItemSheetV2 } = foundry.applications.sheets;
+const { getProperty, hasProperty, setProperty } = foundry.utils;
export class ArmourSheet extends GenericAppMixin(HandlebarsApplicationMixin(ItemSheetV2)) {
@@ -58,6 +59,27 @@ export class ArmourSheet extends GenericAppMixin(HandlebarsApplicationMixin(Item
await this.render(false);
};
};
+
+ /**
+ * Customize how form data is extracted into an expanded object.
+ * @param {SubmitEvent|null} event The originating form submission event
+ * @param {HTMLFormElement} form The form element that was submitted
+ * @param {FormDataExtended} formData Processed data for the submitted form
+ * @returns {object} An expanded object of processed form data
+ * @throws {Error} Subclasses may throw validation errors here to prevent form submission
+ * @protected
+ */
+ _processFormData(event, form, formData) {
+ const data = super._processFormData(event, form, formData);
+
+ if (hasProperty(data, `system.location`)) {
+ let locations = getProperty(data, `system.location`);
+ locations = locations.filter(value => value != null);
+ setProperty(data, `system.location`, locations);
+ };
+
+ return data;
+ };
// #endregion
// #region Data Prep
diff --git a/module/data/Item/Armour.mjs b/module/data/Item/Armour.mjs
index 2d95562..726c929 100644
--- a/module/data/Item/Armour.mjs
+++ b/module/data/Item/Armour.mjs
@@ -5,7 +5,7 @@ import { Logger } from "../../utils/Logger.mjs";
import { requiredInteger } from "../helpers.mjs";
const { fields } = foundry.data;
-const { hasProperty, diffObject, mergeObject } = foundry.utils;
+const { getProperty, diffObject, mergeObject } = foundry.utils;
/** Used for Armour and Shields */
export class ArmourData extends CommonItemData {
@@ -19,16 +19,16 @@ export class ArmourData extends CommonItemData {
blank: false,
trim: true,
nullable: false,
+ required: true,
options: Object.values(gameTerms.Anatomy),
}),
{
nullable: false,
- required: true,
+ initial: [],
},
),
equipped: new fields.BooleanField({
initial: false,
- required: true,
nullable: false,
}),
weight: new fields.StringField({
@@ -59,7 +59,7 @@ export class ArmourData extends CommonItemData {
const diff = diffObject(this.parent._source, changes);
let valid = await super._preUpdate(changes, options, user);
- if (hasProperty(diff, `system.equipped`) && !this._canEquip()) {
+ if (getProperty(diff, `system.equipped`) && !this._canEquip()) {
ui.notifications.error(
localizer(
`RipCrypt.notifs.error.cannot-equip`,
@@ -80,7 +80,10 @@ export class ArmourData extends CommonItemData {
return valid;
};
- /** Used to tell the preUpdate logic whether or not to prevent the */
+ /**
+ * Used to tell the preUpdate logic whether or not to prevent the item from
+ * being equipped or not.
+ */
_canEquip() {
const parent = this.parent;
if (!parent.isEmbedded || !(parent.parent instanceof Actor)) {
diff --git a/templates/Apps/ArmourSheet/content.hbs b/templates/Apps/ArmourSheet/content.hbs
index 89a9373..b3ad0b3 100644
--- a/templates/Apps/ArmourSheet/content.hbs
+++ b/templates/Apps/ArmourSheet/content.hbs
@@ -12,7 +12,17 @@
- {{!-- TODO: Add equipped boolean control --}}
+ {{#if meta.embedded}}
+
+
+ {{/if}}
diff --git a/templates/Apps/ArmourSheet/style.css b/templates/Apps/ArmourSheet/style.css
index 9751c53..24535ce 100644
--- a/templates/Apps/ArmourSheet/style.css
+++ b/templates/Apps/ArmourSheet/style.css
@@ -57,6 +57,10 @@
border-radius: 4px;
padding: 2px 4px;
}
+ input[type="checkbox"] {
+ justify-self: end;
+ padding: 0;
+ }
.value {
border: 2px solid var(--accent-2);
}