diff --git a/webgis/index.html b/webgis/index.html index 37fef7a..f2f481d 100644 --- a/webgis/index.html +++ b/webgis/index.html @@ -462,12 +462,36 @@ -
Immagini
`; - content += ` -Cliccare sull'immagine per aprire la gallery
-Nessuna risorsa visuale disponibile
'; } /** * @param {number} recordId */ async biblio(recordId) { - let finding = await this.fetchData(`${GisState.apiUrl}/finding/${recordId}`); + let {citations, biblioElements} = await Utils.buildBibliography('not_conserved', recordId); + this.biblioElements = biblioElements; - let citations = ''; - - if (finding.bibliography.length) { - finding.bibliography.forEach(record => { - citations += ` - - ${record.citation}`; - - citations += record.pages?.length ? `, ${record.pages};` : ';'; - - this.biblioElements.push(` -${record.reference}
-Immagini
`; - content += ` -Cliccare sull'immagine per aprire la gallery
-Nessuna risorsa visuale disponibile
'; } async renderDocs() { - let record = await this.fetchData(`${GisState.apiUrl}/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 = ` -Documentazione di archivio | -||
---|---|---|
Titolo | Luogo di conservazione | Download |
${doc.title} | ${doc.conservationPlace} | - PDF - |
Pubblicazioni del progetto Carta Archeologica | -||
Titolo | Autori | Download |
${doc.title} | ${doc.authors} | - PDF - |
Nessun documento disponibile.
'; - } - - return content; + return await Utils.generateDocsTable(this._data, 'not_conserved'); } async biblio(recordId) { - let record = await this.fetchData(`${GisState.apiUrl}/not_conserved/${recordId}`); + let {citations, biblioElements} = await Utils.buildBibliography('not_conserved', recordId); + this.biblioElements = biblioElements; - let citations = ''; - - if (record.bibliography.length) { - record.bibliography.forEach(record => { - citations += ` - - ${record.citation.trim()}`; - - citations += record.pages?.length ? `, ${record.pages};` : ';'; - - this.biblioElements.push(` -${record.reference}
-Nessuna risorsa visuale disponibile
'; + } - async fetchData(url) { - return await fetch(url).then(res => res.json()); + async renderDocs() { + return await Utils.generateDocsTable(this._data, 'underwater'); } } diff --git a/webgis/js/components/utils.js b/webgis/js/components/utils.js new file mode 100644 index 0000000..fc940df --- /dev/null +++ b/webgis/js/components/utils.js @@ -0,0 +1,152 @@ +import { GisState } from "../state.js"; +/** + * @namespace Utils + */ +const Utils = {}; + + +/** + * + * @param {string} galleryId The image gallery's id + * @param {Object} imagesData + * @returns {string} + */ +Utils.renderImages = function (galleryId, imagesData) { + let content = `Immagini
`; + content += ` +Cliccare sull'immagine per aprire la gallery
+Nessun documento disponibile.
'; + + const documentation = record.documents.filter(d => d.type === 'documentazione') + const publications = record.documents.filter(d => d.type === 'pubblicazione'); + + let content = ` +Documentazione di archivio | +||
---|---|---|
Titolo | Luogo di conservazione | Download |
${doc.title} | ${doc.conservationPlace} | + PDF + |
Pubblicazioni del progetto Carta Archeologica | +||
Titolo | Autori | Download |
${doc.title} | ${doc.authors} | + PDF + |
Nessun documento disponibile.
'; + } + + return content; +} + +/** + * + * @param {String} recordUri The record URI used for API calls + * @param {Number} recordId This record's ID + * @returns {{citations:String,biblioElements:String[]}} + */ +Utils.buildBibliography = async function(recordUri, recordId) { + let record = await Utils.fetchData(`${GisState.apiUrl}/${recordUri}/${recordId}`); + let biblioElements = []; + + let citations = ''; + + if (record.bibliography.length) { + record.bibliography.forEach(record => { + citations += ` + + ${record.citation.trim()} + + `; + + citations += record.pages?.length ? `, ${record.pages};` : ';'; + + biblioElements.push(` +${record.reference}
+