Documents for not conserved
This commit is contained in:
		
							parent
							
								
									3f6d70f159
								
							
						
					
					
						commit
						50f474e49e
					
				| @ -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> | ||||
|  | ||||
| @ -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}`); | ||||
| 
 | ||||
|  | ||||
| @ -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'); | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user