add/make visible weakly matched presets

This commit is contained in:
Max Grossman
2018-12-14 15:42:25 -05:00
parent f627f1e659
commit d87b1822f7
3 changed files with 18 additions and 6 deletions

View File

@@ -503,8 +503,8 @@ export function coreContext() {
features.init();
if (utilStringQs(window.location.hash).presets) {
var external = utilStringQs(window.location.hash).presets;
presets.fromExternal(external, function(externalPresets){
presets = externalPresets; // default + external presets...
presets.fromExternal(external, function(externalPresets) {
context.presets = function() { return externalPresets; }; // default + external presets...
areaKeys = presets.areaKeys();
});
} else {

View File

@@ -73,7 +73,6 @@ export function presetIndex() {
if (address && (!match || match.isFallback())) {
match = address;
}
return match || all.item(geometry);
});
};
@@ -139,13 +138,23 @@ export function presetIndex() {
if (d.presets) {
_forEach(d.presets, function(d, id) {
all.collection.push(presetPreset(id, d, _fields, visible));
var existing = all.collection.findIndex(function(p) { return p.id === id; });
if (existing !== -1) {
all.collection[existing] = presetPreset(id, d, _fields, visible);
} else {
all.collection.push(presetPreset(id, d, _fields, visible));
}
});
}
if (d.categories) {
_forEach(d.categories, function(d, id) {
all.collection.push(presetCategory(id, d, all));
var existing = all.collection.findIndex(function(p) { return p.id === id; });
if (existing !== -1) {
all.collection[existing] = presetCategory(id, d, all);
} else {
all.collection.push(presetCategory(id, d, all));
}
});
}
@@ -165,7 +174,7 @@ export function presetIndex() {
var geometry = preset.geometry;
for (var j = 0; j < geometry.length; j++) {
var g = _index[geometry[j]];
var g = _index[geometry[j]];
for (var k in preset.tags) {
(g[k] = g[k] || []).push(preset);
}

View File

@@ -218,6 +218,8 @@ export function uiEntityEditor(context) {
// A "weak" preset doesn't set any tags. (e.g. "Address")
// Don't replace a weak preset with a fallback preset (e.g. "Point")
if (!(weakPreset && match.isFallback())) {
match.visible(true);
context.presets().choose(match);
entityEditor.preset(match);
}
entityEditor.modified(_base !== graph);
@@ -250,6 +252,7 @@ export function uiEntityEditor(context) {
context.overwrite(actionChangeTags(_entityID, tags), annotation);
} else {
context.perform(actionChangeTags(_entityID, tags), annotation);
// context.presets().choose(context.presets().match(context.graph))
_coalesceChanges = !!onInput;
}
}