Fix issue the deleted item is selected again with batch delete

Items recently deleted with batch action are shown in deletion
confirmation dialog when execute the batch delete action again.

Steps to reproduce:
1. Create 2 new items
2. Delete one of them using the batch delete action on top of the table
3. Select the another item and click the batch delete action

Expect to see the confirmation dialog shows one selected item,
but it shows the item that was deleted in step 2 as well.
Also, HTTP DELETE method for already deleted item is submitted
again and occurs error.

This patch fixes this issue.

Change-Id: Ib475761363e85be8df3c64e94d8000295796fd1c
Closes-Bug: #1742599
This commit is contained in:
Shu Muto 2018-01-11 13:43:53 +09:00
parent 7b5db0a354
commit d946e483cd
2 changed files with 10 additions and 4 deletions

View File

@ -136,8 +136,11 @@
deleteModalResult.fail.forEach(function markFailed(item) {
result.failed(resourceType, getEntity(item).id);
});
if (result.result.failed.length === 0 && result.result.deleted.length > 0) {
$location.path("/project/cluster_templates");
var indexPath = "/project/cluster_templates";
var currentPath = $location.path();
if (result.result.failed.length === 0 && result.result.deleted.length > 0 &&
currentPath !== indexPath) {
$location.path(indexPath);
} else {
return result.result;
}

View File

@ -136,8 +136,11 @@
deleteModalResult.fail.forEach(function markFailed(item) {
result.failed(resourceType, getEntity(item).id);
});
if (result.result.failed.length === 0 && result.result.deleted.length > 0) {
$location.path("/project/clusters");
var indexPath = "/project/clusters";
var currentPath = $location.path();
if (result.result.failed.length === 0 && result.result.deleted.length > 0 &&
currentPath !== indexPath) {
$location.path(indexPath);
} else {
return result.result;
}