From 50f474e49e147ac0184b10786cd95b360f8a171b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= <nicolo.paraciani@cnr.it> Date: Mon, 28 Apr 2025 15:55:34 +0200 Subject: [PATCH] Documents for not conserved --- webgis/index.html | 9 +++++ webgis/js/components/NotConserved.js | 59 ++++++++++++++++++++++++++-- webgis/js/ui.js | 3 +- 3 files changed, 66 insertions(+), 5 deletions(-) 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 @@ <span>Immagini</span> </a> </li> + <li id="for-documents" data-tabs-target="tab" data-action="click->tabs#activate"> + <a> + <span class="icon is-small" + ><i class="fas fa-book" aria-hidden="true"></i + ></span> + <span>Documenti</span> + </a> + </li> </ul> </div> <div class="data-tabs" id="not-conserved-sheet" data-tabs-target="content"></div> <div class="data-tabs is-hidden" id="photos" data-tabs-target="content"></div> + <div class="data-tabs is-hidden" id="documents" data-tabs-target="content"></div> </div> <button class="modal-close is-large" aria-label="close" data-action="modal#close"></button> </div> 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 = '<p class="has-text-centered">Nessuna risorsa visuale disponibile</p>'; } + 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 = ` + <div class="has-bottom-border"> + <div class="p-2"> + <table class="p-4 table is-fullwidth is-striped"> + <thead> + <tr><th colspan=3 class="p-2 has-text-centered is-size-5">Documentazione di archivio</th> + <tr><th>Titolo</th><th>Luogo di conservazione</th><th>Download</th></tr> + </thead> + <tbody> + `; + + for (const doc of this.documentation) { + content += ` + <tr><td>${doc.title}</td><td>${doc.conservationPlace}</td><td><a class="button is-link has-text-white" href="docs/${doc.filename}"> + <i class="fa fa-download mr-2"></i> PDF + </a></td></tr> + `; + } + if (this.publications.length) { + content += ` + </tbody> + <thead> + <tr><th colspan=3 class="p-2 has-text-centered is-size-5">Pubblicazioni del progetto Carta Archeologica</th> + <tr><th>Titolo</th><th>Autori</th><th>Download</th></tr> + </thead> + <tbody> + `; + for (const doc of this.publications) { + content += ` + <tr><td>${doc.title}</td><td>${doc.authors}</td><td><a class="button is-link has-text-white" href="docs/${doc.filename}"> + <i class="fa fa-download mr-2"></i> PDF + </a></td></tr> + `; + } + } + content += ` + </tbody> + </table> + </div> + </div> + `; + + 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'); }