Contact editor: fix cancel and reset buttons

pull/91/head
Francis Lachapelle 2014-09-29 12:12:28 -04:00
parent 31ea7a5ab5
commit 654c8d26b7
2 changed files with 7 additions and 6 deletions

View File

@ -57,7 +57,6 @@
},
resolve: {
stateCard: ['$stateParams', 'stateAddressbook', function($stateParams, stateAddressbook) {
console.debug('resovle');
return stateAddressbook.$getCard($stateParams.cardId);
}]
}
@ -267,10 +266,10 @@
}
};
$scope.reset = function() {
$scope.card.reset();
$scope.card.$reset();
};
$scope.cancel = function() {
$scope.card.reset();
$scope.card.$reset();
if ($scope.card.isNew) {
// Cancelling the creation of a card
delete $scope.card;
@ -289,9 +288,11 @@
// User confirmed the deletion
card.$delete()
.then(function() {
// Remove card from list of addressbook
$rootScope.addressbook.cards = _.reject($rootScope.addressbook.cards, function(o) {
return o.id == card.id;
});
// Remove card object from scope
delete $scope.card;
}, function(data, status) {
Dialog.alert(l('Warning'), l('An error occured while deleting the card "%{0}".',

View File

@ -294,14 +294,14 @@
l('Are you sure you want to delete the card of <b>%{0}</b>?', card.$fullname()))
.then(function(res) {
if (res) {
// User has confirmed deletion
// User confirmed the deletion
card.$delete()
.then(function() {
// Delete card from list of addressbook
// Remove card from list of addressbook
$rootScope.addressbook.cards = _.reject($rootScope.addressbook.cards, function(o) {
return o.id == card.id;
});
// Delete card object
// Remove card object from scope
delete $scope.card;
// Delete modal editor
$scope.$cardEditorModal.remove();