Restore numeric lanes preset, but keep code for new WIP lanes field

This commit is contained in:
Bryan Housel
2016-06-22 16:21:51 -04:00
parent 8b0fb33c8b
commit 304b3b3579
6 changed files with 56 additions and 9 deletions
+2
View File
@@ -472,6 +472,8 @@ en:
lanes:
# 'lanes=*'
label: Lanes
# lanes field placeholder
placeholder: '1, 2, 3...'
layer:
# 'layer=*'
label: Layer
+3 -2
View File
@@ -647,8 +647,9 @@
},
"lanes": {
"key": "lanes",
"type": "lanes",
"label": "Lanes"
"type": "number",
"label": "Lanes",
"placeholder": "1, 2, 3..."
},
"layer": {
"key": "layer",
+3 -2
View File
@@ -1,5 +1,6 @@
{
"key": "lanes",
"type": "lanes",
"label": "Lanes"
"type": "number",
"label": "Lanes",
"placeholder":"1, 2, 3..."
}
+2 -1
View File
@@ -1046,7 +1046,8 @@
"label": "Type"
},
"lanes": {
"label": "Lanes"
"label": "Lanes",
"placeholder": "1, 2, 3..."
},
"layer": {
"label": "Layer"
+46
View File
@@ -1238,6 +1238,51 @@
return d3.rebind(localized, dispatch, 'on');
}
function lanes(field, context) {
var dispatch = d3.dispatch('change'),
wayID,
laneData;
function lanes(selection) {
// if form field is hidden or has detached from dom, clean up.
if (!d3.select('.inspector-wrap.inspector-hidden').empty() || !selection.node().parentNode) {
selection.call(lanes.off);
return;
}
laneData = context.entity(wayID).lanes();
var wrap = selection.selectAll('.preset-input-wrap')
.data([0]);
var enter = wrap.enter()
.append('div')
.attr('class', 'preset-input-wrap');
enter
.append('div')
.attr('class', 'lane-count')
.append('span');
selection.selectAll('.lane-count')
.text(laneData.tagged.lanes.count || laneData.defaults.lanes.count);
}
lanes.entity = function(_) {
if (!wayID || wayID !== _.id) {
wayID = _.id;
}
};
lanes.tags = function() {};
lanes.focus = function() {};
lanes.off = function() {};
return d3.rebind(lanes, dispatch, 'on');
}
function maxspeed(field, context) {
var dispatch = d3.dispatch('change'),
entity,
@@ -1851,6 +1896,7 @@
exports.email = url;
exports.tel = url;
exports.localized = localized;
exports.lanes = lanes;
exports.maxspeed = maxspeed;
exports.radio = radio;
exports.restrictions = restrictions;
-4
View File
@@ -88,10 +88,6 @@ export function preset(context) {
fields.push(UIField(context.presets().field('restrictions'), entity, true));
}
if (entity.lanes(context.graph())) {
fields.push(UIField(context.presets().field('lanes'), entity, true));
}
context.presets().universal().forEach(function(field) {
if (preset.fields.indexOf(field) < 0) {
fields.push(UIField(field, entity));