Skip to content

Commit

Permalink
Add ConfirmationModal for deleting visualizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Feb 4, 2017
1 parent f243762 commit d0325ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@
<!-- Bulk delete button -->
<button
class="kuiButton kuiButton--danger"
confirm-click="listingController.deleteSelectedItems()"
confirmation="Are you sure you want to delete the selected visualizations? This action is irreversible!"
aria-label="Delete selected objects"
ng-if="listingController.getSelectedItemsCount() > 0"
ng-click="listingController.deleteSelectedItems()"
tooltip="Delete selected visualizations"
>
<span aria-hidden="true" class="kuiButton__icon kuiIcon fa-trash"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import SavedObjectRegistryProvider from 'ui/saved_objects/saved_object_registry'

export function VisualizeListingController(
$scope,
confirmModal,
kbnUrl,
Notifier,
Private,
Expand Down Expand Up @@ -56,14 +57,23 @@ export function VisualizeListingController(
};

this.deleteSelectedItems = function deleteSelectedItems() {
const selectedIds = selectedItems.map(item => item.id);
const doDelete = () => {
const selectedIds = selectedItems.map(item => item.id);

visualizationService.delete(selectedIds)
.then(fetchObjects)
.then(() => {
selectedItems = [];
})
.catch(error => notify.error(error));
visualizationService.delete(selectedIds)
.then(fetchObjects)
.then(() => {
selectedItems = [];
})
.catch(error => notify.error(error));
};

confirmModal(
'Are you sure you want to delete the selected visualizations? This action is irreversible!',
{
confirmButtonText: 'Delete',
onConfirm: doDelete
});
};

this.getUrlForItem = function getUrlForItem(item) {
Expand Down

0 comments on commit d0325ba

Please sign in to comment.