added warning when changeset comment length > 255 chars

This commit is contained in:
alanb43
2022-11-27 01:55:30 -05:00
parent 4dcf6090d8
commit de23bd5c33
2 changed files with 25 additions and 17 deletions
+1
View File
@@ -615,6 +615,7 @@ en:
comment_needed_message: Please add a changeset comment first.
about_changeset_comments: About changeset comments
about_changeset_comments_link: //wiki.openstreetmap.org/wiki/Good_changeset_comments
changeset_comment_length_warning: "Changeset comments can have a maximum of 255 characters"
google_warning: "You mentioned Google in this comment: remember that copying from Google Maps is strictly forbidden."
google_warning_link: https://www.openstreetmap.org/copyright
contributors:
+24 -17
View File
@@ -85,10 +85,10 @@ export function uiChangesetEditor(context) {
}
}
// Add warning if comment mentions Google
var hasGoogle = _tags.comment.match(/google/i);
var commentTooLong = _tags.comment.length > 255;
var commentWarning = selection.select('.form-field-comment').selectAll('.comment-warning')
.data(hasGoogle ? [0] : []);
.data(hasGoogle || commentTooLong ? [0] : []);
commentWarning.exit()
.transition()
@@ -96,23 +96,30 @@ export function uiChangesetEditor(context) {
.style('opacity', 0)
.remove();
var commentEnter = commentWarning.enter()
.insert('div', '.tag-reference-body')
.attr('class', 'field-warning comment-warning')
.style('opacity', 0);
function displayWarningMessage(msg, link) {
var commentEnter = commentWarning.enter()
.insert('div', '.tag-reference-body')
.attr('class', 'field-warning comment-warning')
.style('opacity', 0);
commentEnter
.append('a')
.attr('target', '_blank')
.call(svgIcon('#iD-icon-alert', 'inline'))
.attr('href', t('commit.google_warning_link'))
.append('span')
.call(t.append('commit.google_warning'));
commentEnter
.append('a')
.attr('target', '_blank')
.call(svgIcon('#iD-icon-alert', 'inline'))
.attr('href', t(link))
.append('span')
.call(t.append(msg));
commentEnter
.transition()
.duration(200)
.style('opacity', 1);
commentEnter
.transition()
.duration(200)
.style('opacity', 1);
}
// Add warning if comment mentions Google or comment length
// exceeds 255 chars
if (hasGoogle) displayWarningMessage('commit.google_warning', 'commit.google_warning_link');
if (commentTooLong) displayWarningMessage('commit.changeset_comment_length_warning', 'commit.about_changeset_comments_link');
}