mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 01:33:03 +00:00
Add tooltip to delete feature fix explaining if it's disabled (close #6588)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user