Contact editor: fix cancel and reset buttons
This commit is contained in:
parent
caa920e0ff
commit
22970bd510
|
@ -57,7 +57,6 @@
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
stateCard: ['$stateParams', 'stateAddressbook', function($stateParams, stateAddressbook) {
|
stateCard: ['$stateParams', 'stateAddressbook', function($stateParams, stateAddressbook) {
|
||||||
console.debug('resovle');
|
|
||||||
return stateAddressbook.$getCard($stateParams.cardId);
|
return stateAddressbook.$getCard($stateParams.cardId);
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
@ -267,10 +266,10 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$scope.reset = function() {
|
$scope.reset = function() {
|
||||||
$scope.card.reset();
|
$scope.card.$reset();
|
||||||
};
|
};
|
||||||
$scope.cancel = function() {
|
$scope.cancel = function() {
|
||||||
$scope.card.reset();
|
$scope.card.$reset();
|
||||||
if ($scope.card.isNew) {
|
if ($scope.card.isNew) {
|
||||||
// Cancelling the creation of a card
|
// Cancelling the creation of a card
|
||||||
delete $scope.card;
|
delete $scope.card;
|
||||||
|
@ -289,9 +288,11 @@
|
||||||
// User confirmed the deletion
|
// User confirmed the deletion
|
||||||
card.$delete()
|
card.$delete()
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
// Remove card from list of addressbook
|
||||||
$rootScope.addressbook.cards = _.reject($rootScope.addressbook.cards, function(o) {
|
$rootScope.addressbook.cards = _.reject($rootScope.addressbook.cards, function(o) {
|
||||||
return o.id == card.id;
|
return o.id == card.id;
|
||||||
});
|
});
|
||||||
|
// Remove card object from scope
|
||||||
delete $scope.card;
|
delete $scope.card;
|
||||||
}, function(data, status) {
|
}, function(data, status) {
|
||||||
Dialog.alert(l('Warning'), l('An error occured while deleting the card "%{0}".',
|
Dialog.alert(l('Warning'), l('An error occured while deleting the card "%{0}".',
|
||||||
|
|
|
@ -294,14 +294,14 @@
|
||||||
l('Are you sure you want to delete the card of <b>%{0}</b>?', card.$fullname()))
|
l('Are you sure you want to delete the card of <b>%{0}</b>?', card.$fullname()))
|
||||||
.then(function(res) {
|
.then(function(res) {
|
||||||
if (res) {
|
if (res) {
|
||||||
// User has confirmed deletion
|
// User confirmed the deletion
|
||||||
card.$delete()
|
card.$delete()
|
||||||
.then(function() {
|
.then(function() {
|
||||||
// Delete card from list of addressbook
|
// Remove card from list of addressbook
|
||||||
$rootScope.addressbook.cards = _.reject($rootScope.addressbook.cards, function(o) {
|
$rootScope.addressbook.cards = _.reject($rootScope.addressbook.cards, function(o) {
|
||||||
return o.id == card.id;
|
return o.id == card.id;
|
||||||
});
|
});
|
||||||
// Delete card object
|
// Remove card object from scope
|
||||||
delete $scope.card;
|
delete $scope.card;
|
||||||
// Delete modal editor
|
// Delete modal editor
|
||||||
$scope.$cardEditorModal.remove();
|
$scope.$cardEditorModal.remove();
|
||||||
|
|
Loading…
Reference in a new issue