Commit ca54b5e448add4e2cd14b1dc0979aa230afd4f9b

Authored by Eric Fernandez
1 parent eaba826af9
Exists in master and in 1 other branch validar_pve

ordenar

src/app/components/busqueda-productos/busqueda-productos.component.html
... ... @@ -14,7 +14,7 @@
14 14 <div class="row m-3 disable-user-select">
15 15  
16 16 <!-- FILTROS -->
17   - <div *ngIf="verCategorias" class="col-sm-2 p-1">
  17 + <div *ngIf="queMostrar != 'promociones'" class="col-sm-2 p-1">
18 18 <div class="text-center">
19 19 <p class="font-weight-bold text-muted border-bottom pb-2">Buscar por Categoría</p>
20 20 </div>
src/app/components/busqueda-productos/busqueda-productos.component.ts
... ... @@ -17,7 +17,7 @@ export class BusquedaProductosComponent implements OnInit {
17 17 private searchTerm: string = '';
18 18 private categoriaActive: number = null;
19 19 private showSpinner: boolean = true;
20   - private verCategorias: boolean = true;
  20 + private queMostrar: string = 'todo';
21 21 private apiUrl: string = appSettings.apiUrl;
22 22 private categorias: Categoria[] = [];
23 23 private blurFocus = new EventEmitter();
... ... @@ -28,12 +28,32 @@ export class BusquedaProductosComponent implements OnInit {
28 28  
29 29 ngOnInit() {
30 30  
31   - this.verCategorias = this.productoService.verCategoriasProductos;
  31 + this.queMostrar = this.productoService.mostrar;
32 32  
33 33 this.productoService.getCategorias()
34 34 .subscribe((categorias: Categoria[]) => {
35 35 this.categorias = categorias;
36   - this.categoriaActive = this.verCategorias ? 1 : categorias[0].id;
  36 +
  37 + switch (this.queMostrar) {
  38 + case 'todos':
  39 + this.categoriaActive = 1;
  40 + break;
  41 + case 'promociones':
  42 + this.categoriaActive = 1;
  43 + break;
  44 + case 'ordenar':
  45 +
  46 + this.categorias = this.categorias.filter((categoria: Categoria) => {
  47 + return categoria.ES_PEDIDO;
  48 + });
  49 +
  50 + this.categoriaActive = this.categorias[0].id;
  51 +
  52 + break;
  53 + default:
  54 + break;
  55 + }
  56 +
37 57 });
38 58  
39 59 this.productoService.productoAcargar = undefined;
src/app/components/inicio/inicio.component.html
... ... @@ -13,7 +13,7 @@
13 13  
14 14 <!-- PROMOCIONES -->
15 15 <div
16   - (click)="irBusquedaProductos(false)"
  16 + (click)="irBusquedaProductos('promociones')"
17 17 class="card card-effect bg-white border-0 shadow rounded w-100 mb-auto">
18 18 <div class="card-body text-left px-4 py-3">
19 19 <div class="row">
... ... @@ -45,7 +45,8 @@
45 45 </div>
46 46  
47 47 <!-- ORDENAR -->
48   - <div class="card card-effect bg-white border-0 shadow rounded w-100 mt-4">
  48 + <div (click)="irBusquedaProductos('ordenar')"
  49 + class="card card-effect bg-white border-0 shadow rounded w-100 mt-4">
49 50 <div class="card-body text-left px-4 py-3">
50 51 <div class="row">
51 52 <div class="col-auto">
... ... @@ -184,7 +185,7 @@
184 185 </div>
185 186  
186 187 <!-- BUSCAR PRODUCTOS -->
187   - <div (click)="irBusquedaProductos(true)"
  188 + <div (click)="irBusquedaProductos('todos')"
188 189 class="card card-effect bg-white border-0 shadow rounded w-100 mt-4">
189 190 <div class="card-body text-left px-4 py-3">
190 191 <div class="row">
src/app/components/inicio/inicio.component.ts
... ... @@ -85,9 +85,9 @@ export class InicioComponent implements OnInit {
85 85 });
86 86 }
87 87  
88   - irBusquedaProductos(verPromociones) {
  88 + irBusquedaProductos(value) {
89 89  
90   - this.productoService.verCategoriasProductos = verPromociones;
  90 + this.productoService.mostrar = value;
91 91 this.router.navigate(['busqueda-productos']);
92 92 }
93 93  
src/app/services/producto.service.ts
... ... @@ -12,7 +12,7 @@ export class ProductoService {
12 12 productos: Producto[] = [];
13 13 productoAcargar: Producto;
14 14 promoAcargar: Producto;
15   - verCategoriasProductos: boolean = true;
  15 + mostrar: string;
16 16  
17 17 constructor(private http: HttpClient) { }
18 18  
src/app/wrappers/categoria.ts
... ... @@ -3,5 +3,6 @@ export interface Categoria {
3 3 detalle: string,
4 4 es_promocion: boolean,
5 5 vigencia_desde: Date,
6   - vigencia_hasta: Date
  6 + vigencia_hasta: Date,
  7 + ES_PEDIDO: boolean
7 8 }
8 9 \ No newline at end of file