Commit 00fbea86ea5ae847609b0c1b3b1b13fded5433a8

Authored by Eric Fernandez
1 parent d0c69fa0c8
Exists in master

code review

Showing 2 changed files with 17 additions and 26 deletions   Show diff stats
... ... @@ -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; }, cotizacion: 1}
  46 + resolve: {
  47 + idLista : function() { return -1; },
  48 + cotizacion: function() { return 1;}
  49 + }
47 50 }
48 51 );
49 52  
src/js/controller.js
... ... @@ -29,35 +29,23 @@ angular.module('focaBusquedaProductos')
29 29 if(idLista > 0) {
30 30 focaBusquedaProductosService
31 31 .getProductosByIdLista(idLista, $scope.filters)
32   - .then(
33   - function(res) {
34   - for(var i = 0; i < res.data.length; i++) {
35   - res.data[i].precio = res.data[i].precio / cotizacion;
36   - }
37   - $scope.searchLoading = false;
38   - $scope.primerBusqueda = true;
39   - $scope.productos = res.data;
40   - $scope.search();
41   - primera();
42   - }
43   - );
  32 + .then(llenarDatos);
44 33 } else if(idLista === -1) {
45   - focaBusquedaProductosService.getProductos().then(
46   - function(res) {
47   - for(var i = 0; i < res.data.length; i++) {
48   - res.data[i].precio = res.data[i].precio / cotizacion;
49   - }
50   - $scope.searchLoading = false;
51   - $scope.primerBusqueda = true;
52   - $scope.productos = res.data;
53   - $scope.search();
54   - primera();
55   - }
56   - );
  34 + focaBusquedaProductosService.getProductos()
  35 + .then(llenarDatos);
57 36 }
58 37 }
59 38 };
60   -
  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 + }
61 49 $scope.search = function() {
62 50 if($scope.productos.length > 0) {
63 51 $scope.filteredProductos = $filter('filter')(