This commit is contained in:
2024-11-20 11:13:54 +01:00
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());
}
}