mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
display explicit "context" tags of deprecation rules, closes #10104
This commit is contained in:
@@ -41,6 +41,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
|
||||
#### :scissors: Operations
|
||||
#### :camera: Street-Level
|
||||
#### :white_check_mark: Validation
|
||||
* Show unchanged tags of a [deprecation rule](https://github.com/ideditor/schema-builder?tab=readme-ov-file#deprecations) explicitly in the validation warning ([#10104])
|
||||
#### :bug: Bugfixes
|
||||
* Fix removed tooltips from re-appearing when using keyboard navigation ([#9873])
|
||||
#### :earth_asia: Localization
|
||||
@@ -49,6 +50,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
|
||||
#### :hammer: Development
|
||||
|
||||
[#9873]: https://github.com/openstreetmap/iD/issues/9873
|
||||
[#10104]: https://github.com/openstreetmap/iD/issues/10104
|
||||
|
||||
|
||||
# v2.33.0
|
||||
|
||||
@@ -55,9 +55,10 @@ export function validationOutdatedTags() {
|
||||
}
|
||||
const nsiDiff = nsiResult ? utilTagDiff(oldTags, nsiResult.newTags) : [];
|
||||
|
||||
// Upgrade deprecated tags..
|
||||
// Upgrade deprecated tags
|
||||
let deprecatedTags;
|
||||
if (_dataDeprecated) {
|
||||
const deprecatedTags = getDeprecatedTags(entity.tags, _dataDeprecated);
|
||||
deprecatedTags = getDeprecatedTags(entity.tags, _dataDeprecated);
|
||||
if (entity.type === 'way' && entity.isClosed() &&
|
||||
entity.tags.traffic_calming === 'island' && !entity.tags.highway) {
|
||||
// https://github.com/openstreetmap/id-tagging-schema/issues/1162#issuecomment-2000356902
|
||||
@@ -90,13 +91,23 @@ export function validationOutdatedTags() {
|
||||
}
|
||||
});
|
||||
}
|
||||
const deprecationDiff = utilTagDiff(oldTags, newTags);
|
||||
const deprecationDiff = utilTagDiff(oldTags, newTags).concat(
|
||||
Object.keys(oldTags)
|
||||
.filter(key => deprecatedTags?.some(deprecated => deprecated.replace?.[key] !== undefined))
|
||||
.filter(key => newTags[key] === oldTags[key])
|
||||
.map(key => ({
|
||||
type: '~',
|
||||
key,
|
||||
oldVal: oldTags[key],
|
||||
newVal: newTags[key],
|
||||
display: ' ' + key + '=' + oldTags[key]
|
||||
})));
|
||||
|
||||
let issues = [];
|
||||
issues.provisional = (_waitingForDeprecated || waitingForNsi);
|
||||
|
||||
if (deprecationDiff.length) {
|
||||
const isOnlyAddingTags = deprecationDiff.every(d => d.type === '+');
|
||||
const isOnlyAddingTags = !deprecationDiff.some(d => d.type === '-');
|
||||
const prefix = isOnlyAddingTags ? 'incomplete.' : '';
|
||||
|
||||
issues.push(new validationIssue({
|
||||
@@ -244,8 +255,15 @@ export function validationOutdatedTags() {
|
||||
.attr('class', 'tagDiff-row')
|
||||
.append('td')
|
||||
.attr('class', d => {
|
||||
let klass = d.type === '+' ? 'add' : 'remove';
|
||||
return `tagDiff-cell tagDiff-cell-${klass}`;
|
||||
const klass = 'tagDiff-cell';
|
||||
switch (d.type) {
|
||||
case '+':
|
||||
return `${klass} tagDiff-cell-add`;
|
||||
case '-':
|
||||
return `${klass} tagDiff-cell-remove`;
|
||||
default:
|
||||
return `${klass} tagDiff-cell-unchanged`;
|
||||
}
|
||||
})
|
||||
.html(d => d.display);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { select as d3_select } from 'd3-selection';
|
||||
import { setTimeout } from 'node:timers/promises';
|
||||
|
||||
describe('iD.validations.outdated_tags', function () {
|
||||
@@ -194,6 +195,20 @@ describe('iD.validations.outdated_tags', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('includes unchanged context tags of deprecation rule in tag reference', async () => {
|
||||
createWay({ building: 'roof' });
|
||||
const validator = iD.validationOutdatedTags(context);
|
||||
await setTimeout(20);
|
||||
const issues = validate(validator);
|
||||
expect(issues).toHaveLength(1);
|
||||
const selection = d3_select(document.createElement('div'));
|
||||
issues[0].reference(selection);
|
||||
const tagReference = selection.selectAll('table .tagDiff-row').data();
|
||||
expect(tagReference).toHaveLength(2);
|
||||
expect(tagReference.some(ref => ref.type === '+' && ref.key === 'layer')).toBeTruthy();
|
||||
expect(tagReference.some(ref => ref.type === '~' && ref.key === 'building')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('generates 2 separate issues for incomplete tags and NSI suggestions', async () => {
|
||||
createWay({ building: 'roof', amenity: 'fast_food', brand: 'Fish Bowl' });
|
||||
const validator = iD.validationOutdatedTags(context);
|
||||
|
||||
Reference in New Issue
Block a user