Files
l5rx-chiaroscuro/system/scripts/items/arcane-sheet.js

45 lines
1.6 KiB
JavaScript

import { BaseItemSheetL5r5e } from "./base-item-sheet.js";
/**
* Sheet for Arcane items (Chiaroscuro).
* @extends {BaseItemSheetL5r5e}
*/
export class ArcaneSheetL5r5e extends BaseItemSheetL5r5e {
/** @override */
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["l5r5e", "sheet", "arcane"],
template: CONFIG.l5r5e.paths.templates + "items/arcane/arcane-sheet.html",
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "attributes" }],
});
}
/** @override */
async getData(options = {}) {
const sheetData = await super.getData(options);
// Convert application array to comma-separated string for display
const app = sheetData.data.system.application;
sheetData.data.system.applicationDisplay = Array.isArray(app) ? app.join(", ") : (app ?? "");
sheetData.data.enrichedHtml = {
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
sheetData.data.system.description ?? "",
{ async: true }
),
};
return sheetData;
}
/** @override */
async _updateObject(event, formData) {
// Convert comma-separated application string back to array
const raw = formData["system.applicationDisplay"] ?? "";
formData["system.application"] = raw.split(",").map((s) => s.trim()).filter(Boolean);
delete formData["system.applicationDisplay"];
return super._updateObject(event, formData);
}
}