Fix error reporting urls and make sure sidebar not showing stale data

This commit is contained in:
Bryan Housel
2019-01-03 11:37:14 -05:00
parent 0256ad7f0d
commit 46ebce2d6f
14 changed files with 72 additions and 75 deletions

View File

@@ -396,5 +396,11 @@ export default {
delete _krCache.keepRight[error.id];
updateRtree(encodeErrorRtree(error), false); // false = remove
},
errorURL: function(error) {
return apibase + 'report_map.php?schema=' + error.schema + '&error=' + error.id;
}
};

View File

@@ -431,8 +431,9 @@ export default {
return urlroot + '/note/' + note.id;
},
keepRightURL: function(error) {
return 'https://www.keepright.at/report_map.php?schema=' + error.schema + '&error=' + error.id;
noteReportURL: function(note) {
return urlroot + '/reports/new?reportable_type=Note&reportable_id=' + note.id;
},

View File

@@ -24,7 +24,6 @@ export function svgKeepRight(projection, context, dispatch) {
if (svgKeepRight.initialized) return; // run once
svgKeepRight.enabled = false;
svgKeepRight.initialized = true;
svgKeepRight.visibleErrors = [30];
}
@@ -184,20 +183,6 @@ export function svgKeepRight(projection, context, dispatch) {
};
drawKeepRight.visibleErrors = function(_) {
if (!arguments.length) return svgKeepRight.visibleErrors;
svgKeepRight.visibleErrors.push(_);
if (svgKeepRight.visibleErrors) {
showLayer();
} else {
hideLayer();
}
dispatch.call('change');
return this;
};
init();
return drawKeepRight;
}

View File

@@ -92,9 +92,9 @@ export function uiInspector(context) {
}
inspector.state = function(_) {
inspector.state = function(val) {
if (!arguments.length) return _state;
_state = _;
_state = val;
entityEditor.state(_state);
// remove any old field help overlay that might have gotten attached to the inspector
@@ -104,16 +104,16 @@ export function uiInspector(context) {
};
inspector.entityID = function(_) {
inspector.entityID = function(val) {
if (!arguments.length) return _entityID;
_entityID = _;
_entityID = val;
return inspector;
};
inspector.newFeature = function(_) {
inspector.newFeature = function(val) {
if (!arguments.length) return _newFeature;
_newFeature = _;
_newFeature = val;
return inspector;
};

View File

@@ -32,7 +32,7 @@ export function uiKeepRightDetails(context) {
var details = selection.selectAll('.kr_error-details')
.data(
(_error ? [_error] : []),
function(d) { return d.status + d.id; }
function(d) { return d.id + '-' + (d.status || 0); }
);
details.exit()
@@ -69,9 +69,9 @@ export function uiKeepRightDetails(context) {
}
keepRightDetails.error = function(_) {
keepRightDetails.error = function(val) {
if (!arguments.length) return _error;
_error = _;
_error = val;
return keepRightDetails;
};

View File

@@ -71,8 +71,12 @@ export function uiKeepRightEditor(context) {
function keepRightSaveSection(selection) {
var isSelected = (_error && _error.id === context.selectedErrorID());
var isShown = (_error && (isSelected || _error.newComment || _error.comment));
var saveSection = selection.selectAll('.error-save')
.data((isSelected ? [_error] : []), function(d) { return d.status + d.id; });
.data(
(isShown ? [_error] : []),
function(d) { return d.id + '-' + (d.status || 0); }
);
// exit
saveSection.exit()
@@ -206,9 +210,9 @@ export function uiKeepRightEditor(context) {
}
keepRightEditor.error = function(_) {
keepRightEditor.error = function(val) {
if (!arguments.length) return _error;
_error = _;
_error = val;
return keepRightEditor;
};

View File

@@ -31,14 +31,12 @@ export function uiKeepRightHeader() {
var header = selection.selectAll('.kr_error-header')
.data(
(_error ? [_error] : []),
function(d) { return d.status + d.id; }
function(d) { return d.id + '-' + (d.status || 0); }
);
header.exit()
.remove();
var headerEnter = header.enter()
.append('div')
.attr('class', 'kr_error-header');
@@ -62,9 +60,9 @@ export function uiKeepRightHeader() {
}
keepRightHeader.error = function(_) {
keepRightHeader.error = function(val) {
if (!arguments.length) return _error;
_error = _;
_error = val;
return keepRightHeader;
};

View File

@@ -110,9 +110,9 @@ export function uiNoteComments() {
}
noteComments.note = function(_) {
noteComments.note = function(val) {
if (!arguments.length) return _note;
_note = _;
_note = val;
return noteComments;
};

View File

@@ -425,9 +425,9 @@ export function uiNoteEditor(context) {
}
noteEditor.note = function(_) {
noteEditor.note = function(val) {
if (!arguments.length) return _note;
_note = _;
_note = val;
return noteEditor;
};

View File

@@ -49,9 +49,9 @@ export function uiNoteHeader() {
}
noteHeader.note = function(_) {
noteHeader.note = function(val) {
if (!arguments.length) return _note;
_note = _;
_note = val;
return noteHeader;
};

View File

@@ -1,23 +1,20 @@
import { t } from '../util/locale';
import { osmNote } from '../osm';
import { services } from '../services';
import { svgIcon } from '../svg';
import {
osmNote
} from '../osm';
export function uiNoteReport() {
var _note;
var url = 'https://www.openstreetmap.org/reports/new?reportable_id=';
function noteReport(selection) {
var url;
if (services.osm && (_note instanceof osmNote) && (!_note.isNew())) {
url = services.osm.noteReportURL(_note);
}
if (!(_note instanceof osmNote)) return;
url += _note.id + '&reportable_type=Note';
var data = ((!_note || _note.isNew()) ? [] : [_note]);
var link = selection.selectAll('.note-report')
.data(data, function(d) { return d.id; });
.data(url ? [url] : []);
// exit
link.exit()
@@ -28,7 +25,7 @@ export function uiNoteReport() {
.append('a')
.attr('class', 'note-report')
.attr('target', '_blank')
.attr('href', url)
.attr('href', function(d) { return d; })
.call(svgIcon('#iD-icon-out-link', 'inline'));
linkEnter
@@ -37,9 +34,9 @@ export function uiNoteReport() {
}
noteReport.note = function(_) {
noteReport.note = function(val) {
if (!arguments.length) return _note;
_note = _;
_note = val;
return noteReport;
};

View File

@@ -10,6 +10,7 @@ import {
} from 'd3-selection';
import { osmEntity, osmNote, krError } from '../osm';
import { services } from '../services';
import { uiDataEditor, uiFeatureList, uiInspector, uiNoteEditor, uiKeepRightEditor } from './index';
import { textDirection } from '../util/locale';
@@ -22,7 +23,7 @@ export function uiSidebar(context) {
var _current;
var _wasData = false;
var _wasNote = false;
var _was_krError = false;
var _wasKRError = false;
function sidebar(selection) {
@@ -119,6 +120,11 @@ export function uiSidebar(context) {
if (context.mode().id === 'drag-note') return;
_wasNote = true;
var osm = services.osm;
if (osm) {
datum = osm.getNote(datum.id); // marker may contain stale data - get latest
}
sidebar
.show(noteEditor.note(datum));
@@ -126,10 +132,15 @@ export function uiSidebar(context) {
.classed('inspector-hover', true);
} else if (datum instanceof krError) {
_was_krError = true;
var kr_errors = d3_selectAll('.kr_error');
kr_errors
.classed('hover', function(d) { return d === datum; });
_wasKRError = true;
var keepRight = services.keepRight;
if (keepRight) {
datum = keepRight.getError(datum.id); // marker may contain stale data - get latest
}
d3_selectAll('.kr_error')
.classed('hover', function(d) { return d.id === datum.id; });
sidebar
.show(keepRightEditor.error(datum));
@@ -162,14 +173,12 @@ export function uiSidebar(context) {
inspector
.state('hide');
} else if (_wasData || _wasNote) {
} else if (_wasData || _wasNote || _wasKRError) {
_wasNote = false;
_wasData = false;
_wasKRError = false;
d3_selectAll('.note').classed('hover', false);
sidebar.hide();
} else if (_was_krError) {
d3_selectAll('.kr_error')
.classed('hover', false);
d3_selectAll('.kr_error').classed('hover', false);
sidebar.hide();
}
}

View File

@@ -1,21 +1,21 @@
import { t } from '../util/locale';
import { services } from '../services';
import { svgIcon } from '../svg';
import { krError } from '../osm';
export function uiViewOnKeepRight(context) {
export function uiViewOnKeepRight() {
var _error; // a keepright error
function viewOnKeepRight(selection) {
var url;
if (_error instanceof krError) {
url = context.connection().keepRightURL(_error);
if (services.keepRight && (_error instanceof krError)) {
url = services.keepRight.errorURL(_error);
}
var data = ((!_error) ? [] : [_error]);
var link = selection.selectAll('.view-on-keepRight')
.data(data, function(d) { return d.id; });
.data(url ? [url] : []);
// exit
link.exit()
@@ -26,7 +26,7 @@ export function uiViewOnKeepRight(context) {
.append('a')
.attr('class', 'view-on-keepRight')
.attr('target', '_blank')
.attr('href', url)
.attr('href', function(d) { return d; })
.call(svgIcon('#iD-icon-out-link', 'inline'));
linkEnter
@@ -35,9 +35,9 @@ export function uiViewOnKeepRight(context) {
}
viewOnKeepRight.what = function(_) {
viewOnKeepRight.what = function(val) {
if (!arguments.length) return _error;
_error = _;
_error = val;
return viewOnKeepRight;
};

View File

@@ -1,9 +1,6 @@
import { t } from '../util/locale';
import { osmEntity, osmNote } from '../osm';
import { svgIcon } from '../svg';
import {
osmEntity,
osmNote
} from '../osm';
export function uiViewOnOSM(context) {