Commit 16b2b4e772963c698dc43ecc5c51616e5a01e01d

Authored by Nicolás Guarnieri
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

master(efernandez)

See merge request modulos-npm/foca-modal-busqueda-productos!15
... ... @@ -43,7 +43,10 @@
43 43 templateUrl: 'src/views/modal-busqueda-productos.html',
44 44 controller: 'modalBusquedaProductosCtrl',
45 45 size: 'lg',
46   - resolve: {idLista : function() { return -1; }}
  46 + resolve: {
  47 + idLista : function() { return -1; },
  48 + cotizacion: function() { return 1;}
  49 + }
47 50 }
48 51 );
49 52  
src/js/controller.js
... ... @@ -5,8 +5,11 @@ angular.module('focaBusquedaProductos')
5 5 '$scope',
6 6 '$uibModalInstance',
7 7 'idLista',
  8 + 'cotizacion',
8 9 'focaBusquedaProductosService',
9   - function($filter, $scope, $uibModalInstance, idLista, focaBusquedaProductosService) {
  10 + function($filter, $scope, $uibModalInstance, idLista,
  11 + cotizacion, focaBusquedaProductosService
  12 + ) {
10 13  
11 14 $scope.filters = '';
12 15 $scope.productos = [];
... ... @@ -26,33 +29,27 @@ angular.module('focaBusquedaProductos')
26 29 if(idLista > 0) {
27 30 focaBusquedaProductosService
28 31 .getProductosByIdLista(idLista, $scope.filters)
29   - .then(
30   - function(res) {
31   - $scope.searchLoading = false;
32   - $scope.primerBusqueda = true;
33   - $scope.productos = res.data;
34   - $scope.search();
35   - primera();
36   - }
37   - );
  32 + .then(llenarDatos);
38 33 } else if(idLista === -1) {
39   - focaBusquedaProductosService.getProductos().then(
40   - function(res) {
41   - $scope.searchLoading = false;
42   - $scope.primerBusqueda = true;
43   - $scope.productos = res.data;
44   - $scope.search();
45   - primera();
46   - }
47   - );
  34 + focaBusquedaProductosService.getProductos()
  35 + .then(llenarDatos);
48 36 }
49 37 }
50 38 };
51   -
  39 + function llenarDatos(res) {
  40 + for(var i = 0; i < res.data.length; i++) {
  41 + res.data[i].precio = res.data[i].precio / cotizacion;
  42 + }
  43 + $scope.searchLoading = false;
  44 + $scope.primerBusqueda = true;
  45 + $scope.productos = res.data;
  46 + $scope.search();
  47 + primera();
  48 + }
52 49 $scope.search = function() {
53 50 if($scope.productos.length > 0) {
54 51 $scope.filteredProductos = $filter('filter')(
55   - $scope.productos,
  52 + $scope.productos,
56 53 {$: $scope.filters}
57 54 );
58 55