Fetch biblio for individual record (until API fix...)
This commit is contained in:
parent
ad1aafa243
commit
0320bf60b7
@ -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">
|
||||
<span class="icon has-text-link">
|
||||
@ -50,11 +50,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};
|
||||
@ -64,4 +66,8 @@ export class NotConservedSheet {
|
||||
|
||||
return biblio.trim().slice(0, -1);
|
||||
}
|
||||
|
||||
async fetchData(url) {
|
||||
return await fetch(url).then(res => res.json());
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ if (BASE_URL.includes('localhost')) {
|
||||
API_URL = API_CONFIG.prod;
|
||||
}
|
||||
|
||||
window.API_URL = API_URL;
|
||||
|
||||
// Global leaflet
|
||||
/**
|
||||
* @namespace GIS
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user