mapping fixes, select by map
parent
b2da12dac1
commit
452565943e
|
|
@ -17,6 +17,7 @@ export default async function handler(
|
||||||
|
|
||||||
response.json({
|
response.json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
||||||
burialSiteComments
|
burialSiteComments
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<div class="modal" role="dialog">
|
||||||
|
<div class="modal-background"></div>
|
||||||
|
<div class="modal-card">
|
||||||
|
<header class="modal-card-head">
|
||||||
|
<h3 class="modal-card-title">Select Coordinate</h3>
|
||||||
|
<button
|
||||||
|
class="delete is-close-modal-button"
|
||||||
|
aria-label="close"
|
||||||
|
type="button"
|
||||||
|
></button>
|
||||||
|
</header>
|
||||||
|
<section class="modal-card-body">
|
||||||
|
<div class="message is-info">
|
||||||
|
<div class="message-body">
|
||||||
|
<p>Click on the map to select a coordinate.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="leaflet-map" style="height:300px"></div>
|
||||||
|
</section>
|
||||||
|
<footer class="modal-card-foot is-justify-content-right">
|
||||||
|
<div class="buttons">
|
||||||
|
<button
|
||||||
|
class="button is-success is-update-button"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<span class="icon"><i class="fas fa-save" aria-hidden="true"></i></span>
|
||||||
|
<span>Update Coordinate</span>
|
||||||
|
</button>
|
||||||
|
<button class="button is-close-modal-button" type="button">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -183,6 +183,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Leaflet Map
|
||||||
|
document
|
||||||
|
.querySelector('#button--selectCoordinate')
|
||||||
|
?.addEventListener('click', (clickEvent) => {
|
||||||
|
clickEvent.preventDefault();
|
||||||
|
sunrise.openLeafletCoordinateSelectorModal({
|
||||||
|
latitudeElement: document.querySelector('#burialSite--burialSiteLatitude'),
|
||||||
|
longitudeElement: document.querySelector('#burialSite--burialSiteLongitude'),
|
||||||
|
callbackFunction: () => {
|
||||||
|
sunrise.setUnsavedChanges();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
// Comments
|
// Comments
|
||||||
let burialSiteComments = exports.burialSiteComments;
|
let burialSiteComments = exports.burialSiteComments;
|
||||||
delete exports.burialSiteComments;
|
delete exports.burialSiteComments;
|
||||||
|
|
|
||||||
|
|
@ -281,6 +281,27 @@ declare const exports: Record<string, unknown>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Leaflet Map
|
||||||
|
|
||||||
|
document
|
||||||
|
.querySelector('#button--selectCoordinate')
|
||||||
|
?.addEventListener('click', (clickEvent) => {
|
||||||
|
clickEvent.preventDefault()
|
||||||
|
|
||||||
|
sunrise.openLeafletCoordinateSelectorModal({
|
||||||
|
latitudeElement: document.querySelector(
|
||||||
|
'#burialSite--burialSiteLatitude'
|
||||||
|
) as HTMLInputElement,
|
||||||
|
longitudeElement: document.querySelector(
|
||||||
|
'#burialSite--burialSiteLongitude'
|
||||||
|
) as HTMLInputElement,
|
||||||
|
|
||||||
|
callbackFunction: () => {
|
||||||
|
sunrise.setUnsavedChanges()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
|
|
||||||
let burialSiteComments = exports.burialSiteComments as BurialSiteComment[]
|
let burialSiteComments = exports.burialSiteComments as BurialSiteComment[]
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,34 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
(() => {
|
(() => {
|
||||||
const mapContainerElement = document.querySelector('#burialSite--cemeterySvg');
|
/*
|
||||||
|
* Map
|
||||||
|
*/
|
||||||
|
const sunrise = exports.sunrise;
|
||||||
|
const mapContainerElement = document.querySelector('#burialSite--leaflet');
|
||||||
if (mapContainerElement !== null) {
|
if (mapContainerElement !== null) {
|
||||||
exports.sunrise.highlightMap(mapContainerElement, mapContainerElement.dataset.cemeterySvgId ?? '', 'success');
|
const mapLatitude = Number.parseFloat(mapContainerElement.dataset.latitude ?? '');
|
||||||
|
const mapLongitude = Number.parseFloat(mapContainerElement.dataset.longitude ?? '');
|
||||||
|
const mapCoordinates = [mapLatitude, mapLongitude];
|
||||||
|
// eslint-disable-next-line unicorn/no-array-callback-reference
|
||||||
|
const map = L.map(mapContainerElement);
|
||||||
|
map.setView(mapCoordinates, sunrise.leafletConstants.defaultZoom);
|
||||||
|
L.tileLayer(sunrise.leafletConstants.tileLayerURL, {
|
||||||
|
attribution: sunrise.leafletConstants.attribution,
|
||||||
|
maxZoom: sunrise.leafletConstants.maxZoom
|
||||||
|
}).addTo(map);
|
||||||
|
L.marker(mapCoordinates).addTo(map);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Image
|
||||||
|
*/
|
||||||
|
const svgContainerElement = document.querySelector('#burialSite--cemeterySvg');
|
||||||
|
if (svgContainerElement !== null) {
|
||||||
|
sunrise.highlightMap(svgContainerElement, svgContainerElement.dataset.cemeterySvgId ?? '', 'success');
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Contracts
|
||||||
|
*/
|
||||||
document
|
document
|
||||||
.querySelector('#burialSite--contractsToggle')
|
.querySelector('#burialSite--contractsToggle')
|
||||||
?.addEventListener('click', () => {
|
?.addEventListener('click', () => {
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,64 @@
|
||||||
|
import type * as Leaflet from 'leaflet'
|
||||||
|
|
||||||
import type { Sunrise } from './types.js'
|
import type { Sunrise } from './types.js'
|
||||||
|
|
||||||
|
declare const L: typeof Leaflet
|
||||||
declare const exports: {
|
declare const exports: {
|
||||||
sunrise: Sunrise
|
sunrise: Sunrise
|
||||||
}
|
}
|
||||||
;(() => {
|
;(() => {
|
||||||
|
/*
|
||||||
|
* Map
|
||||||
|
*/
|
||||||
|
|
||||||
|
const sunrise = exports.sunrise
|
||||||
|
|
||||||
const mapContainerElement: HTMLElement | null = document.querySelector(
|
const mapContainerElement: HTMLElement | null = document.querySelector(
|
||||||
'#burialSite--cemeterySvg'
|
'#burialSite--leaflet'
|
||||||
)
|
)
|
||||||
|
|
||||||
if (mapContainerElement !== null) {
|
if (mapContainerElement !== null) {
|
||||||
exports.sunrise.highlightMap(
|
const mapLatitude = Number.parseFloat(
|
||||||
mapContainerElement,
|
mapContainerElement.dataset.latitude ?? ''
|
||||||
mapContainerElement.dataset.cemeterySvgId ?? '',
|
)
|
||||||
|
const mapLongitude = Number.parseFloat(
|
||||||
|
mapContainerElement.dataset.longitude ?? ''
|
||||||
|
)
|
||||||
|
|
||||||
|
const mapCoordinates: Leaflet.LatLngTuple = [mapLatitude, mapLongitude]
|
||||||
|
|
||||||
|
// eslint-disable-next-line unicorn/no-array-callback-reference
|
||||||
|
const map: Leaflet.Map = L.map(mapContainerElement)
|
||||||
|
map.setView(mapCoordinates, sunrise.leafletConstants.defaultZoom)
|
||||||
|
|
||||||
|
L.tileLayer(sunrise.leafletConstants.tileLayerURL, {
|
||||||
|
attribution: sunrise.leafletConstants.attribution,
|
||||||
|
maxZoom: sunrise.leafletConstants.maxZoom
|
||||||
|
}).addTo(map)
|
||||||
|
|
||||||
|
L.marker(mapCoordinates).addTo(map)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Image
|
||||||
|
*/
|
||||||
|
|
||||||
|
const svgContainerElement: HTMLElement | null = document.querySelector(
|
||||||
|
'#burialSite--cemeterySvg'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (svgContainerElement !== null) {
|
||||||
|
sunrise.highlightMap(
|
||||||
|
svgContainerElement,
|
||||||
|
svgContainerElement.dataset.cemeterySvgId ?? '',
|
||||||
'success'
|
'success'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Contracts
|
||||||
|
*/
|
||||||
|
|
||||||
document
|
document
|
||||||
.querySelector('#burialSite--contractsToggle')
|
.querySelector('#burialSite--contractsToggle')
|
||||||
?.addEventListener('click', () => {
|
?.addEventListener('click', () => {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const sunrise = exports.sunrise;
|
const sunrise = exports.sunrise;
|
||||||
const cemeteryId = document.querySelector('#cemetery--cemeteryId').value;
|
const cemeteryId = document.querySelector('#cemetery--cemeteryId').value;
|
||||||
const isCreate = cemeteryId === '';
|
const isCreate = cemeteryId === '';
|
||||||
|
/*
|
||||||
|
* Cemetery Map
|
||||||
|
*/
|
||||||
|
document
|
||||||
|
.querySelector('#button--selectCoordinate')
|
||||||
|
?.addEventListener('click', (clickEvent) => {
|
||||||
|
clickEvent.preventDefault();
|
||||||
|
sunrise.openLeafletCoordinateSelectorModal({
|
||||||
|
latitudeElement: document.querySelector('#cemetery--cemeteryLatitude'),
|
||||||
|
longitudeElement: document.querySelector('#cemetery--cemeteryLongitude'),
|
||||||
|
callbackFunction: () => {
|
||||||
|
sunrise.setUnsavedChanges();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
/*
|
||||||
|
* Cemetery Form
|
||||||
|
*/
|
||||||
const cemeteryForm = document.querySelector('#form--cemetery');
|
const cemeteryForm = document.querySelector('#form--cemetery');
|
||||||
function setUnsavedChanges() {
|
function setUnsavedChanges() {
|
||||||
sunrise.setUnsavedChanges();
|
sunrise.setUnsavedChanges();
|
||||||
|
|
@ -28,14 +46,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bulmaJS.alert({
|
bulmaJS.alert({
|
||||||
message: "Cemetery Updated Successfully",
|
message: 'Cemetery Updated Successfully',
|
||||||
contextualColorName: 'success'
|
contextualColorName: 'success'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bulmaJS.alert({
|
bulmaJS.alert({
|
||||||
title: "Error Updating Cemetery",
|
title: 'Error Updating Cemetery',
|
||||||
message: responseJSON.errorMessage ?? '',
|
message: responseJSON.errorMessage ?? '',
|
||||||
contextualColorName: 'danger'
|
contextualColorName: 'danger'
|
||||||
});
|
});
|
||||||
|
|
@ -61,7 +79,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bulmaJS.alert({
|
bulmaJS.alert({
|
||||||
title: "Error Deleting Cemetery",
|
title: 'Error Deleting Cemetery',
|
||||||
message: responseJSON.errorMessage ?? '',
|
message: responseJSON.errorMessage ?? '',
|
||||||
contextualColorName: 'danger'
|
contextualColorName: 'danger'
|
||||||
});
|
});
|
||||||
|
|
@ -69,11 +87,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
bulmaJS.confirm({
|
bulmaJS.confirm({
|
||||||
title: "Delete Cemetery",
|
title: 'Delete Cemetery',
|
||||||
message: "Are you sure you want to delete this cemetery and all related burial sites?",
|
message: 'Are you sure you want to delete this cemetery and all related burial sites?',
|
||||||
contextualColorName: 'warning',
|
contextualColorName: 'warning',
|
||||||
okButton: {
|
okButton: {
|
||||||
text: "Yes, Delete Cemetery",
|
text: 'Yes, Delete Cemetery',
|
||||||
callbackFunction: doDelete
|
callbackFunction: doDelete
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,36 @@ declare const exports: Record<string, unknown>
|
||||||
const cemeteryId = (
|
const cemeteryId = (
|
||||||
document.querySelector('#cemetery--cemeteryId') as HTMLInputElement
|
document.querySelector('#cemetery--cemeteryId') as HTMLInputElement
|
||||||
).value
|
).value
|
||||||
|
|
||||||
const isCreate = cemeteryId === ''
|
const isCreate = cemeteryId === ''
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cemetery Map
|
||||||
|
*/
|
||||||
|
|
||||||
|
document
|
||||||
|
.querySelector('#button--selectCoordinate')
|
||||||
|
?.addEventListener('click', (clickEvent) => {
|
||||||
|
clickEvent.preventDefault()
|
||||||
|
|
||||||
|
sunrise.openLeafletCoordinateSelectorModal({
|
||||||
|
latitudeElement: document.querySelector(
|
||||||
|
'#cemetery--cemeteryLatitude'
|
||||||
|
) as HTMLInputElement,
|
||||||
|
longitudeElement: document.querySelector(
|
||||||
|
'#cemetery--cemeteryLongitude'
|
||||||
|
) as HTMLInputElement,
|
||||||
|
|
||||||
|
callbackFunction: () => {
|
||||||
|
sunrise.setUnsavedChanges()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cemetery Form
|
||||||
|
*/
|
||||||
|
|
||||||
const cemeteryForm = document.querySelector(
|
const cemeteryForm = document.querySelector(
|
||||||
'#form--cemetery'
|
'#form--cemetery'
|
||||||
) as HTMLFormElement
|
) as HTMLFormElement
|
||||||
|
|
@ -56,13 +84,13 @@ declare const exports: Record<string, unknown>
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
bulmaJS.alert({
|
bulmaJS.alert({
|
||||||
message: "Cemetery Updated Successfully",
|
message: 'Cemetery Updated Successfully',
|
||||||
contextualColorName: 'success'
|
contextualColorName: 'success'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bulmaJS.alert({
|
bulmaJS.alert({
|
||||||
title: "Error Updating Cemetery",
|
title: 'Error Updating Cemetery',
|
||||||
message: responseJSON.errorMessage ?? '',
|
message: responseJSON.errorMessage ?? '',
|
||||||
contextualColorName: 'danger'
|
contextualColorName: 'danger'
|
||||||
})
|
})
|
||||||
|
|
@ -101,7 +129,7 @@ declare const exports: Record<string, unknown>
|
||||||
globalThis.location.href = sunrise.getCemeteryURL()
|
globalThis.location.href = sunrise.getCemeteryURL()
|
||||||
} else {
|
} else {
|
||||||
bulmaJS.alert({
|
bulmaJS.alert({
|
||||||
title: "Error Deleting Cemetery",
|
title: 'Error Deleting Cemetery',
|
||||||
message: responseJSON.errorMessage ?? '',
|
message: responseJSON.errorMessage ?? '',
|
||||||
contextualColorName: 'danger'
|
contextualColorName: 'danger'
|
||||||
})
|
})
|
||||||
|
|
@ -111,11 +139,12 @@ declare const exports: Record<string, unknown>
|
||||||
}
|
}
|
||||||
|
|
||||||
bulmaJS.confirm({
|
bulmaJS.confirm({
|
||||||
title: "Delete Cemetery",
|
title: 'Delete Cemetery',
|
||||||
message: "Are you sure you want to delete this cemetery and all related burial sites?",
|
message:
|
||||||
|
'Are you sure you want to delete this cemetery and all related burial sites?',
|
||||||
contextualColorName: 'warning',
|
contextualColorName: 'warning',
|
||||||
okButton: {
|
okButton: {
|
||||||
text: "Yes, Delete Cemetery",
|
text: 'Yes, Delete Cemetery',
|
||||||
callbackFunction: doDelete
|
callbackFunction: doDelete
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,18 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call */
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
(() => {
|
(() => {
|
||||||
const mapContainerElement = document.querySelector('#map--leaflet');
|
const sunrise = exports.sunrise;
|
||||||
|
const mapContainerElement = document.querySelector('#cemetery--leaflet');
|
||||||
if (mapContainerElement !== null) {
|
if (mapContainerElement !== null) {
|
||||||
const mapLatitude = Number.parseFloat(mapContainerElement.dataset.mapLatitude ?? '');
|
const mapLatitude = Number.parseFloat(mapContainerElement.dataset.latitude ?? '');
|
||||||
const mapLongitude = Number.parseFloat(mapContainerElement.dataset.mapLongitude ?? '');
|
const mapLongitude = Number.parseFloat(mapContainerElement.dataset.longitude ?? '');
|
||||||
const mapCoordinates = [mapLatitude, mapLongitude];
|
const mapCoordinates = [mapLatitude, mapLongitude];
|
||||||
// eslint-disable-next-line unicorn/no-array-callback-reference
|
// eslint-disable-next-line unicorn/no-array-callback-reference
|
||||||
const map = L.map(mapContainerElement);
|
const map = L.map(mapContainerElement);
|
||||||
map.setView(mapCoordinates, 15);
|
map.setView(mapCoordinates, sunrise.leafletConstants.defaultZoom);
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
L.tileLayer(sunrise.leafletConstants.tileLayerURL, {
|
||||||
maxZoom: 19,
|
attribution: sunrise.leafletConstants.attribution,
|
||||||
attribution: '© OpenStreetMap'
|
maxZoom: sunrise.leafletConstants.maxZoom
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
L.marker(mapCoordinates).addTo(map);
|
L.marker(mapCoordinates).addTo(map);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,34 @@
|
||||||
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call */
|
|
||||||
|
|
||||||
import type * as Leaflet from 'leaflet'
|
import type * as Leaflet from 'leaflet'
|
||||||
|
|
||||||
declare const L
|
import type { Sunrise } from './types.js'
|
||||||
|
|
||||||
|
declare const L: typeof Leaflet
|
||||||
|
declare const exports: {
|
||||||
|
sunrise: Sunrise
|
||||||
|
}
|
||||||
;(() => {
|
;(() => {
|
||||||
|
const sunrise = exports.sunrise
|
||||||
|
|
||||||
const mapContainerElement: HTMLElement | null =
|
const mapContainerElement: HTMLElement | null =
|
||||||
document.querySelector('#map--leaflet')
|
document.querySelector('#cemetery--leaflet')
|
||||||
|
|
||||||
if (mapContainerElement !== null) {
|
if (mapContainerElement !== null) {
|
||||||
const mapLatitude = Number.parseFloat(
|
const mapLatitude = Number.parseFloat(
|
||||||
mapContainerElement.dataset.mapLatitude ?? ''
|
mapContainerElement.dataset.latitude ?? ''
|
||||||
)
|
)
|
||||||
const mapLongitude = Number.parseFloat(
|
const mapLongitude = Number.parseFloat(
|
||||||
mapContainerElement.dataset.mapLongitude ?? ''
|
mapContainerElement.dataset.longitude ?? ''
|
||||||
)
|
)
|
||||||
|
|
||||||
const mapCoordinates: Leaflet.LatLngTuple = [mapLatitude, mapLongitude]
|
const mapCoordinates: Leaflet.LatLngTuple = [mapLatitude, mapLongitude]
|
||||||
|
|
||||||
// eslint-disable-next-line unicorn/no-array-callback-reference
|
// eslint-disable-next-line unicorn/no-array-callback-reference
|
||||||
const map: Leaflet.Map = L.map(mapContainerElement)
|
const map: Leaflet.Map = L.map(mapContainerElement)
|
||||||
map.setView(mapCoordinates, 15)
|
map.setView(mapCoordinates, sunrise.leafletConstants.defaultZoom)
|
||||||
|
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
L.tileLayer(sunrise.leafletConstants.tileLayerURL, {
|
||||||
maxZoom: 19,
|
attribution: sunrise.leafletConstants.attribution,
|
||||||
attribution: '© OpenStreetMap'
|
maxZoom: sunrise.leafletConstants.maxZoom
|
||||||
}).addTo(map)
|
}).addTo(map)
|
||||||
|
|
||||||
L.marker(mapCoordinates).addTo(map)
|
L.marker(mapCoordinates).addTo(map)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
return _hasUnsavedChanges;
|
return _hasUnsavedChanges;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Mapping
|
* SVG Mapping
|
||||||
*/
|
*/
|
||||||
function highlightMap(mapContainerElement, mapKey, contextualClass) {
|
function highlightMap(mapContainerElement, mapKey, contextualClass) {
|
||||||
// Search for ID
|
// Search for ID
|
||||||
|
|
@ -41,6 +41,71 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Leaflet Mapping
|
||||||
|
*/
|
||||||
|
const leafletConstants = {
|
||||||
|
tileLayerURL: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
|
defaultZoom: 15,
|
||||||
|
maxZoom: 19,
|
||||||
|
attribution: '© OpenStreetMap'
|
||||||
|
};
|
||||||
|
function openLeafletCoordinateSelectorModal(options) {
|
||||||
|
const latitude = Number.parseFloat(options.latitudeElement.value);
|
||||||
|
const longitude = Number.parseFloat(options.longitudeElement.value);
|
||||||
|
let currentMarker;
|
||||||
|
cityssm.openHtmlModal('leaflet-selectCoordinate', {
|
||||||
|
onshown(modalElement, closeModalFunction) {
|
||||||
|
bulmaJS.toggleHtmlClipped();
|
||||||
|
/*
|
||||||
|
* Set up the Leaflet map
|
||||||
|
*/
|
||||||
|
const mapContainerElement = modalElement.querySelector('.leaflet-map');
|
||||||
|
// eslint-disable-next-line unicorn/no-array-callback-reference
|
||||||
|
const map = L.map(mapContainerElement);
|
||||||
|
L.tileLayer(sunrise.leafletConstants.tileLayerURL, {
|
||||||
|
attribution: sunrise.leafletConstants.attribution,
|
||||||
|
maxZoom: sunrise.leafletConstants.maxZoom
|
||||||
|
}).addTo(map);
|
||||||
|
if (!Number.isNaN(latitude) && !Number.isNaN(longitude)) {
|
||||||
|
const mapCoordinates = [latitude, longitude];
|
||||||
|
map.setView(mapCoordinates, sunrise.leafletConstants.defaultZoom);
|
||||||
|
currentMarker = L.marker(mapCoordinates).addTo(map);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const middleLatitude = (Number.parseFloat(options.latitudeElement.min) + Number.parseFloat(options.latitudeElement.max)) / 2;
|
||||||
|
const middleLongitude = (Number.parseFloat(options.longitudeElement.min) + Number.parseFloat(options.longitudeElement.max)) / 2;
|
||||||
|
const mapCoordinates = [middleLatitude, middleLongitude];
|
||||||
|
map.setView(mapCoordinates, 5);
|
||||||
|
}
|
||||||
|
map.on('click', (clickEvent) => {
|
||||||
|
const mapCoordinates = clickEvent.latlng;
|
||||||
|
if (currentMarker !== undefined) {
|
||||||
|
currentMarker.remove();
|
||||||
|
}
|
||||||
|
currentMarker = L.marker(mapCoordinates).addTo(map);
|
||||||
|
});
|
||||||
|
modalElement
|
||||||
|
.querySelector('.is-update-button')
|
||||||
|
?.addEventListener('click', (clickEvent) => {
|
||||||
|
clickEvent.preventDefault();
|
||||||
|
if (currentMarker !== undefined) {
|
||||||
|
const mapCoordinates = currentMarker.getLatLng();
|
||||||
|
options.latitudeElement.value = mapCoordinates.lat.toFixed(8);
|
||||||
|
options.longitudeElement.value = mapCoordinates.lng.toFixed(8);
|
||||||
|
options.callbackFunction(mapCoordinates.lat, mapCoordinates.lng);
|
||||||
|
}
|
||||||
|
closeModalFunction();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onremoved() {
|
||||||
|
bulmaJS.toggleHtmlClipped();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Field Unlocking
|
||||||
|
*/
|
||||||
function unlockField(clickEvent) {
|
function unlockField(clickEvent) {
|
||||||
const fieldElement = clickEvent.currentTarget.closest('.field');
|
const fieldElement = clickEvent.currentTarget.closest('.field');
|
||||||
const inputOrSelectElement = fieldElement.querySelector('input, select');
|
const inputOrSelectElement = fieldElement.querySelector('input, select');
|
||||||
|
|
@ -206,6 +271,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
dynamicsGPIntegrationIsEnabled,
|
dynamicsGPIntegrationIsEnabled,
|
||||||
urlPrefix,
|
urlPrefix,
|
||||||
highlightMap,
|
highlightMap,
|
||||||
|
leafletConstants,
|
||||||
|
openLeafletCoordinateSelectorModal,
|
||||||
initializeUnlockFieldButtons,
|
initializeUnlockFieldButtons,
|
||||||
escapedAliases,
|
escapedAliases,
|
||||||
populateAliases,
|
populateAliases,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
import type { BulmaJS } from '@cityssm/bulma-js/types.js'
|
||||||
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
|
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
|
||||||
|
import type * as Leaflet from 'leaflet'
|
||||||
|
|
||||||
import type { Sunrise } from './types.js'
|
import type { Sunrise } from './types.js'
|
||||||
|
|
||||||
|
|
@ -13,7 +15,10 @@ type RandomColorHue =
|
||||||
| 'yellow'
|
| 'yellow'
|
||||||
type RandomColorLuminosity = 'bright' | 'dark' | 'light'
|
type RandomColorLuminosity = 'bright' | 'dark' | 'light'
|
||||||
|
|
||||||
|
declare const L: typeof Leaflet
|
||||||
declare const cityssm: cityssmGlobal
|
declare const cityssm: cityssmGlobal
|
||||||
|
declare const bulmaJS: BulmaJS
|
||||||
|
|
||||||
declare const exports: Record<string, unknown> & {
|
declare const exports: Record<string, unknown> & {
|
||||||
aliases: Record<string, string>
|
aliases: Record<string, string>
|
||||||
randomColor: (options?: {
|
randomColor: (options?: {
|
||||||
|
|
@ -49,7 +54,7 @@ declare const exports: Record<string, unknown> & {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mapping
|
* SVG Mapping
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function highlightMap(
|
function highlightMap(
|
||||||
|
|
@ -83,6 +88,100 @@ declare const exports: Record<string, unknown> & {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Leaflet Mapping
|
||||||
|
*/
|
||||||
|
|
||||||
|
const leafletConstants = {
|
||||||
|
tileLayerURL: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
|
|
||||||
|
defaultZoom: 15,
|
||||||
|
maxZoom: 19,
|
||||||
|
|
||||||
|
attribution: '© OpenStreetMap'
|
||||||
|
}
|
||||||
|
|
||||||
|
function openLeafletCoordinateSelectorModal(options: {
|
||||||
|
latitudeElement: HTMLInputElement
|
||||||
|
longitudeElement: HTMLInputElement
|
||||||
|
|
||||||
|
callbackFunction: (latitude: number, longitude: number) => void
|
||||||
|
}): void {
|
||||||
|
const latitude = Number.parseFloat(options.latitudeElement.value)
|
||||||
|
const longitude = Number.parseFloat(options.longitudeElement.value)
|
||||||
|
|
||||||
|
let currentMarker: Leaflet.Marker | undefined
|
||||||
|
|
||||||
|
cityssm.openHtmlModal('leaflet-selectCoordinate', {
|
||||||
|
onshown(modalElement, closeModalFunction) {
|
||||||
|
bulmaJS.toggleHtmlClipped()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up the Leaflet map
|
||||||
|
*/
|
||||||
|
|
||||||
|
const mapContainerElement = modalElement.querySelector(
|
||||||
|
'.leaflet-map'
|
||||||
|
) as HTMLElement
|
||||||
|
|
||||||
|
// eslint-disable-next-line unicorn/no-array-callback-reference
|
||||||
|
const map = L.map(mapContainerElement)
|
||||||
|
|
||||||
|
L.tileLayer(sunrise.leafletConstants.tileLayerURL, {
|
||||||
|
attribution: sunrise.leafletConstants.attribution,
|
||||||
|
maxZoom: sunrise.leafletConstants.maxZoom
|
||||||
|
}).addTo(map)
|
||||||
|
|
||||||
|
if (!Number.isNaN(latitude) && !Number.isNaN(longitude)) {
|
||||||
|
const mapCoordinates: Leaflet.LatLngTuple = [latitude, longitude]
|
||||||
|
map.setView(mapCoordinates, sunrise.leafletConstants.defaultZoom)
|
||||||
|
currentMarker = L.marker(mapCoordinates).addTo(map)
|
||||||
|
} else {
|
||||||
|
const middleLatitude = (Number.parseFloat(options.latitudeElement.min) + Number.parseFloat(options.latitudeElement.max)) / 2
|
||||||
|
const middleLongitude = (Number.parseFloat(options.longitudeElement.min) + Number.parseFloat(options.longitudeElement.max)) / 2
|
||||||
|
|
||||||
|
const mapCoordinates: Leaflet.LatLngTuple = [middleLatitude, middleLongitude]
|
||||||
|
map.setView(mapCoordinates, 5)
|
||||||
|
}
|
||||||
|
|
||||||
|
map.on('click', (clickEvent: Leaflet.LeafletMouseEvent) => {
|
||||||
|
const mapCoordinates = clickEvent.latlng as Leaflet.LatLng
|
||||||
|
|
||||||
|
if (currentMarker !== undefined) {
|
||||||
|
currentMarker.remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
currentMarker = L.marker(mapCoordinates).addTo(map)
|
||||||
|
})
|
||||||
|
|
||||||
|
modalElement
|
||||||
|
.querySelector('.is-update-button')
|
||||||
|
?.addEventListener('click', (clickEvent) => {
|
||||||
|
clickEvent.preventDefault()
|
||||||
|
|
||||||
|
if (currentMarker !== undefined) {
|
||||||
|
const mapCoordinates = currentMarker.getLatLng() as Leaflet.LatLng
|
||||||
|
|
||||||
|
options.latitudeElement.value = mapCoordinates.lat.toFixed(8)
|
||||||
|
options.longitudeElement.value = mapCoordinates.lng.toFixed(8)
|
||||||
|
|
||||||
|
options.callbackFunction(mapCoordinates.lat, mapCoordinates.lng)
|
||||||
|
}
|
||||||
|
|
||||||
|
closeModalFunction()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
onremoved() {
|
||||||
|
bulmaJS.toggleHtmlClipped()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Field Unlocking
|
||||||
|
*/
|
||||||
|
|
||||||
function unlockField(clickEvent: Event): void {
|
function unlockField(clickEvent: Event): void {
|
||||||
const fieldElement = (clickEvent.currentTarget as HTMLElement).closest(
|
const fieldElement = (clickEvent.currentTarget as HTMLElement).closest(
|
||||||
'.field'
|
'.field'
|
||||||
|
|
@ -347,6 +446,9 @@ declare const exports: Record<string, unknown> & {
|
||||||
urlPrefix,
|
urlPrefix,
|
||||||
|
|
||||||
highlightMap,
|
highlightMap,
|
||||||
|
leafletConstants,
|
||||||
|
openLeafletCoordinateSelectorModal,
|
||||||
|
|
||||||
initializeUnlockFieldButtons,
|
initializeUnlockFieldButtons,
|
||||||
|
|
||||||
escapedAliases,
|
escapedAliases,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,18 @@
|
||||||
export interface Sunrise {
|
export interface Sunrise {
|
||||||
urlPrefix: string;
|
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
|
urlPrefix: string;
|
||||||
highlightMap: (mapContainerElement: HTMLElement, mapKey: string, contextualClass: 'danger' | 'success') => void;
|
highlightMap: (mapContainerElement: HTMLElement, mapKey: string, contextualClass: 'danger' | 'success') => void;
|
||||||
|
leafletConstants: {
|
||||||
|
tileLayerURL: string;
|
||||||
|
defaultZoom: number;
|
||||||
|
maxZoom: number;
|
||||||
|
attribution: string;
|
||||||
|
};
|
||||||
|
openLeafletCoordinateSelectorModal: (options: {
|
||||||
|
latitudeElement: HTMLInputElement;
|
||||||
|
longitudeElement: HTMLInputElement;
|
||||||
|
callbackFunction: (latitude: number, longitude: number) => void;
|
||||||
|
}) => void;
|
||||||
initializeUnlockFieldButtons: (containerElement: HTMLElement) => void;
|
initializeUnlockFieldButtons: (containerElement: HTMLElement) => void;
|
||||||
populateAliases: (containerElement: HTMLElement) => void;
|
populateAliases: (containerElement: HTMLElement) => void;
|
||||||
escapedAliases: {
|
escapedAliases: {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
export interface Sunrise {
|
export interface Sunrise {
|
||||||
urlPrefix: string
|
|
||||||
apiKey: string
|
apiKey: string
|
||||||
|
urlPrefix: string
|
||||||
|
|
||||||
highlightMap: (
|
highlightMap: (
|
||||||
mapContainerElement: HTMLElement,
|
mapContainerElement: HTMLElement,
|
||||||
|
|
@ -8,6 +8,22 @@ export interface Sunrise {
|
||||||
contextualClass: 'danger' | 'success'
|
contextualClass: 'danger' | 'success'
|
||||||
) => void
|
) => void
|
||||||
|
|
||||||
|
leafletConstants: {
|
||||||
|
tileLayerURL: string
|
||||||
|
|
||||||
|
defaultZoom: number
|
||||||
|
maxZoom: number
|
||||||
|
|
||||||
|
attribution: string
|
||||||
|
}
|
||||||
|
|
||||||
|
openLeafletCoordinateSelectorModal: (options: {
|
||||||
|
latitudeElement: HTMLInputElement
|
||||||
|
longitudeElement: HTMLInputElement
|
||||||
|
|
||||||
|
callbackFunction: (latitude: number, longitude: number) => void
|
||||||
|
}) => void
|
||||||
|
|
||||||
initializeUnlockFieldButtons: (containerElement: HTMLElement) => void
|
initializeUnlockFieldButtons: (containerElement: HTMLElement) => void
|
||||||
|
|
||||||
populateAliases: (containerElement: HTMLElement) => void
|
populateAliases: (containerElement: HTMLElement) => void
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="level-right">
|
<div class="level-right">
|
||||||
<div class="level-item">
|
<div class="level-item">
|
||||||
<i class="fas fa-map-marker-alt" aria-hidden="true"></i>
|
<button class="button is-small" id="button--selectCoordinate" type="button">
|
||||||
|
<span class="icon"><i class="fas fa-map-marked-alt" aria-hidden="true"></i></span>
|
||||||
|
<span>Select Coordinate</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -59,42 +59,70 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="panel">
|
||||||
|
<div class="panel-block is-block">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column">
|
||||||
|
<p class="mb-2">
|
||||||
|
<strong>Cemetery</strong><br />
|
||||||
|
<a href="<%= urlPrefix %>/cemeteries/<%= burialSite.cemeteryId %>">
|
||||||
|
<%= burialSite.cemeteryName || "(No Name)" %>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<p class="mb-2">
|
||||||
|
<strong>Burial Site Type</strong><br />
|
||||||
|
<%= burialSite.burialSiteType %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Status</strong><br />
|
||||||
|
<%= burialSite.burialSiteStatus %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<% if (burialSite.burialSiteFields.length > 0) { %>
|
||||||
|
<div class="column">
|
||||||
|
<% for (const burialSiteField of burialSite.burialSiteFields) { %>
|
||||||
|
<p class="mb-2">
|
||||||
|
<strong><%= burialSiteField.burialSiteTypeField %></strong><br />
|
||||||
|
<% if (burialSiteField.fieldValue) { %>
|
||||||
|
<%= burialSiteField.fieldValue %>
|
||||||
|
<% } else { %>
|
||||||
|
<span class="has-text-grey">(No Value)</span>
|
||||||
|
<% } %>
|
||||||
|
</p>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<div class="level">
|
||||||
|
<div class="level-left">
|
||||||
|
<div class="level-item">
|
||||||
|
<h2 class="title is-5 has-text-weight-bold has-text-white">Geographic Location</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="level-right">
|
||||||
|
<div class="level-item">
|
||||||
|
<i class="fas fa-map-marker-alt" aria-hidden="true"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="panel-block is-block">
|
<div class="panel-block is-block">
|
||||||
<div class="columns">
|
<% if (burialSite.burialSiteLatitude && burialSite.burialSiteLongitude) { %>
|
||||||
<div class="column">
|
<div id="burialSite--leaflet" data-latitude="<%= burialSite.burialSiteLatitude %>" data-longitude="<%= burialSite.burialSiteLongitude %>" style="height:300px"></div>
|
||||||
<p class="mb-2">
|
<% } else { %>
|
||||||
<strong>Cemetery</strong><br />
|
<div class="message is-info">
|
||||||
<a href="<%= urlPrefix %>/cemeteries/<%= burialSite.cemeteryId %>">
|
<p class="message-body">
|
||||||
<%= burialSite.cemeteryName || "(No Name)" %>
|
There are no geographic coordinates associated with this burial site.
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
<p class="mb-2">
|
|
||||||
<strong>Burial Site Type</strong><br />
|
|
||||||
<%= burialSite.burialSiteType %>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<strong>Status</strong><br />
|
|
||||||
<%= burialSite.burialSiteStatus %>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% if (burialSite.burialSiteFields.length > 0) { %>
|
<% } %>
|
||||||
<div class="column">
|
|
||||||
<% for (const burialSiteField of burialSite.burialSiteFields) { %>
|
|
||||||
<p class="mb-2">
|
|
||||||
<strong><%= burialSiteField.burialSiteTypeField %></strong><br />
|
|
||||||
<% if (burialSiteField.fieldValue) { %>
|
|
||||||
<%= burialSiteField.fieldValue %>
|
|
||||||
<% } else { %>
|
|
||||||
<span class="has-text-grey">(No Value)</span>
|
|
||||||
<% } %>
|
|
||||||
</p>
|
|
||||||
<% } %>
|
|
||||||
</div>
|
|
||||||
<% } %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="level-right">
|
<div class="level-right">
|
||||||
<div class="level-item">
|
<div class="level-item">
|
||||||
<i class="fas fa-map-marker-alt" aria-hidden="true"></i>
|
<button class="button is-small" id="button--selectCoordinate" type="button">
|
||||||
|
<span class="icon"><i class="fas fa-map-marked-alt" aria-hidden="true"></i></span>
|
||||||
|
<span>Select Coordinate</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-block is-block">
|
<div class="panel-block is-block">
|
||||||
<% if (cemetery.cemeteryLatitude && cemetery.cemeteryLongitude) { %>
|
<% if (cemetery.cemeteryLatitude && cemetery.cemeteryLongitude) { %>
|
||||||
<div id="cemetery--leaflet" data-cemetery-latitude="<%= cemetery.cemeteryLatitude %>" data-cemetery-longitude="<%= cemetery.cemeteryLongitude %>" style="height:300px"></div>
|
<div id="cemetery--leaflet" data-latitude="<%= cemetery.cemeteryLatitude %>" data-longitude="<%= cemetery.cemeteryLongitude %>" style="height:300px"></div>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<div class="message is-info">
|
<div class="message is-info">
|
||||||
<p class="message-body">
|
<p class="message-body">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue