Commit 127da2947943f5d82409001b8d11db00a267c89d
1 parent
45b40416e2
Exists in
master
implementación confirm global
Showing
2 changed files
with
11 additions
and
28 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', '$uibModal', | 3 | '$scope', 'focaAbmPlazoPagoService', '$location', 'modal', |
4 | function($scope, focaAbmPlazoPagoService, $location, $uibModal) { | 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 | $uibModal.open({ | 12 | modal.confirm('¿Está seguro que desea borrar el plazo de pago'+plazoPago.item+' '+ |
13 | templateUrl: 'foca-abm-plazos-pago-modal-confirmar.html', | 13 | plazoPago.dias+' ?').then( |
14 | controller: 'focaAbmPlazosPagoModalConfirmarController', | 14 | function(plazoPago) { |
15 | animation: false, | 15 | focaAbmPlazoPagoService.borrarPlazoPago(plazoPago.id); |
16 | backdrop: false, | 16 | $scope.plazosPago.splice( |
17 | resolve: {plazoPago: function(){return plazoPago;}} | 17 | $scope.plazosPago.indexOf(plazoPago), 1 |
18 | }) | 18 | ); |
19 | .result.then(function(plazoPago){ | 19 | } |
20 | focaAbmPlazoPagoService.borrarPlazoPago(plazoPago.id); | 20 | ); |
21 | $scope.plazosPago.splice( | ||
22 | $scope.plazosPago.indexOf(plazoPago), 1 | ||
23 | ); | ||
24 | }); | ||
25 | }; | 21 | }; |
26 | } | 22 | } |
27 | ]) | 23 | ]) |
28 | .controller('focaAbmPlazoPagoController', [ | 24 | .controller('focaAbmPlazoPagoController', [ |
29 | '$scope', 'focaAbmPlazoPagoService', | 25 | '$scope', 'focaAbmPlazoPagoService', |
30 | '$routeParams', '$location', | 26 | '$routeParams', '$location', |
31 | function( | 27 | function( |
32 | $scope, focaAbmPlazoPagoService, | 28 | $scope, focaAbmPlazoPagoService, |
33 | $routeParams, $location | 29 | $routeParams, $location |
34 | ) { | 30 | ) { |
35 | focaAbmPlazoPagoService.obtenerPlazoPago($routeParams.id) | 31 | focaAbmPlazoPagoService.obtenerPlazoPago($routeParams.id) |
36 | .then(function(datos) { | 32 | .then(function(datos) { |
37 | $scope.plazoPago = { | 33 | $scope.plazoPago = { |
38 | id: 0, | 34 | id: 0, |
39 | idPreciosCondiciones: $routeParams.idPreciosCondiciones, | 35 | idPreciosCondiciones: $routeParams.idPreciosCondiciones, |
40 | item: '', | 36 | item: '', |
41 | dias: '' | 37 | dias: '' |
42 | }; | 38 | }; |
43 | if(datos.data.id) { | 39 | if(datos.data.id) { |
44 | $scope.plazoPago = datos.data; | 40 | $scope.plazoPago = datos.data; |
45 | } | 41 | } |
46 | }); | 42 | }); |
47 | $scope.cancelar = function() { | 43 | $scope.cancelar = function() { |
48 | $location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones); | 44 | $location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones); |
49 | }; | 45 | }; |
50 | $scope.guardar = function(plazoPago) { | 46 | $scope.guardar = function(plazoPago) { |
51 | focaAbmPlazoPagoService.guardarPlazoPago(plazoPago) | 47 | focaAbmPlazoPagoService.guardarPlazoPago(plazoPago) |
52 | .then(function() { | 48 | .then(function() { |
53 | $location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones); | 49 | $location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones); |
54 | }); | 50 | }); |
55 | }; | 51 | }; |
56 | } | 52 | } |
57 | ]) | 53 | ]) |
58 | .controller('focaAbmPlazosPagoModalConfirmarController', [ | 54 | .controller('focaAbmPlazosPagoModalConfirmarController', [ |
59 | '$uibModalInstance', '$scope', 'plazoPago', | 55 | '$uibModalInstance', '$scope', 'plazoPago', |
60 | function($uibModalInstance, $scope, plazoPago) { | 56 | function($uibModalInstance, $scope, plazoPago) { |
61 | $scope.plazoPago = plazoPago; | 57 | $scope.plazoPago = plazoPago; |
62 | $scope.cancelar = function() { | 58 | $scope.cancelar = function() { |
63 | $uibModalInstance.dismiss(); | 59 | $uibModalInstance.dismiss(); |
64 | }; | 60 | }; |
65 | $scope.borrar = function() { | 61 | $scope.borrar = function() { |
66 | $uibModalInstance.close(plazoPago); | 62 | $uibModalInstance.close(plazoPago); |
67 | }; | 63 | }; |
68 | } | 64 | } |
69 | ]); | 65 | ]); |
70 | 66 |
src/views/foca-abm-plazos-pago-modal-confirmar.html
1 | <div class="modal-header"> | File was deleted | |
2 | <h4>Confirmar</h4> | ||
3 | </div> | ||
4 | <div class="modal-body"> | ||
5 | <p> | ||
6 | ¿Está seguro que desea borrar el plazo de pago | ||
7 | {{plazoPago.item}} {{plazoPago.dias}}? | ||
8 | </p> | ||
9 | </div> | ||
10 | <div class="modal-footer"> | ||
11 | <button class="btn btn-danger" ng-click="borrar()">Borrar</button> | ||
12 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | ||
13 | </div> | ||
14 | 1 | <div class="modal-header"> |