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:
Julius Härtl
2018-02-28 10:01:39 +01:00
parent 5d3f952d92
commit 19a3466b18
3 changed files with 29 additions and 3 deletions

View File

@@ -169,8 +169,14 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
};
$scope.cardDelete = function (card) {
CardService.delete(card.id);
StackService.removeCard(card);
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);

View File

@@ -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;
});