Commit fb10d862ae76e6984ec2821390051536f5a0bbda

Authored by Marcelo Puebla
1 parent cf8a87c861
Exists in master and in 1 other branch develop

Creado nuevo filtro para mostrar todos los productos.

src/js/controller.js
... ... @@ -13,10 +13,12 @@ angular.module('focaBusquedaProductos')
13 13  
14 14 $scope.simbolo = parametroProducto.simbolo;
15 15 $scope.filters = '';
16   - $scope.productos = [];
  16 + $scope.listaProductos = [];
  17 + $scope.todosProductos = [];
17 18 $scope.primerBusqueda = false;
18 19 $scope.searchLoading = false;
19 20 $scope.soloMostrar = parametroProducto.soloMostrar;
  21 + $scope.useAllProducts = false;
20 22 //#region pagination variables
21 23 $scope.numPerPage = 10;
22 24 $scope.currentPage = 1;
... ... @@ -32,9 +34,8 @@ angular.module('focaBusquedaProductos')
32 34 if (parametroProducto.idLista > 0) {
33 35 focaBusquedaProductosService.getProductosByIdLista(parametroProducto.idLista, $scope.filters)
34 36 .then(llenarDatos);
35   - } else if (parametroProducto.idLista === -1) {
36 37 focaBusquedaProductosService.getProductos()
37   - .then(llenarDatos);
  38 + .then(fillAllProductos);
38 39 }
39 40 }
40 41 };
... ... @@ -44,14 +45,29 @@ angular.module('focaBusquedaProductos')
44 45 }
45 46 $scope.searchLoading = false;
46 47 $scope.primerBusqueda = true;
47   - $scope.productos = res.data;
  48 + $scope.listaProductos = res.data;
  49 + $scope.search(true);
  50 + primera();
  51 + };
  52 + function fillAllProductos(res) {
  53 + for (var i = 0; i < res.data.length; i++) {
  54 + res.data[i].precio = res.data[i].precio / parametroProducto.cotizacion;
  55 + }
  56 + $scope.searchLoading = false;
  57 + $scope.primerBusqueda = true;
  58 + $scope.todosProductos = res.data;
48 59 $scope.search(true);
49 60 primera();
50   - }
  61 + };
  62 + $scope.changeProductsData = function () {
  63 + $scope.useAllProducts = !$scope.useAllProducts;
  64 + $scope.search(false);
  65 + primera();
  66 + };
51 67 $scope.search = function (pressed) {
52   - if ($scope.productos.length > 0) {
  68 + if ($scope.listaProductos.length > 0) {
53 69 $scope.filteredProductos = $filter('filter')(
54   - $scope.productos,
  70 + ($scope.useAllProducts ? $scope.todosProductos : $scope.listaProductos),
55 71 { $: $scope.filters }
56 72 );
57 73  
... ... @@ -80,6 +96,8 @@ angular.module(&#39;focaBusquedaProductos&#39;)
80 96 $scope.currentPage = page;
81 97 };
82 98 $scope.select = function (producto) {
  99 + // if ($scope.useAllProducts)
  100 + // producto.precio = producto.precioBase;
83 101 $uibModalInstance.close(producto);
84 102 };
85 103 $scope.cancel = function () {
src/views/modal-busqueda-productos.html
... ... @@ -32,6 +32,14 @@
32 32 </div>
33 33 </div>
34 34 </div>
  35 + <div class="row">
  36 + <div class="col my-1 d-flex justify-content-end">
  37 + <div class="custom-control custom-checkbox mt-auto">
  38 + <input type="checkbox" class="custom-control-input" id="check" ng-click="changeProductsData()">
  39 + <label class="custom-control-label" for="check">Buscar en todos los artículos disponibles</label>
  40 + </div>
  41 + </div>
  42 + </div>
35 43 </div>
36 44 <div class="modal-body" id="modal-body">
37 45  
... ... @@ -45,7 +53,7 @@
45 53 <th ng-hide="soloMostrar">Código</th>
46 54 <th>Descripción</th>
47 55 <th class="text-right">P. Lista</th>
48   - <th class="text-right">P. Base</th>
  56 + <th class="text-right" ng-show="useAllProducts">P. Base</th>
49 57 <th ng-hide="soloMostrar"></th>
50 58 </tr>
51 59 </thead>
... ... @@ -62,7 +70,7 @@
62 70 ng-hide="soloMostrar"></td>
63 71 <td ng-bind="producto.descripcion"></td>
64 72 <td class="text-right" ng-bind="producto.precio | number: 2"></td>
65   - <td class="text-right" ng-bind="producto.precioBase | number: 2"></td>
  73 + <td class="text-right" ng-bind="producto.precioBase | number: 2" ng-show="useAllProducts"></td>
66 74 <td class="d-md-none text-primary">
67 75 <i class="fa fa-circle-thin" aria-hidden="true"></i>
68 76 </td>