Pass whole selected entity to deleteEntity callback
For now, delete-modal service passes only ID to deleteEntity callback. Some plugins need other parameters to delete entity. So this patch passes whole selected entity to callback as second argument. Change-Id: I395470110a5f03ebb08a043ca433b16b999dad3f Needed-By: Ic5aba9b2e953cde7950ae7656cd5a3fee3f4a55c Closes-Bug: #1761074
This commit is contained in:
parent
9ca9b5cd81
commit
d0beeb7e14
@ -71,6 +71,7 @@
|
||||
* @param {function} context.deleteEntity
|
||||
* The function that should be called to delete each entity.
|
||||
* The first argument is the id of the Entity to delete.
|
||||
* The second argument is the Entity itself.
|
||||
* Note: This callback might need to suppress errors on the
|
||||
* alert service.
|
||||
*
|
||||
@ -100,7 +101,7 @@
|
||||
}
|
||||
|
||||
function deleteEntityPromise(entity) {
|
||||
return {promise: context.deleteEntity(entity.id), context: entity};
|
||||
return {promise: context.deleteEntity(entity.id, entity), context: entity};
|
||||
}
|
||||
|
||||
function notify(result) {
|
||||
|
@ -117,8 +117,8 @@
|
||||
|
||||
$scope.$apply();
|
||||
|
||||
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1');
|
||||
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('2');
|
||||
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1', {name: 'entity1', id: '1'});
|
||||
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('2', {name: 'entity2', id: '2'});
|
||||
expect(toastService.add).toHaveBeenCalledWith('success', 'Deleted : entity1, entity2.');
|
||||
expect($scope.$emit).toHaveBeenCalledWith('custom_delete_event_passed', [ '1', '2' ]);
|
||||
});
|
||||
@ -134,7 +134,7 @@
|
||||
|
||||
$scope.$apply();
|
||||
|
||||
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad');
|
||||
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad', {name: 'entity1', id: 'bad'});
|
||||
expect(toastService.add).toHaveBeenCalledWith('error', 'Unable to delete: entity1.');
|
||||
expect($scope.$emit).toHaveBeenCalledWith('custom_delete_event_failed', ['bad']);
|
||||
});
|
||||
@ -153,8 +153,8 @@
|
||||
|
||||
$scope.$apply();
|
||||
|
||||
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad');
|
||||
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1');
|
||||
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('bad', {name: 'bad_entity', id: 'bad'});
|
||||
expect(entityAPI.deleteEntity).toHaveBeenCalledWith('1', {name: 'entity2', id: '1'});
|
||||
expect(toastService.add).toHaveBeenCalledWith('success', 'Deleted : entity2.');
|
||||
expect(toastService.add).toHaveBeenCalledWith('error', 'Unable to delete: bad_entity.');
|
||||
expect($scope.$emit).toHaveBeenCalledWith('custom_delete_event_passed', ['1']);
|
||||
|
Loading…
Reference in New Issue
Block a user