mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 13:38:26 +02:00
Use assumed values for access placeholders (fixes #1924)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
iD.ui.preset.access = function(field) {
|
||||
var event = d3.dispatch('change'),
|
||||
entity,
|
||||
items;
|
||||
|
||||
function access(selection) {
|
||||
@@ -64,18 +63,84 @@ iD.ui.preset.access = function(field) {
|
||||
});
|
||||
};
|
||||
|
||||
access.entity = function(_) {
|
||||
if (!arguments.length) return entity;
|
||||
entity = _;
|
||||
return access;
|
||||
var placeholders = {
|
||||
footway: {
|
||||
foot: 'yes',
|
||||
motor_vehicle: 'no'
|
||||
},
|
||||
steps: {
|
||||
foot: 'yes',
|
||||
motor_vehicle: 'no'
|
||||
},
|
||||
pedestrian: {
|
||||
foot: 'yes',
|
||||
motor_vehicle: 'no'
|
||||
},
|
||||
cycleway: {
|
||||
bicycle: 'yes',
|
||||
motor_vehicle: 'no'
|
||||
},
|
||||
bridleway: {
|
||||
horse: 'yes'
|
||||
},
|
||||
path: {
|
||||
motor_vehicle: 'no'
|
||||
},
|
||||
motorway: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
trunk: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
primary: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
secondary: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
tertiary: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
residential: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
unclassified: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
service: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
motorway_link: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
trunk_link: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
primary_link: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
secondary_link: {
|
||||
motor_vehicle: 'yes'
|
||||
},
|
||||
tertiary_link: {
|
||||
motor_vehicle: 'yes'
|
||||
}
|
||||
};
|
||||
|
||||
access.tags = function(tags) {
|
||||
items.selectAll('.preset-input-access')
|
||||
.value(function(d) { return tags[d] || ''; })
|
||||
.attr('placeholder', function(d) {
|
||||
return d !== 'access' && tags.access ? tags.access : field.placeholder();
|
||||
.attr('placeholder', function() {
|
||||
return tags.access ? tags.access : field.placeholder();
|
||||
});
|
||||
|
||||
items.selectAll('#preset-input-access-access')
|
||||
.attr('placeholder', 'yes');
|
||||
|
||||
_.forEach(placeholders[tags.highway], function(value, key) {
|
||||
items.selectAll('#preset-input-access-' + key)
|
||||
.attr('placeholder', value);
|
||||
});
|
||||
};
|
||||
|
||||
access.focus = function() {
|
||||
|
||||
@@ -7,7 +7,7 @@ describe('iD.ui.preset.access', function() {
|
||||
});
|
||||
|
||||
it('creates inputs for a variety of modes of access', function() {
|
||||
var access = iD.ui.preset.access(field, {});
|
||||
var access = iD.ui.preset.access(field);
|
||||
selection.call(access);
|
||||
expect(selection.selectAll('.preset-access-access')[0].length).to.equal(1);
|
||||
expect(selection.selectAll('.preset-access-foot')[0].length).to.equal(1);
|
||||
@@ -17,7 +17,56 @@ describe('iD.ui.preset.access', function() {
|
||||
});
|
||||
|
||||
it('does not include a "yes" option for general access (#934)', function() {
|
||||
var access = iD.ui.preset.access(field, {});
|
||||
var access = iD.ui.preset.access(field);
|
||||
expect(_.pluck(access.options('access'), 'value')).not.to.include('yes');
|
||||
});
|
||||
|
||||
it('sets foot placeholder to "yes" for footways, steps, and pedestrian', function() {
|
||||
var access = iD.ui.preset.access(field);
|
||||
selection.call(access);
|
||||
|
||||
access.tags({highway: 'footway'});
|
||||
expect(selection.selectAll('#preset-input-access-foot').attr('placeholder')).to.equal('yes');
|
||||
|
||||
access.tags({highway: 'steps'});
|
||||
expect(selection.selectAll('#preset-input-access-foot').attr('placeholder')).to.equal('yes');
|
||||
|
||||
access.tags({highway: 'pedestrian'});
|
||||
expect(selection.selectAll('#preset-input-access-foot').attr('placeholder')).to.equal('yes');
|
||||
});
|
||||
|
||||
it('sets bicycle placeholder to "yes" for cycleways', function() {
|
||||
var access = iD.ui.preset.access(field);
|
||||
selection.call(access);
|
||||
|
||||
access.tags({highway: 'cycleway'});
|
||||
expect(selection.selectAll('#preset-input-access-bicycle').attr('placeholder')).to.equal('yes');
|
||||
});
|
||||
|
||||
it('sets horse placeholder to "yes" for bridleways', function() {
|
||||
var access = iD.ui.preset.access(field);
|
||||
selection.call(access);
|
||||
|
||||
access.tags({highway: 'bridleway'});
|
||||
expect(selection.selectAll('#preset-input-access-horse').attr('placeholder')).to.equal('yes');
|
||||
});
|
||||
|
||||
it('sets motor_vehicle placeholder to "no" for footways, steps, pedestrian, cycleway, and path', function() {
|
||||
var access = iD.ui.preset.access(field);
|
||||
selection.call(access);
|
||||
['footway', 'steps', 'pedestrian', 'cycleway', 'path'].forEach(function(value) {
|
||||
access.tags({highway: value});
|
||||
expect(selection.selectAll('#preset-input-access-motor_vehicle').attr('placeholder')).to.equal('no');
|
||||
});
|
||||
});
|
||||
|
||||
it('sets motor_vehicle placeholder to "yes" for various other highway tags', function() {
|
||||
var access = iD.ui.preset.access(field);
|
||||
selection.call(access);
|
||||
['residential', 'motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'service',
|
||||
'unclassified', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link'].forEach(function(value) {
|
||||
access.tags({highway: value});
|
||||
expect(selection.selectAll('#preset-input-access-motor_vehicle').attr('placeholder')).to.equal('yes');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user