Files
iD/modules/ui/view_on_keepRight.js
SilentSpike 51efd5b714 Update and standardise QA implementations
- ES6ify (now using class syntax to define QAItem objects)
- Fix bug with KeepRight marker rendering not updating properly
- Use `qa-` prefix for the UI element classes to differentiate from iD
validation error related UI element classes
- Move away from "error" where possible in source
- Move away from snake_case naming where possible

Note that some function/method names have been untouched to make life
easier for v3 development. Have added note comments where appropriate.
2020-02-06 23:07:50 +00:00

43 lines
1016 B
JavaScript

import { t } from '../util/locale';
import { services } from '../services';
import { svgIcon } from '../svg/icon';
import { QAItem } from '../osm';
export function uiViewOnKeepRight() {
let _qaItem;
function viewOnKeepRight(selection) {
let url;
if (services.keepRight && (_qaItem instanceof QAItem)) {
url = services.keepRight.issueURL(_qaItem);
}
const link = selection.selectAll('.view-on-keepRight')
.data(url ? [url] : []);
// exit
link.exit()
.remove();
// enter
const linkEnter = link.enter()
.append('a')
.attr('class', 'view-on-keepRight')
.attr('target', '_blank')
.attr('href', function(d) { return d; })
.call(svgIcon('#iD-icon-out-link', 'inline'));
linkEnter
.append('span')
.text(t('inspector.view_on_keepRight'));
}
viewOnKeepRight.what = function(val) {
if (!arguments.length) return _qaItem;
_qaItem = val;
return viewOnKeepRight;
};
return viewOnKeepRight;
}