Commit 4217403c54c07b9e891b5d14e1c1e567cd6de4c1
1 parent
f6d3cfe67a
Exists in
master
elminar corrobora que se eligió borrar
elmino controlador del modal antiguo
Showing
1 changed file
with
5 additions
and
15 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaAbmPlazoPago') | 1 | angular.module('focaAbmPlazoPago') |
2 | .controller('focaAbmPlazosPagoController', [ | 2 | .controller('focaAbmPlazosPagoController', [ |
3 | '$scope', 'focaAbmPlazoPagoService', '$location', 'modal', | 3 | '$scope', 'focaAbmPlazoPagoService', '$location', 'modal', |
4 | function($scope, focaAbmPlazoPagoService, $location, modal) { | 4 | function($scope, focaAbmPlazoPagoService, $location, modal) { |
5 | focaAbmPlazoPagoService.obtenerPlazosPago().then(function(datos) { | 5 | focaAbmPlazoPagoService.obtenerPlazosPago().then(function(datos) { |
6 | $scope.plazosPago = datos.data; | 6 | $scope.plazosPago = datos.data; |
7 | }); | 7 | }); |
8 | $scope.editar = function(id) { | 8 | $scope.editar = function(id) { |
9 | $location.path('/plazo-pago/' + id); | 9 | $location.path('/plazo-pago/' + id); |
10 | }; | 10 | }; |
11 | $scope.solicitarConfirmacion = function(plazoPago) { | 11 | $scope.solicitarConfirmacion = function(plazoPago) { |
12 | modal.confirm('¿Está seguro que desea borrar el plazo de pago'+plazoPago.item+' '+ | 12 | modal.confirm('¿Está seguro que desea borrar el plazo de pago'+plazoPago.item+' '+ |
13 | plazoPago.dias+' ?').then( | 13 | plazoPago.dias+' ?').then( |
14 | function(plazoPago) { | 14 | function(confirm) { |
15 | focaAbmPlazoPagoService.borrarPlazoPago(plazoPago.id); | 15 | if(confirm){ |
16 | $scope.plazosPago.splice( | 16 | focaAbmPlazoPagoService.borrarPlazoPago(plazoPago.id); |
17 | $scope.plazosPago.splice( | ||
17 | $scope.plazosPago.indexOf(plazoPago), 1 | 18 | $scope.plazosPago.indexOf(plazoPago), 1 |
18 | ); | 19 | ); |
20 | } | ||
19 | } | 21 | } |
20 | ); | 22 | ); |
21 | }; | 23 | }; |
22 | } | 24 | } |
23 | ]) | 25 | ]) |
24 | .controller('focaAbmPlazoPagoController', [ | 26 | .controller('focaAbmPlazoPagoController', [ |
25 | '$scope', 'focaAbmPlazoPagoService', | 27 | '$scope', 'focaAbmPlazoPagoService', |
26 | '$routeParams', '$location', | 28 | '$routeParams', '$location', |
27 | function( | 29 | function( |
28 | $scope, focaAbmPlazoPagoService, | 30 | $scope, focaAbmPlazoPagoService, |
29 | $routeParams, $location | 31 | $routeParams, $location |
30 | ) { | 32 | ) { |
31 | focaAbmPlazoPagoService.obtenerPlazoPago($routeParams.id) | 33 | focaAbmPlazoPagoService.obtenerPlazoPago($routeParams.id) |
32 | .then(function(datos) { | 34 | .then(function(datos) { |
33 | $scope.plazoPago = { | 35 | $scope.plazoPago = { |
34 | id: 0, | 36 | id: 0, |
35 | idPreciosCondiciones: $routeParams.idPreciosCondiciones, | 37 | idPreciosCondiciones: $routeParams.idPreciosCondiciones, |
36 | item: '', | 38 | item: '', |
37 | dias: '' | 39 | dias: '' |
38 | }; | 40 | }; |
39 | if(datos.data.id) { | 41 | if(datos.data.id) { |
40 | $scope.plazoPago = datos.data; | 42 | $scope.plazoPago = datos.data; |
41 | } | 43 | } |
42 | }); | 44 | }); |
43 | $scope.cancelar = function() { | 45 | $scope.cancelar = function() { |
44 | $location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones); | 46 | $location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones); |
45 | }; | 47 | }; |
46 | $scope.guardar = function(plazoPago) { | 48 | $scope.guardar = function(plazoPago) { |
47 | focaAbmPlazoPagoService.guardarPlazoPago(plazoPago) | 49 | focaAbmPlazoPagoService.guardarPlazoPago(plazoPago) |
48 | .then(function() { | 50 | .then(function() { |
49 | $location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones); | 51 | $location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones); |
50 | }); | 52 | }); |
51 | }; | 53 | }; |
52 | } | 54 | } |
53 | ]) | ||
54 | .controller('focaAbmPlazosPagoModalConfirmarController', [ | ||
55 | '$uibModalInstance', '$scope', 'plazoPago', | ||
56 | function($uibModalInstance, $scope, plazoPago) { | ||
57 | $scope.plazoPago = plazoPago; | ||
58 | $scope.cancelar = function() { | ||
59 | $uibModalInstance.dismiss(); | ||
60 | }; | ||
61 | $scope.borrar = function() { | ||
62 | $uibModalInstance.close(plazoPago); | ||
63 | }; | ||
64 | } |