Commit 386044763bc7e2b4fd0e17b5624f64756970c186
1 parent
547bcae879
Exists in
master
Cambio en la estructura al crear nuevo objeto.
Showing
1 changed file
with
3 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', 'focaAbmPlazoPagoService', | 29 | '$scope', 'focaAbmPreciosCondicionesService', 'focaAbmPlazoPagoService', | 
| 30 | '$routeParams', '$location', | 30 | '$routeParams', '$location', | 
| 31 | function( | 31 | function( | 
| 32 | $scope, focaAbmPreciosCondicionesService, focaAbmPlazoPagoService, | 32 | $scope, focaAbmPreciosCondicionesService, focaAbmPlazoPagoService, | 
| 33 | $routeParams, $location | 33 | $routeParams, $location | 
| 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 | poseeAforadores: 0, | 41 | descripcion: '', | 
| 42 | imagen: '' | 42 | idListaPrecio: 0, | 
| 43 | vigencia: new Date() | ||
| 43 | }; | 44 | }; | 
| 44 | if(datos.data.id) { | 45 | if(datos.data.id) { | 
| 45 | $scope.precioCondicion = datos.data; | 46 | $scope.precioCondicion = datos.data; | 
| 46 | focaAbmPlazoPagoService.obtenerPlazoPago(datos.data.id) | 47 | focaAbmPlazoPagoService.obtenerPlazoPago(datos.data.id) | 
| 47 | .then(function(datos){ | 48 | .then(function(datos){ | 
| 48 | $scope.precioCondicion.plazos = datos.data; | 49 | $scope.precioCondicion.plazos = datos.data; | 
| 49 | }); | 50 | }); | 
| 50 | } | 51 | } | 
| 51 | }); | 52 | }); | 
| 52 | $scope.cancelar = function() { | 53 | $scope.cancelar = function() { | 
| 53 | $location.path('/precio-condicion'); | 54 | $location.path('/precio-condicion'); | 
| 54 | }; | 55 | }; | 
| 55 | $scope.guardar = function(precioCondicion) { | 56 | $scope.guardar = function(precioCondicion) { | 
| 56 | focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) | 57 | focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) | 
| 57 | .then(function() { | 58 | .then(function() { | 
| 58 | $location.path('/precio-condicion'); | 59 | $location.path('/precio-condicion'); | 
| 59 | }); | 60 | }); | 
| 60 | }; | 61 | }; | 
| 61 | } | 62 | } | 
| 62 | ]) | 63 | ]) | 
| 63 | .controller('focaAbmPreciosCondicionesModalConfirmarController', [ | 64 | .controller('focaAbmPreciosCondicionesModalConfirmarController', [ | 
| 64 | '$uibModalInstance', '$scope', 'precioCondicion', | 65 | '$uibModalInstance', '$scope', 'precioCondicion', | 
| 65 | function($uibModalInstance, $scope, precioCondicion) { | 66 | function($uibModalInstance, $scope, precioCondicion) { | 
| 66 | $scope.precioCondicion = precioCondicion; | 67 | $scope.precioCondicion = precioCondicion; | 
| 67 | $scope.cancelar = function() { | 68 | $scope.cancelar = function() { | 
| 68 | $uibModalInstance.dismiss(); | 69 | $uibModalInstance.dismiss(); | 
| 69 | }; | 70 | }; | 
| 70 | $scope.borrar = function() { | 71 | $scope.borrar = function() { | 
| 71 | $uibModalInstance.close(precioCondicion); | 72 | $uibModalInstance.close(precioCondicion); | 
| 72 | }; | 73 | }; | 
| 73 | } | 74 | } | 
| 74 | ]); | 75 | ]); | 
| 75 | 76 | 
