Commit c6054a09bfb5bb217af3463f3866344a2fb12f47

Authored by Luis Suarez
Exists in develop

resolviendo merges

Showing 30 changed files   Show diff stats
src/app/interfaces/IArticulo.ts
... ... @@ -14,6 +14,7 @@ export interface IArticulo {
14 14 FPP?: boolean;
15 15 id: number;
16 16 idSinonimo?: number;
  17 + ID_SIN?: number;
17 18 imagenes?: any[];
18 19 ImpInt: number;
19 20 ImpInt2: number;
... ... @@ -25,7 +26,10 @@ export interface IArticulo {
25 26 seleccionado?: boolean;
26 27 tieneSinonimo?: boolean;
27 28 tipo_articulo?: number;
28   - comentario?: string;
  29 + CODA?: number;
  30 + CODP?: number;
  31 + SECA?: number;
  32 + SECP?: number;
29 33 }
30 34  
31 35 export interface ICodigoBarra {
src/app/interfaces/ISinonimo.ts
... ... @@ -0,0 +1,9 @@
  1 +import { IArticulo } from './IArticulo';
  2 +
  3 +export interface ISinonimo {
  4 + ID_SIN: number;
  5 + descripcion: string;
  6 + productos: IArticulo[];
  7 + productoPadre?: number;
  8 + cantidad?: number;
  9 +}
src/app/modules/carrito/carrito.component.ts
... ... @@ -42,7 +42,7 @@ export class CarritoComponent implements OnInit, OnDestroy {
42 42 this.router.navigate(['']);
43 43 return;
44 44 }
45   - this.mediaPantallaP()
  45 + this.mediaPantallaP();
46 46 }
47 47  
48 48 ngOnDestroy() {
... ... @@ -50,8 +50,7 @@ export class CarritoComponent implements OnInit, OnDestroy {
50 50 }
51 51  
52 52 deleteArticulo(index: number) {
53   - this.articuloService.carrito.splice(index, 1);
54   - this.articuloService.calcularTotal();
  53 + this.articuloService.deleteArticulo(index);
55 54 }
56 55  
57 56 substractCant(articulo: IArticulo) {
... ... @@ -76,6 +75,12 @@ export class CarritoComponent implements OnInit, OnDestroy {
76 75 this.inactiveScreen.startTimeOutInactividad();
77 76 }
78 77  
  78 + @HostListener('scroll', ['$event'])
  79 + scrollEvent(event: Event) {
  80 + clearTimeout(this.inactiveScreen.timerReposo);
  81 + this.inactiveScreen.startTimeOutInactividad();
  82 + }
  83 +
79 84 mediaPantallaP() {
80 85 if ($('body').hasClass('media-pantalla')) {
81 86 $('.carrito-content,.carrito-articulo').addClass('media-pantalla');
src/app/modules/forma-pago/forma-pago.component.ts
1   -import { Component, OnInit } from "@angular/core";
2   -import { ArticuloService } from "src/app/services/articulo/articulo.service";
3   -import { Router } from "@angular/router";
  1 +import { Component, OnInit } from '@angular/core';
  2 +import { ArticuloService } from 'src/app/services/articulo/articulo.service';
  3 +import { Router } from '@angular/router';
4 4  
5 5 @Component({
6   - selector: "app-forma-pago",
7   - templateUrl: "./forma-pago.component.html",
8   - styleUrls: ["./forma-pago.component.scss"]
  6 + selector: 'app-forma-pago',
  7 + templateUrl: './forma-pago.component.html',
  8 + styleUrls: ['./forma-pago.component.scss']
9 9 })
10 10 export class FormaPagoComponent implements OnInit {
11 11 constructor(
... ... @@ -15,7 +15,7 @@ export class FormaPagoComponent implements OnInit {
15 15  
16 16 ngOnInit() {
17 17 if (!this.articuloService.carrito.length) {
18   - this.router.navigate([""]);
  18 + this.router.navigate(['']);
19 19 return;
20 20 }
21 21 this.mediaPantalla();
... ... @@ -25,10 +25,10 @@ export class FormaPagoComponent implements OnInit {
25 25 this.articuloService.medioPago = medioPago;
26 26 switch (medioPago) {
27 27 case 4:
28   - this.router.navigate(["pago-tarjeta"]);
  28 + this.router.navigate(['pago-tarjeta']);
29 29 break;
30 30 case 9:
31   - this.router.navigate(["pago-electronico"]);
  31 + this.router.navigate(['pago-electronico']);
32 32 break;
33 33 }
34 34 }
src/app/modules/info-formas-pago/info-formas-pago.component.html
... ... @@ -11,8 +11,9 @@
11 11 </div>
12 12 <div class="h-85">
13 13 <div class="row h-auto mt-6 mx-0 justify-content-center text-center">
14   - <div class="col-7 col-lg-4 p-5 m-5 h-auto align-self-end border
15   - border-secondary rounded reduce-card-1">
  14 + <div
  15 + [routerLink]="['/opcion-pedido']"
  16 + class="col-7 col-xl-4 p-5 m-5 h-auto align-self-end border border-secondary rounded">
16 17 <img
17 18 draggable="false"
18 19 ondragstart="return false;"
... ... @@ -29,9 +30,7 @@
29 30 class="icon-150"
30 31 src="assets/img/icono-mercado-pago.svg">
31 32 </p>
32   - <div
33   - class="d-inline-block py-1 btn-effect bg-secondary badge-pill text-white"
34   - [routerLink]="['/opcion-pedido']">
  33 + <div class="d-inline-block py-1 btn-effect bg-secondary badge-pill text-white">
35 34 CONTINUAR
36 35 <img
37 36 draggable="false"
... ... @@ -50,7 +49,7 @@
50 49 class="img-in-top px-4 bg-white"
51 50 src="assets/img/icono-efectivo.svg">
52 51 <p class="h6 m-0">SI PREFERIS PAGAR EN EFECTIVO</p>
53   - <p class="h2 m-0 text-primary">te esperamos en la caja</p>
  52 + <p class="h2 m-0 text-primary">haga su pedido<br>en caja</p>
54 53 </div>
55 54 </div>
56 55 </div>
src/app/modules/info-formas-pago/info-formas-pago.component.ts
... ... @@ -7,13 +7,13 @@ import { Component, OnInit } from &#39;@angular/core&#39;;
7 7 })
8 8 export class InfoFormasPagoComponent implements OnInit {
9 9 mediaPantalla = false;
10   -
11   - constructor() {}
  10 +
  11 + constructor() { }
12 12  
13 13 ngOnInit() {
14 14 this.reducirPantalla();
15 15 }
16   -
  16 +
17 17 reducirPantalla() {
18 18 if ($('body').hasClass('media-pantalla')) {
19 19 $('.reduce-card-1,.reduce-card-2').addClass('media-pantalla');
src/app/modules/opcion-pedido/opcion-pedido.component.html
... ... @@ -19,7 +19,7 @@
19 19 <div class="col-auto px-0 h-auto align-self-start reduce-card-1">
20 20 <div
21 21 class="btn-effect col-auto align-self-center px-0 bg-white"
22   - (click)="goTo('/seleccion-articulos'); seleccionPedido('comer aca')">
  22 + (click)="goTo('/seleccion-articulos'); seleccionPedido('false')">
23 23 <div class="row mx-0 bg-primary badge-pill">
24 24 <div class="col-auto p-0">
25 25 <img
... ... @@ -46,7 +46,7 @@
46 46 <div class="col-auto px-0 h-auto align-self-start reduce-card-2">
47 47 <div
48 48 class="btn-effect col-auto align-self-center px-0 bg-white"
49   - (click)="goTo('/seleccion-articulos'); seleccionPedido('para llevar')">
  49 + (click)="goTo('/seleccion-articulos'); seleccionPedido('true')">
50 50 <div class="row mx-0 bg-primary badge-pill">
51 51 <div class="col-auto p-0">
52 52 <img
src/app/modules/opcion-pedido/opcion-pedido.component.ts
... ... @@ -21,7 +21,8 @@ export class OpcionPedidoComponent implements OnInit {
21 21 }
22 22  
23 23 seleccionPedido(lugar) {
24   - localStorage.setItem('pedidoPara', lugar);
  24 + lugar === 'true' ? lugar = true : false;
  25 + localStorage.setItem('pedidoParaLlevar', lugar);
25 26 }
26 27  
27 28 reducirPantalla() {
src/app/modules/pago-electronico/pago-electronico.component.scss
1   -.mt-6 {
2   - margin-top: 4.5rem;
3   -}
4   -
5 1 .mt-7 {
6 2 margin-top: 6rem;
7   -}
8 3 \ No newline at end of file
  4 +}
src/app/modules/seleccion-articulos/seleccion-articulos.component.html
... ... @@ -38,7 +38,7 @@
38 38 (scroll)="scrollEvent($event)">
39 39 <div
40 40 class="row mx-4 mb-2 h-25 h-md-32 h-lg-45 justify-content-center tab cat-content"
41   - [ngClass]="{ 'active': allActive, 'border-bottom-effect': !allActive,
  41 + [ngClass]="{ 'active rounded-sm shadow': allActive, 'border-bottom-effect': !allActive,
42 42 'media-pantalla' : boxCarrito.classList.contains('media-pantalla') }"
43 43 (click)="selectCategoria(-1, 0)">
44 44 <img
... ... @@ -51,7 +51,7 @@
51 51 </div>
52 52 <div
53 53 class="row mx-4 mb-2 h-25 h-md-32 h-lg-45 justify-content-center tab cat-content"
54   - [ngClass]="{ 'active': categoria.selected, 'border-bottom-effect': !categoria.selected,
  54 + [ngClass]="{ 'active rounded-sm shadow': categoria.selected, 'border-bottom-effect': !categoria.selected,
55 55 'media-pantalla' : boxCarrito.classList.contains('media-pantalla') }"
56 56 (click)="selectCategoria(i, categoria.id)"
57 57 *ngFor="let categoria of categorias; let i = index;">
... ... @@ -63,7 +63,7 @@
63 63 [ngClass]="{'media-pantalla' : boxCarrito.classList.contains('media-pantalla')}"
64 64 src="{{urlImagenes}}{{categoria.path_imagen}}"
65 65 onerror="this.src='assets/img/image-not-found.jpg'">
66   - <small class="col-12 px-0 my-1 h-100 h-md-25 align-self-end text-center text-truncate">{{categoria.detalle}}</small>
  66 + <small class="col-12 px-1 my-1 h-100 h-md-25 align-self-end text-center text-truncate">{{categoria.detalle}}</small>
67 67 </div>
68 68 </div>
69 69 <div class="col-auto btn-effect h-5 cat-btn">
... ... @@ -90,7 +90,7 @@
90 90 *ngFor="let articulo of auxArticulos | slice:0:showQuantity;">
91 91 <div
92 92 class="swing-in-top-fwd btn-effect card h-auto"
93   - (click)="elegirArticulo(articulo)">
  93 + (click)="selectArticulo(articulo)">
94 94 <img
95 95 draggable="false"
96 96 ondragstart="return false;"
... ... @@ -102,10 +102,7 @@
102 102 <p
103 103 [ngClass]="{'text-primary': articulo.PRO, 'text-secondary': !articulo.PRO}"
104 104 class="col-12 px-1 h6 h-auto text-center min-h-60">
105   - {{articulo.DetArt}}
106   - </p>
107   - <p class="col-12 px-1 h-auto text-center line-height-sm min-h-50">
108   - <small>{{articulo.DET_LAR}}</small>
  105 + {{articulo.DetArt.toUpperCase()}}
109 106 </p>
110 107 <div class="col-12 px-1 align-self-end h-auto">
111 108 <div
src/app/modules/seleccion-articulos/seleccion-articulos.component.scss
... ... @@ -7,6 +7,9 @@ $primary: #aa006b;
7 7 .active {
8 8 background-color: white;
9 9 border-bottom: 3px solid $primary !important;
  10 + border-top: 3px solid $primary !important;
  11 + border-left: 3px solid $primary !important;
  12 + border-right: 3px solid $primary !important;
10 13 }
11 14  
12 15 .border-bottom-effect {
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
1   -import { Component, OnInit, TemplateRef, OnDestroy, HostListener } from '@angular/core';
  1 +import { Component, OnInit, OnDestroy, HostListener } from '@angular/core';
2 2 import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
3 3 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
4 4 import { IArticulo } from 'src/app/interfaces/IArticulo';
5 5 import { APP_SETTINGS } from 'src/etc/AppSettings';
6 6 import { ICategoria } from 'src/app/interfaces/ICategoria';
  7 +import { ISinonimo } from 'src/app/interfaces/ISinonimo';
7 8 import { CategoriaService } from 'src/app/services/categoria/categoria.service';
8   -import { PromocionService } from 'src/app/services/promocion/promocion.service';
9 9 import { PromocionComponent } from 'src/app/shared/promocion/promocion.component';
10 10 import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service';
  11 +import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service';
  12 +import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component';
11 13  
12 14 @Component({
13 15 selector: 'app-seleccion-articulos',
... ... @@ -33,6 +35,7 @@ export class SeleccionArticulosComponent implements OnInit, OnDestroy {
33 35 constructor(
34 36 public articuloService: ArticuloService,
35 37 private categoriaService: CategoriaService,
  38 + private sinonimoService: SinonimoService,
36 39 private modalService: BsModalService,
37 40 private inactiveScreen: InactiveScreenService,
38 41 ) { }
... ... @@ -43,7 +46,9 @@ export class SeleccionArticulosComponent implements OnInit, OnDestroy {
43 46 }
44 47  
45 48 ngOnDestroy() {
46   - if (this.modalRef) this.modalRef.hide();
  49 + for (let i = 1; i <= this.modalService.getModalsCount(); i++) {
  50 + this.modalService.hide(i);
  51 + }
47 52 }
48 53  
49 54 getCategorias() {
... ... @@ -129,35 +134,65 @@ export class SeleccionArticulosComponent implements OnInit, OnDestroy {
129 134 this.filterItems();
130 135 }
131 136  
132   - elegirArticulo(articulo: IArticulo) {
133   - if (!articulo.FPP) {
134   - this.getByID(articulo.id);
135   - } else {
136   - this.openModalPromos(articulo);
137   - }
  137 + selectArticulo(articulo: IArticulo) {
  138 + this.getByID(articulo.id);
138 139 }
139 140  
140 141 getByID(id: number) {
141 142 this.articuloService.getById(id)
142 143 .subscribe((res: IArticulo) => {
143   - res.cantidad = 1;
144   - this.articuloService.setArticulo(res);
  144 + if (res.FPP) {
  145 + this.openModalPromos(res);
  146 + } else {
  147 + this.getSinonimos(res);
  148 + }
145 149 }, err => console.error(err));
146 150 }
147 151  
  152 + getSinonimos(articulo: IArticulo) {
  153 + this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt)
  154 + .subscribe((res: ISinonimo[]) => {
  155 + if (res.length) {
  156 + this.openModalSinonimos(res, articulo);
  157 + } else {
  158 + this.articuloService.setArticulo(articulo);
  159 + }
  160 + });
  161 + }
  162 +
148 163 openModalPromos(articulo: IArticulo) {
149   - this.modalRef = this.modalService.show(PromocionComponent,
150   - {
151   - initialState: {
152   - idArticulo: articulo.id
153   - },
154   - class: 'modal-promo modal-dialog-centered'
  164 + this.modalRef = this.modalService.show(PromocionComponent, {
  165 + initialState: { articulosPromo: [articulo] },
  166 + class: 'modal-promo modal-dialog-centered'
  167 + });
  168 + }
  169 +
  170 + openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) {
  171 + this.modalRef = this.modalService.show(SinonimoComponent, {
  172 + initialState: { sinonimos: sinonimosData },
  173 + class: 'modal-promo modal-dialog-centered'
  174 + });
  175 +
  176 + this.modalRef.content.onClose
  177 + .subscribe((res: any) => {
  178 + for (const a of articulo.productos) {
  179 + if (a.idSinonimo === res.ID_SIN) {
  180 + a.CODA = res.articulo.CodArt;
  181 + a.CodArt = res.articulo.CodArt;
  182 + a.SECA = res.articulo.CodSec;
  183 + a.CodSec = res.articulo.CodSec;
  184 + a.PreVen = res.articulo.PreVen;
  185 + a.id = res.articulo.id;
  186 + a.DET_LAR = res.articulo.DET_LAR;
  187 + a.DetArt = res.articulo.DetArt;
  188 + }
  189 + }
  190 + this.articuloService.setArticulo(articulo);
155 191 });
156 192 }
157 193  
158 194 deleteArticulo(index: number) {
159   - this.articuloService.carrito.splice(index, 1);
160   - this.articuloService.calcularTotal();
  195 + this.articuloService.deleteArticulo(index);
161 196 }
162 197  
163 198 increaseShow() {
src/app/modules/seleccion-articulos/seleccion-articulos.module.ts
... ... @@ -7,6 +7,8 @@ import { ModalModule } from &#39;ngx-bootstrap/modal&#39;;
7 7 import { CarouselModule } from 'ngx-bootstrap/carousel';
8 8 import { PromocionComponent } from 'src/app/shared/promocion/promocion.component';
9 9 import { SharedModule } from '../shared/shared.module';
  10 +import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component';
  11 +import { FormsModule } from '@angular/forms';
10 12 import { ConfirmacionComponent } from 'src/app/shared/confirmacion/confirmacion.component';
11 13  
12 14 @NgModule({
... ... @@ -14,16 +16,18 @@ import { ConfirmacionComponent } from &#39;src/app/shared/confirmacion/confirmacion.
14 16 SeleccionArticulosComponent,
15 17 HeaderPublicidadComponent,
16 18 PromocionComponent,
  19 + SinonimoComponent,
17 20 ConfirmacionComponent
18 21 ],
19 22 imports: [
20 23 CommonModule,
21 24 SeleccionArticulosRoutingModule,
  25 + FormsModule,
22 26 ModalModule.forRoot(),
23 27 CarouselModule.forRoot(),
24 28 SharedModule
25 29 ],
26 30 exports: [HeaderPublicidadComponent],
27   - entryComponents: [PromocionComponent, ConfirmacionComponent]
  31 + entryComponents: [PromocionComponent, ConfirmacionComponent, SinonimoComponent]
28 32 })
29 33 export class SeleccionArticulosModule { }
src/app/modules/shared/shared.module.ts
1 1 import { NgModule, ModuleWithProviders } from '@angular/core';
2 2 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
3 3 import { CategoriaService } from 'src/app/services/categoria/categoria.service';
  4 +import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service';
4 5  
5 6 @NgModule({})
6 7 export class SharedModule {
... ... @@ -9,7 +10,8 @@ export class SharedModule {
9 10 ngModule: SharedModule,
10 11 providers: [
11 12 ArticuloService,
12   - CategoriaService
  13 + CategoriaService,
  14 + SinonimoService
13 15 ]
14 16 };
15 17 }
src/app/modules/splash-screen/splash-screen.component.ts
1   -import { Component, OnInit } from "@angular/core";
  1 +import { Component, OnInit } from '@angular/core';
2 2  
3 3 @Component({
4   - selector: "app-splash-screen",
5   - templateUrl: "./splash-screen.component.html",
6   - styleUrls: ["./splash-screen.component.scss"]
  4 + selector: 'app-splash-screen',
  5 + templateUrl: './splash-screen.component.html',
  6 + styleUrls: ['./splash-screen.component.scss']
7 7 })
8 8 export class SplashScreenComponent implements OnInit {
9 9 timerSplashScreen = 2000;
10 10 showSplashScreen = true;
11   - textWelcome = "BIENVENIDO A SPOT!";
12   - textComoEstas = "ยฟcรณmo estรกs?";
13   - textInvitamos = "TE INVITAMOS A HACER";
14   - textTuPedido = "tu pedido acรก";
  11 + textWelcome = 'BIENVENIDO A SPOT!';
  12 + textComoEstas = 'ยฟcรณmo estรกs?';
  13 + textInvitamos = 'TE INVITAMOS A HACER';
  14 + textTuPedido = 'tu pedido acรก';
15 15  
16 16 constructor() {}
17 17  
src/app/services/articulo/articulo.service.ts
... ... @@ -42,8 +42,9 @@ export class ArticuloService {
42 42 }
43 43  
44 44 setArticulo(articulo: IArticulo) {
  45 + articulo.cantidad = 1;
45 46 for (const articuloCarrito of this.carrito) {
46   - if (articuloCarrito.id === articulo.id) {
  47 + if (articuloCarrito.id === articulo.id && !articulo.productos.length) {
47 48 articuloCarrito.cantidad++;
48 49 this.calcularTotal();
49 50 return;
... ... @@ -54,6 +55,11 @@ export class ArticuloService {
54 55 this.calcularTotal();
55 56 }
56 57  
  58 + deleteArticulo(index: number) {
  59 + this.carrito.splice(index, 1);
  60 + this.calcularTotal();
  61 + }
  62 +
57 63 pay(dataPago: any) {
58 64 return new Observable((observer) => {
59 65 this.clienteService.getById(-1)
... ... @@ -67,6 +73,7 @@ export class ArticuloService {
67 73 puntoVenta: APP_SETTINGS.puntoVenta,
68 74 pedidoAnombreDe: dataPago.pedidoAnombreDe,
69 75 numeroPlanilla: APP_SETTINGS.numeroPlanilla,
  76 + pedidoParaLlevar: localStorage.getItem('pedidoParaLlevar'),
70 77 })
71 78 .subscribe((data) => {
72 79 observer.next(data);
src/app/services/sinonimo/sinonimo.service.ts
... ... @@ -12,7 +12,7 @@ export class SinonimoService {
12 12 private http: HttpClient,
13 13 ) { }
14 14  
15   - getPromocionSinonimos(sector, codigo) {
  15 + getSinonimos(sector, codigo) {
16 16 return this.http.get(`${this.urlDeboSuite}/sinonimos/promo/${sector}/${codigo}`);
17 17 }
18 18 }
src/app/shared/confirmacion/confirmacion.component.ts
1 1 import { Component, OnInit, HostListener } from '@angular/core';
2   -import { ArticuloService } from 'src/app/services/articulo/articulo.service';
3   -import { IArticulo } from 'src/app/interfaces/IArticulo';
4 2 import { BsModalRef } from 'ngx-bootstrap/modal';
5 3 import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service';
6 4 import { Subject } from 'rxjs';
  5 +import { APP_SETTINGS } from 'src/etc/AppSettings';
7 6  
8 7 @Component({
9 8 selector: 'app-confirmacion',
... ... @@ -11,11 +10,14 @@ import { Subject } from &#39;rxjs&#39;;
11 10 styleUrls: ['./confirmacion.component.scss']
12 11 })
13 12 export class ConfirmacionComponent implements OnInit {
14   - idArticulo: number;
15   - imagenArticulo: any;
16   - detLarArticulo: string;
17   - preVenArticulo: any;
  13 + titleMessage: string;
  14 + imagenPath: any;
  15 + footerMessageFirst: string;
  16 + footerMessageSecond: string;
  17 + footerConfirmation: number;
  18 + footerClose: string;
18 19 onClose: Subject<any>;
  20 + urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`;
19 21  
20 22 constructor(
21 23 public modalRef: BsModalRef,
src/app/shared/footer/footer.component.html
1 1 <div class="row w-90 mx-auto h-100 justify-content-between bg-white">
2 2 <div class="col-auto align-self-center px-0 bg-white">
3   - <div class="btn-effect row mx-0 bg-light" (click)="reducirPantalla()">
4   - <div class="col-auto align-self-center text-primary">REDUCIR PANTALLA</div>
  3 + <div class="btn-effect row mx-0 bg-light" (click)="reducirPantalla()">
  4 + <div class="col-auto align-self-center text-primary">ADAPTAR PANTALLA</div>
5 5 <div class="col-auto p-0 bg-primary d-none d-sm-block">
6 6 <img
7 7 draggable="false"
src/app/shared/footer/footer.component.ts
... ... @@ -7,15 +7,31 @@ import { Location } from &#39;@angular/common&#39;;
7 7 styleUrls: ['./footer.component.scss']
8 8 })
9 9 export class FooterComponent implements OnInit {
10   - constructor(private location: Location) {}
  10 + constructor(private location: Location) { }
11 11  
12   - ngOnInit() {}
  12 + ngOnInit() { }
13 13  
14 14 goBack() {
15 15 this.location.back();
16 16 }
17 17  
18 18 reducirPantalla() {
19   - $('body,.reduce-card-1,.reduce-card-2,#content,.cat-content,.cat-btn,.cat-box,#boxCarrito,#headerPublicidad,#headerPad,.img-categoria,.carrito-articulo,.carrito-content,.pago-tarjeta,.modal-promo').toggleClass('media-pantalla');
  19 + $(`
  20 + body,
  21 + .reduce-card-1,
  22 + .reduce-card-2,
  23 + #content,
  24 + .cat-content,
  25 + .cat-btn,
  26 + .cat-box,
  27 + #boxCarrito,
  28 + #headerPublicidad,
  29 + #headerPad,
  30 + .img-categoria,
  31 + .carrito-articulo,
  32 + .carrito-content,
  33 + .pago-tarjeta,
  34 + .modal-promo`)
  35 + .toggleClass('media-pantalla');
20 36 }
21 37 }
src/app/shared/header-publicidad/header-publicidad.component.ts
... ... @@ -68,7 +68,7 @@ export class HeaderPublicidadComponent implements OnInit {
68 68 {
69 69 initialState: {
70 70 titleMessage: articulo.DET_LAR,
71   - imagenPath: articulo.imagenes,
  71 + imagenPath: articulo.imagenes.length ? articulo.imagenes[0].imagen : '',
72 72 footerMessageFirst: `ยฟDESEA AGREGAR ESTE ARTรCULO`,
73 73 footerMessageSecond: `a su carrito?`,
74 74 footerConfirmation: articulo.PreVen,
... ... @@ -77,7 +77,6 @@ export class HeaderPublicidadComponent implements OnInit {
77 77 class: 'modal-promo modal-dialog-centered'
78 78 });
79 79 this.modalRef.content.onClose.subscribe(() => {
80   - articulo.cantidad = 1;
81 80 this.articuloService.setArticulo(articulo);
82 81 });
83 82 }
src/app/shared/promocion/promocion.component.html
... ... @@ -6,7 +6,7 @@
6 6 <div class="col-4 align-self-center">
7 7 <div
8 8 class="row mx-0 justify-content-between bg-white badge-pill"
9   - (click)="elegirPromo(articulosPromo[0])">
  9 + (click)="selectPromo(articulosPromo[0])">
10 10 <div class="col px-0 align-self-center text-primary">
11 11 <p class="font-weight-bold">{{articulosPromo[0].PreVen | currency}}</p>
12 12 </div>
... ... @@ -43,7 +43,7 @@
43 43 (scroll)="scrollEvent($event)">
44 44 <div class="col-12">
45 45 <div *ngFor="let promo of promociones">
46   - <div class="mx-0 mb-2 bg-white badge-pill text-primary" (click)="elegirPromo(promo)">
  46 + <div class="mx-0 mb-2 bg-white badge-pill text-primary" (click)="selectPromo(promo)">
47 47 <div class="d-flex">
48 48 <p class="text-truncate mr-auto my-auto"><small>{{promo.DetArt}}</small></p>
49 49 <p class="font-weight-bold my-auto pr-2">
src/app/shared/promocion/promocion.component.ts
1 1 import { Component, OnInit, HostListener } from '@angular/core';
2   -import { BsModalRef } from 'ngx-bootstrap/modal';
  2 +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
3 3 import { IArticulo } from 'src/app/interfaces/IArticulo';
4 4 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
5 5 import { PromocionService } from 'src/app/services/promocion/promocion.service';
6 6 import { Subject } from 'rxjs';
7 7 import { APP_SETTINGS } from 'src/etc/AppSettings';
8 8 import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service';
  9 +import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service';
  10 +import { ISinonimo } from 'src/app/interfaces/ISinonimo';
  11 +import { SinonimoComponent } from '../sinonimo/sinonimo.component';
9 12  
10 13 @Component({
11 14 selector: 'app-promocion',
... ... @@ -13,34 +16,63 @@ import { InactiveScreenService } from &#39;src/app/services/inactive-screen/inactive
13 16 styleUrls: ['./promocion.component.scss']
14 17 })
15 18 export class PromocionComponent implements OnInit {
16   - idArticulo: number;
17 19 articulosPromo: IArticulo[] = [];
18 20 promociones: IArticulo[] = [];
19 21 onClose: Subject<any>;
20 22 urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`;
21 23  
22 24 constructor(
23   - public modalRef: BsModalRef,
  25 + public modalPromocion: BsModalRef,
  26 + private modalService: BsModalService,
24 27 private articuloService: ArticuloService,
25 28 private promocionService: PromocionService,
  29 + private sinonimoService: SinonimoService,
26 30 private inactiveScreen: InactiveScreenService,
27 31 ) {
28 32 this.onClose = new Subject();
29 33 }
30 34  
31 35 ngOnInit() {
32   - this.articuloService.getById(this.idArticulo)
33   - .subscribe((res: IArticulo) => {
34   - this.articulosPromo[0] = res;
35   - this.getPromociones();
  36 + this.getPromociones();
  37 + }
  38 +
  39 + selectPromo(promo: IArticulo) {
  40 + this.sinonimoService.getSinonimos(promo.CodSec, promo.CodArt)
  41 + .subscribe((res: ISinonimo[]) => {
  42 + if (res.length) {
  43 + this.openModalSinonimos(res, promo);
  44 + } else {
  45 + promo.cantidad = 1;
  46 + this.articuloService.setArticulo(promo);
  47 + this.modalPromocion.hide();
  48 + }
36 49 }, err => console.error(err));
37   - this.mediaPantalla();
  50 + this.mediaPantalla();
38 51 }
39 52  
40   - elegirPromo(promo: IArticulo) {
41   - promo.cantidad = 1;
42   - this.articuloService.setArticulo(promo);
43   - this.modalRef.hide();
  53 + openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) {
  54 + const modalSinonimo = this.modalService.show(SinonimoComponent, {
  55 + initialState: { sinonimos: sinonimosData },
  56 + class: 'modal-promo modal-dialog-centered'
  57 + });
  58 +
  59 + modalSinonimo.content.onClose
  60 + .subscribe((res: any) => {
  61 + for (const a of articulo.productos) {
  62 + if (a.idSinonimo === res.ID_SIN) {
  63 + a.CODA = res.articulo.CodArt;
  64 + a.CodArt = res.articulo.CodArt;
  65 + a.SECA = res.articulo.CodSec;
  66 + a.CodSec = res.articulo.CodSec;
  67 + a.PreVen = res.articulo.PreVen;
  68 + a.id = res.articulo.id;
  69 + a.DET_LAR = res.articulo.DET_LAR;
  70 + a.DetArt = res.articulo.DetArt;
  71 + }
  72 + }
  73 + this.articuloService.setArticulo(articulo);
  74 + this.modalPromocion.hide();
  75 + });
44 76 }
45 77  
46 78 getPromociones() {
... ... @@ -58,8 +90,14 @@ export class PromocionComponent implements OnInit {
58 90 this.inactiveScreen.startTimeOutInactividad();
59 91 }
60 92  
  93 + @HostListener('scroll', ['$event'])
  94 + scrollEvent(event: Event) {
  95 + clearTimeout(this.inactiveScreen.timerReposo);
  96 + this.inactiveScreen.startTimeOutInactividad();
  97 + }
  98 +
61 99 mediaPantalla() {
62   - if($('body').hasClass('media-pantalla')) {
  100 + if ($('body').hasClass('media-pantalla')) {
63 101 $('.modal-content').addClass('media-pantalla');
64 102 }
65 103 }
src/app/shared/sinonimo/sinonimo.component.html
... ... @@ -0,0 +1,42 @@
  1 +<div class="bg-primary rounded text-white">
  2 + <div class="modal-header">
  3 + <p class="h4">Seleccione sinonimos</p>
  4 + </div>
  5 +
  6 + <div class="modal-body">
  7 + <div
  8 + class="lista-sinonimos scroll-y-visible"
  9 + *ngFor="let s of sinonimos">
  10 + <div *ngFor="let articulo of s.productos">
  11 + <div class="custom-control custom-checkbox">
  12 + <input
  13 + type="checkbox"
  14 + class="custom-control-input"
  15 + [(ngModel)]="articulo.seleccionado"
  16 + (click)="selectArticulo(articulo)"
  17 + [id]="articulo.id">
  18 + <label
  19 + class="custom-control-label"
  20 + [for]="articulo.id">
  21 + {{articulo.DET_LAR}}
  22 + </label>
  23 + </div>
  24 + </div>
  25 + </div>
  26 + </div>
  27 +
  28 + <div class="modal-footer">
  29 + <div
  30 + [ngClass]="validate()"
  31 + class="d-inline-block py-1 btn-effect bg-white badge-pill text-primary"
  32 + (click)="continue()">
  33 + CONTINUAR
  34 + <img
  35 + draggable="false"
  36 + ondragstart="return false;"
  37 + (contextmenu)="false"
  38 + class="icon-30"
  39 + src="assets/img/ir-color.svg">
  40 + </div>
  41 + </div>
  42 +</div>
src/app/shared/sinonimo/sinonimo.component.scss
... ... @@ -0,0 +1,4 @@
  1 +.lista-sinonimos {
  2 + min-height: auto;
  3 + max-height: 25vh;
  4 +}
src/app/shared/sinonimo/sinonimo.component.spec.ts
... ... @@ -0,0 +1,25 @@
  1 +import { async, ComponentFixture, TestBed } from '@angular/core/testing';
  2 +
  3 +import { SinonimoComponent } from './sinonimo.component';
  4 +
  5 +describe('SinonimoComponent', () => {
  6 + let component: SinonimoComponent;
  7 + let fixture: ComponentFixture<SinonimoComponent>;
  8 +
  9 + beforeEach(async(() => {
  10 + TestBed.configureTestingModule({
  11 + declarations: [ SinonimoComponent ]
  12 + })
  13 + .compileComponents();
  14 + }));
  15 +
  16 + beforeEach(() => {
  17 + fixture = TestBed.createComponent(SinonimoComponent);
  18 + component = fixture.componentInstance;
  19 + fixture.detectChanges();
  20 + });
  21 +
  22 + it('should create', () => {
  23 + expect(component).toBeTruthy();
  24 + });
  25 +});
src/app/shared/sinonimo/sinonimo.component.ts
... ... @@ -0,0 +1,64 @@
  1 +import { Component, OnInit } from '@angular/core';
  2 +import { ISinonimo } from 'src/app/interfaces/ISinonimo';
  3 +import { IArticulo } from 'src/app/interfaces/IArticulo';
  4 +import { BsModalRef } from 'ngx-bootstrap/modal';
  5 +import { Subject } from 'rxjs';
  6 +import { ArticuloService } from 'src/app/services/articulo/articulo.service';
  7 +
  8 +@Component({
  9 + selector: 'app-sinonimo',
  10 + templateUrl: './sinonimo.component.html',
  11 + styleUrls: ['./sinonimo.component.scss']
  12 +})
  13 +export class SinonimoComponent implements OnInit {
  14 + sinonimos: ISinonimo[] = [];
  15 + isValid: boolean;
  16 + onClose: Subject<any>;
  17 + articuloSelected: IArticulo;
  18 +
  19 + constructor(
  20 + private modalRef: BsModalRef,
  21 + private articuloService: ArticuloService,
  22 + ) {
  23 + this.onClose = new Subject();
  24 + }
  25 +
  26 + ngOnInit() {
  27 + }
  28 +
  29 + selectArticulo(articulo: IArticulo) {
  30 + for (const s of this.sinonimos) {
  31 + for (const a of s.productos) {
  32 + a.seleccionado = false;
  33 + }
  34 + }
  35 + articulo.seleccionado = true;
  36 + this.articuloSelected = articulo;
  37 + }
  38 +
  39 + validate() {
  40 + this.isValid = false;
  41 + for (const s of this.sinonimos) {
  42 + for (const articulo of s.productos) {
  43 + if (articulo.seleccionado) {
  44 + this.isValid = true;
  45 + }
  46 + }
  47 + }
  48 + return !this.isValid ? 'disabled' : '';
  49 + }
  50 +
  51 + continue() {
  52 + if (!this.isValid) return;
  53 + const ID_SIN = this.articuloSelected.ID_SIN;
  54 + this.articuloService.getById(this.articuloSelected.id)
  55 + .subscribe((res: IArticulo) => {
  56 + this.modalRef.hide();
  57 + this.onClose.next({
  58 + articulo: res,
  59 + ID_SIN
  60 + });
  61 + }, err => console.error(err));
  62 + }
  63 +
  64 +}
src/scss/height-width.scss
... ... @@ -32,10 +32,6 @@
32 32 }
33 33 }
34 34  
35   -.min-h-50 {
36   - min-height: 50px;
37   -}
38   -
39 35 .min-h-60 {
40 36 min-height: 60px;
41 37 }
src/scss/styles-bootstrap.scss
... ... @@ -40,9 +40,24 @@ $border-radius-sm: 0.5rem;
40 40 height: 100% !important;
41 41 }
42 42  
  43 +.custom-checkbox .custom-control-input:checked ~ .custom-control-label::before {
  44 + background-color: $primary !important;
  45 +}
  46 +
  47 +.custom-control-input:checked ~ .custom-control-label::before {
  48 + border-color: $primary !important;
  49 + background-color: $primary !important;
  50 +}
  51 +
  52 +.custom-control-input:checked ~ .custom-control-label::before {
  53 + color: #fff;
  54 + border-color: $primary !important;
  55 + background-color: $primary !important;
  56 +}
  57 +
43 58 .modal-promo > div {
44 59 border: none !important;
45   - border-radius: 10rem;
  60 + border-radius: $border-radius;
46 61 margin-left: 10px !important;
47 62 }
48 63  
... ... @@ -74,6 +74,10 @@ p {
74 74 transform: rotate(-180deg);
75 75 }
76 76  
  77 +.disabled {
  78 + opacity: 0.5;
  79 +}
  80 +
77 81 body.media-pantalla {
78 82 height: 50% !important;
79 83 position: absolute;