Files
iD/modules/validations/help_request.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

55 lines
1.7 KiB
JavaScript

import { t } from '../core/localizer';
import { utilDisplayLabel } from '../util';
import { validationIssue, validationIssueFix } from '../core/validation';
export function validationHelpRequest(context) {
var type = 'help_request';
var validation = function checkFixmeTag(entity) {
if (!entity.tags.fixme) return [];
// don't flag fixmes on features added by the user
if (entity.version === undefined) return [];
if (entity.v !== undefined) {
var baseEntity = context.history().base().hasEntity(entity.id);
// don't flag fixmes added by the user on existing features
if (!baseEntity || !baseEntity.tags.fixme) return [];
}
return [new validationIssue({
type: type,
subtype: 'fixme_tag',
severity: 'warning',
message: function(context) {
var entity = context.hasEntity(this.entityIds[0]);
return entity ? t('issues.fixme_tag.message', { feature: utilDisplayLabel(entity, context) }) : '';
},
dynamicFixes: function() {
return [
new validationIssueFix({
title: t('issues.fix.address_the_concern.title')
})
];
},
reference: showReference,
entityIds: [entity.id]
})];
function showReference(selection) {
selection.selectAll('.issue-reference')
.data([0])
.enter()
.append('div')
.attr('class', 'issue-reference')
.text(t('issues.fixme_tag.reference'));
}
};
validation.type = type;
return validation;
}