Add tooltip to delete feature fix explaining if it's disabled (close #6588)

This commit is contained in:
Quincy Morgan
2019-11-13 14:52:57 -05:00
parent 24c72b64d1
commit 96c8bcb152
3 changed files with 15 additions and 6 deletions

View File

@@ -81,11 +81,12 @@ export function validationIssue(attrs) {
export function validationIssueFix(attrs) {
this.title = attrs.title; // Required
this.onClick = attrs.onClick; // Optional - the function to run to apply the fix
this.icon = attrs.icon; // Optional - shows 'iD-icon-wrench' if not set
this.entityIds = attrs.entityIds || []; // Optional - used for hover-higlighting.
this.autoArgs = attrs.autoArgs; // Optional - pass [actions, annotation] arglist if this fix can automatically run
this.title = attrs.title; // Required
this.onClick = attrs.onClick; // Optional - the function to run to apply the fix
this.disabledReason = attrs.disabledReason; // Optional - a string explaining why the fix is unavailable, if any
this.icon = attrs.icon; // Optional - shows 'iD-icon-wrench' if not set
this.entityIds = attrs.entityIds || []; // Optional - used for hover-higlighting.
this.autoArgs = attrs.autoArgs; // Optional - pass [actions, annotation] arglist if this fix can automatically run
this.issue = null; // Generated link - added by validationIssue
}

View File

@@ -255,6 +255,12 @@ export function uiEntityIssues(context) {
fixesEnter.merge(fixes)
.classed('actionable', function(d) {
return d.onClick;
})
.attr('title', function(d) {
if (d.disabledReason) {
return d.disabledReason;
}
return null;
});
}

View File

@@ -99,7 +99,8 @@ export function validationMissingTag() {
var id = this.entityIds[0];
var operation = operationDelete([id], context);
if (!operation.disabled()) {
var disabledReasonID = operation.disabled();
if (!disabledReasonID) {
deleteOnClick = function(context) {
var id = this.issue.entityIds[0];
var operation = operationDelete([id], context);
@@ -113,6 +114,7 @@ export function validationMissingTag() {
new validationIssueFix({
icon: 'iD-operation-delete',
title: t('issues.fix.delete_feature.title'),
disabledReason: disabledReasonID ? t('operations.delete.' + disabledReasonID + '.single') : undefined,
onClick: deleteOnClick
})
);