mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 13:38:26 +02:00
universal presets
presets with universal=true show up for any preset if the key is present
This commit is contained in:
@@ -28,7 +28,6 @@ fs.writeFileSync('data/presets/presets.json', JSON.stringify(
|
||||
fs.writeFileSync('data/data.js', 'iD.data = ' + JSON.stringify({
|
||||
deprecated: r('deprecated.json'),
|
||||
discarded: r('discarded.json'),
|
||||
imagery: r('imagery.json'),
|
||||
keys: r('keys.json'),
|
||||
imagery: r('imagery.json'),
|
||||
presets: {
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
"addr:housenumber",
|
||||
"addr:street",
|
||||
"addr:city"
|
||||
]
|
||||
],
|
||||
"universal": true
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"key": "ele",
|
||||
"type": "number"
|
||||
}
|
||||
"type": "number",
|
||||
"universal": true
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"key": "source",
|
||||
"type": "text",
|
||||
"universal": true
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"key": "phone",
|
||||
"type": "tel",
|
||||
"universal": true
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"key": "website",
|
||||
"type": "url",
|
||||
"universal": true
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"key": "wikipedia",
|
||||
"type": "text",
|
||||
"universal": true
|
||||
}
|
||||
@@ -15,6 +15,7 @@ iD.presets = function(context) {
|
||||
all = iD.presets.Collection([iD.presets.Preset(other)]),
|
||||
defaults = { area: all, line: all, point: all, vertex: all },
|
||||
forms = {},
|
||||
universal = [],
|
||||
recent = iD.presets.Collection([]);
|
||||
|
||||
all.load = function(d) {
|
||||
@@ -22,6 +23,7 @@ iD.presets = function(context) {
|
||||
if (d.forms) {
|
||||
_.forEach(d.forms, function(d, id) {
|
||||
forms[id] = iD.presets.Form(d, id);
|
||||
if (d.universal) universal.push(forms[id]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,6 +33,7 @@ iD.presets = function(context) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (d.categories) {
|
||||
d.categories.forEach(function(d) {
|
||||
all.collection.push(iD.presets.Category(d, all));
|
||||
@@ -50,6 +53,10 @@ iD.presets = function(context) {
|
||||
return all;
|
||||
};
|
||||
|
||||
all.universal = function() {
|
||||
return universal;
|
||||
};
|
||||
|
||||
all.defaults = function(entity, n) {
|
||||
var rec = recent.matchGeometry(entity, context.graph()).collection.slice(0, 4),
|
||||
def = _.uniq(rec.concat(defaults[entity.geometry(context.graph())].collection)).slice(0, n - 1);
|
||||
|
||||
+7
-1
@@ -46,7 +46,7 @@ iD.ui.preset = function(context) {
|
||||
.enter()
|
||||
.append('button')
|
||||
.attr('class', 'preset-add-form')
|
||||
.attr('title', function(d) { return d.title || d.key; })
|
||||
.attr('title', function(d) { return d.label(); })
|
||||
.on('click', addForm)
|
||||
.append('span')
|
||||
.attr('class', function(d) { return 'icon ' + d.icon; });
|
||||
@@ -105,6 +105,12 @@ iD.ui.preset = function(context) {
|
||||
}
|
||||
});
|
||||
|
||||
context.presets().universal().forEach(function(p) {
|
||||
if (haveKey(p.key) || _.any(p.keys, haveKey)) {
|
||||
draw(formwrap, [p]);
|
||||
}
|
||||
});
|
||||
|
||||
event.setTags(tags);
|
||||
return presets;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user