84 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import Utils from "./utils.js";
 | |
| 
 | |
| /**
 | |
|  * Component to render data for not conserved assets
 | |
|  * @class NotConserved
 | |
|  */
 | |
| export class NotConserved {
 | |
|     biblioElements = [];
 | |
|     /**
 | |
|      * @param {object} data
 | |
|      */
 | |
|     set data(data) {
 | |
|         this._data = data;
 | |
|     }
 | |
| 
 | |
|     async render() {
 | |
|         return `
 | |
|         <div class="container px-4 pt-4">
 | |
|             <p class="p-2">
 | |
|                 <span class="icon has-text-link">
 | |
|                     <i class="fa fa-tag"></i>
 | |
|                 </span>
 | |
|                 <strong>Denominazione:</strong> ${this._data.denomination}
 | |
|             </p>
 | |
|             <p class="p-2">
 | |
|                 <span class="icon has-text-link">
 | |
|                     <i class="fa fa-hourglass"></i>
 | |
|                 </span>
 | |
|                 <strong>Periodo:</strong> ${this._data.period}
 | |
|             </p>
 | |
|             <p class="p-2">
 | |
|                 <span class="icon has-text-link">
 | |
|                     <i class="fa fa-map"></i>
 | |
|                 </span>
 | |
|                 <strong>Località generica:</strong> ${Utils.parseMarkers(this._data.genericLocation)}
 | |
|             </p>
 | |
|             <p class="mt-4 pl-2 pr-5">
 | |
|                 <strong class="pb-3">Descrizione</strong></br>
 | |
|                 ${Utils.parseMarkers(this._data.shortDescription)}
 | |
|             </p>
 | |
|             <p class="mt-4 pl-2 pr-5">
 | |
|                 <span class="icon has-text-link">
 | |
|                     <i class="fa fa-book"></i>
 | |
|                 </span>
 | |
|                 <strong>Bibliografia:</strong> ${await this.biblio(this._data.id)}
 | |
|             </p>
 | |
|             <div class="notification is-light mx-3 mt-4 mb-0 p-2 is-hidden" data-biblio-target="biblio"></div>
 | |
|             <p class="p-2 mb-4">
 | |
|                 <strong>Autore scheda:</strong> ${this._data.author}
 | |
|             </p>
 | |
|         </div>`;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param {HTMLElement} imageContainer
 | |
|      * @param {Function} gallery
 | |
|      */
 | |
|     setImages(imageContainer, gallery) {
 | |
|         if (this._data.images?.length) {
 | |
|             imageContainer.innerHTML = Utils.renderImages('not-conserved-gallery', this._data.images);
 | |
|             gallery('not-conserved-gallery', this._data.images);
 | |
|         } else
 | |
|             imageContainer.innerHTML = '<p class="has-text-centered">Nessuna risorsa visuale disponibile</p>';
 | |
|     }
 | |
| 
 | |
|     async renderDocs() {
 | |
|         return await Utils.generateDocsTable(this._data, 'not_conserved');
 | |
|     }
 | |
| 
 | |
|     async biblio(recordId) {
 | |
|         let {citations, biblioElements} = await Utils.buildBibliography('not_conserved', recordId);
 | |
|         this.biblioElements = biblioElements;
 | |
| 
 | |
|         return citations;
 | |
|     }
 | |
| 
 | |
|     getReference(id) {
 | |
|         return this.biblioElements.find(ref => {
 | |
|             let regex = new RegExp('ref-'+id+'"');
 | |
|             return ref.match(regex);
 | |
|         });
 | |
|     }
 | |
| }
 |