From 68be0ae388c13aaff5a3dccd6842d099d3c14038 Mon Sep 17 00:00:00 2001 From: Will Freeman Date: Thu, 19 Jun 2025 18:16:57 -0600 Subject: [PATCH] handle wikidata, reset presets to custom --- config/id.js | 2 +- modules/modes/drag_node.js | 8 ++++---- modules/ui/field.js | 31 +++++++++++++++++++++++++++++++ modules/ui/tools/modes.js | 2 +- scripts/build_data.js | 4 ++-- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/config/id.js b/config/id.js index dbdc56512..d06f5d02d 100644 --- a/config/id.js +++ b/config/id.js @@ -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 diff --git a/modules/modes/drag_node.js b/modules/modes/drag_node.js index 1334f9b1e..ccf0a81f4 100644 --- a/modules/modes/drag_node.js +++ b/modules/modes/drag_node.js @@ -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') diff --git a/modules/ui/field.js b/modules/ui/field.js index d6a7333aa..ed738d3d8 100644 --- a/modules/ui/field.js +++ b/modules/ui/field.js @@ -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); } diff --git a/modules/ui/tools/modes.js b/modules/ui/tools/modes.js index 3f04f8856..3176b8e78 100644 --- a/modules/ui/tools/modes.js +++ b/modules/ui/tools/modes.js @@ -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' }) ]; diff --git a/scripts/build_data.js b/scripts/build_data.js index 1f2b57008..ca4d6bc01 100644 --- a/scripts/build_data.js +++ b/scripts/build_data.js @@ -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;