handle wikidata, reset presets to custom

This commit is contained in:
Will Freeman
2025-06-19 18:16:57 -06:00
parent 5357a235e1
commit 68be0ae388
5 changed files with 39 additions and 8 deletions

View File

@@ -2,7 +2,7 @@
// cdns for external data packages
const presetsCdnUrl = ENV__ID_PRESETS_CDN_URL
|| 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@{presets_version}/';
|| 'https://id-tagging-schema.deflock.me/';
const ociCdnUrl = ENV__ID_OCI_CDN_URL
|| 'https://cdn.jsdelivr.net/npm/osm-community-index@{version}/';
const wmfSitematrixCdnUrl = ENV__ID_WMF_SITEMATRIX_CDN_URL

View File

@@ -130,9 +130,9 @@ export function modeDragNode(context) {
function start(d3_event, entity) {
_wasMidpoint = entity.type === 'midpoint';
var hasHidden = context.features().hasHiddenConnections(entity, context.graph());
var isNewFeature = !entity.version;
// var isALPR = entity.tags && entity.tags['surveillance:type'] === 'ALPR'; // Allow ALPR editing
_isCancelled = !context.editable() || d3_event.shiftKey || hasHidden || !isNewFeature;
// var isNewFeature = !entity.version;
var isALPR = entity.tags && entity.tags['surveillance:type'] === 'ALPR';
_isCancelled = !context.editable() || d3_event.shiftKey || hasHidden || !isALPR;
if (_isCancelled) {
if (hasHidden) {
@@ -140,7 +140,7 @@ export function modeDragNode(context) {
.duration(4000)
.iconName('#iD-icon-no')
.label(t.append('modes.drag_node.connected_to_hidden'))();
} else if (!isNewFeature) {
} else if (!isALPR) {
context.ui().flash
.duration(4000)
.iconName('#iD-icon-no')

View File

@@ -53,6 +53,33 @@ export function uiField(context, presetField, entityIDs, options) {
field.impl = uiFields[field.type](field, context)
.on('change', function(t, onInput) {
dispatch.call('change', field, t, onInput);
// Ensure the logic for manufacturer:wikidata is executed after a change
if (field.key === 'manufacturer') {
const manufacturersToWikidata = {
'Flock Safety': 'Q108485435',
'Motorola Solutions': 'Q634815',
'Genetec': 'Q30295174',
'Leonardo': 'Q910379',
};
const currentManufacturer = t['manufacturer'];
if (currentManufacturer) {
const wikidataKey = 'manufacturer:wikidata';
const wikidataValue = manufacturersToWikidata[currentManufacturer];
if (t[wikidataKey] !== wikidataValue) {
const tagUpdate = {};
tagUpdate[wikidataKey] = wikidataValue;
dispatch.call('change', this, tagUpdate);
}
} else {
// If the manufacturer is removed, ensure the wikidata tag is deleted
const wikidataKey = 'manufacturer:wikidata';
const tagUpdate = {};
tagUpdate[wikidataKey] = undefined;
dispatch.call('change', this, tagUpdate);
}
}
});
if (entityIDs) {
@@ -133,6 +160,10 @@ export function uiField(context, presetField, entityIDs, options) {
t[key] = undefined;
});
if (d.key === 'manufacturer') {
t['manufacturer:wikidata'] = undefined;
}
dispatch.call('change', d, t);
}

View File

@@ -26,7 +26,7 @@ export function uiToolDrawModes(context) {
title: t.append('modes.add_point.title'),
button: 'point',
description: t.append('modes.add_point.description'),
preset: presetManager.item('man_made/surveillance/camera'), // Restrict to ALPR preset
preset: presetManager.item('man_made/surveillance/alpr'), // Restrict to ALPR preset
key: '1'
})
];

View File

@@ -17,9 +17,9 @@ fontawesome.library.add(fas, far, fab);
const dotenv = require('dotenv');
dotenv.config();
const presetsVersion = require('../package.json').devDependencies['@openstreetmap/id-tagging-schema'];
// const presetsVersion = require('../package.json').devDependencies['@openstreetmap/id-tagging-schema'];
/* eslint-disable no-process-env */
const presetsUrl = (process.env.ID_PRESETS_CDN_URL || 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@{presets_version}/').replace('{presets_version}', presetsVersion);
const presetsUrl = (process.env.ID_PRESETS_CDN_URL || 'https://id-tagging-schema.deflock.me/');
/* eslint-enable no-process-env */
let _currBuild = null;