Commit 569a98e9faab563caa3ab019c0fa2047f5577119
Exists in
master
Merge branch 'master' of git.focasoftware.com:angular/autoservicio
Showing
9 changed files
Show diff stats
src/app/app-routing.module.ts
... | ... | @@ -8,6 +8,7 @@ import { MasterComponent } from './components/master/master.component'; |
8 | 8 | import { CancelarCompraComponent } from './components/cancelar-compra/cancelar-compra.component'; |
9 | 9 | import { MensajeFinalComponent } from './components/mensaje-final/mensaje-final.component'; |
10 | 10 | import { ComandaComponent } from './components/comanda/comanda.component'; |
11 | +import { PedidosSalientesComponent } from './components/pedidos-salientes/pedidos-salientes.component'; | |
11 | 12 | |
12 | 13 | const routes: Routes = [ |
13 | 14 | { path: '', component: HomeComponent }, |
... | ... | @@ -16,6 +17,7 @@ const routes: Routes = [ |
16 | 17 | { path: 'cancelar-compra', component: CancelarCompraComponent }, |
17 | 18 | { path: 'mensaje-final', component: MensajeFinalComponent }, |
18 | 19 | { path: 'comanda', component: ComandaComponent }, |
20 | + { path: 'pedidos-salientes', component: PedidosSalientesComponent }, | |
19 | 21 | { |
20 | 22 | path: '', |
21 | 23 | component: MasterComponent, |
src/app/app.module.ts
... | ... | @@ -30,6 +30,7 @@ import { PopoverSinonimosComponent } from './components/popover-sinonimos/popove |
30 | 30 | import { CancelarCompraComponent } from './components/cancelar-compra/cancelar-compra.component'; |
31 | 31 | import { MensajeFinalComponent } from './components/mensaje-final/mensaje-final.component'; |
32 | 32 | import { ComandaComponent } from './components/comanda/comanda.component'; |
33 | +import { PedidosSalientesComponent } from './components/pedidos-salientes/pedidos-salientes.component'; | |
33 | 34 | //#endregion |
34 | 35 | |
35 | 36 | @NgModule({ |
... | ... | @@ -46,7 +47,8 @@ import { ComandaComponent } from './components/comanda/comanda.component'; |
46 | 47 | PopoverSinonimosComponent, |
47 | 48 | CancelarCompraComponent, |
48 | 49 | MensajeFinalComponent, |
49 | - ComandaComponent | |
50 | + ComandaComponent, | |
51 | + PedidosSalientesComponent | |
50 | 52 | ], |
51 | 53 | imports: [ |
52 | 54 | BrowserModule, |
src/app/components/busqueda-productos/busqueda-productos.component.html
... | ... | @@ -63,7 +63,7 @@ |
63 | 63 | <button |
64 | 64 | class="btn btn-outline-primary badge badge-light px-2 shadow-sm" |
65 | 65 | [ngClass]="{'active': ordenandoByVendidos}" |
66 | - (click)="ordenandoByVendidos = !ordenandoByVendidos; ordenar()" | |
66 | + (click)="ordenandoByVendidos = !ordenandoByVendidos; filterItems()" | |
67 | 67 | >Más vendidos</button> |
68 | 68 | </div> |
69 | 69 | </div> |
src/app/components/busqueda-productos/busqueda-productos.component.ts
... | ... | @@ -46,10 +46,10 @@ export class BusquedaProductosComponent implements OnInit { |
46 | 46 | this.categoriaActive = 1; |
47 | 47 | this.title = 'Promociones'; |
48 | 48 | break; |
49 | - case 'ordenar': | |
49 | + case 'ordenar': | |
50 | 50 | this.categorias = categorias.filter((categoria: Categoria) => { |
51 | 51 | return categoria.ES_PEDIDO; |
52 | - }); | |
52 | + }); | |
53 | 53 | this.categoriaActive = 0; |
54 | 54 | this.title = 'Ordenar'; |
55 | 55 | break; |
... | ... | @@ -82,7 +82,6 @@ export class BusquedaProductosComponent implements OnInit { |
82 | 82 | this.productos = data; |
83 | 83 | } |
84 | 84 | this.filterItems(); |
85 | - this.ordenar(); | |
86 | 85 | }, (error) => { |
87 | 86 | this.showSpinner = false; |
88 | 87 | console.error(error); |
... | ... | @@ -101,6 +100,8 @@ export class BusquedaProductosComponent implements OnInit { |
101 | 100 | } |
102 | 101 | }); |
103 | 102 | |
103 | + this.ordenar(); | |
104 | + | |
104 | 105 | } |
105 | 106 | |
106 | 107 | agregarAlCarrito(producto: Producto) { |
... | ... | @@ -116,8 +117,6 @@ export class BusquedaProductosComponent implements OnInit { |
116 | 117 | this.auxProductos.sort((a, b) => { |
117 | 118 | return b.cantidadVendida - a.cantidadVendida; |
118 | 119 | }); |
119 | - } else { | |
120 | - this.filterItems(); | |
121 | 120 | } |
122 | 121 | |
123 | 122 | } |
src/app/components/pedidos-salientes/pedidos-salientes.component.html
... | ... | @@ -0,0 +1,16 @@ |
1 | +<div class="bg-primary-gradient vh-100"> | |
2 | + <div class="d-flex justify-content-center"> | |
3 | + <div class="row my-5 text-white text-center"> | |
4 | + <h1 class="col-12">Su pedido ya esta listo.</h1> | |
5 | + <h2 class="col-12 mt-3">Nº de Pedido</h2> | |
6 | + | |
7 | + <h1 *ngIf="pedidosRecientes.length" class="col-12 border rounded"> | |
8 | + {{rellenar(pedidosRecientes[0].id, 2)}} | |
9 | + </h1> | |
10 | + | |
11 | + <h2 *ngFor="let pedido of pedidosRecientes; let i = index" [hidden]="i == 0" class="col-4 border rounded mx-0"> | |
12 | + {{rellenar(pedido.id, 2)}} | |
13 | + </h2> | |
14 | + </div> | |
15 | + </div> | |
16 | +</div> |
src/app/components/pedidos-salientes/pedidos-salientes.component.scss
src/app/components/pedidos-salientes/pedidos-salientes.component.spec.ts
... | ... | @@ -0,0 +1,25 @@ |
1 | +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
2 | + | |
3 | +import { PedidosSalientesComponent } from './pedidos-salientes.component'; | |
4 | + | |
5 | +describe('PedidosSalientesComponent', () => { | |
6 | + let component: PedidosSalientesComponent; | |
7 | + let fixture: ComponentFixture<PedidosSalientesComponent>; | |
8 | + | |
9 | + beforeEach(async(() => { | |
10 | + TestBed.configureTestingModule({ | |
11 | + declarations: [ PedidosSalientesComponent ] | |
12 | + }) | |
13 | + .compileComponents(); | |
14 | + })); | |
15 | + | |
16 | + beforeEach(() => { | |
17 | + fixture = TestBed.createComponent(PedidosSalientesComponent); | |
18 | + component = fixture.componentInstance; | |
19 | + fixture.detectChanges(); | |
20 | + }); | |
21 | + | |
22 | + it('should create', () => { | |
23 | + expect(component).toBeTruthy(); | |
24 | + }); | |
25 | +}); |
src/app/components/pedidos-salientes/pedidos-salientes.component.ts
... | ... | @@ -0,0 +1,46 @@ |
1 | +import { Component, OnInit } from '@angular/core'; | |
2 | +import { ComandaService } from 'src/app/services/comanda.service'; | |
3 | + | |
4 | +@Component({ | |
5 | + selector: 'app-pedidos-salientes', | |
6 | + templateUrl: './pedidos-salientes.component.html', | |
7 | + styleUrls: ['./pedidos-salientes.component.scss'] | |
8 | +}) | |
9 | +export class PedidosSalientesComponent implements OnInit { | |
10 | + | |
11 | + private pedidosRecientes = []; | |
12 | + private ciclo; | |
13 | + | |
14 | + constructor(private comandaService: ComandaService) { } | |
15 | + | |
16 | + ngOnInit() { | |
17 | + this.buscar(); | |
18 | + | |
19 | + this.ciclo = setTimeout(() => { | |
20 | + this.buscar(); | |
21 | + }, 5000) | |
22 | + } | |
23 | + | |
24 | + ngOnDestroy() { | |
25 | + | |
26 | + clearTimeout(this.ciclo); | |
27 | + } | |
28 | + | |
29 | + buscar() { | |
30 | + | |
31 | + this.comandaService | |
32 | + .getPendientesEntrega() | |
33 | + .subscribe((pedidos: []) => { | |
34 | + | |
35 | + this.pedidosRecientes = pedidos; | |
36 | + }, console.log); | |
37 | + } | |
38 | + | |
39 | + rellenar(relleno, longitud) { | |
40 | + relleno = '' + relleno; | |
41 | + while (relleno.length < longitud) { | |
42 | + relleno = '0' + relleno; | |
43 | + } | |
44 | + return relleno; | |
45 | + } | |
46 | +} |
src/app/services/comanda.service.ts