From 429f20a450db5cd360fab571ba0b2abbcb996dd2 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 19 May 2014 12:22:52 -0400 Subject: [PATCH] Improve access tag placeholders #2221 --- js/id/ui/preset/access.js | 77 +++++++++++++++++++++++++++-------- test/spec/ui/preset/access.js | 36 ++++++++-------- 2 files changed, 79 insertions(+), 34 deletions(-) diff --git a/js/id/ui/preset/access.js b/js/id/ui/preset/access.js index d11788e38..2de42513e 100644 --- a/js/id/ui/preset/access.js +++ b/js/id/ui/preset/access.js @@ -66,65 +66,106 @@ iD.ui.preset.access = function(field) { var placeholders = { footway: { - foot: 'yes', + foot: 'designated', motor_vehicle: 'no' }, steps: { foot: 'yes', - motor_vehicle: 'no' + motor_vehicle: 'no', + bicycle: 'no', + horse: 'no' }, pedestrian: { foot: 'yes', motor_vehicle: 'no' }, cycleway: { - bicycle: 'yes', - motor_vehicle: 'no' + foot: 'yes', + motor_vehicle: 'no', + bicycle: 'designated' }, bridleway: { - horse: 'yes' + foot: 'yes', + motor_vehicle: 'no', + horse: 'designated' }, path: { - motor_vehicle: 'no' + foot: 'yes', + motor_vehicle: 'no', + bicycle: 'yes', + horse: 'yes' }, motorway: { - motor_vehicle: 'yes' + foot: 'no', + motor_vehicle: 'yes', + bicycle: 'no', + horse: 'no' }, trunk: { motor_vehicle: 'yes' }, primary: { - motor_vehicle: 'yes' + foot: 'yes', + motor_vehicle: 'yes', + bicycle: 'yes', + horse: 'yes' }, secondary: { - motor_vehicle: 'yes' + foot: 'yes', + motor_vehicle: 'yes', + bicycle: 'yes', + horse: 'yes' }, tertiary: { - motor_vehicle: 'yes' + foot: 'yes', + motor_vehicle: 'yes', + bicycle: 'yes', + horse: 'yes' }, residential: { - motor_vehicle: 'yes' + foot: 'yes', + motor_vehicle: 'yes', + bicycle: 'yes', + horse: 'yes' }, unclassified: { - motor_vehicle: 'yes' + foot: 'yes', + motor_vehicle: 'yes', + bicycle: 'yes', + horse: 'yes' }, service: { - motor_vehicle: 'yes' + foot: 'yes', + motor_vehicle: 'yes', + bicycle: 'yes', + horse: 'yes' }, motorway_link: { - motor_vehicle: 'yes' + foot: 'no', + motor_vehicle: 'yes', + bicycle: 'no', + horse: 'no' }, trunk_link: { motor_vehicle: 'yes' }, primary_link: { - motor_vehicle: 'yes' + foot: 'yes', + motor_vehicle: 'yes', + bicycle: 'yes', + horse: 'yes' }, secondary_link: { - motor_vehicle: 'yes' + foot: 'yes', + motor_vehicle: 'yes', + bicycle: 'yes', + horse: 'yes' }, tertiary_link: { - motor_vehicle: 'yes' + foot: 'yes', + motor_vehicle: 'yes', + bicycle: 'yes', + horse: 'yes' } }; @@ -141,7 +182,7 @@ iD.ui.preset.access = function(field) { _.forEach(placeholders[tags.highway], function(value, key) { items.selectAll('#preset-input-access-' + key) .attr('placeholder', function() { - return (tags.access && value === 'yes') ? tags.access : value; + return (tags.access && (value === 'yes' || value === 'designated')) ? tags.access : value; }); }); }; diff --git a/test/spec/ui/preset/access.js b/test/spec/ui/preset/access.js index b0b3e04a6..aa6dcf788 100644 --- a/test/spec/ui/preset/access.js +++ b/test/spec/ui/preset/access.js @@ -16,23 +16,16 @@ describe('iD.ui.preset.access', function() { expect(selection.selectAll('.preset-access-horse')[0].length).to.equal(1); }); - it('does not include a "yes" option for general access (#934)', function() { + it('does not include a "yes" or "designated" option for general access (#934), (#2213)', function() { var access = iD.ui.preset.access(field); expect(_.pluck(access.options('access'), 'value')).not.to.include('yes'); - }); - - it('does not include a "designated" option for general access (#2213)', function() { - var access = iD.ui.preset.access(field); expect(_.pluck(access.options('access'), 'value')).not.to.include('designated'); }); - it('sets foot placeholder to "yes" for footways, steps, and pedestrian', function() { + it('sets foot placeholder to "yes" for 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'); @@ -40,26 +33,34 @@ describe('iD.ui.preset.access', function() { expect(selection.selectAll('#preset-input-access-foot').attr('placeholder')).to.equal('yes'); }); - it('sets bicycle placeholder to "yes" for cycleways', function() { + it('sets foot placeholder to "designated" for footways', 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('designated'); + }); + + it('sets bicycle placeholder to "designated" 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'); + expect(selection.selectAll('#preset-input-access-bicycle').attr('placeholder')).to.equal('designated'); }); - it('sets horse placeholder to "yes" for bridleways', function() { + it('sets horse placeholder to "designated" 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'); + expect(selection.selectAll('#preset-input-access-horse').attr('placeholder')).to.equal('designated'); }); - it('sets motor_vehicle placeholder to "no" for footways, steps, pedestrian, cycleway, and path', function() { + it('sets motor_vehicle placeholder to "no" for footways, steps, pedestrian, cycleway, bridleway, and path', function() { var access = iD.ui.preset.access(field); selection.call(access); - ['footway', 'steps', 'pedestrian', 'cycleway', 'path'].forEach(function(value) { + ['footway', 'steps', 'pedestrian', 'cycleway', 'bridleway', 'path'].forEach(function(value) { access.tags({highway: value}); expect(selection.selectAll('#preset-input-access-motor_vehicle').attr('placeholder')).to.equal('no'); }); @@ -75,12 +76,15 @@ describe('iD.ui.preset.access', function() { }); }); - it('overrides a "yes" placeholder with more specific access tag (#2213)', function() { + it('overrides a "yes" or "designated" placeholder with more specific access tag (#2213)', function() { var access = iD.ui.preset.access(field); selection.call(access); access.tags({highway: 'service', access: 'emergency'}); expect(selection.selectAll('#preset-input-access-motor_vehicle').attr('placeholder')).to.equal('emergency'); + + access.tags({highway: 'cycleway', access: 'permissive'}); + expect(selection.selectAll('#preset-input-access-bicycle').attr('placeholder')).to.equal('permissive'); }); it('does not override a "no" placeholder with more specific access tag (#2213)', function() {