From 0d70f0670d9ecbcfb138ae8159be8fd47e560c01 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 16 Apr 2019 22:56:43 -0400 Subject: [PATCH] Better test for whether untagged entities can be deleted Now entities can always be deleted if the user created them in the first place.. We skip asking `operationDelete.disabled()` because there are reasons why this may return true. A thing that could happen before: - User creates an untagged entity - Quits browser and restarts iD - Restores history - The entity happens to be in a part of the map that hasn't been loaded yet, so `operationDelete.disabled()` returns true, and the issue ends up as a 'warning' instead of an 'error' --- modules/validations/missing_tag.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/validations/missing_tag.js b/modules/validations/missing_tag.js index 8b0a6fa05..062ddba3c 100644 --- a/modules/validations/missing_tag.js +++ b/modules/validations/missing_tag.js @@ -62,9 +62,15 @@ export function validationMissingTag() { }) ]; - var canDelete = false; - if (!operationDelete([entity.id], context).disabled()) { - canDelete = true; + // can always delete if the user created it in the first place.. + var canDelete = (entity.version === undefined || entity.v !== undefined); + + // otherwise check with operationDelete whether we can delete this entity + if (!canDelete) { + canDelete = !operationDelete([entity.id], context).disabled(); + } + + if (canDelete) { fixes.push( new validationIssueFix({ icon: 'iD-operation-delete', @@ -80,12 +86,9 @@ export function validationMissingTag() { ); } - // error if created or modified and is deletable, else warning - var isError = (entity.version === undefined || entity.v !== undefined) && canDelete; - return [new validationIssue({ type: type, - severity: isError ? 'error' : 'warning', + severity: canDelete ? 'error' : 'warning', message: t('issues.missing_tag.' + missingTagType + '.message', messageObj), reference: showReference, entities: [entity],