Commit fbbc020e5887355bcb28e63c37e4b3178de753ab
1 parent
780a9f584b
Exists in
master
- Agregué confirmación al borrar plazo pago.
- Agregué funcionalidad para borrar plazo pago. - Agregué servicio para borrar plazo pago.
Showing
2 changed files
with
34 additions
and
2 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaAbmPreciosCondiciones') | 1 | angular.module('focaAbmPreciosCondiciones') |
2 | .controller('focaAbmPreciosCondicionesController', [ | 2 | .controller('focaAbmPreciosCondicionesController', [ |
3 | '$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal', | 3 | '$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal', |
4 | function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) { | 4 | function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) { |
5 | focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { | 5 | focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { |
6 | $scope.preciosCondiciones = datos.data; | 6 | $scope.preciosCondiciones = datos.data; |
7 | }); | 7 | }); |
8 | $scope.editar = function(id) { | 8 | $scope.editar = function(id) { |
9 | $location.path('/precio-condicion/' + id); | 9 | $location.path('/precio-condicion/' + id); |
10 | }; | 10 | }; |
11 | $scope.solicitarConfirmacion = function(precioCondicion) { | 11 | $scope.solicitarConfirmacion = function(precioCondicion) { |
12 | $uibModal.open({ | 12 | $uibModal.open({ |
13 | templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html', | 13 | templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html', |
14 | controller: 'focaAbmPreciosCondicionesModalConfirmarController', | 14 | controller: 'focaAbmPreciosCondicionesModalConfirmarController', |
15 | animation: false, | 15 | animation: false, |
16 | backdrop: false, | 16 | backdrop: false, |
17 | resolve: {precioCondicion: function(){return precioCondicion;}} | 17 | resolve: {precioCondicion: function(){return precioCondicion;}} |
18 | }) | 18 | }) |
19 | .result.then(function(precioCondicion){ | 19 | .result.then(function(precioCondicion){ |
20 | focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id); | 20 | focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id); |
21 | $scope.preciosCondiciones.splice( | 21 | $scope.preciosCondiciones.splice( |
22 | $scope.preciosCondiciones.indexOf(precioCondicion), 1 | 22 | $scope.preciosCondiciones.indexOf(precioCondicion), 1 |
23 | ); | 23 | ); |
24 | }); | 24 | }); |
25 | }; | 25 | }; |
26 | } | 26 | } |
27 | ]) | 27 | ]) |
28 | .controller('focaAbmPrecioCondicionController', [ | 28 | .controller('focaAbmPrecioCondicionController', [ |
29 | '$scope', 'focaAbmPreciosCondicionesService', | 29 | '$scope', 'focaAbmPreciosCondicionesService', |
30 | '$routeParams', '$location', | 30 | '$routeParams', '$location', '$uibModal', |
31 | function( | 31 | function( |
32 | $scope, focaAbmPreciosCondicionesService, | 32 | $scope, focaAbmPreciosCondicionesService, |
33 | $routeParams, $location | 33 | $routeParams, $location, $uibModal |
34 | ) { | 34 | ) { |
35 | focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) | 35 | focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) |
36 | .then(function(datos) { | 36 | .then(function(datos) { |
37 | $scope.precioCondicion = { | 37 | $scope.precioCondicion = { |
38 | id: 0, | 38 | id: 0, |
39 | codigo: '', | 39 | codigo: '', |
40 | nombre: '', | 40 | nombre: '', |
41 | descripcion: '', | 41 | descripcion: '', |
42 | idListaPrecio: 0, | 42 | idListaPrecio: 0, |
43 | vigencia: new Date() | 43 | vigencia: new Date() |
44 | }; | 44 | }; |
45 | if(datos.data.id) { | 45 | if(datos.data.id) { |
46 | $scope.precioCondicion = datos.data; | 46 | $scope.precioCondicion = datos.data; |
47 | focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id) | 47 | focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id) |
48 | .then(function(datos){ | 48 | .then(function(datos){ |
49 | $scope.precioCondicion.plazos = datos.data; | 49 | $scope.precioCondicion.plazos = datos.data; |
50 | }); | 50 | }); |
51 | } | 51 | } |
52 | }); | 52 | }); |
53 | $scope.cancelar = function() { | 53 | $scope.cancelar = function() { |
54 | $location.path('/precio-condicion'); | 54 | $location.path('/precio-condicion'); |
55 | }; | 55 | }; |
56 | $scope.guardar = function(precioCondicion) { | 56 | $scope.guardar = function(precioCondicion) { |
57 | focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) | 57 | focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) |
58 | .then(function() { | 58 | .then(function() { |
59 | $location.path('/precio-condicion'); | 59 | $location.path('/precio-condicion'); |
60 | }); | 60 | }); |
61 | }; | 61 | }; |
62 | $scope.editarPlazoPago = function(id) { | 62 | $scope.editarPlazoPago = function(id) { |
63 | $location.path( | 63 | $location.path( |
64 | '/precio-condicion/' + $scope.precioCondicion.id + | 64 | '/precio-condicion/' + $scope.precioCondicion.id + |
65 | '/plazo-pago/' + id | 65 | '/plazo-pago/' + id |
66 | ); | 66 | ); |
67 | }; | 67 | }; |
68 | $scope.solicitarConfirmacionPlazoPago = function(plazoPago) { | ||
69 | $uibModal.open({ | ||
70 | templateUrl: 'foca-abm-plazos-pago-modal-confirmar.html', | ||
71 | controller: 'focaAbmPlazosPagosModalConfirmarController', | ||
72 | animation: false, | ||
73 | backdrop: false, | ||
74 | resolve: {plazoPago: function(){return plazoPago;}} | ||
75 | }) | ||
76 | .result.then(function(plazoPago){ | ||
77 | console.log(plazoPago); | ||
78 | console.log($scope.precioCondicion); | ||
79 | focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id); | ||
80 | $scope.precioCondicion.plazos.splice( | ||
81 | $scope.precioCondicion.plazos.indexOf(plazoPago), 1 | ||
82 | ); | ||
83 | }); | ||
84 | } | ||
68 | } | 85 | } |
69 | ]) | 86 | ]) |
70 | .controller('focaAbmPreciosCondicionesModalConfirmarController', [ | 87 | .controller('focaAbmPreciosCondicionesModalConfirmarController', [ |
71 | '$uibModalInstance', '$scope', 'precioCondicion', | 88 | '$uibModalInstance', '$scope', 'precioCondicion', |
72 | function($uibModalInstance, $scope, precioCondicion) { | 89 | function($uibModalInstance, $scope, precioCondicion) { |
73 | $scope.precioCondicion = precioCondicion; | 90 | $scope.precioCondicion = precioCondicion; |
74 | $scope.cancelar = function() { | 91 | $scope.cancelar = function() { |
75 | $uibModalInstance.dismiss(); | 92 | $uibModalInstance.dismiss(); |
76 | }; | 93 | }; |
77 | $scope.borrar = function() { | 94 | $scope.borrar = function() { |
78 | $uibModalInstance.close(precioCondicion); | 95 | $uibModalInstance.close(precioCondicion); |
79 | }; | 96 | }; |
80 | } | 97 | } |
98 | ]) | ||
99 | .controller('focaAbmPlazosPagosModalConfirmarController', [ | ||
100 | '$uibModalInstance', '$scope', 'plazoPago', | ||
101 | function($uibModalInstance, $scope, plazoPago) { | ||
102 | $scope.plazoPago = plazoPago; | ||
103 | $scope.cancelar = function() { | ||
104 | $uibModalInstance.dismiss(); | ||
105 | }; | ||
106 | $scope.borrar = function() { | ||
107 | $uibModalInstance.close(plazoPago); | ||
108 | }; | ||
109 | } | ||
81 | ]); | 110 | ]); |
82 | 111 |
src/js/service.js
1 | angular.module('focaAbmPreciosCondiciones') | 1 | angular.module('focaAbmPreciosCondiciones') |
2 | .service('focaAbmPreciosCondicionesService', [ | 2 | .service('focaAbmPreciosCondicionesService', [ |
3 | '$http', 'API_ENDPOINT', | 3 | '$http', 'API_ENDPOINT', |
4 | function($http, API_ENDPOINT) { | 4 | function($http, API_ENDPOINT) { |
5 | return { | 5 | return { |
6 | obtenerPreciosCondiciones: function() { | 6 | obtenerPreciosCondiciones: function() { |
7 | return $http.get(API_ENDPOINT.URL + '/precio-condicion'); | 7 | return $http.get(API_ENDPOINT.URL + '/precio-condicion'); |
8 | }, | 8 | }, |
9 | obtenerPrecioCondicion: function(id) { | 9 | obtenerPrecioCondicion: function(id) { |
10 | return $http.get(API_ENDPOINT.URL + '/precio-condicion/' + id); | 10 | return $http.get(API_ENDPOINT.URL + '/precio-condicion/' + id); |
11 | }, | 11 | }, |
12 | guardarPrecioCondicion: function(precioCondicion) { | 12 | guardarPrecioCondicion: function(precioCondicion) { |
13 | return $http.post( | 13 | return $http.post( |
14 | API_ENDPOINT.URL + '/precio-condicion', | 14 | API_ENDPOINT.URL + '/precio-condicion', |
15 | {precioCondicion: precioCondicion} | 15 | {precioCondicion: precioCondicion} |
16 | ); | 16 | ); |
17 | }, | 17 | }, |
18 | borrarPrecioCondicion: function(id) { | 18 | borrarPrecioCondicion: function(id) { |
19 | return $http.delete(API_ENDPOINT.URL + '/precio-condicion/' + id); | 19 | return $http.delete(API_ENDPOINT.URL + '/precio-condicion/' + id); |
20 | }, | 20 | }, |
21 | obtenerPlazoPago: function(idPrecioCondicion) { | 21 | obtenerPlazoPago: function(idPrecioCondicion) { |
22 | return $http.get( | 22 | return $http.get( |
23 | API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + idPrecioCondicion | 23 | API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + idPrecioCondicion |
24 | ); | 24 | ); |
25 | }, | ||
26 | borrarPlazoPago: function(id) { | ||
27 | return $http.delete(API_ENDPOINT.URL + '/plazo-pago/' + id); | ||
25 | } | 28 | } |
26 | }; | 29 | }; |
27 | } | 30 | } |
28 | ]); | 31 | ]); |
29 | 32 |