From ee92758801ce71fa93933e61fab691e54b346b41 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Wed, 2 Jan 2019 16:15:21 -0500 Subject: [PATCH] KeepRight only allows one anonymous comment per issue - simplify --- data/core.yaml | 7 ++--- dist/locales/en.json | 7 ++--- modules/ui/index.js | 1 - modules/ui/keepRight_comment.js | 33 -------------------- modules/ui/keepRight_editor.js | 54 ++++++++++++--------------------- 5 files changed, 23 insertions(+), 79 deletions(-) delete mode 100644 modules/ui/keepRight_comment.js diff --git a/data/core.yaml b/data/core.yaml index 699e272d2..165bded6d 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -652,11 +652,8 @@ en: title: KeepRight Error detail_title: Error detail_description: Description - comment_header: Comment - newInputPlaceholder: Enter a comment to share with other users. - updateInputPlaceholder: Update the comment above to share with other users. - newComment: New Comment - updateComment: Update Comment + comment: Comment + comment_placeholder: Enter a comment to share with other users. upload_explanation: Your comments will be publicly visible on KeepRight. upload_explanation_with_user: "Your comments as {user} will be publicly visible on KeepRight." resolve_comment: Comment and Resolve diff --git a/dist/locales/en.json b/dist/locales/en.json index d06031da9..302354360 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -792,11 +792,8 @@ "title": "KeepRight Error", "detail_title": "Error", "detail_description": "Description", - "comment_header": "Comment", - "newInputPlaceholder": "Enter a comment to share with other users.", - "updateInputPlaceholder": "Update the comment above to share with other users.", - "newComment": "New Comment", - "updateComment": "Update Comment", + "comment": "Comment", + "comment_placeholder": "Enter a comment to share with other users.", "upload_explanation": "Your comments will be publicly visible on KeepRight.", "upload_explanation_with_user": "Your comments as {user} will be publicly visible on KeepRight.", "resolve_comment": "Comment and Resolve", diff --git a/modules/ui/index.js b/modules/ui/index.js index d80ba9117..d92bd0a7d 100644 --- a/modules/ui/index.js +++ b/modules/ui/index.js @@ -30,7 +30,6 @@ export { uiGeolocate } from './geolocate'; export { uiHelp } from './help'; export { uiInfo } from './info'; export { uiInspector } from './inspector'; -export { uiKeepRightComment } from './keepRight_comment'; export { uiKeepRightDetails } from './keepRight_details'; export { uiKeepRightEditor } from './keepRight_editor'; export { uiKeepRightHeader } from './keepRight_header'; diff --git a/modules/ui/keepRight_comment.js b/modules/ui/keepRight_comment.js deleted file mode 100644 index 516847600..000000000 --- a/modules/ui/keepRight_comment.js +++ /dev/null @@ -1,33 +0,0 @@ -import { t } from '../util/locale'; - - -export function uiKeepRightComment() { - var _error; - - function keepRightComment(selection) { - if (!_error.comment) return; - var comment = selection.selectAll('.comments-container') - .data([0]); - - var comment_details = comment.enter() - .append('div') - .attr('class', 'kr_error-comment-container'); - - comment_details - .append('h4') - .text(t('QA.keepRight.comment_header')); - - comment_details - .append('div') - .text(_error.comment); - } - - keepRightComment.error = function(val) { - if (!arguments.length) return _error; - _error = val; - return keepRightComment; - }; - - - return keepRightComment; -} diff --git a/modules/ui/keepRight_editor.js b/modules/ui/keepRight_editor.js index 6194f4b5e..f8b9d7687 100644 --- a/modules/ui/keepRight_editor.js +++ b/modules/ui/keepRight_editor.js @@ -8,23 +8,12 @@ import { t } from '../util/locale'; import { services } from '../services'; import { modeBrowse } from '../modes'; import { svgIcon } from '../svg'; - -import { - uiKeepRightComment, - uiKeepRightDetails, - uiKeepRightHeader, - uiViewOnKeepRight, -} from './index'; - -import { - utilNoAuto, - utilRebind -} from '../util'; +import { uiKeepRightDetails, uiKeepRightHeader, uiViewOnKeepRight } from './index'; +import { utilNoAuto, utilRebind } from '../util'; export function uiKeepRightEditor(context) { var dispatch = d3_dispatch('change'); - var keepRightComment = uiKeepRightComment(); var keepRightDetails = uiKeepRightDetails(context); var keepRightHeader = uiKeepRightHeader(context); @@ -69,8 +58,7 @@ export function uiKeepRightEditor(context) { .merge(editor) .call(keepRightHeader.error(_error)) .call(keepRightDetails.error(_error)) - .call(keepRightComment.error(_error)) - .call(errorSaveSection); + .call(keepRightSaveSection); var footer = selection.selectAll('.footer') @@ -84,44 +72,40 @@ export function uiKeepRightEditor(context) { } - function errorSaveSection(selection) { + function keepRightSaveSection(selection) { var isSelected = (_error && _error.id === context.selectedErrorID()); - var errorSave = selection.selectAll('.error-save') + var saveSection = selection.selectAll('.error-save') .data((isSelected ? [_error] : []), function(d) { return d.status + d.id; }); // exit - errorSave.exit() + saveSection.exit() .remove(); // enter - var errorSaveEnter = errorSave.enter() + var saveSectionEnter = saveSection.enter() .append('div') .attr('class', 'keepRight-save save-section cf'); - errorSaveEnter + saveSectionEnter .append('h4') .attr('class', '.error-save-header') - .text(function(d) { - return d.comment ? t('QA.keepRight.updateComment') : t('QA.keepRight.newComment'); - }); + .text(t('QA.keepRight.comment')); - errorSaveEnter + saveSectionEnter .append('textarea') .attr('class', 'new-comment-input') - .attr('placeholder', function(d) { - return d.comment ? t('QA.keepRight.updateInputPlaceholder') : t('QA.keepRight.newInputPlaceholder'); - }) + .attr('placeholder', t('QA.keepRight.comment_placeholder')) .attr('maxlength', 1000) - .property('value', function(d) { return d.newComment; }) + .property('value', function(d) { return d.comment; }) .call(utilNoAuto) .on('input', changeInput) .on('blur', changeInput); // update - errorSave = errorSaveEnter - .merge(errorSave) + saveSection = saveSectionEnter + .merge(saveSection) .call(userDetails) - .call(errorSaveButtons); + .call(keepRightSaveButtons); function changeInput() { @@ -129,15 +113,15 @@ export function uiKeepRightEditor(context) { var val = input.property('value').trim() || undefined; // store the unsaved comment with the error itself - _error = _error.update({ newComment: val }); + _error = _error.update({ newComment: val, comment: val }); var keepRight = services.keepRight; if (keepRight) { keepRight.replaceError(_error); // update keepright cache } - errorSave - .call(errorSaveButtons); + saveSection + .call(keepRightSaveButtons); } } @@ -232,7 +216,7 @@ export function uiKeepRightEditor(context) { } - function errorSaveButtons(selection) { + function keepRightSaveButtons(selection) { var osm = services.osm; var hasAuth = osm && osm.authenticated();