Commit a8a760b735ed9ab6f9f03d880a57b5d9afaf2f79

Authored by Marcelo Puebla
Exists in develop

Merge branch 'develop' into 'develop'

Develop

See merge request !125
src/app/interfaces/ISinonimo.ts
1 import { IArticulo } from './IArticulo'; 1 import { IArticulo } from './IArticulo';
2 2
3 export interface ISinonimo { 3 export interface ISinonimo {
4 ID_SIN: number; 4 ID_SIN: number;
5 descripcion: string; 5 descripcion: string;
6 productos: IArticulo[]; 6 productos: IArticulo[];
7 productoPadre?: number; 7 productoPadre?: number;
8 cantidad?: number; 8 cantidad?: number;
9 cantidadRestante?: number;
9 selected?: boolean; 10 selected?: boolean;
10 } 11 }
11 12
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
1 import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit } from '@angular/core'; 1 import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit } from '@angular/core';
2 import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; 2 import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
3 import { ArticuloService } from 'src/app/services/articulo/articulo.service'; 3 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
4 import { IArticulo } from 'src/app/interfaces/IArticulo'; 4 import { IArticulo } from 'src/app/interfaces/IArticulo';
5 import { APP_SETTINGS } from 'src/etc/AppSettings'; 5 import { APP_SETTINGS } from 'src/etc/AppSettings';
6 import { ICategoria } from 'src/app/interfaces/ICategoria'; 6 import { ICategoria } from 'src/app/interfaces/ICategoria';
7 import { ISinonimo } from 'src/app/interfaces/ISinonimo'; 7 import { ISinonimo } from 'src/app/interfaces/ISinonimo';
8 import { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; 8 import { PromocionComponent } from 'src/app/shared/promocion/promocion.component';
9 import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; 9 import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service';
10 import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; 10 import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service';
11 import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component'; 11 import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component';
12 import { FiltroCategoriasComponent } from './filtro-categorias/filtro-categorias.component'; 12 import { FiltroCategoriasComponent } from './filtro-categorias/filtro-categorias.component';
13 import * as _ from 'lodash'; 13 import * as _ from 'lodash';
14 import { ANIMATIONS } from 'src/app/utils/animations'; 14 import { ANIMATIONS } from 'src/app/utils/animations';
15 15
16 @Component({ 16 @Component({
17 selector: 'app-seleccion-articulos', 17 selector: 'app-seleccion-articulos',
18 templateUrl: './seleccion-articulos.component.html', 18 templateUrl: './seleccion-articulos.component.html',
19 styleUrls: ['./seleccion-articulos.component.scss'], 19 styleUrls: ['./seleccion-articulos.component.scss'],
20 animations: [ANIMATIONS.EnterLeaveY] 20 animations: [ANIMATIONS.EnterLeaveY]
21 }) 21 })
22 export class SeleccionArticulosComponent implements OnInit, AfterViewInit, OnDestroy { 22 export class SeleccionArticulosComponent implements OnInit, AfterViewInit, OnDestroy {
23 loading = true; 23 loading = true;
24 timeoutHandler: any; 24 timeoutHandler: any;
25 urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`; 25 urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`;
26 articulos: IArticulo[] = []; 26 articulos: IArticulo[] = [];
27 auxArticulos: IArticulo[] = []; 27 auxArticulos: IArticulo[] = [];
28 showQuantity = 100; 28 showQuantity = 100;
29 searchTerm = ''; 29 searchTerm = '';
30 ordenandoByVendidos = true; 30 ordenandoByVendidos = true;
31 modalRef: BsModalRef; 31 modalRef: BsModalRef;
32 total = 0; 32 total = 0;
33 @ViewChild(FiltroCategoriasComponent, { static: false }) filtroCategorias: FiltroCategoriasComponent; 33 @ViewChild(FiltroCategoriasComponent, { static: false }) filtroCategorias: FiltroCategoriasComponent;
34 34
35 constructor( 35 constructor(
36 public articuloService: ArticuloService, 36 public articuloService: ArticuloService,
37 private sinonimoService: SinonimoService, 37 private sinonimoService: SinonimoService,
38 private modalService: BsModalService, 38 private modalService: BsModalService,
39 private inactiveScreen: InactiveScreenService, 39 private inactiveScreen: InactiveScreenService,
40 ) { } 40 ) { }
41 41
42 ngOnInit() { } 42 ngOnInit() { }
43 43
44 ngAfterViewInit(): void { 44 ngAfterViewInit(): void {
45 this.filtroCategorias.getCategorias(); 45 this.filtroCategorias.getCategorias();
46 this.mediaPantalla(); 46 this.mediaPantalla();
47 } 47 }
48 48
49 ngOnDestroy() { 49 ngOnDestroy() {
50 for (let i = 1; i <= this.modalService.getModalsCount(); i++) { 50 for (let i = 1; i <= this.modalService.getModalsCount(); i++) {
51 this.modalService.hide(i); 51 this.modalService.hide(i);
52 } 52 }
53 } 53 }
54 54
55 getProductos() { 55 getProductos() {
56 this.articuloService.getAll() 56 this.articuloService.getAll()
57 .subscribe((result: IArticulo[]) => { 57 .subscribe((result: IArticulo[]) => {
58 this.articuloService.setArticulosSinImagen(result); 58 this.articuloService.setArticulosSinImagen(result);
59 if (this.filtroCategorias.queMostrar === 'ordenar') { 59 if (this.filtroCategorias.queMostrar === 'ordenar') {
60 this.filtroCategorias.categorias.forEach((categoria: ICategoria) => { 60 this.filtroCategorias.categorias.forEach((categoria: ICategoria) => {
61 const tempArticulos = result.filter((articulo: IArticulo) => { 61 const tempArticulos = result.filter((articulo: IArticulo) => {
62 return articulo.categoria_selfservice === categoria.id; 62 return articulo.categoria_selfservice === categoria.id;
63 }); 63 });
64 result = tempArticulos; 64 result = tempArticulos;
65 }); 65 });
66 } 66 }
67 localStorage.setItem('articulos', JSON.stringify(result)); 67 localStorage.setItem('articulos', JSON.stringify(result));
68 this.setProductos(); 68 this.setProductos();
69 }, (error) => { 69 }, (error) => {
70 console.error(error); 70 console.error(error);
71 }); 71 });
72 } 72 }
73 73
74 setProductos() { 74 setProductos() {
75 this.articulos = JSON.parse(localStorage.getItem('articulos')); 75 this.articulos = JSON.parse(localStorage.getItem('articulos'));
76 this.filterItems(); 76 this.filterItems();
77 this.loading = false; 77 this.loading = false;
78 } 78 }
79 79
80 filterItems() { 80 filterItems() {
81 if (this.filtroCategorias.categoriaActive === 0) { 81 if (this.filtroCategorias.categoriaActive === 0) {
82 this.auxArticulos = this.articulos; 82 this.auxArticulos = this.articulos;
83 return; 83 return;
84 } 84 }
85 this.auxArticulos = this.articulos.filter(x => { 85 this.auxArticulos = this.articulos.filter(x => {
86 return x.categoria_selfservice === this.filtroCategorias.categoriaActive; 86 return x.categoria_selfservice === this.filtroCategorias.categoriaActive;
87 }); 87 });
88 this.ordenar(); 88 this.ordenar();
89 } 89 }
90 90
91 ordenar() { 91 ordenar() {
92 if (this.ordenandoByVendidos) { 92 if (this.ordenandoByVendidos) {
93 this.auxArticulos.sort((a, b) => { 93 this.auxArticulos.sort((a, b) => {
94 return b.cantidadVendida - a.cantidadVendida; 94 return b.cantidadVendida - a.cantidadVendida;
95 }); 95 });
96 } 96 }
97 } 97 }
98 98
99 selectArticulo(articulo: IArticulo) { 99 selectArticulo(articulo: IArticulo) {
100 this.getByID(articulo.id); 100 this.getByID(articulo.id);
101 } 101 }
102 102
103 getByID(id: number) { 103 getByID(id: number) {
104 this.articuloService.getById(id) 104 this.articuloService.getById(id)
105 .subscribe((res: IArticulo) => { 105 .subscribe((res: IArticulo) => {
106 if (res.FPP) { 106 if (res.FPP) {
107 this.openModalPromos(res); 107 this.openModalPromos(res);
108 } else { 108 } else {
109 this.getSinonimos(res); 109 this.getSinonimos(res);
110 } 110 }
111 }, err => console.error(err)); 111 }, err => console.error(err));
112 } 112 }
113 113
114 getSinonimos(articulo: IArticulo) { 114 getSinonimos(articulo: IArticulo) {
115 this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) 115 this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt)
116 .subscribe((res: any[]) => { 116 .subscribe((res: any[]) => {
117 if (res.length) { 117 if (res.length) {
118 const sinonimos = []; 118 const sinonimos = [];
119 const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); 119 const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN');
120 Object.keys(gruposArticulos).forEach(key => { 120 Object.keys(gruposArticulos).forEach((key, i) => {
121 sinonimos.push({ productos: gruposArticulos[key] }); 121 sinonimos.push({ productos: gruposArticulos[key] });
122 sinonimos[i].cantidad = articulo.productos[i].cantidad;
123 sinonimos[i].cantidadRestante = articulo.productos[i].cantidad;
122 }); 124 });
123 res = sinonimos; 125 res = sinonimos;
124 this.openModalSinonimos(res, articulo); 126 this.openModalSinonimos(res, articulo);
125 } else { 127 } else {
126 this.articuloService.setArticulo(articulo); 128 this.articuloService.setArticulo(articulo);
127 } 129 }
128 }); 130 });
129 } 131 }
130 132
131 openModalPromos(articulo: IArticulo) { 133 openModalPromos(articulo: IArticulo) {
132 if (this.modalRef) return; 134 if (this.modalRef) return;
133 this.articuloService.setArticulosSinImagen([articulo]); 135 this.articuloService.setArticulosSinImagen([articulo]);
134 this.modalRef = this.modalService.show(PromocionComponent, { 136 this.modalRef = this.modalService.show(PromocionComponent, {
135 initialState: { articulosPromo: [articulo] }, 137 initialState: { articulosPromo: [articulo] },
136 class: 'modal-dialog-centered', 138 class: 'modal-dialog-centered',
137 ignoreBackdropClick: true, 139 ignoreBackdropClick: true,
138 }); 140 });
139 this.modalRef.content.onClose 141 this.modalRef.content.onClose
140 .subscribe(() => this.modalRef = null); 142 .subscribe(() => this.modalRef = null);
141 this.mediaPantalla(); 143 this.mediaPantalla();
142 } 144 }
143 145
144 openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { 146 openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) {
145 if (this.modalRef) return; 147 if (this.modalRef) return;
146 this.modalRef = this.modalService.show(SinonimoComponent, { 148 this.modalRef = this.modalService.show(SinonimoComponent, {
147 initialState: { 149 initialState: {
148 sinonimos: sinonimosData, 150 sinonimos: sinonimosData,
149 articulo 151 articulo
150 }, 152 },
151 class: 'modal-dialog-centered', 153 class: 'modal-dialog-centered',
152 ignoreBackdropClick: true, 154 ignoreBackdropClick: true,
153 }); 155 });
154 156
155 this.modalRef.content.onClose 157 this.modalRef.content.onClose
156 .subscribe((res: any) => { 158 .subscribe((res: any) => {
157 this.modalRef = null; 159 this.modalRef = null;
158 if (!res) return; 160 if (!res) return;
159 for (const a of articulo.productos) { 161 for (const a of articulo.productos) {
160 for (const aRes of res.articulos) { 162 for (const aRes of res.articulos) {
161 if (a.idSinonimo === aRes.ID_SIN) { 163 if (a.idSinonimo === aRes.ID_SIN) {
162 this.articuloService.changeArticulo(a, aRes); 164 this.articuloService.changeArticulo(a, aRes);
163 } 165 }
164 } 166 }
165 } 167 }
166 this.articuloService.setArticulo(articulo); 168 this.articuloService.setArticulo(articulo);
167 }); 169 });
168 this.mediaPantalla(); 170 this.mediaPantalla();
169 } 171 }
170 172
171 deleteArticulo(index: number) { 173 deleteArticulo(index: number) {
172 this.articuloService.deleteArticulo(index); 174 this.articuloService.deleteArticulo(index);
173 } 175 }
174 176
175 increaseShow() { 177 increaseShow() {
176 this.showQuantity += 100; 178 this.showQuantity += 100;
177 } 179 }
178 180
179 @HostListener('scroll', ['$event']) 181 @HostListener('scroll', ['$event'])
180 scrollEvent(event: Event) { 182 scrollEvent(event: Event) {
181 clearTimeout(this.inactiveScreen.timerReposo); 183 clearTimeout(this.inactiveScreen.timerReposo);
182 this.inactiveScreen.startTimeOutInactividad(); 184 this.inactiveScreen.startTimeOutInactividad();
183 } 185 }
184 186
185 mouseup() { 187 mouseup() {
186 if (!this.timeoutHandler) return; 188 if (!this.timeoutHandler) return;
187 clearInterval(this.timeoutHandler); 189 clearInterval(this.timeoutHandler);
188 } 190 }
189 191
190 scrollY(el: HTMLElement, value) { 192 scrollY(el: HTMLElement, value) {
191 el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); 193 el.scroll({ behavior: 'smooth', top: value + el.scrollTop });
192 this.timeoutHandler = setInterval(() => { 194 this.timeoutHandler = setInterval(() => {
193 el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); 195 el.scroll({ behavior: 'smooth', top: value + el.scrollTop });
194 }, 500); 196 }, 500);
195 } 197 }
196 198
197 scrollX(el: HTMLElement, value) { 199 scrollX(el: HTMLElement, value) {
198 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); 200 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft });
199 this.timeoutHandler = setInterval(() => { 201 this.timeoutHandler = setInterval(() => {
200 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); 202 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft });
201 }, 500); 203 }, 500);
202 } 204 }
203 205
204 mediaPantalla() { 206 mediaPantalla() {
205 if ($('body').hasClass('media-pantalla')) { 207 if ($('body').hasClass('media-pantalla')) {
206 $(`.cat-content,#cat-content,#content,.cat-btn,#boxCarrito, 208 $(`.cat-content,#cat-content,#content,.cat-btn,#boxCarrito,
207 .cat-box,.img-categoria, .modal-content`) 209 .cat-box,.img-categoria, .modal-content`)
208 .addClass('media-pantalla') 210 .addClass('media-pantalla')
209 .addBack('media-pantalla'); 211 .addBack('media-pantalla');
210 } 212 }
211 } 213 }
212 } 214 }
213 215
src/app/shared/sinonimo/sinonimo.component.html
1 <div class="bg-primary rounded text-white"> 1 <div class="bg-primary rounded text-white">
2 <div class="modal-header"> 2 <div class="modal-header">
3 <img 3 <img
4 draggable="false" 4 draggable="false"
5 ondragstart="return false;" 5 ondragstart="return false;"
6 (contextmenu)="false" 6 (contextmenu)="false"
7 (click)="close()" 7 (click)="close()"
8 class="btn-effect icon-30 mt-2 mr-2 position-absolute right-0 top-0 z-index" 8 class="btn-effect icon-30 mt-2 mr-2 position-absolute right-0 top-0 z-index"
9 src="assets/img/icono-cancelar-blanco.svg"> 9 src="assets/img/icono-cancelar-blanco.svg">
10 <p class="col-7 h4 px-0 align-self-center">{{ articulo.MKT_DESC ? articulo.MKT_DESC.toUpperCase() : articulo.DetArt.toUpperCase() }}</p> 10 <p class="col-12 h4 px-0 align-self-center">{{ articulo.MKT_DESC ? articulo.MKT_DESC.toUpperCase() : articulo.DetArt.toUpperCase() }}</p>
11 <div class="col-5 pt-4 pr-0 text-right"> 11 <!-- <div class="col-5 pt-4 pr-0 text-right">
12 <p *ngFor="let s of sinonimos; let i = index"> 12 <p *ngFor="let s of sinonimos; let i = index">
13 <span 13 <span
14 class="btn-effect" 14 class="btn-effect"
15 (click)="scrollTo(i)"> 15 (click)="scrollTo(i)">
16 Ir a opciรณn {{i+1}} 16 Ir a opciรณn {{i+1}}
17 <i class="far fa-hand-point-left"></i> 17 <i class="far fa-hand-point-left"></i>
18 </span> 18 </span>
19 </p> 19 </p>
20 </div> 20 </div> -->
21 </div> 21 </div>
22 22
23 <div class="modal-body lista-sinonimos scroll-y-visible my-2 mr-2"> 23 <div class="modal-body lista-sinonimos scroll-y-visible my-2 mr-2">
24 <div *ngFor="let s of sinonimos; let i = index"> 24 <div class="row mx-0 mb-2" *ngFor="let articulo of sinonimos[currentIndex].productos">
25 <div [id]="i"></div> 25 <div class="col-7 p-0 my-auto h6 text-right">
26 <hr [hidden]="i === 0" class="bg-white"> 26 <p class="m-0 font-weight-normal">
27 <div *ngFor="let articulo of s.productos"> 27 {{articulo.MKT_DESC ? articulo.MKT_DESC.toUpperCase() : articulo.DetArt.toUpperCase()}}
28 <div class="custom-control custom-checkbox"> 28 </p>
29 <input 29 </div>
30 type="checkbox" 30 <div class="col-5 pr-0">
31 class="custom-control-input" 31 <div class="row mx-0 justify-content-between border border-white badge-pill">
32 [(ngModel)]="articulo.seleccionado" 32 <!-- BOTON MENOS -->
33 (click)="selectSinonimo(i, articulo)" 33 <div class="col-auto px-0 my-auto">
34 [id]="articulo.id"> 34 <img
35 <label 35 draggable="false"
36 class="custom-control-label" 36 ondragstart="return false;"
37 [for]="articulo.id"> 37 (contextmenu)="false"
38 {{articulo.DET_LAR.toUpperCase()}} 38 class="d-block ml-auto py-2 icon-15 btn-effect"
39 </label> 39 src="assets/img/menos-blanco.svg"
40 (click)="restarCantidadSinonimo(articulo, currentIndex)">
41 </div>
42 <!-- CANTIDAD -->
43 <div class="col px-0 my-auto text-white text-center">
44 <p><small>{{articulo.cantidad}}</small></p>
45 </div>
46 <!-- BOTON MAS -->
47 <div class="col-auto px-0 my-auto">
48 <img
49 draggable="false"
50 ondragstart="return false;"
51 (contextmenu)="false"
52 class="d-block ml-auto py-2 icon-15 btn-effect"
53 src="assets/img/mas-blanco.svg"
54 (click)="sumarCantidadSinonimo(articulo, currentIndex)">
55 </div>
40 </div> 56 </div>
41 </div> 57 </div>
42 </div> 58 </div>
43 </div> 59 </div>
44 60
45 <div class="modal-footer"> 61 <div class="modal-footer">
46 <div 62 <div
63 *ngIf="currentIndex != 0 && sinonimos.length > 1"
64 class="d-inline-block py-1 bg-white badge-pill text-primary btn-effect mr-auto"
65 (click)="currentIndex = currentIndex-1">
66 <img
67 draggable="false"
68 ondragstart="return false;"
69 (contextmenu)="false"
70 class="icon-30 flip"
71 src="assets/img/ir-color.svg">
72 VOLVER
73 </div>
74 <div
75 *ngIf="currentIndex == 0 && currentIndex != sinonimos.length-1"
76 class="d-inline-block py-1 bg-white badge-pill text-primary btn-effect ml-auto"
77 (click)="currentIndex = currentIndex+1">
78 SIGUIENTE
79 <img
80 draggable="false"
81 ondragstart="return false;"
82 (contextmenu)="false"
83 class="icon-30"
84 src="assets/img/ir-color.svg">
85 </div>
86 <div
47 [ngClass]="validate()" 87 [ngClass]="validate()"
48 class="d-inline-block py-1 bg-white badge-pill text-primary" 88 *ngIf="currentIndex == sinonimos.length-1"
89 class="d-inline-block py-1 bg-white badge-pill text-primary ml-auto"
49 (click)="continue()"> 90 (click)="continue()">
50 CONTINUAR 91 CONTINUAR
51 <img 92 <img
52 draggable="false" 93 draggable="false"
53 ondragstart="return false;" 94 ondragstart="return false;"
54 (contextmenu)="false" 95 (contextmenu)="false"
55 class="icon-30" 96 class="icon-30"
56 src="assets/img/ir-color.svg"> 97 src="assets/img/ir-color.svg">
57 </div> 98 </div>
58 </div> 99 </div>
59 </div> 100 </div>
60 101
src/app/shared/sinonimo/sinonimo.component.scss
1 .lista-sinonimos { 1 .lista-sinonimos {
2 min-height: auto; 2 min-height: 35vh;
3 max-height: 35vh; 3 max-height: 35vh;
4 } 4 }
5 5
src/app/shared/sinonimo/sinonimo.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { ISinonimo } from 'src/app/interfaces/ISinonimo'; 2 import { ISinonimo } from 'src/app/interfaces/ISinonimo';
3 import { IArticulo } from 'src/app/interfaces/IArticulo'; 3 import { IArticulo } from 'src/app/interfaces/IArticulo';
4 import { BsModalRef } from 'ngx-bootstrap/modal'; 4 import { BsModalRef } from 'ngx-bootstrap/modal';
5 import { Subject, forkJoin } from 'rxjs'; 5 import { Subject, forkJoin } from 'rxjs';
6 import { ArticuloService } from 'src/app/services/articulo/articulo.service'; 6 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
7 import { element } from 'protractor'; 7 import { element } from 'protractor';
8 8
9 @Component({ 9 @Component({
10 selector: 'app-sinonimo', 10 selector: 'app-sinonimo',
11 templateUrl: './sinonimo.component.html', 11 templateUrl: './sinonimo.component.html',
12 styleUrls: ['./sinonimo.component.scss'] 12 styleUrls: ['./sinonimo.component.scss']
13 }) 13 })
14 export class SinonimoComponent implements OnInit { 14 export class SinonimoComponent implements OnInit {
15 sinonimos: ISinonimo[] = []; 15 sinonimos: ISinonimo[] = [];
16 isValid: boolean; 16 isValid: boolean;
17 onClose: Subject<any>; 17 onClose: Subject<any>;
18 articulosSelected: IArticulo[] = []; 18 articulosSelected: IArticulo[] = [];
19 articulo: IArticulo; 19 articulo: IArticulo;
20 isSinonimoSelected = false; 20 isSinonimoSelected = false;
21 currentIndex = 0;
21 22
22 constructor( 23 constructor(
23 private modalRef: BsModalRef, 24 private modalRef: BsModalRef,
24 private articuloService: ArticuloService, 25 private articuloService: ArticuloService,
25 ) { 26 ) {
26 this.onClose = new Subject(); 27 this.onClose = new Subject();
27 this.articulosSelected.length = this.sinonimos.length; 28 this.articulosSelected.length = this.sinonimos.length;
28 } 29 }
29 30
30 ngOnInit() { } 31 ngOnInit() {
32 for (const s of this.sinonimos) {
33 for (const a of s.productos) {
34 a.cantidad = 0;
35 }
36 }
37 }
31 38
32 selectSinonimo(index: number, articulo: IArticulo) { 39 selectSinonimo(index: number, articulo: IArticulo) {
33 for (const a of this.sinonimos[index].productos) { 40 for (const a of this.sinonimos[index].productos) {
34 a.seleccionado = false; 41 a.seleccionado = false;
35 } 42 }
36 articulo.seleccionado = true; 43 articulo.seleccionado = true;
37 this.articulosSelected[index] = articulo; 44 this.articulosSelected[index] = articulo;
38 } 45 }
39 46
40 validate() { 47 validate() {
41 this.isValid = true; 48 this.isValid = true;
42 for (const s of this.sinonimos) { 49 for (const s of this.sinonimos) {
43 for (const a of s.productos) { 50 for (const a of s.productos) {
44 this.isValid = (!a.seleccionado) ? false : true; 51 this.isValid = (!a.seleccionado) ? false : true;
45 if (this.isValid) break; 52 if (this.isValid) break;
46 } 53 }
47 if (!this.isValid) break; 54 if (!this.isValid) break;
48 } 55 }
49 return !this.isValid ? 'disabled' : 'btn-effect'; 56 return !this.isValid ? 'disabled' : 'btn-effect';
50 } 57 }
51 58
52 continue() { 59 continue() {
53 if (!this.isValid) return; 60 if (!this.isValid) return;
54 if (this.isSinonimoSelected) return; 61 if (this.isSinonimoSelected) return;
55 this.isSinonimoSelected = true; 62 this.isSinonimoSelected = true;
56 const ID_SINS = []; 63 const ID_SINS = [];
57 const observables = []; 64 const observables = [];
58 65
59 for (const articulo of this.articulosSelected) { 66 for (const articulo of this.articulosSelected) {
60 ID_SINS.push(articulo.ID_SIN); 67 ID_SINS.push(articulo.ID_SIN);
61 observables.push(this.articuloService.getById(articulo.id)); 68 observables.push(this.articuloService.getById(articulo.id));
62 } 69 }
63 70
64 forkJoin(observables) 71 forkJoin(observables)
65 .subscribe((res: IArticulo[]) => { 72 .subscribe((res: IArticulo[]) => {
66 res.forEach((articulo, i) => { 73 res.forEach((articulo, i) => {
67 articulo.ID_SIN = ID_SINS[i]; 74 articulo.ID_SIN = ID_SINS[i];
68 }); 75 });
69 this.modalRef.hide(); 76 this.modalRef.hide();
70 this.onClose.next({ 77 this.onClose.next({
71 articulos: res, 78 articulos: res,
72 }); 79 });
73 }, err => console.error(err)); 80 }, err => console.error(err));
74 } 81 }
75 82
83 sumarCantidadSinonimo(articulo: IArticulo, i: number) {
84 if (this.sinonimos[i].cantidadRestante === 0) return;
85 articulo.cantidad++;
86 this.sinonimos[i].cantidadRestante--;
87 }
88
89 restarCantidadSinonimo(articulo: IArticulo, i: number) {
90 if (this.sinonimos[i].cantidadRestante === this.sinonimos[i].cantidad) return;
91 if (articulo.cantidad === 0) return;
92 articulo.cantidad--;
93 this.sinonimos[i].cantidadRestante++;
94 }
95
76 scrollTo(index: number) { 96 scrollTo(index: number) {
77 const el = document.getElementById(index.toString()); 97 const el = document.getElementById(index.toString());
78 el.scrollIntoView({ behavior: 'smooth' }); 98 el.scrollIntoView({ behavior: 'smooth' });
79 } 99 }
80 100
81 close() { 101 close() {
82 this.modalRef.hide(); 102 this.modalRef.hide();
83 this.onClose.next(); 103 this.onClose.next();
84 } 104 }
85 105
86 } 106 }
87 107
1 @import "scss/styles-bootstrap.scss"; 1 @import "scss/styles-bootstrap.scss";
2 @import "scss/typography.scss"; 2 @import "scss/typography.scss";
3 @import "scss/height-width.scss"; 3 @import "scss/height-width.scss";
4 @import "scss/animations.scss"; 4 @import "scss/animations.scss";
5 @import "scss/icons.scss"; 5 @import "scss/icons.scss";
6 @import "scss/scroll.scss"; 6 @import "scss/scroll.scss";
7 @import "node_modules/bootstrap/scss/_variables.scss"; 7 @import "node_modules/bootstrap/scss/_variables.scss";
8 8
9 @font-face { 9 @font-face {
10 font-family: "Gotham"; 10 font-family: "Gotham";
11 font-style: normal; 11 font-style: normal;
12 font-weight: normal; 12 font-weight: normal;
13 src: url("assets/fonts/gotham-medium.woff") format("woff"); 13 src: url("assets/fonts/gotham-medium.woff") format("woff");
14 } 14 }
15 15
16 html, 16 html,
17 body { 17 body {
18 max-height: 100vh; 18 max-height: 100vh;
19 height: 100%; 19 height: 100%;
20 font-family: "Gotham"; 20 font-family: "Gotham";
21 overflow: hidden; 21 overflow: hidden;
22 user-select: none; 22 user-select: none;
23 } 23 }
24 24
25 body.media-pantalla { 25 body.media-pantalla {
26 height: calc(50%) !important; 26 height: calc(50%) !important;
27 position: absolute; 27 position: absolute;
28 bottom: 0; 28 bottom: 0;
29 width: 100%; 29 width: 100%;
30 background-color: #3d3d3d; 30 background-color: #3d3d3d;
31 } 31 }
32 32
33 .btn-effect { 33 .btn-effect {
34 transition: all 0.3s !important; 34 transition: all 0.3s !important;
35 &:hover { 35 &:hover {
36 cursor: pointer !important; 36 cursor: pointer !important;
37 opacity: 0.7 !important; 37 opacity: 0.7 !important;
38 } 38 }
39 &:active { 39 &:active {
40 transform: scale(1.02) !important; 40 transform: scale(1.02) !important;
41 } 41 }
42 } 42 }
43 43
44 .cursor-pointer { 44 .cursor-pointer {
45 cursor: pointer; 45 cursor: pointer;
46 } 46 }
47 47
48 p { 48 p {
49 margin: 0 !important; 49 margin: 0 !important;
50 } 50 }
51 51
52 .img-in-top { 52 .img-in-top {
53 position: absolute; 53 position: absolute;
54 top: -35px; 54 top: -35px;
55 left: 50%; 55 left: 50%;
56 height: 70px; 56 height: 70px;
57 -webkit-transform: translateX(-50%); 57 -webkit-transform: translateX(-50%);
58 transform: translateX(-50%); 58 transform: translateX(-50%);
59 } 59 }
60 60
61 .right-0 { 61 .right-0 {
62 right: 0; 62 right: 0;
63 } 63 }
64 64
65 .top-0 { 65 .top-0 {
66 top: 0; 66 top: 0;
67 } 67 }
68 68
69 .left-0 { 69 .left-0 {
70 left: 0; 70 left: 0;
71 } 71 }
72 72
73 .rotate-45 { 73 .rotate-45 {
74 transform: rotate(45deg); 74 transform: rotate(45deg);
75 } 75 }
76 76
77 .rotate-90 { 77 .rotate-90 {
78 transform: rotate(90deg); 78 transform: rotate(90deg);
79 } 79 }
80 80
81 .rotate-90-neg { 81 .rotate-90-neg {
82 transform: rotate(-90deg); 82 transform: rotate(-90deg);
83 } 83 }
84 84
85 .rotate-180-neg { 85 .rotate-180-neg {
86 transform: rotate(-180deg); 86 transform: rotate(-180deg);
87 } 87 }
88 88
89 .disabled { 89 .disabled {
90 opacity: 0.5; 90 opacity: 0.5;
91 } 91 }
92 92
93 .modal-content.media-pantalla { 93 .modal-content.media-pantalla {
94 margin-top: auto !important; 94 margin-top: auto !important;
95 margin-bottom: 50px !important; 95 margin-bottom: 50px !important;
96 } 96 }
97 97
98 .modal-content { 98 .modal-content {
99 background: transparent !important; 99 background: transparent !important;
100 } 100 }
101 101
102 .z-index { 102 .z-index {
103 z-index: 1000; 103 z-index: 1000;
104 } 104 }
105
106 .flip {
107 -webkit-transform: scaleX(-1);
108 transform: scaleX(-1);
109 }