Idiotic instance panel...

This commit is contained in:
2026-07-08 13:01:48 +02:00
parent 56d3f0a20f
commit 8fec26f69f
8 changed files with 149 additions and 25 deletions

View File

@@ -19,6 +19,31 @@ export class Ontology {
return this.#data.instancesById[id];
}
/**
* @todo Revise loop approach...
* @param {String} label
* @param {String} lang The language identifier, either 'en' or 'it'
* @returns {Object} The instance object as per onto JSON... (document it!!)
*/
getInstanceByLabel(label, lang) {
if (!['en','it'].includes(lang)) {
throw new Error(`Invalid language string provided: '${lang}'`);
}
let instance = {};
for (const key of Object.keys(this.#data.instancesById)) {
const currentInstance = this.#data.instancesById[key];
const currentLabel = currentInstance.label[lang];
if (currentLabel === label) {
instance = currentInstance;
break;
}
}
return instance;
}
/**
* @returns {Array<{en: string, it: string}>} The bloody array of label objects
*/