Consenti di rinominare gli oggetti mappa
This commit is contained in:
1 parent
fc303e2555
commit
94805f1027
3 files changed
+75
-4
No files matched your search
@@ -28,8 +28,8 @@
|
||||
<ApplicationId>com.companyname.lmemappecatastaliapp</ApplicationId>
|
||||
|
||||
<!-- Versions -->
|
||||
<ApplicationDisplayVersion>0.2.22</ApplicationDisplayVersion>
|
||||
<ApplicationVersion>26</ApplicationVersion>
|
||||
<ApplicationDisplayVersion>0.2.23</ApplicationDisplayVersion>
|
||||
<ApplicationVersion>27</ApplicationVersion>
|
||||
|
||||
<!-- To develop, package, and publish an app to the Microsoft Store, see: https://aka.ms/MauiTemplateUnpackaged -->
|
||||
<WindowsPackageType>None</WindowsPackageType>
|
||||
|
||||
@@ -283,6 +283,10 @@ input[type="checkbox"] {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.layer-manager-object > summary {
|
||||
grid-template-columns: 28px 20px minmax(0, 1fr) auto auto auto;
|
||||
}
|
||||
|
||||
.layer-manager-group > summary::-webkit-details-marker,
|
||||
.layer-manager-block > summary::-webkit-details-marker,
|
||||
.layer-manager-object > summary::-webkit-details-marker {
|
||||
@@ -302,6 +306,21 @@ input[type="checkbox"] {
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
.layer-rename-button {
|
||||
min-height: 28px;
|
||||
padding: 0 8px;
|
||||
border: 1px solid #bfd4cd;
|
||||
border-radius: 4px;
|
||||
background: #eef8f5;
|
||||
color: var(--accent-strong);
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.layer-rename-button:active {
|
||||
background: #d9eee7;
|
||||
}
|
||||
|
||||
.layer-move-buttons {
|
||||
display: inline-grid;
|
||||
grid-template-columns: 24px 24px;
|
||||
|
||||
+54
-2
@@ -1145,6 +1145,42 @@ function managedObjectLabel(record, index) {
|
||||
return `Oggetto ${index + 1}`;
|
||||
}
|
||||
|
||||
function managedObjectEditableName(record) {
|
||||
const properties = record?.layer?.feature?.properties || {};
|
||||
return properties.name || properties.Name || properties.label || properties.LABEL || "";
|
||||
}
|
||||
|
||||
function managedObjectCanRename(record) {
|
||||
return ["drawings", "imported", "importedSheets"].includes(record.categoryKey)
|
||||
&& record.layer?.feature?.properties;
|
||||
}
|
||||
|
||||
function renameManagedObject(record, index) {
|
||||
if (!managedObjectCanRename(record)) {
|
||||
return;
|
||||
}
|
||||
const currentName = String(managedObjectEditableName(record) || managedObjectLabel(record, index)).trim();
|
||||
const requestedName = window.prompt("Nuovo nome oggetto", currentName);
|
||||
if (requestedName === null) {
|
||||
return;
|
||||
}
|
||||
const name = requestedName.trim().slice(0, 120);
|
||||
if (!name) {
|
||||
setInfo("Nome non modificato: inserisci un testo.");
|
||||
return;
|
||||
}
|
||||
const properties = record.layer.feature.properties;
|
||||
properties.name = name;
|
||||
record.layer.lmeManagerLabel = record.categoryKey === "drawings" && record.layer instanceof L.Marker
|
||||
? `POI: ${name}`
|
||||
: null;
|
||||
updateStoredFeaturePopup(record.layer);
|
||||
refreshImportedMeasurements();
|
||||
refreshDrawingMeasurements();
|
||||
refreshLayerManager();
|
||||
setInfo(`Oggetto rinominato: ${name}.`);
|
||||
}
|
||||
|
||||
function managedObjectDetails(layer) {
|
||||
const details = [];
|
||||
const properties = layer?.feature?.properties || {};
|
||||
@@ -1280,10 +1316,18 @@ function renderLayerManagerObject(record, index) {
|
||||
object.dataset.objectId = record.id;
|
||||
bindLayerManagerExpansion(object, `object:${record.id}`);
|
||||
const visible = !lmeState.managerHiddenObjectIds.has(record.id);
|
||||
object.innerHTML = `<summary><button type="button" class="layer-drag-handle" aria-label="Trascina oggetto">☰</button><input type="checkbox" ${visible ? "checked" : ""} aria-label="Mostra oggetto"><span class="layer-manager-title">${escapeHtml(managedObjectLabel(record, index))}</span>${layerManagerMoveButtons("oggetto")}<span class="layer-manager-count">›</span></summary><div class="layer-manager-details"></div>`;
|
||||
const renameButton = managedObjectCanRename(record)
|
||||
? `<button type="button" class="layer-rename-button" aria-label="Rinomina oggetto" title="Rinomina">Rinomina</button>`
|
||||
: "";
|
||||
object.innerHTML = `<summary><button type="button" class="layer-drag-handle" aria-label="Trascina oggetto">☰</button><input type="checkbox" ${visible ? "checked" : ""} aria-label="Mostra oggetto"><span class="layer-manager-title">${escapeHtml(managedObjectLabel(record, index))}</span>${renameButton}${layerManagerMoveButtons("oggetto")}<span class="layer-manager-count">›</span></summary><div class="layer-manager-details"></div>`;
|
||||
const checkbox = object.querySelector("input");
|
||||
checkbox.addEventListener("click", event => event.stopPropagation());
|
||||
checkbox.addEventListener("change", () => setManagedObjectVisible(record, checkbox.checked, true));
|
||||
object.querySelector(".layer-rename-button")?.addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
renameManagedObject(record, index);
|
||||
});
|
||||
object.querySelector(".layer-manager-title").addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
@@ -2641,10 +2685,18 @@ function clearManagedCategoryState(categoryKey) {
|
||||
}
|
||||
|
||||
function bindStoredFeaturePopup(feature, layer) {
|
||||
const properties = feature?.properties || {};
|
||||
updateStoredFeaturePopup(layer, feature?.properties);
|
||||
}
|
||||
|
||||
function updateStoredFeaturePopup(layer, sourceProperties) {
|
||||
const properties = sourceProperties || layer?.feature?.properties || {};
|
||||
const label = properties.name || properties.Name || properties.label || properties.LABEL;
|
||||
if (label) {
|
||||
layer.bindPopup(`<strong>${escapeHtml(label)}</strong>`);
|
||||
return;
|
||||
}
|
||||
if (typeof layer?.unbindPopup === "function") {
|
||||
layer.unbindPopup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user