mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
get validaiton objects on context
ref #remote-presets
This commit is contained in:
@@ -41,9 +41,11 @@ import { utilDetect } from '../util/detect';
|
||||
import {
|
||||
utilCallWhenIdle,
|
||||
utilRebind,
|
||||
utilExternalPresets
|
||||
utilExternalPresets,
|
||||
utilExternalValidationRules
|
||||
} from '../util';
|
||||
|
||||
import { validationCollection } from '../validations';
|
||||
|
||||
export var areaKeys = {};
|
||||
|
||||
@@ -494,11 +496,21 @@ export function coreContext() {
|
||||
|
||||
background.init();
|
||||
features.init();
|
||||
|
||||
// get external data if directed by query parameters
|
||||
if (utilExternalPresets()) {
|
||||
presets.fromExternal();
|
||||
} else {
|
||||
presets.init();
|
||||
}
|
||||
}
|
||||
|
||||
if (utilExternalValidationRules()) {
|
||||
var validations = validationCollection();
|
||||
validations.init(function(rules) {
|
||||
context.validationRules = function() { return rules; };
|
||||
});
|
||||
}
|
||||
|
||||
areaKeys = presets.areaKeys();
|
||||
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ export function presetIndex() {
|
||||
|
||||
};
|
||||
|
||||
all.fromExternal = function(callback) {
|
||||
all.fromExternal = function() {
|
||||
var presetsUrl = utilStringQs(window.location.hash)['presets'];
|
||||
d3_json(presetsUrl, function(err, presets) {
|
||||
if (err) all.init();
|
||||
|
||||
@@ -38,11 +38,11 @@ export function uiEntityEditor(context) {
|
||||
var rawTagEditor = uiRawTagEditor(context)
|
||||
.on('change', changeTags);
|
||||
|
||||
|
||||
function entityEditor(selection) {
|
||||
var entity = context.entity(_entityID);
|
||||
var tags = _clone(entity.tags);
|
||||
|
||||
console.log(context.validationRules());
|
||||
// Header
|
||||
var header = selection.selectAll('.header')
|
||||
.data([0]);
|
||||
|
||||
@@ -8,6 +8,7 @@ export { utilEditDistance } from './util';
|
||||
export { utilEntitySelector } from './util';
|
||||
export { utilEntityOrMemberSelector } from './util';
|
||||
export { utilExternalPresets } from './util';
|
||||
export { utilExternalValidationRules } from './util';
|
||||
export { utilFastMouse } from './util';
|
||||
export { utilFunctor } from './util';
|
||||
export { utilGetAllNodes } from './util';
|
||||
|
||||
@@ -270,3 +270,7 @@ export function utilNoAuto(selection) {
|
||||
export function utilExternalPresets() {
|
||||
return utilStringQs(window.location.hash).hasOwnProperty('presets');
|
||||
}
|
||||
|
||||
export function utilExternalValidationRules() {
|
||||
return utilStringQs(window.location.hash).hasOwnProperty('validations');
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export { validationCollection } from './validation_collection';
|
||||
export { validationDeprecatedTag } from './deprecated_tag';
|
||||
export { validationDisconnectedHighway } from './disconnected_highway';
|
||||
export { validationManyDeletions } from './many_deletions';
|
||||
|
||||
16
modules/validations/validation_collection.js
Normal file
16
modules/validations/validation_collection.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { utilStringQs } from '../util';
|
||||
import { text as d3_text } from 'd3-request';
|
||||
import mapcssParse from 'mapcss-parse/source/index';
|
||||
|
||||
export function validationCollection() {
|
||||
var validations = {};
|
||||
validations.init = function (callback) {
|
||||
var validationsUrl = utilStringQs(window.location.hash)['validations'];
|
||||
d3_text(validationsUrl, function(err, mapcss) {
|
||||
if (err) return;
|
||||
callback(mapcssParse(mapcss));
|
||||
});
|
||||
};
|
||||
|
||||
return validations;
|
||||
}
|
||||
Reference in New Issue
Block a user