Add ability to comment on ImproveOSM issues

This commit is contained in:
SilentSpike
2019-02-05 16:51:51 +00:00
parent 13e9e99c4a
commit 448119324f
2 changed files with 63 additions and 28 deletions
+8 -7
View File
@@ -360,17 +360,16 @@ export default {
payload.targetIds = [ d.identifier ];
}
// Comments don't currently work, if they ever do in future
// it looks as though they require a separate post
// if (d.newComment !== undefined) {
// payload.text = d.newComment;
// }
if (d.newStatus !== d.status) {
if (d.newStatus !== undefined) {
payload.status = d.newStatus;
payload.text = 'status changed';
}
// Comment take place of default text
if (d.newComment !== undefined) {
payload.text = d.newComment;
}
_erCache.inflightPost[d.id] = d3_request(url)
.header('Content-Type', 'application/json')
.post(JSON.stringify(payload), function(err) {
@@ -378,6 +377,8 @@ export default {
// Unsuccessful response status, keep issue open
if (err.status !== 200) { return callback(err, d); }
// Just a comment, error still open
if (d.newStatus === undefined) { return callback(err, d); }
that.removeError(d);
+55 -21
View File
@@ -1,4 +1,5 @@
import { dispatch as d3_dispatch } from 'd3-dispatch';
import { select as d3_select } from 'd3-selection';
import { t } from '../util/locale';
import { services } from '../services';
@@ -12,7 +13,7 @@ import {
uiTooltipHtml
} from './index';
import { utilRebind } from '../util';
import { utilNoAuto, utilRebind } from '../util';
export function uiImproveOsmEditor(context) {
@@ -97,10 +98,45 @@ export function uiImproveOsmEditor(context) {
.append('div')
.attr('class', 'keepRight-save save-section cf');
saveSectionEnter
.append('h4')
.attr('class', '.error-save-header')
.text(t('QA.keepRight.comment'));
saveSectionEnter
.append('textarea')
.attr('class', 'new-comment-input')
.attr('placeholder', t('QA.keepRight.comment_placeholder'))
.attr('maxlength', 1000)
.property('value', function(d) { return d.newComment; })
.call(utilNoAuto)
.on('input', changeInput)
.on('blur', changeInput);
// update
saveSection = saveSectionEnter
.merge(saveSection)
.call(errorSaveButtons);
function changeInput() {
var input = d3_select(this);
var val = input.property('value').trim();
if (val === '') {
val = undefined;
}
// store the unsaved comment with the error itself
_error = _error.update({ newComment: val });
var errorService = services.improveOSM;
if (errorService) {
errorService.replaceError(_error);
}
saveSection
.call(errorSaveButtons);
}
}
function errorSaveButtons(selection) {
@@ -117,11 +153,10 @@ export function uiImproveOsmEditor(context) {
.append('div')
.attr('class', 'buttons');
// Comments don't currently work
// buttonEnter
// .append('button')
// .attr('class', 'button comment-button action')
// .text(t('QA.keepRight.save_comment'));
buttonEnter
.append('button')
.attr('class', 'button comment-button action')
.text(t('QA.keepRight.save_comment'));
buttonEnter
.append('button')
@@ -136,20 +171,19 @@ export function uiImproveOsmEditor(context) {
buttonSection = buttonSection
.merge(buttonEnter);
// Comments don't currently work
// buttonSection.select('.comment-button')
// .attr('disabled', function(d) {
// return d.newComment === undefined ? true : null;
// })
// .on('click.comment', function(d) {
// this.blur(); // avoid keeping focus on the button - #4641
// var errorService = services.improveOSM;
// if (errorService) {
// errorService.postUpdate(d, function(err, error) {
// dispatch.call('change', error);
// });
// }
// });
buttonSection.select('.comment-button')
.attr('disabled', function(d) {
return d.newComment === undefined ? true : null;
})
.on('click.comment', function(d) {
this.blur(); // avoid keeping focus on the button - #4641
var errorService = services.improveOSM;
if (errorService) {
errorService.postUpdate(d, function(err, error) {
dispatch.call('change', error);
});
}
});
buttonSection.select('.close-button')
.text(function(d) {
@@ -192,4 +226,4 @@ export function uiImproveOsmEditor(context) {
return utilRebind(improveOsmEditor, dispatch, 'on');
}
}