Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions js/controller/BoardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions js/service/StackService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
2 changes: 1 addition & 1 deletion templates/part.board.mainView.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class="icon icon-archive"></span><span><?php p($l->t('Unarchive')); ?></span></a
<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>
Expand Down