Commit 94397333ee37f4476212c2f009883c083fe9aaaa
1 parent
d83b461aa9
Exists in
master
Actualizar campo MOD al cambiar de lista
Showing
3 changed files
with
27 additions
and
16 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -136,16 +136,19 @@ angular.module('focaModalPrecioCondicion') |
| 136 | 136 | $uibModalInstance.dismiss('cancel'); |
| 137 | 137 | }; |
| 138 | 138 | $scope.guardarPrecioCondicion = function () { |
| 139 | - $scope.plazos.shift(); | |
| 140 | - focaModalPrecioCondicionService.createPlazo($scope.plazos) | |
| 141 | - .then(function () { | |
| 142 | - var precioCondicion = { | |
| 143 | - listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | |
| 144 | - plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | |
| 145 | - }; | |
| 146 | - $uibModalInstance.close(precioCondicion); | |
| 147 | - }) | |
| 148 | - .catch(function (e) { console.error(e) }) | |
| 149 | - } | |
| 139 | + var mod = $scope.associatedList ? parseInt($scope.listaDePreciosAsociada.ID) : parseInt($scope.listaDePreciosAlternativa.ID); | |
| 140 | + focaModalPrecioCondicionService.actualizarLista(idCliente, mod).then(function (){ | |
| 141 | + $scope.plazos.shift(); | |
| 142 | + focaModalPrecioCondicionService.createPlazo($scope.plazos) | |
| 143 | + .then(function () { | |
| 144 | + var precioCondicion = { | |
| 145 | + listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | |
| 146 | + plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | |
| 147 | + }; | |
| 148 | + $uibModalInstance.close(precioCondicion); | |
| 149 | + }) | |
| 150 | + .catch(function (e) { console.error(e) }) | |
| 151 | + }); | |
| 152 | + }; | |
| 150 | 153 | } |
| 151 | 154 | ]); |
src/js/controllerCliente.js
| ... | ... | @@ -9,9 +9,10 @@ angular.module('focaModalPrecioCondicion') |
| 9 | 9 | 'focaModalService', |
| 10 | 10 | 'focaModalPrecioCondicionService', |
| 11 | 11 | 'idListaPrecio', |
| 12 | + 'idCliente', | |
| 12 | 13 | function ( |
| 13 | 14 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, |
| 14 | - focaModalService, focaModalPrecioCondicionService, idListaPrecio | |
| 15 | + focaModalService, focaModalPrecioCondicionService, idListaPrecio, idCliente | |
| 15 | 16 | ) { |
| 16 | 17 | $scope.openModalListaDePrecios = false; |
| 17 | 18 | $scope.associatedList = true; |
| ... | ... | @@ -82,10 +83,14 @@ angular.module('focaModalPrecioCondicion') |
| 82 | 83 | $uibModalInstance.dismiss('cancel'); |
| 83 | 84 | }; |
| 84 | 85 | $scope.guardarPrecioCondicion = function () { |
| 85 | - var precioCondicion = { | |
| 86 | - listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | |
| 87 | - }; | |
| 88 | - $uibModalInstance.close(precioCondicion); | |
| 86 | + var mod = $scope.associatedList ? parseInt($scope.listaDePreciosAsociada.ID) : parseInt($scope.listaDePreciosAlternativa.ID); | |
| 87 | + | |
| 88 | + focaModalPrecioCondicionService.actualizarLista(idCliente, mod).then(function (){ | |
| 89 | + var precioCondicion = { | |
| 90 | + listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | |
| 91 | + }; | |
| 92 | + $uibModalInstance.close(precioCondicion); | |
| 93 | + }); | |
| 89 | 94 | }; |
| 90 | 95 | } |
| 91 | 96 | ]) |
src/js/service.js
| ... | ... | @@ -26,6 +26,9 @@ angular.module('focaModalPrecioCondicion') |
| 26 | 26 | }, |
| 27 | 27 | createPlazo: function (plazosPago){ |
| 28 | 28 | return $http.post(API_ENDPOINT.URL + '/plazos-pago', { plazosPago: plazosPago }); |
| 29 | + }, | |
| 30 | + actualizarLista: function(id , mod) { | |
| 31 | + return $http.post(API_ENDPOINT.URL + '/cliente/update/mod', { id: id, mod: mod}); | |
| 29 | 32 | } |
| 30 | 33 | }; |
| 31 | 34 | } |