Use GisState for biblio as well

This commit is contained in:
Nicolò P 2025-06-02 21:58:17 +02:00
parent c265e4aa94
commit 5b5d0aeb3d
4 changed files with 11 additions and 20 deletions

View File

@ -23,7 +23,7 @@ export default API_CONFIG;
### Entry point ### Entry point
Il punto d'ingresso dell'applicazione è `webgis/js/index.js` che registra i controller Stimulus, inizializza alcune funzioni UI che potrebbero essere migrate in un controller Stimulus dedicato in futuro. Il punto d'ingresso dell'applicazione è `webgis/js/index.js` che registra i controller Stimulus e inizializza alcune funzioni UI (che potrebbero essere migrate in un controller Stimulus dedicato in futuro).
### Mappa ### Mappa

View File

@ -1,10 +1,11 @@
import { Controller } from "@hotwired/stimulus" import { Controller } from "@hotwired/stimulus"
import { GisState } from "../state.js";
export default class extends Controller { export default class extends Controller {
static targets = ['biblio', 'cit', 'ref', 'close']; static targets = ['biblio', 'cit', 'ref', 'close'];
open(event) { open(event) {
const biblio = window.Biblio; const biblio = GisState.bibliography;
this.trigger = event.currentTarget; this.trigger = event.currentTarget;
const id = this.trigger.id.replace('cit-', ''); const id = this.trigger.id.replace('cit-', '');
this.ref = this.biblioTarget; this.ref = this.biblioTarget;

View File

@ -8,18 +8,13 @@
* A lookup table of Leaflet layer groups by category * A lookup table of Leaflet layer groups by category
*/ */
/**
* @typedef {Object.<string, Object>} BibliographyLookup
* A lookup table of bibliography data by category
*/
/** /**
* @typedef {Object} GisStateType * @typedef {Object} GisStateType
* @property {L.Map|null} map * @property {L.Map|null} map
* @property {String|null} apiUrl * @property {String|null} apiUrl
* @property {MarkerLookup} markers * @property {MarkerLookup} markers
* @property {LayerGroupLookup} layers * @property {LayerGroupLookup} layers
* @property {BibliographyLookup} bibliography * @property {Object|null} bibliography
*/ */
/** @type {GisStateType} */ /** @type {GisStateType} */
@ -39,13 +34,7 @@ export const GisState = {
prehistoric: {}, prehistoric: {},
underwater: {}, underwater: {},
}, },
bibliography: { bibliography: null,
sites: {},
notConserved: {},
findings: {},
prehistoric: {},
underwater: {},
},
apiUrl : null, apiUrl : null,
} }

View File

@ -9,6 +9,7 @@ import { NotConserved } from './components/NotConserved.js';
import { Finding } from './components/Finding.js'; import { Finding } from './components/Finding.js';
import { Prehistoric } from './components/Prehistoric.js'; import { Prehistoric } from './components/Prehistoric.js';
import { Underwater } from './components/Underwater.js'; import { Underwater } from './components/Underwater.js';
import { GisState } from "./state.js";
/** /**
* @namespace UI * @namespace UI
@ -107,7 +108,7 @@ UI.openSiteModal = function (data, selector) {
let siteSheet = new SiteSheet(); let siteSheet = new SiteSheet();
siteSheet.siteData = data; siteSheet.siteData = data;
window.Biblio = siteSheet; GisState.bibliography = siteSheet;
modal.querySelector('#short-sheet').innerHTML = siteSheet.renderShort(); modal.querySelector('#short-sheet').innerHTML = siteSheet.renderShort();
if (data.description) { if (data.description) {
@ -169,7 +170,7 @@ UI.openNotConserModal = function (data, selector) {
let notConserved = new NotConserved(); let notConserved = new NotConserved();
notConserved.data = data; notConserved.data = data;
// For Stimulus biblio_controller // For Stimulus biblio_controller
window.Biblio = notConserved; GisState.bibliography = notConserved;
notConserved.render().then(html => modal.querySelector('#not-conserved-sheet').innerHTML = html); notConserved.render().then(html => modal.querySelector('#not-conserved-sheet').innerHTML = html);
notConserved.renderDocs().then(html => modal.querySelector('#documents').innerHTML = html); notConserved.renderDocs().then(html => modal.querySelector('#documents').innerHTML = html);
@ -191,7 +192,7 @@ UI.openFindingModal = function (data, selector) {
finding.data = data; finding.data = data;
// For Stimulus biblio_controller // For Stimulus biblio_controller
window.Biblio = finding; GisState.bibliography = finding;
finding.render().then(html => modal.querySelector('#finding-sheet').innerHTML = html); finding.render().then(html => modal.querySelector('#finding-sheet').innerHTML = html);
finding.setImages(modal.querySelector('#photos'), this.imageGallery); finding.setImages(modal.querySelector('#photos'), this.imageGallery);
@ -214,7 +215,7 @@ UI.openPrehistModal = function (data, selector) {
prehistoric.data = data; prehistoric.data = data;
// For Stimulus biblio_controller // For Stimulus biblio_controller
//window.Biblio = prehistoric; //GisState.bibliography = prehistoric;
prehistoric.render().then(html => modal.querySelector('#prehist-sheet').innerHTML = html); prehistoric.render().then(html => modal.querySelector('#prehist-sheet').innerHTML = html);
prehistoric.setImages(modal.querySelector('#photos'), this.imageGallery); prehistoric.setImages(modal.querySelector('#photos'), this.imageGallery);
modal.classList.add('is-active'); modal.classList.add('is-active');
@ -231,7 +232,7 @@ UI.openUnderwaterModal = function (data, selector) {
underwater.data = data; underwater.data = data;
// For Stimulus biblio_controller // For Stimulus biblio_controller
//window.Biblio = prehistoric; //GisState.bibliography = underwater;
underwater.render().then(html => modal.querySelector('#underwater-sheet').innerHTML = html); underwater.render().then(html => modal.querySelector('#underwater-sheet').innerHTML = html);
modal.classList.add('is-active'); modal.classList.add('is-active');
} }