mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-21 15:56:56 +02:00
Add access field (#934)
This commit is contained in:
@@ -948,6 +948,10 @@ a:hover .icon.out-link { background-position: -500px -14px;}
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.form-field-access .preset-input-wrap {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
/* adding additional preset fields */
|
||||
|
||||
.more-buttons {
|
||||
|
||||
+34
-1
@@ -321,7 +321,40 @@ locale.en = {
|
||||
"presets": {
|
||||
"fields": {
|
||||
"access": {
|
||||
"label": "Access"
|
||||
"label": "Access",
|
||||
"types": {
|
||||
"access": "General",
|
||||
"foot": "Foot",
|
||||
"motor_vehicle": "Motor Vehicles",
|
||||
"bicycle": "Bicycles",
|
||||
"horse": "Horses"
|
||||
},
|
||||
"options": {
|
||||
"yes": {
|
||||
"title": "Allowed",
|
||||
"description": "Access permitted by law; a right of way"
|
||||
},
|
||||
"no": {
|
||||
"title": "Prohibited",
|
||||
"description": "Access not permitted to the general public"
|
||||
},
|
||||
"permissive": {
|
||||
"title": "Permissive",
|
||||
"description": "Access permitted until such time as the owner revokes the permission"
|
||||
},
|
||||
"private": {
|
||||
"title": "Private",
|
||||
"description": "Access permitted only with permission of the owner on an individual basis"
|
||||
},
|
||||
"designated": {
|
||||
"title": "Designated",
|
||||
"description": "Access permitted according to signs or specific local laws"
|
||||
},
|
||||
"destination": {
|
||||
"title": "Destination",
|
||||
"description": "Access permitted only to reach a destination"
|
||||
}
|
||||
}
|
||||
},
|
||||
"address": {
|
||||
"label": "Address",
|
||||
|
||||
@@ -3,6 +3,31 @@ en:
|
||||
fields:
|
||||
access:
|
||||
label: Access
|
||||
types:
|
||||
access: General
|
||||
foot: Foot
|
||||
motor_vehicle: Motor Vehicles
|
||||
bicycle: Bicycles
|
||||
horse: Horses
|
||||
options:
|
||||
yes:
|
||||
title: Allowed
|
||||
description: Access permitted by law; a right of way
|
||||
no:
|
||||
title: Prohibited
|
||||
description: Access not permitted to the general public
|
||||
permissive:
|
||||
title: Permissive
|
||||
description: Access permitted until such time as the owner revokes the permission
|
||||
private:
|
||||
title: Private
|
||||
description: Access permitted only with permission of the owner on an individual basis
|
||||
designated:
|
||||
title: Designated
|
||||
description: Access permitted according to signs or specific local laws
|
||||
destination:
|
||||
title: Destination
|
||||
description: Access permitted only to reach a destination
|
||||
address:
|
||||
label: Address
|
||||
placeholders:
|
||||
|
||||
@@ -1,8 +1,49 @@
|
||||
{
|
||||
"access": {
|
||||
"key": "access",
|
||||
"type": "combo",
|
||||
"label": "Access"
|
||||
"keys": [
|
||||
"access",
|
||||
"foot",
|
||||
"motor_vehicle",
|
||||
"bicycle",
|
||||
"horse"
|
||||
],
|
||||
"type": "access",
|
||||
"label": "Access",
|
||||
"strings": {
|
||||
"types": {
|
||||
"access": "General",
|
||||
"foot": "Foot",
|
||||
"motor_vehicle": "Motor Vehicles",
|
||||
"bicycle": "Bicycles",
|
||||
"horse": "Horses"
|
||||
},
|
||||
"options": {
|
||||
"yes": {
|
||||
"title": "Allowed",
|
||||
"description": "Access permitted by law; a right of way"
|
||||
},
|
||||
"no": {
|
||||
"title": "Prohibited",
|
||||
"description": "Access not permitted to the general public"
|
||||
},
|
||||
"permissive": {
|
||||
"title": "Permissive",
|
||||
"description": "Access permitted until such time as the owner revokes the permission"
|
||||
},
|
||||
"private": {
|
||||
"title": "Private",
|
||||
"description": "Access permitted only with permission of the owner on an individual basis"
|
||||
},
|
||||
"designated": {
|
||||
"title": "Designated",
|
||||
"description": "Access permitted according to signs or specific local laws"
|
||||
},
|
||||
"destination": {
|
||||
"title": "Destination",
|
||||
"description": "Access permitted only to reach a destination"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"address": {
|
||||
"type": "address",
|
||||
|
||||
@@ -1,5 +1,40 @@
|
||||
{
|
||||
"key": "access",
|
||||
"type": "combo",
|
||||
"label": "Access"
|
||||
"keys": ["access", "foot", "motor_vehicle", "bicycle", "horse"],
|
||||
"type": "access",
|
||||
"label": "Access",
|
||||
"strings": {
|
||||
"types": {
|
||||
"access": "General",
|
||||
"foot": "Foot",
|
||||
"motor_vehicle": "Motor Vehicles",
|
||||
"bicycle": "Bicycles",
|
||||
"horse": "Horses"
|
||||
},
|
||||
"options": {
|
||||
"yes": {
|
||||
"title": "Allowed",
|
||||
"description": "Access permitted by law; a right of way"
|
||||
},
|
||||
"no": {
|
||||
"title": "Prohibited",
|
||||
"description": "Access not permitted to the general public"
|
||||
},
|
||||
"permissive": {
|
||||
"title": "Permissive",
|
||||
"description": "Access permitted until such time as the owner revokes the permission"
|
||||
},
|
||||
"private": {
|
||||
"title": "Private",
|
||||
"description": "Access permitted only with permission of the owner on an individual basis"
|
||||
},
|
||||
"designated": {
|
||||
"title": "Designated",
|
||||
"description": "Access permitted according to signs or specific local laws"
|
||||
},
|
||||
"destination": {
|
||||
"title": "Destination",
|
||||
"description": "Access permitted only to reach a destination"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
"description": "Type of field",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"access",
|
||||
"address",
|
||||
"check",
|
||||
"combo",
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
<script src='js/id/ui/tag_editor.js'></script>
|
||||
<script src='js/id/ui/tail.js'></script>
|
||||
|
||||
<script src='js/id/ui/preset/access.js'></script>
|
||||
<script src='js/id/ui/preset/address.js'></script>
|
||||
<script src='js/id/ui/preset/check.js'></script>
|
||||
<script src='js/id/ui/preset/combo.js'></script>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
iD.ui.preset.access = function(field, context) {
|
||||
var event = d3.dispatch('change', 'close'),
|
||||
entity,
|
||||
items;
|
||||
|
||||
function access(selection) {
|
||||
var wrap = selection.append('div')
|
||||
.attr('class', 'cf preset-input-wrap');
|
||||
|
||||
items = wrap.append('ul').selectAll('li')
|
||||
.data(field.keys);
|
||||
|
||||
var enter = items.enter()
|
||||
.append('li')
|
||||
.attr('class', function(d) { return 'cf preset-access-' + d; });
|
||||
|
||||
enter.append('label')
|
||||
.attr('class', 'col3 preset-label-access')
|
||||
.attr('for', function(d) { return 'preset-input-access-' + d; })
|
||||
.text(function(d) { return field.t('types.' + d); });
|
||||
|
||||
enter.append('div')
|
||||
.attr('class', 'col9 preset-input-access-wrap')
|
||||
.append('input')
|
||||
.attr('type', 'text')
|
||||
.attr('class', 'preset-input-access')
|
||||
.attr('id', function(d) { return 'preset-input-access-' + d; })
|
||||
.on('change', change)
|
||||
.on('blur', change)
|
||||
.each(function(d) {
|
||||
d3.select(this)
|
||||
.call(d3.combobox()
|
||||
.data(access.options(d)));
|
||||
});
|
||||
}
|
||||
|
||||
function change(d) {
|
||||
var tag = {};
|
||||
tag[d] = d3.select(this).property('value');
|
||||
event.change(tag);
|
||||
}
|
||||
|
||||
access.options = function(type) {
|
||||
var options = ['no', 'permissive', 'private', 'designated', 'destination'];
|
||||
|
||||
if (type != 'access') {
|
||||
options.unshift('yes');
|
||||
}
|
||||
|
||||
return options.map(function(option) {
|
||||
return {
|
||||
title: field.t('options.' + option + '.description'),
|
||||
value: option
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
access.entity = function(_) {
|
||||
if (!arguments.length) return entity;
|
||||
entity = _;
|
||||
return access;
|
||||
};
|
||||
|
||||
access.tags = function(tags) {
|
||||
items.selectAll('.preset-input-access')
|
||||
.property('value', function(d) { return tags[d] || ''; });
|
||||
return access;
|
||||
};
|
||||
|
||||
access.focus = function() {
|
||||
items.selectAll('.preset-input-access')
|
||||
.node().focus();
|
||||
};
|
||||
|
||||
return d3.rebind(access, event, 'on');
|
||||
};
|
||||
@@ -93,6 +93,7 @@
|
||||
<script src='../js/id/ui/tag_editor.js'></script>
|
||||
<script src='../js/id/ui/tail.js'></script>
|
||||
|
||||
<script src='../js/id/ui/preset/access.js'></script>
|
||||
<script src='../js/id/ui/preset/address.js'></script>
|
||||
<script src='../js/id/ui/preset/input.js'></script>
|
||||
<script src='../js/id/ui/preset/check.js'></script>
|
||||
@@ -230,6 +231,8 @@
|
||||
<script src="spec/ui/confirm.js"></script>
|
||||
<script src="spec/ui/cmd.js"></script>
|
||||
|
||||
<script src="spec/ui/preset/access.js"></script>
|
||||
|
||||
<script src="spec/connection.js"></script>
|
||||
<script src="spec/geo.js"></script>
|
||||
<script src="spec/taginfo.js"></script>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
describe('iD.ui.preset.access', function() {
|
||||
var selection, field;
|
||||
|
||||
beforeEach(function() {
|
||||
selection = d3.select(document.createElement('div'));
|
||||
field = iD().presets().field('access');
|
||||
});
|
||||
|
||||
it('creates inputs for a variety of modes of access', function() {
|
||||
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);
|
||||
expect(selection.selectAll('.preset-access-motor_vehicle')[0].length).to.equal(1);
|
||||
expect(selection.selectAll('.preset-access-bicycle')[0].length).to.equal(1);
|
||||
expect(selection.selectAll('.preset-access-horse')[0].length).to.equal(1);
|
||||
});
|
||||
|
||||
it('does not include a "yes" option for general access (#934)', function() {
|
||||
var access = iD.ui.preset.access(field, {});
|
||||
expect(_.pluck(access.options('access'), 'value')).not.to.include('yes');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user