mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
add core overwrite for external preset source
ref #remote-presets
This commit is contained in:
@@ -306,7 +306,7 @@ export function coreContext() {
|
||||
/* Presets */
|
||||
var presets;
|
||||
context.presets = function() { return presets; };
|
||||
|
||||
context.overwritePresets = function(newPresets) { presets.overwrite(newPresets); };
|
||||
|
||||
/* Map */
|
||||
var map;
|
||||
|
||||
@@ -118,10 +118,7 @@ export function presetIndex() {
|
||||
return areaKeys;
|
||||
};
|
||||
|
||||
|
||||
all.init = function() {
|
||||
var d = data.presets;
|
||||
|
||||
all.build = function (d) {
|
||||
all.collection = [];
|
||||
_recent.collection = [];
|
||||
_fields = {};
|
||||
@@ -172,6 +169,15 @@ export function presetIndex() {
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
all.overwrite = function (d) {
|
||||
all.build(d);
|
||||
return all;
|
||||
};
|
||||
|
||||
all.init = function() {
|
||||
all.build(data.presets);
|
||||
return all;
|
||||
};
|
||||
|
||||
|
||||
@@ -156,7 +156,47 @@ describe('iD.presetIndex', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#overwrite', function() {
|
||||
it('overwrites iD presets with provided list of presets', function() {
|
||||
var testPresets = {
|
||||
presets: {
|
||||
'amenity/fuel/shell': {
|
||||
tags: { 'amenity': 'fuel' },
|
||||
geometry: ['point','area'],
|
||||
suggestion: true
|
||||
},
|
||||
'highway/foo': {
|
||||
tags: { 'highway': 'foo' },
|
||||
geometry: ['area']
|
||||
},
|
||||
'leisure/track': {
|
||||
tags: { 'leisure': 'track' },
|
||||
geometry: ['line', 'area']
|
||||
},
|
||||
'natural': {
|
||||
tags: { 'natural': '*' },
|
||||
geometry: ['point', 'vertex', 'area']
|
||||
},
|
||||
'natural/peak': {
|
||||
tags: { 'natural': 'peak' },
|
||||
geometry: ['point', 'vertex']
|
||||
},
|
||||
'natural/tree_row': {
|
||||
tags: { 'natural': 'tree_row' },
|
||||
geometry: ['line']
|
||||
},
|
||||
'natural/wood': {
|
||||
tags: { 'natural': 'wood' },
|
||||
geometry: ['point', 'area']
|
||||
}
|
||||
}
|
||||
};
|
||||
var currentPresets = iD.Context().presets();
|
||||
var overwrittenPresets = iD.Context().overwritePresets(testPresets);
|
||||
expect(currentPresets).to.not.eql(overwrittenPresets);
|
||||
});
|
||||
});
|
||||
|
||||
describe('expected matches', function() {
|
||||
|
||||
it('prefers building to multipolygon', function() {
|
||||
|
||||
Reference in New Issue
Block a user