mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-12 12:41:58 +02:00
Extend data model for validation issues
Add the Issues pane 1. Add a class to represent the validation issue 2. Extend the data model for an validation issue to (1) add a severity level field (useful for identify save-blocking issues later) (2) replace single entity with an array of entities (useful for issues involving multiple entities) (3) add a coordinates field for highlighting the location of the issue on the map (4) add a fixes field for possible automatic fixes 3. Update existing validation modules to use the new data model
This commit is contained in:
committed by
Xiaoming Gao
parent
0d0521c936
commit
07a53fe6ea
@@ -0,0 +1,41 @@
|
||||
import _isObject from 'lodash-es/isObject';
|
||||
|
||||
|
||||
var ValidationIssueType = Object.freeze({
|
||||
deprecated_tags: 'deprecated_tags',
|
||||
disconnected_highway: 'disconnected_highway',
|
||||
many_deletions: 'many_deletions',
|
||||
missing_tag: 'missing_tag',
|
||||
old_multipolygon: 'old_multipolygon',
|
||||
tag_suggests_area: 'tag_suggests_area',
|
||||
map_rule_issue: 'map_rule_issue',
|
||||
});
|
||||
|
||||
|
||||
var ValidationIssueSeverity = Object.freeze({
|
||||
warning: 'warning',
|
||||
error: 'error',
|
||||
});
|
||||
|
||||
|
||||
export { ValidationIssueType, ValidationIssueSeverity };
|
||||
|
||||
|
||||
export function validationIssue(attrs) {
|
||||
if (!_isObject(attrs)) throw new Error('Input attrs is not an object');
|
||||
if (!attrs.type || !ValidationIssueType.hasOwnProperty(attrs.type)) {
|
||||
throw new Error('Invalid attrs.type: ' + attrs.type);
|
||||
}
|
||||
if (!attrs.severity || !ValidationIssueSeverity.hasOwnProperty(attrs.severity)) {
|
||||
throw new Error('Invalid attrs.severity: ' + attr.severity);
|
||||
}
|
||||
if (!attrs.message) throw new Error('attrs.message is empty');
|
||||
|
||||
this.type = attrs.type;
|
||||
this.severity = attrs.severity;
|
||||
this.message = attrs.message;
|
||||
this.tooltip = attrs.tooltip;
|
||||
this.entities = attrs.entities; // expect an array of entities
|
||||
this.coordinates = attrs.coordinates; // expect an array of [lon, lat]
|
||||
this.fixes = attrs.fixes; // expect an array of functions for possible fixes
|
||||
}
|
||||
Reference in New Issue
Block a user