Commit 571c49ba30f3b1216867f5a75c102d8b797f17e5
1 parent
6b94f5f761
Exists in
develop
Change - Add
Forma de seleccionar articulos. Ahora ofrece sinonimos
Showing
10 changed files
with
148 additions
and
15 deletions
Show diff stats
src/app/modules/seleccion-articulos/seleccion-articulos.component.html
1 | <div class="h-92 bg-white fade-in-left"> | 1 | <div class="h-92 bg-white fade-in-left"> |
2 | <!-- PUBLICIDADES --> | 2 | <!-- PUBLICIDADES --> |
3 | <app-header-publicidad></app-header-publicidad> | 3 | <app-header-publicidad></app-header-publicidad> |
4 | 4 | ||
5 | <div class="row mx-0 h-80 align-items-end"> | 5 | <div class="row mx-0 h-80 align-items-end"> |
6 | <!-- CABECERA --> | 6 | <!-- CABECERA --> |
7 | <div class="row w-100 mx-3 h-auto border border-primary rounded-sm"> | 7 | <div class="row w-100 mx-3 h-auto border border-primary rounded-sm"> |
8 | <div class="col-12 p-2 align-self-center"> | 8 | <div class="col-12 p-2 align-self-center"> |
9 | <div class="px-3"> | 9 | <div class="px-3"> |
10 | <p class="h6 text-truncate">SELECCIONÁ TÚ COMIDA Y/O BEBIDA</p> | 10 | <p class="h6 text-truncate">SELECCIONÁ TÚ COMIDA Y/O BEBIDA</p> |
11 | </div> | 11 | </div> |
12 | </div> | 12 | </div> |
13 | </div> | 13 | </div> |
14 | <!-- CUERPO --> | 14 | <!-- CUERPO --> |
15 | <div class="row w-100 mr-4 h-50 h-md-70"> | 15 | <div class="row w-100 mr-4 h-50 h-md-70"> |
16 | <div class="col-12 h-100 px-0 py-3"> | 16 | <div class="col-12 h-100 px-0 py-3"> |
17 | <div class="row mx-0 h-100"> | 17 | <div class="row mx-0 h-100"> |
18 | <!-- FILTRO CATEGORIAS --> | 18 | <!-- FILTRO CATEGORIAS --> |
19 | <div class="col-5 col-sm-3 col-xl-2 h-100"> | 19 | <div class="col-5 col-sm-3 col-xl-2 h-100"> |
20 | <p class="h6 h-6 m-0 text-center"><small>CATEGORÍAS</small></p> | 20 | <p class="h6 h-6 m-0 text-center"><small>CATEGORÍAS</small></p> |
21 | <div class="row mx-0 h-94 justify-content-center align-items-center"> | 21 | <div class="row mx-0 h-94 justify-content-center align-items-center"> |
22 | <div class="col-auto btn-effect h-5"> | 22 | <div class="col-auto btn-effect h-5"> |
23 | <img | 23 | <img |
24 | draggable="false" | 24 | draggable="false" |
25 | ondragstart="return false;" | 25 | ondragstart="return false;" |
26 | (contextmenu)="false" | 26 | (contextmenu)="false" |
27 | class="h-100 d-block mx-auto rotate-90-neg" | 27 | class="h-100 d-block mx-auto rotate-90-neg" |
28 | src="assets/img/ir-color.svg" | 28 | src="assets/img/ir-color.svg" |
29 | (mousedown)="scrollY(templateCategorias, -100)" | 29 | (mousedown)="scrollY(templateCategorias, -100)" |
30 | (mouseup)="mouseup()" | 30 | (mouseup)="mouseup()" |
31 | (mouseleave)="mouseup()"> | 31 | (mouseleave)="mouseup()"> |
32 | </div> | 32 | </div> |
33 | <!-- CATEGORIAS --> | 33 | <!-- CATEGORIAS --> |
34 | <div | 34 | <div |
35 | #templateCategorias | 35 | #templateCategorias |
36 | class="col-12 px-0 box-categorias border border-primary border-left-0 rounded-right scroll-y" | 36 | class="col-12 px-0 box-categorias border border-primary border-left-0 rounded-right scroll-y" |
37 | (scroll)="scrollEvent($event)"> | 37 | (scroll)="scrollEvent($event)"> |
38 | <div | 38 | <div |
39 | class="row mx-4 mb-2 h-25 h-md-32 h-lg-45 justify-content-center tab" | 39 | class="row mx-4 mb-2 h-25 h-md-32 h-lg-45 justify-content-center tab" |
40 | [ngClass]="{ 'active': allActive, 'border-bottom-effect': !allActive }" | 40 | [ngClass]="{ 'active': allActive, 'border-bottom-effect': !allActive }" |
41 | (click)="selectCategoria(-1, 0)"> | 41 | (click)="selectCategoria(-1, 0)"> |
42 | <img | 42 | <img |
43 | draggable="false" | 43 | draggable="false" |
44 | ondragstart="return false;" | 44 | ondragstart="return false;" |
45 | (contextmenu)="false" | 45 | (contextmenu)="false" |
46 | class="col-12 h-50 align-self-end d-none d-sm-block rounded-circle" | 46 | class="col-12 h-50 align-self-end d-none d-sm-block rounded-circle" |
47 | src="assets/img/logo-spot.svg"> | 47 | src="assets/img/logo-spot.svg"> |
48 | <small class="col-12 px-0 my-1 h-100 h-md-25 align-self-end text-center text-truncate">Todos</small> | 48 | <small class="col-12 px-0 my-1 h-100 h-md-25 align-self-end text-center text-truncate">Todos</small> |
49 | </div> | 49 | </div> |
50 | <div | 50 | <div |
51 | class="row mx-4 mb-2 h-25 h-md-32 h-lg-45 justify-content-center tab" | 51 | class="row mx-4 mb-2 h-25 h-md-32 h-lg-45 justify-content-center tab" |
52 | [ngClass]="{ 'active': categoria.selected, 'border-bottom-effect': !categoria.selected }" | 52 | [ngClass]="{ 'active': categoria.selected, 'border-bottom-effect': !categoria.selected }" |
53 | (click)="selectCategoria(i, categoria.id)" | 53 | (click)="selectCategoria(i, categoria.id)" |
54 | *ngFor="let categoria of categorias; let i = index;"> | 54 | *ngFor="let categoria of categorias; let i = index;"> |
55 | <img | 55 | <img |
56 | draggable="false" | 56 | draggable="false" |
57 | ondragstart="return false;" | 57 | ondragstart="return false;" |
58 | (contextmenu)="false" | 58 | (contextmenu)="false" |
59 | class="col-12 h-50 align-self-end d-none d-sm-block rounded-circle" | 59 | class="col-12 h-50 align-self-end d-none d-sm-block rounded-circle" |
60 | src="{{urlImagenes}}{{categoria.path_imagen}}" | 60 | src="{{urlImagenes}}{{categoria.path_imagen}}" |
61 | onerror="this.src='assets/img/image-not-found.jpg'"> | 61 | onerror="this.src='assets/img/image-not-found.jpg'"> |
62 | <small class="col-12 px-0 my-1 h-100 h-md-25 align-self-end text-center text-truncate">{{categoria.detalle}}</small> | 62 | <small class="col-12 px-0 my-1 h-100 h-md-25 align-self-end text-center text-truncate">{{categoria.detalle}}</small> |
63 | </div> | 63 | </div> |
64 | </div> | 64 | </div> |
65 | <div class="col-auto btn-effect h-5"> | 65 | <div class="col-auto btn-effect h-5"> |
66 | <img | 66 | <img |
67 | draggable="false" | 67 | draggable="false" |
68 | ondragstart="return false;" | 68 | ondragstart="return false;" |
69 | (contextmenu)="false" | 69 | (contextmenu)="false" |
70 | class="h-100 d-block mx-auto rotate-90" | 70 | class="h-100 d-block mx-auto rotate-90" |
71 | src="assets/img/ir-color.svg" | 71 | src="assets/img/ir-color.svg" |
72 | (mousedown)="scrollY(templateCategorias, 100)" | 72 | (mousedown)="scrollY(templateCategorias, 100)" |
73 | (mouseup)="mouseup()" | 73 | (mouseup)="mouseup()" |
74 | (mouseleave)="mouseup()"> | 74 | (mouseleave)="mouseup()"> |
75 | </div> | 75 | </div> |
76 | </div> | 76 | </div> |
77 | </div> | 77 | </div> |
78 | <!-- LISTA DE ARTICULOS --> | 78 | <!-- LISTA DE ARTICULOS --> |
79 | <div | 79 | <div |
80 | class="col-7 col-sm-9 col-xl-10 pb-3 h-100 align-self-center scroll-y-visible" | 80 | class="col-7 col-sm-9 col-xl-10 pb-3 h-100 align-self-center scroll-y-visible" |
81 | (scroll)="scrollEvent($event)"> | 81 | (scroll)="scrollEvent($event)"> |
82 | <div class="row row-cols-1 row-cols-sm-3 row-cols-xl-6"> | 82 | <div class="row row-cols-1 row-cols-sm-3 row-cols-xl-6"> |
83 | <!-- ARTICULO --> | 83 | <!-- ARTICULO --> |
84 | <div | 84 | <div |
85 | class="col px-2 my-1 my-md-3 h-auto" | 85 | class="col px-2 my-1 my-md-3 h-auto" |
86 | *ngFor="let articulo of auxArticulos | slice:0:showQuantity;"> | 86 | *ngFor="let articulo of auxArticulos | slice:0:showQuantity;"> |
87 | <div | 87 | <div |
88 | class="swing-in-top-fwd btn-effect card h-auto" | 88 | class="swing-in-top-fwd btn-effect card h-auto" |
89 | (click)="elegirArticulo(articulo)"> | 89 | (click)="selectArticulo(articulo)"> |
90 | <img | 90 | <img |
91 | draggable="false" | 91 | draggable="false" |
92 | ondragstart="return false;" | 92 | ondragstart="return false;" |
93 | (contextmenu)="false" | 93 | (contextmenu)="false" |
94 | src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}" | 94 | src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}" |
95 | onerror="this.src='assets/img/image-not-found.jpg'" | 95 | onerror="this.src='assets/img/image-not-found.jpg'" |
96 | class="card-img-top h-30 h-md-55 rounded-sm"> | 96 | class="card-img-top h-30 h-md-55 rounded-sm"> |
97 | <div class="row mx-0 py-1 h-auto justify-content-center"> | 97 | <div class="row mx-0 py-1 h-auto justify-content-center"> |
98 | <p | 98 | <p |
99 | [ngClass]="{'text-primary': articulo.PRO, 'text-secondary': !articulo.PRO}" | 99 | [ngClass]="{'text-primary': articulo.PRO, 'text-secondary': !articulo.PRO}" |
100 | class="col-12 px-1 h6 h-auto text-center min-h-60"> | 100 | class="col-12 px-1 h6 h-auto text-center min-h-60"> |
101 | {{articulo.DetArt}} | 101 | {{articulo.DetArt}} |
102 | </p> | 102 | </p> |
103 | <p class="col-12 px-1 h-auto text-center line-height-sm min-h-50"> | 103 | <p class="col-12 px-1 h-auto text-center line-height-sm min-h-50"> |
104 | <small>{{articulo.DET_LAR}}</small> | 104 | <small>{{articulo.DET_LAR}}</small> |
105 | </p> | 105 | </p> |
106 | <div class="col-12 px-1 align-self-end h-auto"> | 106 | <div class="col-12 px-1 align-self-end h-auto"> |
107 | <div | 107 | <div |
108 | [ngClass]="{'bg-primary': articulo.PRO, 'bg-secondary': !articulo.PRO}" | 108 | [ngClass]="{'bg-primary': articulo.PRO, 'bg-secondary': !articulo.PRO}" |
109 | class="row mx-0 justify-content-between badge-pill"> | 109 | class="row mx-0 justify-content-between badge-pill"> |
110 | <div class="col px-0 align-self-center text-white text-right"> | 110 | <div class="col px-0 align-self-center text-white text-right"> |
111 | {{articulo.PreVen | currency}} | 111 | {{articulo.PreVen | currency}} |
112 | </div> | 112 | </div> |
113 | <div class="col-5 px-0"> | 113 | <div class="col-5 px-0"> |
114 | <img | 114 | <img |
115 | draggable="false" | 115 | draggable="false" |
116 | ondragstart="return false;" | 116 | ondragstart="return false;" |
117 | (contextmenu)="false" | 117 | (contextmenu)="false" |
118 | class="d-block ml-auto py-1 icon-30" | 118 | class="d-block ml-auto py-1 icon-30" |
119 | src="assets/img/ir.svg"> | 119 | src="assets/img/ir.svg"> |
120 | </div> | 120 | </div> |
121 | </div> | 121 | </div> |
122 | </div> | 122 | </div> |
123 | </div> | 123 | </div> |
124 | </div> | 124 | </div> |
125 | </div> | 125 | </div> |
126 | </div> | 126 | </div> |
127 | <!-- BOTON VER MAS --> | 127 | <!-- BOTON VER MAS --> |
128 | <div class="row mx-0"> | 128 | <div class="row mx-0"> |
129 | <div | 129 | <div |
130 | *ngIf="showQuantity <= auxArticulos.slice(0, showQuantity).length" | 130 | *ngIf="showQuantity <= auxArticulos.slice(0, showQuantity).length" |
131 | class="col-12 px-0 mb-2"> | 131 | class="col-12 px-0 mb-2"> |
132 | <button | 132 | <button |
133 | (click)="increaseShow()" | 133 | (click)="increaseShow()" |
134 | class="btn btn-block btn-outline-primary"> | 134 | class="btn btn-block btn-outline-primary"> |
135 | Ver Más | 135 | Ver Más |
136 | </button> | 136 | </button> |
137 | </div> | 137 | </div> |
138 | </div> | 138 | </div> |
139 | </div> | 139 | </div> |
140 | </div> | 140 | </div> |
141 | </div> | 141 | </div> |
142 | </div> | 142 | </div> |
143 | <!-- FOOTER CARRITO DE COMPRAS --> | 143 | <!-- FOOTER CARRITO DE COMPRAS --> |
144 | <div class="row w-90 mx-auto h-auto justify-content-center"> | 144 | <div class="row w-90 mx-auto h-auto justify-content-center"> |
145 | <div class="col-12 h-75 px-0 border border-primary rounded"> | 145 | <div class="col-12 h-75 px-0 border border-primary rounded"> |
146 | <!-- CABECERA --> | 146 | <!-- CABECERA --> |
147 | <div class="row mx-0 h-15 border-bottom border-primary"> | 147 | <div class="row mx-0 h-15 border-bottom border-primary"> |
148 | <p class="col align-self-center text-truncate"><small>ARTÍCULOS EN TÚ CARRITO DE COMPRAS</small></p> | 148 | <p class="col align-self-center text-truncate"><small>ARTÍCULOS EN TÚ CARRITO DE COMPRAS</small></p> |
149 | </div> | 149 | </div> |
150 | <!-- CUERPO --> | 150 | <!-- CUERPO --> |
151 | <div class="row h-85 mx-0 justify-content-around"> | 151 | <div class="row h-85 mx-0 justify-content-around"> |
152 | <!-- BOTON SCROLL IZQUIERDA --> | 152 | <!-- BOTON SCROLL IZQUIERDA --> |
153 | <div *ngIf="articuloService.carrito.length" class="col-auto btn-effect h-20 align-self-center"> | 153 | <div *ngIf="articuloService.carrito.length" class="col-auto btn-effect h-20 align-self-center"> |
154 | <img | 154 | <img |
155 | draggable="false" | 155 | draggable="false" |
156 | ondragstart="return false;" | 156 | ondragstart="return false;" |
157 | (contextmenu)="false" | 157 | (contextmenu)="false" |
158 | class="icon-30 rotate-180-neg" | 158 | class="icon-30 rotate-180-neg" |
159 | src="assets/img/ir-fondo-color.svg" | 159 | src="assets/img/ir-fondo-color.svg" |
160 | (mousedown)="scrollX(templateCarrito, -100)" | 160 | (mousedown)="scrollX(templateCarrito, -100)" |
161 | (mouseup)="mouseup()" | 161 | (mouseup)="mouseup()" |
162 | (mouseleave)="mouseup()"> | 162 | (mouseleave)="mouseup()"> |
163 | </div> | 163 | </div> |
164 | <!-- CARRITO --> | 164 | <!-- CARRITO --> |
165 | <div class="col-6 col-sm-8 col-md-9 col-lg-10 h-100"> | 165 | <div class="col-6 col-sm-8 col-md-9 col-lg-10 h-100"> |
166 | <div | 166 | <div |
167 | #templateCarrito | 167 | #templateCarrito |
168 | class="row flex-row flex-nowrap h-100 mx-0 my-2 scroll-x" | 168 | class="row flex-row flex-nowrap h-100 mx-0 my-2 scroll-x" |
169 | (scroll)="scrollEvent($event)"> | 169 | (scroll)="scrollEvent($event)"> |
170 | <!-- MENSAJE DE ADVERTENCIA --> | 170 | <!-- MENSAJE DE ADVERTENCIA --> |
171 | <div *ngIf="!articuloService.carrito.length" class="col h-100"> | 171 | <div *ngIf="!articuloService.carrito.length" class="col h-100"> |
172 | <p class="text-center py-5">No hay articulos en el carrito</p> | 172 | <p class="text-center py-5">No hay articulos en el carrito</p> |
173 | </div> | 173 | </div> |
174 | <!-- ARTICULOS --> | 174 | <!-- ARTICULOS --> |
175 | <div | 175 | <div |
176 | class="col-10 col-sm-4 col-lg-2 px-2 px-xl-4 align-self-center border-right border-primary" | 176 | class="col-10 col-sm-4 col-lg-2 px-2 px-xl-4 align-self-center border-right border-primary" |
177 | *ngFor="let articulo of articuloService.carrito; let i = index;"> | 177 | *ngFor="let articulo of articuloService.carrito; let i = index;"> |
178 | <div class="swing-in-top-fwd"> | 178 | <div class="swing-in-top-fwd"> |
179 | <img | 179 | <img |
180 | class="btn-effect icon-20 position-absolute right-0" | 180 | class="btn-effect icon-20 position-absolute right-0" |
181 | src="assets/img/icono-cancelar-color.svg" | 181 | src="assets/img/icono-cancelar-color.svg" |
182 | (click)="deleteArticulo(i)"> | 182 | (click)="deleteArticulo(i)"> |
183 | <img | 183 | <img |
184 | draggable="false" | 184 | draggable="false" |
185 | ondragstart="return false;" | 185 | ondragstart="return false;" |
186 | (contextmenu)="false" | 186 | (contextmenu)="false" |
187 | class="d-block img-fluid p-2 mx-auto rounded" | 187 | class="d-block img-fluid p-2 mx-auto rounded" |
188 | src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}" | 188 | src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}" |
189 | onerror="this.src='assets/img/image-not-found.jpg'"> | 189 | onerror="this.src='assets/img/image-not-found.jpg'"> |
190 | <p class="d-block mt-auto text-center text-primary text-truncate"> | 190 | <p class="d-block mt-auto text-center text-primary text-truncate"> |
191 | <small>{{articulo.DetArt}}</small> | 191 | <small>{{articulo.DetArt}}</small> |
192 | </p> | 192 | </p> |
193 | </div> | 193 | </div> |
194 | </div> | 194 | </div> |
195 | </div> | 195 | </div> |
196 | </div> | 196 | </div> |
197 | <!-- BOTON SCROLL DERECHA --> | 197 | <!-- BOTON SCROLL DERECHA --> |
198 | <div *ngIf="articuloService.carrito.length" class="col-auto btn-effect h-20 align-self-center"> | 198 | <div *ngIf="articuloService.carrito.length" class="col-auto btn-effect h-20 align-self-center"> |
199 | <img | 199 | <img |
200 | draggable="false" | 200 | draggable="false" |
201 | ondragstart="return false;" | 201 | ondragstart="return false;" |
202 | (contextmenu)="false" | 202 | (contextmenu)="false" |
203 | class="icon-30" | 203 | class="icon-30" |
204 | src="assets/img/ir-fondo-color.svg" | 204 | src="assets/img/ir-fondo-color.svg" |
205 | (mousedown)="scrollX(templateCarrito, 100)" | 205 | (mousedown)="scrollX(templateCarrito, 100)" |
206 | (mouseup)="mouseup()" | 206 | (mouseup)="mouseup()" |
207 | (mouseleave)="mouseup()"> | 207 | (mouseleave)="mouseup()"> |
208 | </div> | 208 | </div> |
209 | </div> | 209 | </div> |
210 | </div> | 210 | </div> |
211 | <!-- TOTAL--> | 211 | <!-- TOTAL--> |
212 | <div | 212 | <div |
213 | class="col-auto mt-2 ml-auto h-20"> | 213 | class="col-auto mt-2 ml-auto h-20"> |
214 | <div class="row mx-0"> | 214 | <div class="row mx-0"> |
215 | <div class="col-auto align-self-center text-primary">TOTAL</div> | 215 | <div class="col-auto align-self-center text-primary">TOTAL</div> |
216 | <div class="col-auto bg-primary badge-pill"> | 216 | <div class="col-auto bg-primary badge-pill"> |
217 | <p class="text-center text-white mt-1 py-1">{{articuloService.subTotal | currency}}</p> | 217 | <p class="text-center text-white mt-1 py-1">{{articuloService.subTotal | currency}}</p> |
218 | </div> | 218 | </div> |
219 | </div> | 219 | </div> |
220 | </div> | 220 | </div> |
221 | 221 | ||
222 | <!-- VER CARRITO --> | 222 | <!-- VER CARRITO --> |
223 | <div | 223 | <div |
224 | class="col-auto px-0 mt-2 h-20" | 224 | class="col-auto px-0 mt-2 h-20" |
225 | *ngIf="articuloService.carrito.length"> | 225 | *ngIf="articuloService.carrito.length"> |
226 | <div | 226 | <div |
227 | class="btn-effect col-auto px-0 align-self-center bg-white" | 227 | class="btn-effect col-auto px-0 align-self-center bg-white" |
228 | [routerLink]="['/carrito']"> | 228 | [routerLink]="['/carrito']"> |
229 | <div class="row mx-0 bg-light"> | 229 | <div class="row mx-0 bg-light"> |
230 | <div class="col-auto p-0 bg-primary"> | 230 | <div class="col-auto p-0 bg-primary"> |
231 | <img | 231 | <img |
232 | draggable="false" | 232 | draggable="false" |
233 | ondragstart="return false;" | 233 | ondragstart="return false;" |
234 | (contextmenu)="false" | 234 | (contextmenu)="false" |
235 | class="p-2 icon-40" | 235 | class="p-2 icon-40" |
236 | src="assets/img/carrito.svg"> | 236 | src="assets/img/carrito.svg"> |
237 | </div> | 237 | </div> |
238 | <div class="col-auto align-self-center text-primary d-none d-sm-block">IR AL CARRITO</div> | 238 | <div class="col-auto align-self-center text-primary d-none d-sm-block">IR AL CARRITO</div> |
239 | </div> | 239 | </div> |
240 | </div> | 240 | </div> |
241 | </div> | 241 | </div> |
242 | 242 | ||
243 | </div> | 243 | </div> |
244 | </div> | 244 | </div> |
245 | 245 | ||
246 | </div> | 246 | </div> |
247 | 247 |
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
1 | import { Component, OnInit, TemplateRef, OnDestroy, HostListener } from '@angular/core'; | 1 | import { Component, OnInit, TemplateRef, OnDestroy, HostListener } 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 { CategoriaService } from 'src/app/services/categoria/categoria.service'; | 8 | import { CategoriaService } from 'src/app/services/categoria/categoria.service'; |
8 | import { PromocionService } from 'src/app/services/promocion/promocion.service'; | 9 | import { PromocionService } from 'src/app/services/promocion/promocion.service'; |
9 | import { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; | 10 | import { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; |
10 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; | 11 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; |
12 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; | ||
13 | import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component'; | ||
11 | 14 | ||
12 | @Component({ | 15 | @Component({ |
13 | selector: 'app-seleccion-articulos', | 16 | selector: 'app-seleccion-articulos', |
14 | templateUrl: './seleccion-articulos.component.html', | 17 | templateUrl: './seleccion-articulos.component.html', |
15 | styleUrls: ['./seleccion-articulos.component.scss'] | 18 | styleUrls: ['./seleccion-articulos.component.scss'] |
16 | }) | 19 | }) |
17 | export class SeleccionArticulosComponent implements OnInit, OnDestroy { | 20 | export class SeleccionArticulosComponent implements OnInit, OnDestroy { |
18 | showSpinner = true; | 21 | showSpinner = true; |
19 | timeoutHandler: any; | 22 | timeoutHandler: any; |
20 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 23 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
21 | articulos: IArticulo[] = []; | 24 | articulos: IArticulo[] = []; |
22 | auxArticulos: IArticulo[] = []; | 25 | auxArticulos: IArticulo[] = []; |
23 | showQuantity = 100; | 26 | showQuantity = 100; |
24 | queMostrar = 'todos'; | 27 | queMostrar = 'todos'; |
25 | categoriaActive = null; | 28 | categoriaActive = null; |
26 | categorias: ICategoria[] = []; | 29 | categorias: ICategoria[] = []; |
27 | searchTerm = ''; | 30 | searchTerm = ''; |
28 | ordenandoByVendidos = true; | 31 | ordenandoByVendidos = true; |
29 | allActive = true; | 32 | allActive = true; |
30 | modalRef: BsModalRef; | 33 | modalRef: BsModalRef; |
31 | total = 0; | 34 | total = 0; |
32 | 35 | ||
33 | constructor( | 36 | constructor( |
34 | public articuloService: ArticuloService, | 37 | public articuloService: ArticuloService, |
35 | private categoriaService: CategoriaService, | 38 | private categoriaService: CategoriaService, |
39 | private sinonimoService: SinonimoService, | ||
36 | private modalService: BsModalService, | 40 | private modalService: BsModalService, |
37 | private inactiveScreen: InactiveScreenService, | 41 | private inactiveScreen: InactiveScreenService, |
38 | ) { } | 42 | ) { } |
39 | 43 | ||
40 | ngOnInit() { | 44 | ngOnInit() { |
41 | this.getCategorias(); | 45 | this.getCategorias(); |
42 | } | 46 | } |
43 | 47 | ||
44 | ngOnDestroy() { | 48 | ngOnDestroy() { |
45 | if (this.modalRef) this.modalRef.hide(); | 49 | if (this.modalRef) this.modalRef.hide(); |
46 | } | 50 | } |
47 | 51 | ||
48 | getCategorias() { | 52 | getCategorias() { |
49 | this.categoriaService.getAll() | 53 | this.categoriaService.getAll() |
50 | .subscribe((categorias: ICategoria[]) => { | 54 | .subscribe((categorias: ICategoria[]) => { |
51 | switch (this.queMostrar) { | 55 | switch (this.queMostrar) { |
52 | case 'todos': | 56 | case 'todos': |
53 | this.categorias = categorias; | 57 | this.categorias = categorias; |
54 | this.categoriaActive = 0; | 58 | this.categoriaActive = 0; |
55 | break; | 59 | break; |
56 | case 'promociones': | 60 | case 'promociones': |
57 | this.categorias = categorias; | 61 | this.categorias = categorias; |
58 | this.categoriaActive = 19; | 62 | this.categoriaActive = 19; |
59 | break; | 63 | break; |
60 | case 'ordenar': | 64 | case 'ordenar': |
61 | this.categorias = categorias.filter((categoria: ICategoria) => { | 65 | this.categorias = categorias.filter((categoria: ICategoria) => { |
62 | return categoria.ES_PEDIDO; | 66 | return categoria.ES_PEDIDO; |
63 | }); | 67 | }); |
64 | this.categoriaActive = 4; | 68 | this.categoriaActive = 4; |
65 | break; | 69 | break; |
66 | default: | 70 | default: |
67 | this.categorias = categorias; | 71 | this.categorias = categorias; |
68 | this.categoriaActive = 0; | 72 | this.categoriaActive = 0; |
69 | break; | 73 | break; |
70 | } | 74 | } |
71 | !localStorage.getItem('articulos') ? | 75 | !localStorage.getItem('articulos') ? |
72 | this.getProductos() : | 76 | this.getProductos() : |
73 | this.setProductos(); | 77 | this.setProductos(); |
74 | }); | 78 | }); |
75 | } | 79 | } |
76 | 80 | ||
77 | getProductos() { | 81 | getProductos() { |
78 | this.articuloService.getAll() | 82 | this.articuloService.getAll() |
79 | .subscribe((result: IArticulo[]) => { | 83 | .subscribe((result: IArticulo[]) => { |
80 | this.articuloService.setArticulosSinImagen(result); | 84 | this.articuloService.setArticulosSinImagen(result); |
81 | if (this.queMostrar === 'ordenar') { | 85 | if (this.queMostrar === 'ordenar') { |
82 | this.categorias.forEach((categoria: ICategoria) => { | 86 | this.categorias.forEach((categoria: ICategoria) => { |
83 | const tempArticulos = result.filter((articulo: IArticulo) => { | 87 | const tempArticulos = result.filter((articulo: IArticulo) => { |
84 | return articulo.categoria_selfservice === categoria.id; | 88 | return articulo.categoria_selfservice === categoria.id; |
85 | }); | 89 | }); |
86 | result = tempArticulos; | 90 | result = tempArticulos; |
87 | }); | 91 | }); |
88 | } | 92 | } |
89 | localStorage.setItem('articulos', JSON.stringify(result)); | 93 | localStorage.setItem('articulos', JSON.stringify(result)); |
90 | this.setProductos(); | 94 | this.setProductos(); |
91 | }, (error) => { | 95 | }, (error) => { |
92 | this.showSpinner = false; | 96 | this.showSpinner = false; |
93 | console.error(error); | 97 | console.error(error); |
94 | }); | 98 | }); |
95 | } | 99 | } |
96 | 100 | ||
97 | setProductos() { | 101 | setProductos() { |
98 | this.articulos = JSON.parse(localStorage.getItem('articulos')); | 102 | this.articulos = JSON.parse(localStorage.getItem('articulos')); |
99 | this.filterItems(); | 103 | this.filterItems(); |
100 | } | 104 | } |
101 | 105 | ||
102 | filterItems() { | 106 | filterItems() { |
103 | if (this.categoriaActive === 0) { | 107 | if (this.categoriaActive === 0) { |
104 | this.auxArticulos = this.articulos; | 108 | this.auxArticulos = this.articulos; |
105 | return; | 109 | return; |
106 | } | 110 | } |
107 | this.auxArticulos = this.articulos.filter(x => { | 111 | this.auxArticulos = this.articulos.filter(x => { |
108 | return x.categoria_selfservice === this.categoriaActive; | 112 | return x.categoria_selfservice === this.categoriaActive; |
109 | }); | 113 | }); |
110 | this.ordenar(); | 114 | this.ordenar(); |
111 | } | 115 | } |
112 | 116 | ||
113 | ordenar() { | 117 | ordenar() { |
114 | if (this.ordenandoByVendidos) { | 118 | if (this.ordenandoByVendidos) { |
115 | this.auxArticulos.sort((a, b) => { | 119 | this.auxArticulos.sort((a, b) => { |
116 | return b.cantidadVendida - a.cantidadVendida; | 120 | return b.cantidadVendida - a.cantidadVendida; |
117 | }); | 121 | }); |
118 | } | 122 | } |
119 | } | 123 | } |
120 | 124 | ||
121 | selectCategoria(index: number, idCategoria?: number) { | 125 | selectCategoria(index: number, idCategoria?: number) { |
122 | if (this.categoriaActive === idCategoria) return; | 126 | if (this.categoriaActive === idCategoria) return; |
123 | this.categoriaActive = idCategoria; | 127 | this.categoriaActive = idCategoria; |
124 | this.allActive = idCategoria === 0 ? true : false; | 128 | this.allActive = idCategoria === 0 ? true : false; |
125 | this.categorias.forEach((categoria, i) => { | 129 | this.categorias.forEach((categoria, i) => { |
126 | categoria.selected = index === i ? true : false; | 130 | categoria.selected = index === i ? true : false; |
127 | }); | 131 | }); |
128 | this.filterItems(); | 132 | this.filterItems(); |
129 | } | 133 | } |
130 | 134 | ||
131 | elegirArticulo(articulo: IArticulo) { | 135 | selectArticulo(articulo: IArticulo) { |
132 | this.getByID(articulo.id); | 136 | this.getByID(articulo.id); |
133 | } | 137 | } |
134 | 138 | ||
135 | getByID(id: number) { | 139 | getByID(id: number) { |
136 | this.articuloService.getById(id) | 140 | this.articuloService.getById(id) |
137 | .subscribe((res: IArticulo) => { | 141 | .subscribe((res: IArticulo) => { |
138 | if (res.FPP) { | 142 | if (res.FPP) { |
139 | this.openModalPromos(res); | 143 | this.openModalPromos(res); |
140 | } else { | 144 | } else { |
141 | res.cantidad = 1; | 145 | this.getSinonimos(res); |
142 | this.articuloService.setArticulo(res); | ||
143 | } | 146 | } |
144 | }, err => console.error(err)); | 147 | }, err => console.error(err)); |
145 | } | 148 | } |
146 | 149 | ||
150 | getSinonimos(articulo: IArticulo) { | ||
151 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) | ||
152 | .subscribe((res: ISinonimo[]) => { | ||
153 | if (res.length) { | ||
154 | this.openModalSinonimos(res); | ||
155 | } else { | ||
156 | articulo.cantidad = 1; | ||
157 | this.articuloService.setArticulo(articulo); | ||
158 | } | ||
159 | }) | ||
160 | } | ||
161 | |||
147 | openModalPromos(articulo: IArticulo) { | 162 | openModalPromos(articulo: IArticulo) { |
148 | this.modalRef = this.modalService.show(PromocionComponent, { | 163 | this.modalRef = this.modalService.show(PromocionComponent, { |
149 | initialState: { articulosPromo: [articulo] }, | 164 | initialState: { articulosPromo: [articulo] }, |
150 | class: 'modal-promo modal-dialog-centered' | 165 | class: 'modal-promo modal-dialog-centered' |
151 | }); | 166 | }); |
152 | } | 167 | } |
153 | 168 | ||
169 | openModalSinonimos(sinonimosData: ISinonimo[]) { | ||
170 | this.modalRef = this.modalService.show(SinonimoComponent, { | ||
171 | initialState: { sinonimos: sinonimosData }, | ||
172 | class: 'modal-promo modal-dialog-centered' | ||
173 | }); | ||
174 | } | ||
175 | |||
154 | deleteArticulo(index: number) { | 176 | deleteArticulo(index: number) { |
155 | this.articuloService.carrito.splice(index, 1); | 177 | this.articuloService.carrito.splice(index, 1); |
156 | this.articuloService.calcularTotal(); | 178 | this.articuloService.calcularTotal(); |
157 | } | 179 | } |
158 | 180 | ||
159 | increaseShow() { | 181 | increaseShow() { |
160 | this.showQuantity += 100; | 182 | this.showQuantity += 100; |
161 | } | 183 | } |
162 | 184 | ||
163 | @HostListener('scroll', ['$event']) | 185 | @HostListener('scroll', ['$event']) |
164 | scrollEvent(event: Event) { | 186 | scrollEvent(event: Event) { |
165 | clearTimeout(this.inactiveScreen.timerReposo); | 187 | clearTimeout(this.inactiveScreen.timerReposo); |
166 | this.inactiveScreen.startTimeOutInactividad(); | 188 | this.inactiveScreen.startTimeOutInactividad(); |
167 | } | 189 | } |
168 | 190 | ||
169 | mouseup() { | 191 | mouseup() { |
170 | if (!this.timeoutHandler) return; | 192 | if (!this.timeoutHandler) return; |
171 | clearInterval(this.timeoutHandler); | 193 | clearInterval(this.timeoutHandler); |
172 | } | 194 | } |
173 | 195 | ||
174 | scrollY(el: HTMLElement, value) { | 196 | scrollY(el: HTMLElement, value) { |
175 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); | 197 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); |
176 | this.timeoutHandler = setInterval(() => { | 198 | this.timeoutHandler = setInterval(() => { |
177 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); | 199 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); |
178 | }, 500); | 200 | }, 500); |
179 | } | 201 | } |
180 | 202 | ||
181 | scrollX(el: HTMLElement, value) { | 203 | scrollX(el: HTMLElement, value) { |
182 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); | 204 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); |
183 | this.timeoutHandler = setInterval(() => { | 205 | this.timeoutHandler = setInterval(() => { |
184 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); | 206 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); |
185 | }, 500); | 207 | }, 500); |
186 | } | 208 | } |
187 | } | 209 | } |
src/app/modules/seleccion-articulos/seleccion-articulos.module.ts
1 | import { NgModule } from '@angular/core'; | 1 | import { NgModule } from '@angular/core'; |
2 | import { CommonModule } from '@angular/common'; | 2 | import { CommonModule } from '@angular/common'; |
3 | import { SeleccionArticulosRoutingModule } from './seleccion-articulos-routing.module'; | 3 | import { SeleccionArticulosRoutingModule } from './seleccion-articulos-routing.module'; |
4 | import { SeleccionArticulosComponent } from './seleccion-articulos.component'; | 4 | import { SeleccionArticulosComponent } from './seleccion-articulos.component'; |
5 | import { HeaderPublicidadComponent } from 'src/app/shared/header-publicidad/header-publicidad.component'; | 5 | import { HeaderPublicidadComponent } from 'src/app/shared/header-publicidad/header-publicidad.component'; |
6 | import { ModalModule } from 'ngx-bootstrap/modal'; | 6 | import { ModalModule } from 'ngx-bootstrap/modal'; |
7 | import { CarouselModule } from 'ngx-bootstrap/carousel'; | 7 | import { CarouselModule } from 'ngx-bootstrap/carousel'; |
8 | import { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; | 8 | import { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; |
9 | import { SharedModule } from '../shared/shared.module'; | 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 | ||
11 | @NgModule({ | 13 | @NgModule({ |
12 | declarations: [ | 14 | declarations: [ |
13 | SeleccionArticulosComponent, | 15 | SeleccionArticulosComponent, |
14 | HeaderPublicidadComponent, | 16 | HeaderPublicidadComponent, |
15 | PromocionComponent | 17 | PromocionComponent, |
18 | SinonimoComponent, | ||
16 | ], | 19 | ], |
17 | imports: [ | 20 | imports: [ |
18 | CommonModule, | 21 | CommonModule, |
19 | SeleccionArticulosRoutingModule, | 22 | SeleccionArticulosRoutingModule, |
23 | FormsModule, | ||
20 | ModalModule.forRoot(), | 24 | ModalModule.forRoot(), |
21 | CarouselModule.forRoot(), | 25 | CarouselModule.forRoot(), |
22 | SharedModule | 26 | SharedModule |
23 | ], | 27 | ], |
24 | exports: [HeaderPublicidadComponent], | 28 | exports: [HeaderPublicidadComponent], |
25 | entryComponents: [PromocionComponent] | 29 | entryComponents: [PromocionComponent, SinonimoComponent] |
26 | }) | 30 | }) |
27 | export class SeleccionArticulosModule { } | 31 | export class SeleccionArticulosModule { } |
28 | 32 |
src/app/shared/promocion/promocion.component.html
1 | <div class="modal-header bg-primary rounded-top pt-4 px-2"> | 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)="selectPromo(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 bg-primary rounded-bottom pb-3 px-2" *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"> | 31 | <div class="col-3"> |
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 | 41 | <div |
42 | class="row mx-0 lista-promociones scroll-y-visible" | 42 | class="row mx-0 lista-promociones scroll-y-visible" |
43 | (scroll)="scrollEvent($event)"> | 43 | (scroll)="scrollEvent($event)"> |
44 | <div class="col-12"> | 44 | <div class="col-12"> |
45 | <div *ngFor="let promo of promociones"> | 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 | <div class="d-flex"> | 47 | <div class="d-flex"> |
48 | <p class="text-truncate mr-auto my-auto"><small>{{promo.DetArt}}</small></p> | 48 | <p class="text-truncate mr-auto my-auto"><small>{{promo.DetArt}}</small></p> |
49 | <p class="font-weight-bold my-auto pr-2"> | 49 | <p class="font-weight-bold my-auto pr-2"> |
50 | <span>{{promo.PreVen | currency}}</span> | 50 | <span>{{promo.PreVen | currency}}</span> |
51 | </p> | 51 | </p> |
52 | <img | 52 | <img |
53 | draggable="false" | 53 | draggable="false" |
54 | ondragstart="return false;" | 54 | ondragstart="return false;" |
55 | (contextmenu)="false" | 55 | (contextmenu)="false" |
56 | class="d-block icon-30 py-1" | 56 | class="d-block icon-30 py-1" |
57 | src="assets/img/ir-color.svg"> | 57 | src="assets/img/ir-color.svg"> |
58 | </div> | 58 | </div> |
59 | </div> | 59 | </div> |
60 | </div> | 60 | </div> |
61 | </div> | 61 | </div> |
62 | </div> | 62 | </div> |
63 | </div> | 63 | </div> |
64 | 64 |
src/app/shared/promocion/promocion.component.ts
1 | import { Component, OnInit, HostListener } from '@angular/core'; | 1 | import { Component, OnInit, HostListener } from '@angular/core'; |
2 | import { BsModalRef } from 'ngx-bootstrap/modal'; | 2 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; |
3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
4 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 4 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
5 | import { PromocionService } from 'src/app/services/promocion/promocion.service'; | 5 | import { PromocionService } from 'src/app/services/promocion/promocion.service'; |
6 | import { Subject } from 'rxjs'; | 6 | import { Subject } from 'rxjs'; |
7 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 7 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
8 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; | 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 | @Component({ | 13 | @Component({ |
11 | selector: 'app-promocion', | 14 | selector: 'app-promocion', |
12 | templateUrl: './promocion.component.html', | 15 | templateUrl: './promocion.component.html', |
13 | styleUrls: ['./promocion.component.scss'] | 16 | styleUrls: ['./promocion.component.scss'] |
14 | }) | 17 | }) |
15 | export class PromocionComponent implements OnInit { | 18 | export class PromocionComponent implements OnInit { |
16 | articulosPromo: IArticulo[] = []; | 19 | articulosPromo: IArticulo[] = []; |
17 | promociones: IArticulo[] = []; | 20 | promociones: IArticulo[] = []; |
18 | onClose: Subject<any>; | 21 | onClose: Subject<any>; |
19 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 22 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
20 | 23 | ||
21 | constructor( | 24 | constructor( |
22 | public modalRef: BsModalRef, | 25 | public modalRef: BsModalRef, |
26 | private modalService: BsModalService, | ||
23 | private articuloService: ArticuloService, | 27 | private articuloService: ArticuloService, |
24 | private promocionService: PromocionService, | 28 | private promocionService: PromocionService, |
29 | private sinonimoService: SinonimoService, | ||
25 | private inactiveScreen: InactiveScreenService, | 30 | private inactiveScreen: InactiveScreenService, |
26 | ) { | 31 | ) { |
27 | this.onClose = new Subject(); | 32 | this.onClose = new Subject(); |
28 | } | 33 | } |
29 | 34 | ||
30 | ngOnInit() { | 35 | ngOnInit() { |
31 | this.getPromociones(); | 36 | this.getPromociones(); |
32 | } | 37 | } |
33 | 38 | ||
34 | elegirPromo(promo: IArticulo) { | 39 | selectPromo(promo: IArticulo) { |
35 | promo.cantidad = 1; | 40 | this.sinonimoService.getSinonimos(promo.CodSec, promo.CodArt) |
36 | this.articuloService.setArticulo(promo); | 41 | .subscribe((res: ISinonimo[]) => { |
37 | this.modalRef.hide(); | 42 | if (res.length) { |
43 | this.openModalSinonimos(res); | ||
44 | } else { | ||
45 | promo.cantidad = 1; | ||
46 | this.articuloService.setArticulo(promo); | ||
47 | this.modalRef.hide(); | ||
48 | } | ||
49 | }, err => console.error(err)); | ||
50 | } | ||
51 | |||
52 | openModalSinonimos(sinonimosData: ISinonimo[]) { | ||
53 | this.modalRef = this.modalService.show(SinonimoComponent, { | ||
54 | initialState: { sinonimos: sinonimosData }, | ||
55 | class: 'modal-promo modal-dialog-centered' | ||
56 | }); | ||
38 | } | 57 | } |
39 | 58 | ||
40 | getPromociones() { | 59 | getPromociones() { |
41 | const sector = this.articulosPromo[0].CodSec; | 60 | const sector = this.articulosPromo[0].CodSec; |
42 | const codigo = this.articulosPromo[0].CodArt; | 61 | const codigo = this.articulosPromo[0].CodArt; |
43 | this.promocionService.getPromociones(sector, codigo) | 62 | this.promocionService.getPromociones(sector, codigo) |
44 | .subscribe((res: IArticulo[]) => { | 63 | .subscribe((res: IArticulo[]) => { |
45 | this.promociones = res; | 64 | this.promociones = res; |
46 | }, error => { console.error(error); }); | 65 | }, error => { console.error(error); }); |
47 | } | 66 | } |
48 | 67 | ||
49 | @HostListener('document:click', ['$event']) | 68 | @HostListener('document:click', ['$event']) |
50 | eventListener(event: Event) { | 69 | eventListener(event: Event) { |
51 | clearTimeout(this.inactiveScreen.timerReposo); | 70 | clearTimeout(this.inactiveScreen.timerReposo); |
52 | this.inactiveScreen.startTimeOutInactividad(); | 71 | this.inactiveScreen.startTimeOutInactividad(); |
53 | } | 72 | } |
54 | 73 | ||
55 | } | 74 | } |
56 | 75 |
src/app/shared/sinonimo/sinonimo.component.html
1 | <p>sinonimo works!</p> | 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 | CONTINUAR | ||
33 | <img | ||
34 | draggable="false" | ||
35 | ondragstart="return false;" | ||
36 | (contextmenu)="false" | ||
37 | class="icon-30" | ||
38 | src="assets/img/ir-color.svg"> | ||
39 | </div> | ||
40 | </div> | ||
41 | </div> | ||
2 | 42 |
src/app/shared/sinonimo/sinonimo.component.scss
1 | .lista-sinonimos { | ||
2 | min-height: auto; | ||
3 | max-height: 25vh; | ||
4 | } | ||
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'; | ||
3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | ||
2 | 4 | ||
3 | @Component({ | 5 | @Component({ |
4 | selector: 'app-sinonimo', | 6 | selector: 'app-sinonimo', |
5 | templateUrl: './sinonimo.component.html', | 7 | templateUrl: './sinonimo.component.html', |
6 | styleUrls: ['./sinonimo.component.scss'] | 8 | styleUrls: ['./sinonimo.component.scss'] |
7 | }) | 9 | }) |
8 | export class SinonimoComponent implements OnInit { | 10 | export class SinonimoComponent implements OnInit { |
11 | sinonimos: ISinonimo[] = []; | ||
12 | isValid: boolean; | ||
9 | 13 | ||
10 | constructor() { } | 14 | constructor() { } |
11 | 15 | ||
12 | ngOnInit() { | 16 | ngOnInit() { |
13 | } | 17 | } |
14 | 18 | ||
19 | selectArticulo(articulo: IArticulo) { | ||
20 | for (const s of this.sinonimos) { | ||
21 | for (const articulo of s.productos) { | ||
22 | articulo.seleccionado = false; | ||
23 | } | ||
24 | } | ||
25 | articulo.seleccionado = true; | ||
26 | } | ||
27 | |||
28 | validate() { | ||
29 | this.isValid = false; | ||
30 | for (const s of this.sinonimos) { | ||
31 | for (const articulo of s.productos) { | ||
32 | if (articulo.seleccionado) { | ||
33 | this.isValid = true; | ||
34 | } | ||
35 | } | ||
36 | } | ||
37 | return !this.isValid ? 'disabled' : ''; | ||
38 | } | ||
39 | |||
15 | } | 40 | } |
16 | 41 |
src/scss/styles-bootstrap.scss
1 | @import "node_modules/bootstrap/scss/functions"; | 1 | @import "node_modules/bootstrap/scss/functions"; |
2 | @import "node_modules/bootstrap/scss/variables"; | 2 | @import "node_modules/bootstrap/scss/variables"; |
3 | @import "node_modules/bootstrap/scss/mixins"; | 3 | @import "node_modules/bootstrap/scss/mixins"; |
4 | 4 | ||
5 | $primary: #aa006b; | 5 | $primary: #aa006b; |
6 | $secondary: #00acd8; | 6 | $secondary: #00acd8; |
7 | $info: #f4b223; | 7 | $info: #f4b223; |
8 | $light: #e6e7e9; | 8 | $light: #e6e7e9; |
9 | $dark: #61666c; | 9 | $dark: #61666c; |
10 | $theme-colors: ( | 10 | $theme-colors: ( |
11 | primary: $primary, | 11 | primary: $primary, |
12 | secondary: $secondary, | 12 | secondary: $secondary, |
13 | info: $info, | 13 | info: $info, |
14 | light: $light, | 14 | light: $light, |
15 | dark: $dark | 15 | dark: $dark |
16 | ); | 16 | ); |
17 | $border-radius: 1.5rem; | 17 | $border-radius: 1.5rem; |
18 | $border-radius-lg: 2.5rem; | 18 | $border-radius-lg: 2.5rem; |
19 | $border-radius-sm: 0.5rem; | 19 | $border-radius-sm: 0.5rem; |
20 | 20 | ||
21 | .custom-modal { | 21 | .custom-modal { |
22 | max-width: 90% !important; | 22 | max-width: 90% !important; |
23 | & > .modal-content { | 23 | & > .modal-content { |
24 | background-color: $primary !important; | 24 | background-color: $primary !important; |
25 | color: white; | 25 | color: white; |
26 | border: none !important; | 26 | border: none !important; |
27 | border-radius: $border-radius !important; | 27 | border-radius: $border-radius !important; |
28 | box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; | 28 | box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; |
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | .carousel-control { | 32 | .carousel-control { |
33 | visibility: hidden !important; | 33 | visibility: hidden !important; |
34 | } | 34 | } |
35 | 35 | ||
36 | .carousel, | 36 | .carousel, |
37 | .carousel-inner, | 37 | .carousel-inner, |
38 | .carousel-item, | 38 | .carousel-item, |
39 | .item { | 39 | .item { |
40 | height: 100% !important; | 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 | .modal-promo > div { | 58 | .modal-promo > div { |
44 | border: none !important; | 59 | border: none !important; |
45 | border-radius: 10rem; | 60 | border-radius: $border-radius; |
46 | margin-left: 10px !important; | 61 | margin-left: 10px !important; |
47 | } | 62 | } |
48 | 63 | ||
49 | @import "node_modules/bootstrap/scss/bootstrap"; | 64 | @import "node_modules/bootstrap/scss/bootstrap"; |
50 | 65 |
src/styles.scss
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 | .btn-effect { | 25 | .btn-effect { |
26 | transition: all 0.3s !important; | 26 | transition: all 0.3s !important; |
27 | &:hover { | 27 | &:hover { |
28 | cursor: pointer !important; | 28 | cursor: pointer !important; |
29 | opacity: 0.7 !important; | 29 | opacity: 0.7 !important; |
30 | } | 30 | } |
31 | &:active { | 31 | &:active { |
32 | transform: scale(1.02) !important; | 32 | transform: scale(1.02) !important; |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | .cursor-pointer { | 36 | .cursor-pointer { |
37 | cursor: pointer; | 37 | cursor: pointer; |
38 | } | 38 | } |
39 | 39 | ||
40 | p { | 40 | p { |
41 | margin: 0 !important; | 41 | margin: 0 !important; |
42 | } | 42 | } |
43 | 43 | ||
44 | .img-in-top { | 44 | .img-in-top { |
45 | position: absolute; | 45 | position: absolute; |
46 | top: -35px; | 46 | top: -35px; |
47 | left: 50%; | 47 | left: 50%; |
48 | height: 70px; | 48 | height: 70px; |
49 | -webkit-transform: translateX(-50%); | 49 | -webkit-transform: translateX(-50%); |
50 | transform: translateX(-50%); | 50 | transform: translateX(-50%); |
51 | } | 51 | } |
52 | 52 | ||
53 | .right-0 { | 53 | .right-0 { |
54 | right: 0; | 54 | right: 0; |
55 | } | 55 | } |
56 | 56 | ||
57 | .left-0 { | 57 | .left-0 { |
58 | left: 0; | 58 | left: 0; |
59 | } | 59 | } |
60 | 60 | ||
61 | .rotate-45 { | 61 | .rotate-45 { |
62 | transform: rotate(45deg); | 62 | transform: rotate(45deg); |
63 | } | 63 | } |
64 | 64 | ||
65 | .rotate-90 { | 65 | .rotate-90 { |
66 | transform: rotate(90deg); | 66 | transform: rotate(90deg); |
67 | } | 67 | } |
68 | 68 | ||
69 | .rotate-90-neg { | 69 | .rotate-90-neg { |
70 | transform: rotate(-90deg); | 70 | transform: rotate(-90deg); |
71 | } | 71 | } |
72 | 72 | ||
73 | .rotate-180-neg { | 73 | .rotate-180-neg { |
74 | transform: rotate(-180deg); | 74 | transform: rotate(-180deg); |
75 | } | 75 | } |
76 | |||
77 | .disabled { | ||
78 | opacity: 0.5; | ||
79 | } | ||
76 | 80 |