Compendium filter

This commit is contained in:
Litasa
2025-02-16 13:24:03 +00:00
committed by Vlyan
parent 257a736c83
commit b0bc91393a
60 changed files with 2408 additions and 1287 deletions

View File

@@ -50,9 +50,42 @@ export class BaseItemSheetL5r5e extends ItemSheet {
sheetData.editable = this.isEditable;
sheetData.options.editable = sheetData.editable;
// Translate current reference
const reference = this.item.system.source_reference.source;
const label_or_reference = CONFIG.l5r5e.source_reference[reference]?.label ?? reference
sheetData.data.system.source_reference.source = game.i18n.localize(label_or_reference);
// Translate list of available references
const all_references = game.settings.get(CONFIG.l5r5e.namespace, "all-compendium-references");
sheetData.source_references = all_references.map((reference) => {
const label_or_reference = CONFIG.l5r5e.source_reference[reference]?.label ?? reference
return game.i18n.localize(label_or_reference)
})
return sheetData;
}
/**
* This method is called upon form submission after form data is validated
* @param {Event} event The initial triggering submission event
* @param {Object} formData The object of validated form data with which to update the object
* @returns {Promise} A Promise which resolves once the update operation has completed
* @override
*/
async _updateObject(event, formData) {
// If we have an official source then store the id instead
if(event.currentTarget.name === "system.source_reference.source") {
Object.entries(CONFIG.l5r5e.source_reference).forEach(([id, value]) => {
if(game.i18n.localize(value.label) === formData["system.source_reference.source"]) {
formData["system.source_reference.source"] = id;
}
});
}
return super._updateObject(event,formData);
}
/**
* Activate a named TinyMCE text editor
* @param {string} name The named data field which the editor modifies.