Add confirmation dialog to delete options
this is only a temporary solution but it will probably safe some users from deleting their data by accident Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -169,8 +169,14 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
|
||||
};
|
||||
|
||||
$scope.cardDelete = function (card) {
|
||||
CardService.delete(card.id);
|
||||
OC.dialogs.confirm(t('deck', 'Are you sure you want to delete this card with all of its data?'), t('deck', 'Delete'), function(state) {
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
CardService.delete(card.id).then(function () {
|
||||
StackService.removeCard(card);
|
||||
});
|
||||
});
|
||||
};
|
||||
$scope.cardArchive = function (card) {
|
||||
CardService.archive(card);
|
||||
|
||||
@@ -118,6 +118,26 @@ app.factory('StackService', function (ApiService, $http, $q) {
|
||||
}
|
||||
};
|
||||
|
||||
// FIXME: Should not sure popup but proper undo mechanism
|
||||
StackService.prototype.delete = function (id) {
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
|
||||
OC.dialogs.confirm('Are you sure you want to delete the stack with all of its data?', t('deck', 'Delete'), function(state) {
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
$http.delete(self.baseUrl + '/' + id).then(function (response) {
|
||||
self.remove(id);
|
||||
deferred.resolve(response.data);
|
||||
|
||||
}, function (error) {
|
||||
deferred.reject('Deleting ' + self.endpoint + ' failed');
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var service = new StackService($http, 'stacks', $q);
|
||||
return service;
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
<li>
|
||||
<a class="menuitem action action-delete permanent"
|
||||
data-action="Delete"
|
||||
ng-click="cardDelete(c)"><span
|
||||
ng-click="cardDelete(c); $event.stopPropagation();"><span
|
||||
class="icon icon-delete"></span><span><?php p($l->t('Delete')); ?></span></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user