Add subscription pricing and Base drawing limit
This commit is contained in:
1 parent
ad64d6def0
commit
6a675ce635
15 files changed
+384
-37
No files matched your search
+32
-1
@@ -96,7 +96,9 @@ const lmeState = {
|
||||
culture: "it-IT",
|
||||
measurementSystem: "metric",
|
||||
entitlements: {
|
||||
advancedGeometry: false
|
||||
advancedGeometry: false,
|
||||
maxDrawingObjects: 15,
|
||||
drawingLimitMessage: "Hai raggiunto il limite di 15 oggetti del piano Base."
|
||||
},
|
||||
labels: {
|
||||
measureArea: "Misura area",
|
||||
@@ -213,6 +215,20 @@ function requireProFeature(feature) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function drawingObjectCount() {
|
||||
return lmeState.drawings ? managedRecordsForCategory("drawings").length : 0;
|
||||
}
|
||||
|
||||
function canAddDrawingObjects(amount = 1) {
|
||||
const configuredMaximum = lmeState.entitlements?.maxDrawingObjects;
|
||||
if (configuredMaximum === null || configuredMaximum === undefined || configuredMaximum === "") return true;
|
||||
const maximum = Number(configuredMaximum);
|
||||
if (!Number.isFinite(maximum) || maximum < 0) return true;
|
||||
if (drawingObjectCount() + Math.max(0, Number(amount) || 0) <= maximum) return true;
|
||||
setInfo(lmeState.entitlements?.drawingLimitMessage || `Limite di ${maximum} oggetti raggiunto.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
function init(dotNetReference) {
|
||||
if (dotNetReference) {
|
||||
lmeState.dotNetReference = dotNetReference;
|
||||
@@ -1775,6 +1791,10 @@ function moveManagedRecordsToGroup(records, targetCategory, targetSource, target
|
||||
setInfo("Sblocca il gruppo prima di spostarlo.");
|
||||
return;
|
||||
}
|
||||
const additionalDrawings = targetCategory === "drawings"
|
||||
? movable.filter(record => record.categoryKey !== "drawings").length
|
||||
: 0;
|
||||
if (!canAddDrawingObjects(additionalDrawings)) return;
|
||||
rememberMapChange();
|
||||
const features = movable.map(record => {
|
||||
const feature = record.layer.toGeoJSON();
|
||||
@@ -2684,6 +2704,7 @@ function storedFeatureStyle(feature) {
|
||||
function duplicateManagedRecords(records) {
|
||||
if (lmeState.readOnly) { setInfo("Il progetto e' in sola lettura."); return; }
|
||||
if (records.some(record => record.layer?.feature?.properties?._lmeLocked)) { setInfo("Sblocca gli oggetti da duplicare."); return; }
|
||||
if (!canAddDrawingObjects(records.length)) return;
|
||||
rememberMapChange();
|
||||
records.forEach((record, index) => {
|
||||
const feature = record.layer.toGeoJSON();
|
||||
@@ -3036,6 +3057,11 @@ function restoreLastTrashItem() {
|
||||
if (lmeState.readOnly) { setInfo("Il progetto e' in sola lettura."); return false; }
|
||||
const entry = lmeState.trash.pop();
|
||||
if (!entry) { setInfo("Il cestino e' vuoto."); return false; }
|
||||
const drawingsToRestore = entry.items.filter(item => !["imported", "importedSheets"].includes(item.categoryKey)).length;
|
||||
if (!canAddDrawingObjects(drawingsToRestore)) {
|
||||
lmeState.trash.push(entry);
|
||||
return false;
|
||||
}
|
||||
rememberMapChange();
|
||||
entry.items.forEach(item => {
|
||||
if (item.categoryKey === "imported") addImportedFeatures({ type: "FeatureCollection", features: [item.feature] });
|
||||
@@ -3825,6 +3851,7 @@ function clearImported() {
|
||||
}
|
||||
|
||||
function addProjectMarker(name) {
|
||||
if (!canAddDrawingObjects()) return false;
|
||||
rememberMapChange();
|
||||
const center = lmeState.map.getCenter();
|
||||
const label = (name || "Nuovo POI").trim();
|
||||
@@ -3840,6 +3867,7 @@ function addProjectMarker(name) {
|
||||
refreshLayerManager();
|
||||
selectDrawingLayer(marker);
|
||||
finishMapChange();
|
||||
return true;
|
||||
}
|
||||
|
||||
function configureDrawLabels() {
|
||||
@@ -3868,6 +3896,7 @@ function bindDrawingEvents() {
|
||||
setInfo("Il progetto e' in sola lettura.");
|
||||
return;
|
||||
}
|
||||
if (!canAddDrawingObjects()) return;
|
||||
snapDrawingLayer(event.layer);
|
||||
annotateDrawingLayer(event.layer, event.layerType);
|
||||
lmeState.drawings.addLayer(event.layer);
|
||||
@@ -4104,6 +4133,7 @@ function startMeasurementDrawing(mode) {
|
||||
if (!lmeState.map) {
|
||||
return;
|
||||
}
|
||||
if (!canAddDrawingObjects()) return;
|
||||
bindDrawingEvents();
|
||||
hideDrawingScopeMenu();
|
||||
if (lmeState.activeDrawHandler) {
|
||||
@@ -5736,6 +5766,7 @@ function bearingToCardinal(value) {
|
||||
|
||||
function saveGpsMeasurementPoint() {
|
||||
if (!lmeState.lastPosition) { setInfo("Attendi una posizione GPS valida."); return; }
|
||||
if (!canAddDrawingObjects()) return;
|
||||
rememberMapChange();
|
||||
const now = new Date();
|
||||
addDrawingFeature({ type: "Feature", properties: {
|
||||
|
||||
Reference in new issue
Block a user