mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-07 20:01:33 +00:00
Revalidate immediately after running most fixes (close #6354)
Allow individual fixes to control revalidation Don't allow fixes to run within a second of running any fix for that issue
This commit is contained in:
@@ -202,12 +202,28 @@ export function uiEntityIssues(context) {
|
||||
return 'issue-fix-item ' + (d.onClick ? 'actionable' : '');
|
||||
})
|
||||
.on('click', function(d) {
|
||||
if (d.onClick) {
|
||||
var issueEntityIDs = d.issue.entityIds;
|
||||
utilHighlightEntities(issueEntityIDs.concat(d.entityIds), false, context);
|
||||
d.onClick();
|
||||
window.setTimeout(function() { context.validator().validate(); }, 300); // after any transition
|
||||
}
|
||||
// not all fixes are actionable
|
||||
if (!d.onClick) return;
|
||||
|
||||
// Don't run another fix for this issue within a second of running one
|
||||
// (Necessary for "Select a feature type" fix. Most fixes should only ever run once)
|
||||
if (d.issue.dateLastRanFix && new Date() - d.issue.dateLastRanFix < 1000) return;
|
||||
d.issue.dateLastRanFix = new Date();
|
||||
|
||||
// remove hover-highlighting
|
||||
utilHighlightEntities(d.issue.entityIds.concat(d.entityIds), false, context);
|
||||
|
||||
new Promise(function(resolve, reject) {
|
||||
d.onClick(resolve, reject);
|
||||
if (!d.onClick.length) {
|
||||
// if the fix doesn't take any completion parameters then consider it resolved
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
.then(function() {
|
||||
// revalidate whenever the fix has finished running successfully
|
||||
context.validator().validate();
|
||||
});
|
||||
})
|
||||
.on('mouseover.highlight', function(d) {
|
||||
utilHighlightEntities(d.entityIds, true, context);
|
||||
|
||||
@@ -83,13 +83,15 @@ export function validationUnsquareWay() {
|
||||
icon: 'iD-operation-orthogonalize',
|
||||
title: t('issues.fix.square_feature.title'),
|
||||
autoArgs: autoArgs,
|
||||
onClick: function() {
|
||||
onClick: function(completionHandler) {
|
||||
var entityId = this.issue.entityIds[0];
|
||||
// note: use default params for actionOrthogonalize, not relaxed epsilon
|
||||
context.perform(
|
||||
actionOrthogonalize(entityId, context.projection),
|
||||
t('operations.orthogonalize.annotation.area')
|
||||
);
|
||||
// run after the squaring transition (currently 150ms)
|
||||
window.setTimeout(function() { completionHandler(); }, 175);
|
||||
}
|
||||
}),
|
||||
new validationIssueFix({
|
||||
|
||||
Reference in New Issue
Block a user