Interactive citations

This commit is contained in:
Nicolò P 2024-11-20 17:05:49 +01:00
parent 0ad8e5c7f9
commit 3043dccd50
6 changed files with 61 additions and 10 deletions

View File

@ -30,6 +30,12 @@ a:visited {
background: #fff; background: #fff;
font-family: inherit; font-family: inherit;
} }
.leaflet-top,
.leaflet-left {
z-index: 999 !important;
}
.leaflet-control a { .leaflet-control a {
text-decoration: none; text-decoration: none;
color: initial; color: initial;
@ -141,6 +147,10 @@ a:visited {
max-width: 600px; max-width: 600px;
left: 35vw; left: 35vw;
} }
/* Menu overlay */
#menu {
z-index: 1000;
}
/* Content in tabs */ /* Content in tabs */
.docs-title { .docs-title {
width: 300px; width: 300px;

View File

@ -42,7 +42,7 @@
<div class="loading loading-lg"></div> <div class="loading loading-lg"></div>
</div> </div>
<div class="main columns"> <div class="main columns">
<div class="column is-hidden" id="menu"> <div class="column is-hidden is-overlay has-background-white" id="menu">
<aside class="menu ml-4"> <aside class="menu ml-4">
<p class="menu-label"> <p class="menu-label">
Beni archeologici Beni archeologici
@ -77,9 +77,13 @@
</a> </a>
</li> </li>
</ul> </ul>
<p class="menu-label">
Beni non conservati
</p>
<ul class="menu-list" id="not-conserved"></ul>
</aside> </aside>
</div> </div>
<div class="column is-full"> <div class="column is-full is-relative">
<div id="map" aria-describedby="map-progress" aria-busy="true" style="position: relative;"> <div id="map" aria-describedby="map-progress" aria-busy="true" style="position: relative;">
<progress id="map-progress" class="p-2 progress is-medium is-link" aria-label="Map loading..." /> <progress id="map-progress" class="p-2 progress is-medium is-link" aria-label="Map loading..." />
</div> </div>

View File

@ -3,6 +3,7 @@
* @class NotConservedSheet * @class NotConservedSheet
*/ */
export class NotConservedSheet { export class NotConservedSheet {
biblioElements = [];
/** /**
* @param {object} data * @param {object} data
*/ */
@ -12,7 +13,7 @@ export class NotConservedSheet {
async render() { async render() {
return ` return `
<div class="container ml-3"> <div class="container">
<p class="p-2"> <p class="p-2">
<span class="icon has-text-link"> <span class="icon has-text-link">
<i class="fa fa-tag"></i> <i class="fa fa-tag"></i>
@ -41,6 +42,8 @@ export class NotConservedSheet {
</span> </span>
<strong>Bibliografia:</strong> ${await this.biblio(this._data.id)} <strong>Bibliografia:</strong> ${await this.biblio(this._data.id)}
</p> </p>
<div class="notification is-light mx-2 mt-2 p-2 is-hidden" id="biblio">
</div>
<p class="p-2"> <p class="p-2">
<strong>Autore scheda:</strong> ${this._data.author} <strong>Autore scheda:</strong> ${this._data.author}
</p> </p>
@ -50,18 +53,32 @@ export class NotConservedSheet {
async biblio(recordId) { async biblio(recordId) {
let record = await this.fetchData(`${window.API_URL}/not_conserved/${recordId}`); let record = await this.fetchData(`${window.API_URL}/not_conserved/${recordId}`);
let biblio = ''; let citations = '';
if (record.bibliography.length) { if (record.bibliography.length) {
record.bibliography.forEach(record => { record.bibliography.forEach(record => {
biblio += ` citations += `
<span class="is-capitalized">${record.citation.toLowerCase()}</span>, <span class="is-clickable is-capitalized has-text-link"
${record.pages}; id="cit-${record.id}">
${record.citation.toLowerCase()},
</span> ${record.pages};
`; `;
this.biblioElements.push(`
<div class="p-2" id="ref-${record.id}">
<p><strong>Riferimento</strong></p>
<p>${record.reference}</p>
</div>
`
);
}); });
} }
return biblio.trim().slice(0, -1); return citations.trim().slice(0, -1);
}
getReference(id) {
return this.biblioElements.find(ref => ref.includes(`ref-${id}`));
} }
async fetchData(url) { async fetchData(url) {

View File

@ -5,6 +5,7 @@
"author": "Nicolò P.", "author": "Nicolò P.",
"license": "GPLv3", "license": "GPLv3",
"dependencies": { "dependencies": {
"@hotwired/stimulus": "^3.2.2",
"@kalisio/leaflet-graphicscale": "^1.0.0", "@kalisio/leaflet-graphicscale": "^1.0.0",
"bulma": "^1.0.1", "bulma": "^1.0.1",
"fontawesome-free": "^1.0.4", "fontawesome-free": "^1.0.4",

View File

@ -69,8 +69,8 @@ UI.toggleMenu = function (triggerId) {
trigger.addEventListener('click', () => { trigger.addEventListener('click', () => {
const menu = document.querySelector('#menu'); const menu = document.querySelector('#menu');
menu.classList.toggle('is-hidden'); menu.classList.toggle('is-hidden');
menu.classList.toggle('is-2'); menu.classList.toggle('is-3');
document.querySelector('#map').parentElement.classList.toggle('is-full'); //document.querySelector('#map').parentElement.classList.toggle('is-full');
}); });
} }
/** /**
@ -154,6 +154,19 @@ UI.openNotConserModal = async function (data, selector) {
let sheet = new NotConservedSheet(); let sheet = new NotConservedSheet();
sheet.siteData = data; sheet.siteData = data;
modal.querySelector('#not-conser-sheet').innerHTML = await sheet.render(); modal.querySelector('#not-conser-sheet').innerHTML = await sheet.render();
modal.addEventListener('click', event => {
const biblio = document.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');
}
if (event.target.className == 'delete') {
biblio.classList.add('is-hidden');
}
});
modal.classList.add('is-active'); modal.classList.add('is-active');
const closeBtn = modal.querySelector('.modal-close'); const closeBtn = modal.querySelector('.modal-close');
@ -162,6 +175,7 @@ UI.openNotConserModal = async function (data, selector) {
// CLose modal when clicking either on the X button or on the background // CLose modal when clicking either on the X button or on the background
closeBtn.addEventListener('click', () => closeModal()); closeBtn.addEventListener('click', () => closeModal());
modalBg.addEventListener('click', () => closeModal()); modalBg.addEventListener('click', () => closeModal());
} }
/** /**
* Open a modal with project info * Open a modal with project info

View File

@ -2,6 +2,11 @@
# yarn lockfile v1 # yarn lockfile v1
"@hotwired/stimulus@^3.2.2":
version "3.2.2"
resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.2.2.tgz#071aab59c600fed95b97939e605ff261a4251608"
integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A==
"@kalisio/leaflet-graphicscale@^1.0.0": "@kalisio/leaflet-graphicscale@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/@kalisio/leaflet-graphicscale/-/leaflet-graphicscale-1.0.0.tgz#5a163e01805208b08ddafd9301e6ad0d4c603e51" resolved "https://registry.yarnpkg.com/@kalisio/leaflet-graphicscale/-/leaflet-graphicscale-1.0.0.tgz#5a163e01805208b08ddafd9301e6ad0d4c603e51"