display lane count on sidebar

This commit is contained in:
Kushan Joshi
2016-06-22 16:20:03 +05:30
committed by Bryan Housel
parent d130456393
commit 332200b404
3 changed files with 54 additions and 13 deletions
+1
View File
@@ -5,6 +5,7 @@ export { combo, typeCombo, multiCombo } from './combo';
export { cycleway } from './cycleway';
export { text, url, number, email, tel } from './input';
export { localized } from './localized';
export { lanes } from './lanes';
export { maxspeed } from './maxspeed';
export { radio } from './radio';
export { restrictions } from './restrictions';
+44
View File
@@ -0,0 +1,44 @@
export 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');
}