Commit e1a9b4e09f5dc2efc7eb7ffd6c423b1f8b95fde9

Authored by Eric Fernandez
Exists in master and in 1 other branch develop

Merge branch 'master' into 'develop'

Master(mpuebla)

See merge request !9
src/js/controller.js
... ... @@ -31,15 +31,14 @@ angular.module('focaBusquedaProductos')
31 31 $scope.busquedaPress = function (key) {
32 32 if (key === 13) {
33 33 $scope.searchLoading = true;
34   - if (parametroProducto.idLista > 0) {
35   - focaBusquedaProductosService
36   - .getProductosByIdLista(parametroProducto.idLista, $scope.filters)
37   - .then(function (data) {
38   - llenarDatos(data);
39   - focaBusquedaProductosService.getProductos()
40   - .then(fillAllProductos);
41   - });
42   - }
  34 + focaBusquedaProductosService
  35 + .getProductosByIdLista(parseInt(parametroProducto.idLista), $scope.filters)
  36 + .then(function (data) {
  37 + llenarDatos(data);
  38 + focaBusquedaProductosService.getProductos()
  39 + .then(fillAllProductos);
  40 + })
  41 + .catch(function (e) { console.log(e) });
43 42 }
44 43 };
45 44 function llenarDatos(res) {
... ... @@ -54,7 +53,7 @@ angular.module('focaBusquedaProductos')
54 53 };
55 54 function fillAllProductos(res) {
56 55 for (var i = 0; i < res.data.length; i++) {
57   - var producto = $scope.listaProductos.filter(function(producto) {
  56 + var producto = $scope.listaProductos.filter(function (producto) {
58 57 return producto.id == res.data[i].id;
59 58 })[0];
60 59  
... ... @@ -74,7 +73,7 @@ angular.module(&#39;focaBusquedaProductos&#39;)
74 73 primera();
75 74 };
76 75 $scope.search = function (pressed) {
77   - if ($scope.listaProductos.length > 0) {
  76 + if ($scope.listaProductos.length > 0 || $scope.todosProductos.length > 0) {
78 77 $scope.filteredProductos = $filter('filter')(
79 78 ($scope.useAllProducts ? $scope.todosProductos : $scope.listaProductos),
80 79 { $: $scope.filters }