diff --git a/webgis/index.html b/webgis/index.html index 26607c1..db9e428 100644 --- a/webgis/index.html +++ b/webgis/index.html @@ -545,10 +545,19 @@ Immagini +
  • + + + Documenti + +
  • + diff --git a/webgis/js/components/NotConserved.js b/webgis/js/components/NotConserved.js index 10ca854..ced4358 100644 --- a/webgis/js/components/NotConserved.js +++ b/webgis/js/components/NotConserved.js @@ -7,7 +7,7 @@ export class NotConserved { /** * @param {object} data */ - set siteData(data) { + set data(data) { this._data = data; } @@ -71,16 +71,67 @@ export class NotConserved { * @param {Function} gallery */ async setImages(imageContainer, gallery) { - let record = await this.fetchData(`${window.API_URL}/not_conserved/${this._data.id}`) + //let record = await this.fetchData(`${window.API_URL}/not_conserved/${this._data.id}`) - if (record.images.length) { - this.images = record.images; + if (this._data.images.length) { + this.images = this._data.images; imageContainer.innerHTML = this.renderImages(); gallery('not-conserved-gallery', this.images); } else imageContainer.innerHTML = '

    Nessuna risorsa visuale disponibile

    '; } + async renderDocs() { + let record = await this.fetchData(`${window.API_URL}/not_conserved/${this._data.id}`); + + this.documentation = record.documents.filter(d => d.type === 'documentazione') + this.publications = record.documents.filter(d => d.type === 'pubblicazione'); + + let content = ` +
    +
    + + + + + + + `; + + for (const doc of this.documentation) { + content += ` + + `; + } + if (this.publications.length) { + content += ` + + + + + + + `; + for (const doc of this.publications) { + content += ` + + `; + } + } + content += ` + +
    Documentazione di archivio
    TitoloLuogo di conservazioneDownload
    ${doc.title}${doc.conservationPlace} + PDF +
    Pubblicazioni del progetto Carta Archeologica
    TitoloAutoriDownload
    ${doc.title}${doc.authors} + PDF +
    +
    +
    + `; + + return content; + } + async biblio(recordId) { let record = await this.fetchData(`${window.API_URL}/not_conserved/${recordId}`); diff --git a/webgis/js/ui.js b/webgis/js/ui.js index a69ffec..86ada0f 100644 --- a/webgis/js/ui.js +++ b/webgis/js/ui.js @@ -166,11 +166,12 @@ UI.openNotConserModal = function (data, selector) { for (let tab of dataTabs) tab.innerHTML = ''; let notConserved = new NotConserved(); - notConserved.siteData = data; + notConserved.data = data; // For Stimulus biblio_controller window.Biblio = notConserved; notConserved.render().then(html => modal.querySelector('#not-conserved-sheet').innerHTML = html); + notConserved.renderDocs().then(html => modal.querySelector('#documents').innerHTML = html); notConserved.setImages(modal.querySelector('#photos'), this.imageGallery); modal.classList.add('is-active'); }