Make reference function optional

Now it shows the "No documentation available" message if there is not one
This commit is contained in:
Bryan Housel
2019-04-17 09:04:55 -04:00
parent 0d70f0670d
commit d6327aec56
2 changed files with 8 additions and 3 deletions

View File

@@ -334,7 +334,7 @@ export function validationIssue(attrs) {
this.type = attrs.type; // required
this.severity = attrs.severity; // required - 'warning' or 'error'
this.message = attrs.message; // required - localized string
this.reference = attrs.reference; // required - function(selection) to render reference info
this.reference = attrs.reference; // optional - function(selection) to render reference info
this.entities = attrs.entities; // optional - array of entities
this.loc = attrs.loc; // optional - expect a [lon, lat] array
this.data = attrs.data; // optional - object containing extra data for the fixes

View File

@@ -160,8 +160,13 @@ export function uiEntityIssues(context) {
.style('max-height', '0')
.style('opacity', '0')
.each(function(d) {
d3_select(this)
.call(d.reference);
if (typeof d.reference === 'function') {
d3_select(this)
.call(d.reference);
} else {
d3_select(this)
.text(t('inspector.no_documentation_key'));
}
});