Skip to content

Commit

Permalink
add missing name tags for clone tags
Browse files Browse the repository at this point in the history
and allow language suffixes
  • Loading branch information
kaligrafy committed Jan 30, 2024
1 parent d891e4f commit 64d2d2c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
19 changes: 14 additions & 5 deletions dist/iD.js
Original file line number Diff line number Diff line change
Expand Up @@ -55519,11 +55519,12 @@
return action;
}

function actionCloneRoadAttributes(selectedIds, cloneTags) {
function actionCloneRoadAttributes(selectedIds, cloneTags, languageSuffixes) {
if ( cloneTags === void 0 ) cloneTags = [];
if ( languageSuffixes === void 0 ) languageSuffixes = [];


var action = function (graph) {
var action = function (graph) {

//console.log('graph before', graph.entities);

Expand Down Expand Up @@ -55552,6 +55553,14 @@
if (cloneRoadAttributesFromEntityTags[cloneTag] !== undefined) {
tags[cloneTag] = cloneRoadAttributesFromEntityTags[cloneTag];
}
if (languageSuffixes.length > 0) {
for (var k = 0, countK = languageSuffixes.length; k < countK; k++) {
var languageSuffix = languageSuffixes[k];
if (cloneRoadAttributesFromEntityTags[cloneTag + ':' + languageSuffix] !== undefined) {
tags[cloneTag + ':' + languageSuffix] = cloneRoadAttributesFromEntityTags[cloneTag + ':' + languageSuffix];
}
}
}
}
entity = entity.update({tags: tags});
graph = graph.replace(entity);
Expand Down Expand Up @@ -78682,8 +78691,8 @@

function operationCloneName(selectedIDs, context) {

var cloneTags = ['name', 'operator', 'name_alt', 'name:fr', 'name:en'];
var action = actionCloneRoadAttributes(selectedIDs, cloneTags);
var cloneTags = ['name', 'operator', 'alt_name', 'old_name', 'short_name', 'official_name', 'int_name', 'loc_name', 'name:left', 'name:right', 'nat_name', 'ref_name', 'reg_name', 'sorting_name', 'nickname'];
var action = actionCloneRoadAttributes(selectedIDs, cloneTags, ['fr', 'en']);

var operation = function () {
context.perform(action, operation.annotation());
Expand All @@ -78699,7 +78708,7 @@
if (selectedIDs.length >= 2) {
var entity = context.entity(selectedIDs[0]);
for (var i = 0, count = cloneTags.length; i < count; i++) {
if (entity.tags[cloneTags[i]] !== undefined) {
if (entity.tags[cloneTags[i]] !== undefined || entity.tags[cloneTags[i]+':fr'] !== undefined || entity.tags[cloneTags[i]+':en'] !== undefined) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/iD.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/iD.min.js

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions modules/actions/clone_road_attributes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function actionCloneRoadAttributes(selectedIds, cloneTags = []) {
export function actionCloneRoadAttributes(selectedIds, cloneTags = [], languageSuffixes = []) {

var action = function (graph) {
var action = function (graph) {

//console.log('graph before', graph.entities);

Expand Down Expand Up @@ -29,6 +29,14 @@ export function actionCloneRoadAttributes(selectedIds, cloneTags = []) {
if (cloneRoadAttributesFromEntityTags[cloneTag] !== undefined) {
tags[cloneTag] = cloneRoadAttributesFromEntityTags[cloneTag];
}
if (languageSuffixes.length > 0) {
for (let k = 0, countK = languageSuffixes.length; k < countK; k++) {
const languageSuffix = languageSuffixes[k];
if (cloneRoadAttributesFromEntityTags[cloneTag + ':' + languageSuffix] !== undefined) {
tags[cloneTag + ':' + languageSuffix] = cloneRoadAttributesFromEntityTags[cloneTag + ':' + languageSuffix];
}
}
}
}
entity = entity.update({tags});
graph = graph.replace(entity);
Expand Down
6 changes: 3 additions & 3 deletions modules/operations/clone_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {

export function operationCloneName(selectedIDs, context) {

const cloneTags = ['name', 'operator', 'name_alt', 'name:fr', 'name:en']
var action = actionCloneRoadAttributes(selectedIDs, cloneTags);
const cloneTags = ['name', 'operator', 'alt_name', 'old_name', 'short_name', 'official_name', 'int_name', 'loc_name', 'name:left', 'name:right', 'nat_name', 'ref_name', 'reg_name', 'sorting_name', 'nickname'];
var action = actionCloneRoadAttributes(selectedIDs, cloneTags, ['fr', 'en']);

var operation = function () {
context.perform(action, operation.annotation());
Expand All @@ -27,7 +27,7 @@ export function operationCloneName(selectedIDs, context) {
if (selectedIDs.length >= 2) {
const entity = context.entity(selectedIDs[0]);
for (let i = 0, count = cloneTags.length; i < count; i++) {
if (entity.tags[cloneTags[i]] !== undefined) {
if (entity.tags[cloneTags[i]] !== undefined || entity.tags[cloneTags[i]+':fr'] !== undefined || entity.tags[cloneTags[i]+':en'] !== undefined) {
return true;
}
}
Expand Down

0 comments on commit 64d2d2c

Please sign in to comment.