Commit 314c9dbe122fdbf44ede72596dbd5867ee5f5740
Exists in
develop
Merge branch 'master' into 'develop'
Master(benjamin) See merge request !31
Showing
2 changed files
Show diff stats
src/app/shared/header-publicidad/header-publicidad.component.ts
1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 2 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
3 | import { IPublicidad } from 'src/app/interfaces/IPublicidad'; | 3 | import { IPublicidad } from 'src/app/interfaces/IPublicidad'; |
4 | import { PublicidadService } from 'src/app/services/publicidad/publicidad.service'; | 4 | import { PublicidadService } from 'src/app/services/publicidad/publicidad.service'; |
5 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 5 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
6 | import { PromocionComponent } from '../promocion/promocion.component'; | 6 | import { PromocionComponent } from '../promocion/promocion.component'; |
7 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; | 7 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; |
8 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 8 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
9 | 9 | ||
10 | @Component({ | 10 | @Component({ |
11 | selector: 'app-header-publicidad', | 11 | selector: 'app-header-publicidad', |
12 | templateUrl: './header-publicidad.component.html', | 12 | templateUrl: './header-publicidad.component.html', |
13 | styleUrls: ['./header-publicidad.component.scss'] | 13 | styleUrls: ['./header-publicidad.component.scss'] |
14 | }) | 14 | }) |
15 | export class HeaderPublicidadComponent implements OnInit { | 15 | export class HeaderPublicidadComponent implements OnInit { |
16 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 16 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
17 | publicidades: IPublicidad[] = []; | 17 | publicidades: IPublicidad[] = []; |
18 | modalRef: BsModalRef; | 18 | modalRef: BsModalRef; |
19 | 19 | ||
20 | constructor( | 20 | constructor( |
21 | private publicidadService: PublicidadService, | 21 | private publicidadService: PublicidadService, |
22 | private articuloService: ArticuloService, | 22 | private articuloService: ArticuloService, |
23 | private modalService: BsModalService, | 23 | private modalService: BsModalService, |
24 | ) { } | 24 | ) { } |
25 | 25 | ||
26 | ngOnInit() { | 26 | ngOnInit() { |
27 | this.getPublicidades(); | 27 | this.getPublicidades(); |
28 | } | 28 | } |
29 | 29 | ||
30 | getPublicidades() { | 30 | getPublicidades() { |
31 | this.publicidadService.getAll() | 31 | this.publicidadService.getAll() |
32 | .subscribe((res: IPublicidad[]) => { | 32 | .subscribe((res: IPublicidad[]) => { |
33 | this.publicidades = res; | 33 | this.publicidades = res; |
34 | }, err => console.error(err)); | 34 | }, err => console.error(err)); |
35 | } | 35 | } |
36 | 36 | ||
37 | elegirArticulo(publicidad: IPublicidad) { | 37 | elegirArticulo(publicidad: IPublicidad) { |
38 | if (publicidad.id_articulo) this.getByID(publicidad.id_articulo); | 38 | if (publicidad.id_articulo) this.getByID(publicidad.id_articulo); |
39 | } | 39 | } |
40 | 40 | ||
41 | |||
42 | getByID(id: number) { | 41 | getByID(id: number) { |
43 | this.articuloService.getById(id) | 42 | this.articuloService.getById(id) |
44 | .subscribe((res: IArticulo) => { | 43 | .subscribe((res: IArticulo) => { |
45 | if (res.FPP) { | 44 | if (res.FPP) { |
46 | this.openModalPromos(res); | 45 | this.openModalPromos(res); |
47 | return; | 46 | return; |
48 | } | 47 | } |
49 | res.cantidad = 1; | 48 | res.cantidad = 1; |
50 | this.articuloService.setArticulo(res); | 49 | this.articuloService.setArticulo(res); |
51 | }, err => console.error(err)); | 50 | }, err => console.error(err)); |
52 | } | 51 | } |
53 | 52 | ||
54 | openModalPromos(articulo: IArticulo) { | 53 | openModalPromos(articulo: IArticulo) { |
55 | this.modalRef = this.modalService.show(PromocionComponent, | 54 | this.modalRef = this.modalService.show(PromocionComponent, |
56 | { | 55 | { |
57 | initialState: { | 56 | initialState: { |
58 | idArticulo: articulo.id | 57 | idArticulo: articulo.id |
59 | }, | 58 | }, |
60 | class: 'modal-promo modal-dialog-centered' | 59 | class: 'modal-promo modal-dialog-centered' |
61 | }); | 60 | }); |
62 | } | 61 | } |
63 | 62 | ||
64 | } | 63 | } |
65 | 64 |
src/app/shared/promocion/promocion.component.html
1 | <div class="modal-header px-0 bg-primary rounded-top"> | 1 | <div class="modal-header bg-primary rounded-top pt-4 px-2"> |
2 | <div class="row mx-0 w-100 justify-content-between" *ngIf="articulosPromo.length"> | 2 | <div class="row mx-0 w-100 justify-content-between" *ngIf="articulosPromo.length"> |
3 | <div class="col-8"> | 3 | <div class="col-8"> |
4 | <p class="h3 text-white">{{articulosPromo[0].DetArt}}</p> | 4 | <p class="h3 text-white">{{articulosPromo[0].DetArt}}</p> |
5 | </div> | 5 | </div> |
6 | <div class="col-4 align-self-center"> | 6 | <div class="col-4 align-self-center"> |
7 | <div | 7 | <div |
8 | class="row mx-0 justify-content-between bg-white badge-pill" | 8 | class="row mx-0 justify-content-between bg-white badge-pill" |
9 | (click)="elegirPromo(articulosPromo[0])"> | 9 | (click)="elegirPromo(articulosPromo[0])"> |
10 | <div class="col px-0 align-self-center text-primary"> | 10 | <div class="col px-0 align-self-center text-primary"> |
11 | <p class="font-weight-bold">{{articulosPromo[0].PreVen | currency}}</p> | 11 | <p class="font-weight-bold">{{articulosPromo[0].PreVen | currency}}</p> |
12 | </div> | 12 | </div> |
13 | <div class="col-3 px-0"> | 13 | <div class="col-3 px-0"> |
14 | <img | 14 | <img |
15 | draggable="false" | 15 | draggable="false" |
16 | ondragstart="return false;" | 16 | ondragstart="return false;" |
17 | (contextmenu)="false" | 17 | (contextmenu)="false" |
18 | class="d-block ml-auto py-1 icon-30 mr-2 pt-2" | 18 | class="d-block ml-auto py-1 icon-30 mr-2 pt-2" |
19 | src="assets/img/ir-color.svg"> | 19 | src="assets/img/ir-color.svg"> |
20 | </div> | 20 | </div> |
21 | </div> | 21 | </div> |
22 | </div> | 22 | </div> |
23 | </div> | 23 | </div> |
24 | </div> | 24 | </div> |
25 | <div class="modal-body px-0 bg-primary rounded-bottom" *ngIf="articulosPromo.length"> | 25 | <div class="modal-body bg-primary rounded-bottom pb-3 px-2" *ngIf="articulosPromo.length"> |
26 | <div class="row mx-0 w-100"> | 26 | <div class="row mx-0 w-100"> |
27 | <div class="col-9"> | 27 | <div class="col-9"> |
28 | <p class="text-white"><small>¿TE GUSTARÍA LLEVAR ESTE ARTÍCULO</small></p> | 28 | <p class="text-white"><small>¿TE GUSTARÍA LLEVAR ESTE ARTÍCULO</small></p> |
29 | <h1 class="text-white mb-4">en un combo?</h1> | 29 | <h1 class="text-white mb-4">en un combo?</h1> |
30 | </div> | 30 | </div> |
31 | <div class="col-3 rounded-circle"> | 31 | <div class="col-3 rounded-circle"> |
32 | <img | 32 | <img |
33 | draggable="false" | 33 | draggable="false" |
34 | ondragstart="return false;" | 34 | ondragstart="return false;" |
35 | (contextmenu)="false" | 35 | (contextmenu)="false" |
36 | src="{{urlImagenes}}{{articulosPromo[0].imagenes[0].imagen}}" | 36 | src="{{urlImagenes}}{{articulosPromo[0].imagenes[0].imagen}}" |
37 | onerror="this.src='assets/img/image-not-found.jpg'" | 37 | onerror="this.src='assets/img/image-not-found.jpg'" |
38 | class="card-img-top img-fluid rounded-circle"> | 38 | class="card-img-top img-fluid rounded-circle"> |
39 | </div> | 39 | </div> |
40 | </div> | 40 | </div> |
41 | <div class="row mx-0 lista-promociones scroll-y-visible"> | 41 | <div class="row mx-0 lista-promociones scroll-y-visible"> |
42 | <div class="col-12"> | 42 | <div class="col-12"> |
43 | <div *ngFor="let promo of promociones"> | 43 | <div *ngFor="let promo of promociones"> |
44 | <div class="mx-0 mb-2 bg-white badge-pill text-primary" (click)="elegirPromo(promo)"> | 44 | <div class="mx-0 mb-2 bg-white badge-pill text-primary" (click)="elegirPromo(promo)"> |
45 | <div class="d-flex"> | 45 | <div class="d-flex"> |
46 | <p class="text-truncate mr-auto my-auto"><small>{{promo.DetArt}}</small></p> | 46 | <p class="text-truncate mr-auto my-auto"><small>{{promo.DetArt}}</small></p> |
47 | <p class="font-weight-bold my-auto pr-2"> | 47 | <p class="font-weight-bold my-auto pr-2"> |
48 | <span>{{promo.PreVen | currency}}</span> | 48 | <span>{{promo.PreVen | currency}}</span> |
49 | </p> | 49 | </p> |
50 | <img | 50 | <img |
51 | draggable="false" | 51 | draggable="false" |
52 | ondragstart="return false;" | 52 | ondragstart="return false;" |
53 | (contextmenu)="false" | 53 | (contextmenu)="false" |
54 | class="d-block icon-30 py-1" | 54 | class="d-block icon-30 py-1" |
55 | src="assets/img/ir-color.svg"> | 55 | src="assets/img/ir-color.svg"> |
56 | </div> | 56 | </div> |
57 | </div> | 57 | </div> |
58 | </div> | 58 | </div> |
59 | </div> | 59 | </div> |
60 | </div> | 60 | </div> |
61 | </div> | 61 | </div> |
62 | 62 |