mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-24 09:04:02 +02:00
Better logic for adding area=yes (closes #2578)
This fixes a few issues: 1. before: checked first key in applyTags and break loop, now: check all of them (this was what caused `area=yes` to be added to 'branded' presets: the first key is for these is `name` which isn't in areaKeys.) 2. add `area=yes` if user is drawing an area but the preset can be an area or a line (e.g. `barrier=city_wall`) 3. remove `area=yes` when switching to another preset
This commit is contained in:
@@ -77,7 +77,7 @@ describe('iD.presets.Preset', function() {
|
||||
it("adds default tags of fields with matching geometry", function() {
|
||||
var field = iD.presets.Field('field', {key: 'building', geometry: 'area', default: 'yes'}),
|
||||
preset = iD.presets.Preset('test', {fields: ['field']}, {field: field});
|
||||
expect(preset.applyTags({}, 'area')).to.eql({building: 'yes'});
|
||||
expect(preset.applyTags({}, 'area')).to.eql({area: 'yes', building: 'yes'});
|
||||
});
|
||||
|
||||
it("adds no default tags of fields with non-matching geometry", function() {
|
||||
@@ -86,15 +86,22 @@ describe('iD.presets.Preset', function() {
|
||||
expect(preset.applyTags({}, 'point')).to.eql({});
|
||||
});
|
||||
|
||||
context("with an area preset whose primary tag is not in areaKeys", function() {
|
||||
var preset = iD.presets.Preset('test', {geometry: ['line', 'area'], tags: {highway: 'pedestrian'}});
|
||||
context("for a preset with no tag in areaKeys", function() {
|
||||
var preset = iD.presets.Preset('test', {geometry: ['line', 'area'], tags: {name: 'testname', highway: 'pedestrian'}});
|
||||
|
||||
it("adds no area=yes to non-areas", function() {
|
||||
expect(preset.applyTags({}, 'line')).to.eql({highway: 'pedestrian'});
|
||||
it("doesn't add area=yes to non-areas", function() {
|
||||
expect(preset.applyTags({}, 'line')).to.eql({name: 'testname', highway: 'pedestrian'});
|
||||
});
|
||||
|
||||
it("adds area=yes to areas", function() {
|
||||
expect(preset.applyTags({}, 'area')).to.eql({highway: 'pedestrian', area: 'yes'});
|
||||
expect(preset.applyTags({}, 'area')).to.eql({name: 'testname', highway: 'pedestrian', area: 'yes'});
|
||||
});
|
||||
});
|
||||
|
||||
context("for a preset with a tag in areaKeys", function() {
|
||||
var preset = iD.presets.Preset('test', {geometry: ['area'], tags: {name: 'testname', natural: 'water'}});
|
||||
it("doesn't add area=yes", function() {
|
||||
expect(preset.applyTags({}, 'area')).to.eql({name: 'testname', natural: 'water'});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -111,6 +118,11 @@ describe('iD.presets.Preset', function() {
|
||||
expect(preset.removeTags({building: 'yes'}, 'area')).to.eql({});
|
||||
});
|
||||
|
||||
it('removes area=yes', function() {
|
||||
var preset = iD.presets.Preset('test', {tags: {highway: 'pedestrian'}});
|
||||
expect(preset.removeTags({highway: 'pedestrian', area: 'yes'}, 'area')).to.eql({});
|
||||
});
|
||||
|
||||
it('preserves tags that do not match field default tags', function() {
|
||||
var field = iD.presets.Field('field', {key: 'building', geometry: 'area', default: 'yes'}),
|
||||
preset = iD.presets.Preset('test', {fields: ['field']}, {field: field});
|
||||
|
||||
Reference in New Issue
Block a user