update directionalCombo fields to tagging schema v6 schema

keeping a fallback to v5's `cycleway` field type for now

for #9477
This commit is contained in:
Martin Raifer
2023-01-24 14:20:05 +01:00
parent 98e9a11a51
commit d9695f1cef
2 changed files with 28 additions and 13 deletions
+13 -6
View File
@@ -13,6 +13,15 @@ export function uiFieldDirectionalCombo(field, context) {
var _combos = {};
// fallback for schema-builder v5's cycleway field type: can be removed eventually
if (field.type === 'cycleway') {
field = {
...field,
key: field.keys[0],
keys: field.keys.slice(1)
};
}
function directionalCombo(selection) {
function stripcolon(s) {
@@ -37,10 +46,8 @@ export function uiFieldDirectionalCombo(field, context) {
.attr('class', 'rows')
.merge(div);
var keys = field.keys.slice(1);
items = div.selectAll('li')
.data(keys);
.data(field.keys);
var enter = items.enter()
.append('li')
@@ -77,8 +84,8 @@ export function uiFieldDirectionalCombo(field, context) {
function change(key, newValue) {
const commonKey = field.keys[0];
const otherKey = key === field.keys[1] ? field.keys[2] : field.keys[1];
const commonKey = field.key;
const otherKey = key === field.keys[0] ? field.keys[1] : field.keys[0];
dispatch.call('change', this, tags => {
const otherValue = tags[otherKey] || tags[commonKey];
@@ -101,7 +108,7 @@ export function uiFieldDirectionalCombo(field, context) {
directionalCombo.tags = function(tags) {
_tags = tags;
const commonKey = field.keys[0];
const commonKey = field.key;
for (let key in _combos) {
const uniqueValues = [... new Set([]
.concat(_tags[commonKey])