KeepRight only allows one anonymous comment per issue - simplify

This commit is contained in:
Bryan Housel
2019-01-02 16:15:21 -05:00
parent 4494c3ab9c
commit ee92758801
5 changed files with 23 additions and 79 deletions
+2 -5
View File
@@ -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
+2 -5
View File
@@ -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",
-1
View File
@@ -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';
-33
View File
@@ -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;
}
+19 -35
View File
@@ -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();