Files
iD/modules/ui/improveOSM_header.js
Quincy Morgan a1af118f0e Ensure locales and presets are loaded before the UI loads (close #7406)
Consolidate localization behavior and init to a coreLocalizer function and singleton
Explicitly support `en-US` locale
Rename coreData to coreFileFetcher and export a singleton rather than using a property of coreContext
Add `apiConnections` property of coreContext to simplify adding a source switcher
Replace some init functions with re-callable, promise-supporting `ensureLoaded` functions
Make coreContext itself load the UI if a container has been specified at init time
Fix code tests
2020-03-31 12:23:31 -07:00

76 lines
2.0 KiB
JavaScript

import { t } from '../core/localizer';
export function uiImproveOsmHeader() {
let _qaItem;
function issueTitle(d) {
const issueKey = d.issueKey;
d.replacements = d.replacements || {};
d.replacements.default = t('inspector.unknown'); // special key `default` works as a fallback string
return t(`QA.improveOSM.error_types.${issueKey}.title`, d.replacements);
}
function improveOsmHeader(selection) {
const header = selection.selectAll('.qa-header')
.data(
(_qaItem ? [_qaItem] : []),
d => `${d.id}-${d.status || 0}`
);
header.exit()
.remove();
const headerEnter = header.enter()
.append('div')
.attr('class', 'qa-header');
const svgEnter = headerEnter
.append('div')
.attr('class', 'qa-header-icon')
.classed('new', d => d.id < 0)
.append('svg')
.attr('width', '20px')
.attr('height', '30px')
.attr('viewbox', '0 0 20 30')
.attr('class', d => `preset-icon-28 qaItem ${d.service} itemId-${d.id} itemType-${d.itemType}`);
svgEnter
.append('polygon')
.attr('fill', 'currentColor')
.attr('class', 'qaItem-fill')
.attr('points', '16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6');
svgEnter
.append('use')
.attr('class', 'icon-annotation')
.attr('width', '13px')
.attr('height', '13px')
.attr('transform', 'translate(3.5, 5)')
.attr('xlink:href', d => {
const picon = d.icon;
if (!picon) {
return '';
} else {
const isMaki = /^maki-/.test(picon);
return `#${picon}${isMaki ? '-11' : ''}`;
}
});
headerEnter
.append('div')
.attr('class', 'qa-header-label')
.text(issueTitle);
}
improveOsmHeader.issue = function(val) {
if (!arguments.length) return _qaItem;
_qaItem = val;
return improveOsmHeader;
};
return improveOsmHeader;
}