This commit is contained in:
Nicolò P 2024-11-20 11:13:54 +01:00
commit 0ad8e5c7f9
3 changed files with 14 additions and 6 deletions

View File

@ -10,7 +10,7 @@ export class NotConservedSheet {
this._data = data;
}
render() {
async render() {
return `
<div class="container ml-3">
<p class="p-2">
@ -39,7 +39,7 @@ export class NotConservedSheet {
<span class="icon has-text-link">
<i class="fa fa-book"></i>
</span>
<strong>Bibliografia:</strong> ${this.biblio(this._data.bibliography)}
<strong>Bibliografia:</strong> ${await this.biblio(this._data.id)}
</p>
<p class="p-2">
<strong>Autore scheda:</strong> ${this._data.author}
@ -47,11 +47,13 @@ export class NotConservedSheet {
</div>`;
}
biblio(records) {
async biblio(recordId) {
let record = await this.fetchData(`${window.API_URL}/not_conserved/${recordId}`);
let biblio = '';
if (records.length) {
records.forEach(record => {
if (record.bibliography.length) {
record.bibliography.forEach(record => {
biblio += `
<span class="is-capitalized">${record.citation.toLowerCase()}</span>,
${record.pages};
@ -61,4 +63,8 @@ export class NotConservedSheet {
return biblio.trim().slice(0, -1);
}
async fetchData(url) {
return await fetch(url).then(res => res.json());
}
}

View File

@ -13,6 +13,8 @@ if (BASE_URL.includes('localhost')) {
API_URL = API_CONFIG.prod;
}
window.API_URL = API_URL;
// Global leaflet
/**
* @namespace GIS

View File

@ -153,7 +153,7 @@ UI.openNotConserModal = async function (data, selector) {
let sheet = new NotConservedSheet();
sheet.siteData = data;
modal.querySelector('#not-conser-sheet').innerHTML = sheet.render();
modal.querySelector('#not-conser-sheet').innerHTML = await sheet.render();
modal.classList.add('is-active');
const closeBtn = modal.querySelector('.modal-close');