Biblio controller + update findings
This commit is contained in:
@@ -39,7 +39,7 @@ export class Finding {
|
||||
</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" id="biblio"></div>
|
||||
<div class="notification is-light mx-3 mt-4 mb-0 p-2 is-hidden" data-biblio-target="biblio"></div>
|
||||
<p class="mt-4 pl-2 pr-5">
|
||||
<strong class="pb-3">Descrizione</strong></br>
|
||||
${this._data.description}
|
||||
@@ -88,6 +88,7 @@ export class Finding {
|
||||
record.bibliography.forEach(biblio => {
|
||||
citations += `
|
||||
<span class="is-clickable is-capitalized has-text-link"
|
||||
data-action="click->biblio#open"
|
||||
id="cit-${biblio.id}">
|
||||
${biblio.citation.toLowerCase()},
|
||||
</span> ${biblio.pages};
|
||||
@@ -97,8 +98,7 @@ export class Finding {
|
||||
<div class="p-2 mt-2" id="ref-${biblio.id}">
|
||||
<p>${biblio.reference}</p>
|
||||
</div>
|
||||
`
|
||||
);
|
||||
`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export class NotConservedSheet {
|
||||
</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" id="biblio"></div>
|
||||
<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>
|
||||
@@ -58,6 +58,7 @@ export class NotConservedSheet {
|
||||
record.bibliography.forEach(record => {
|
||||
citations += `
|
||||
<span class="is-clickable is-capitalized has-text-link"
|
||||
data-action="click->biblio#open"
|
||||
id="cit-${record.id}">
|
||||
${record.citation.toLowerCase()},
|
||||
</span> ${record.pages};
|
||||
|
||||
29
webgis/js/controllers/biblio_controller.js
Normal file
29
webgis/js/controllers/biblio_controller.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['biblio', 'cit', 'ref', 'close'];
|
||||
|
||||
open(event) {
|
||||
const biblio = window.Biblio;
|
||||
const target = event.currentTarget;
|
||||
const id = target.id.replace('cit-', '');
|
||||
|
||||
this.biblioTarget.innerHTML = '<button class="delete" data-action="click->biblio#hideBiblio"></button>';
|
||||
this.biblioTarget.innerHTML += biblio.getReference(id);
|
||||
|
||||
this.showBiblio();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.modalTarget.classList.remove('is-active');
|
||||
}
|
||||
|
||||
showBiblio() {
|
||||
this.biblioTarget.classList.remove('is-hidden');
|
||||
this.biblioTarget.scrollIntoView({behavior: 'smooth'});
|
||||
}
|
||||
|
||||
hideBiblio() {
|
||||
this.biblioTarget.classList.add('is-hidden');
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { Application } from '@hotwired/stimulus';
|
||||
import MenuController from './controllers/menu_controller.js';
|
||||
import ModalController from './controllers/modal_controller.js';
|
||||
import MarkerController from './controllers/marker_controller.js';
|
||||
import BiblioController from './controllers/biblio_controller.js';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
// Register Stimulus controllers
|
||||
@@ -20,7 +21,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
|
||||
UI.addCenterMapControl(map, GIS.CENTER_COORDS, GIS.INIT_ZOOM);
|
||||
UI.toggleBurger('navbar-burger');
|
||||
UI.sitesMenu('.menu-list', map, sites);
|
||||
|
||||
window.LMap = map;
|
||||
});
|
||||
@@ -30,4 +30,5 @@ function initStimulus() {
|
||||
Stimulus.register("menu", MenuController);
|
||||
Stimulus.register("modal", ModalController);
|
||||
Stimulus.register("marker", MarkerController);
|
||||
Stimulus.register("biblio", BiblioController);
|
||||
}
|
||||
@@ -172,24 +172,9 @@ UI.openNotConserModal = async function (data, selector) {
|
||||
|
||||
let sheet = new NotConservedSheet();
|
||||
sheet.siteData = data;
|
||||
// For Stimulus biblio_controller
|
||||
window.Biblio = sheet;
|
||||
modal.querySelector('#not-conser-sheet').innerHTML = await sheet.render();
|
||||
modal.addEventListener('click', event => {
|
||||
const biblio = modal.querySelector('#biblio');
|
||||
if (event.target.id.includes('cit')) {
|
||||
|
||||
const id = event.target.id.replace('cit-','');
|
||||
|
||||
biblio.innerHTML = '<button class="delete"></button>';
|
||||
biblio.innerHTML += sheet.getReference(id);
|
||||
biblio.classList.remove('is-hidden');
|
||||
biblio.scrollIntoView({behavior: 'smooth'});
|
||||
}
|
||||
|
||||
if (event.target.className == 'delete') {
|
||||
biblio.classList.add('is-hidden');
|
||||
}
|
||||
});
|
||||
|
||||
modal.classList.add('is-active');
|
||||
}
|
||||
/**
|
||||
@@ -210,22 +195,8 @@ UI.openFindingModal = async function (data, selector) {
|
||||
finding.data = data;
|
||||
finding.setImages();
|
||||
modal.querySelector('#finding-sheet').innerHTML = await finding.render();
|
||||
modal.addEventListener('click', event => {
|
||||
const biblio = modal.querySelector('#biblio');
|
||||
|
||||
if (event.target.id.includes('cit')) {
|
||||
const id = event.target.id.replace('cit-','');
|
||||
|
||||
biblio.innerHTML = '<button class="delete"></button>';
|
||||
biblio.innerHTML += finding.getReference(id);
|
||||
biblio.classList.remove('is-hidden');
|
||||
biblio.scrollIntoView({behavior: 'smooth'});
|
||||
}
|
||||
|
||||
if (event.target.className == 'delete') {
|
||||
biblio.classList.add('is-hidden');
|
||||
}
|
||||
});
|
||||
// For Stimulus biblio_controller
|
||||
window.Biblio = finding;
|
||||
if (finding.images) {
|
||||
modal.querySelector('#photos').innerHTML = finding.renderImages();
|
||||
this.imageGallery('finding-gallery', finding.images);
|
||||
@@ -254,38 +225,6 @@ UI.openFindingModal = async function (data, selector) {
|
||||
});
|
||||
modal.classList.add('is-active');
|
||||
}
|
||||
/**
|
||||
* @param {string} menuListSel Menu list selector
|
||||
* @param {L.Map} map
|
||||
* @param {L.LayerGroup} sites
|
||||
*/
|
||||
UI.sitesMenu = function (menuListSel, map, sites) {
|
||||
let markers = [];
|
||||
|
||||
map.eachLayer(layer => {
|
||||
if (layer instanceof L.Marker) {
|
||||
markers.push(layer);
|
||||
}
|
||||
})
|
||||
|
||||
const menu = document.querySelector(menuListSel);
|
||||
menu.addEventListener('click', async event => {
|
||||
if (event.target.nodeName === 'A') {
|
||||
const layerId = event.target.id;
|
||||
const marker = markers.filter(m => m.id === layerId)[0];
|
||||
|
||||
// zoom to layer...
|
||||
const layer = sites.customGetLayer(layerId);
|
||||
map.setView(
|
||||
layer.getBounds().getCenter(),
|
||||
19,
|
||||
{animate: true, duration: 1, easeLinearity: 0.25}
|
||||
);
|
||||
|
||||
marker.openTooltip();
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Open Spotlight gallery
|
||||
* @param {string} galleryId The id of the trigger element
|
||||
|
||||
Reference in New Issue
Block a user