import Utils from "./utils.js"; /** * @class Reuse */ export class Reuse { biblioElements = []; images = null; set data(data) { this._data = data; } async render() { return `

Denominazione: ${this._data.denomination}

Materia: ${this._data.material}

Misure: ${this._data.measurements}

Luogo di conservazione: ${this._data.conservationPlace}

Stato di conservazione: ${this._data.conservationState}

Luogo e anno rinvenimento: ${this._data.finding}

Datazione: ${this._data.dating}

Descrizione
${this._data.description}

Bibliografia: ${await this.biblio(this._data.id)}

Autore scheda: ${this._data.author}

`; } /** * @param {HTMLElement} imageContainer * @param {Function} gallery */ async setImages(imageContainer, gallery) { if (this._data.images?.length) { imageContainer.innerHTML = Utils.renderImages('reuse-gallery', this._data.images); gallery('reuse-gallery', this._data.images); } else imageContainer.innerHTML = '

Nessuna risorsa visuale disponibile

'; } /** * @param {number} recordId */ async biblio(recordId) { let {citations, biblioElements} = await Utils.buildBibliography('reuse', recordId); this.biblioElements = biblioElements; return citations; } getReference(id) { return this.biblioElements.find(ref => { let regex = new RegExp('ref-'+id+'"'); return ref.match(regex); }); } }