Commit 542c7962883e05d084e4473722889399ccee536e
1 parent
8a64d48315
Exists in
master
Agregada func para ordenar productos sin imagenes.
Showing
3 changed files
with
21 additions
and
18 deletions
Show diff stats
src/app/components/abm-imagenes/abm-imagenes.component.html
... | ... | @@ -41,20 +41,20 @@ |
41 | 41 | <p class="m-0"><small>Sector: {{articulo.CodSec}}</small></p> |
42 | 42 | <p class="m-0"><small>Código: {{articulo.CodArt}}</small></p> |
43 | 43 | </td> |
44 | - <td> | |
44 | + <td class="text-center"> | |
45 | 45 | <img |
46 | 46 | *ngIf="articulo.imagenes.length == 0" |
47 | - class="fade-in w-100 mx-auto img-fluid" | |
47 | + class="fade-in w-75" | |
48 | 48 | src="{{apiImagenes}}/imagenes/noImage.jpg"> |
49 | 49 | <carousel [interval]="false"> |
50 | 50 | <slide *ngFor="let item of articulo.imagenes; let index = index"> |
51 | 51 | <img |
52 | 52 | *ngIf="!item.fromGallery" |
53 | - class="fade-in img-fluid w-100" | |
53 | + class="fade-in w-75" | |
54 | 54 | src="{{apiImagenes}}/imagenes/{{item.imagen}}"> |
55 | 55 | <img |
56 | 56 | *ngIf="item.fromGallery" |
57 | - class="fade-in img-fluid w-100" | |
57 | + class="fade-in w-75" | |
58 | 58 | src="{{item.base64}}"> |
59 | 59 | <button |
60 | 60 | (click)="deleteImage(articulo.imagenes, index)" |
src/app/components/abm-imagenes/abm-imagenes.component.scss
src/app/components/abm-imagenes/abm-imagenes.component.ts
... | ... | @@ -32,9 +32,9 @@ export class AbmImagenesComponent implements OnInit { |
32 | 32 | this.buscando = true; |
33 | 33 | |
34 | 34 | this.imagenService.getAllWithPaginator(this.searchTerm) |
35 | - .subscribe((res) => { | |
35 | + .subscribe((res: any) => { | |
36 | 36 | |
37 | - this.articulos = res.data; | |
37 | + this.articulos = this.sortImages(res.data); | |
38 | 38 | this.paginationData = res.pagination; |
39 | 39 | this.buscando = false; |
40 | 40 | }, error => console.error(error)); |
... | ... | @@ -69,15 +69,6 @@ export class AbmImagenesComponent implements OnInit { |
69 | 69 | }) |
70 | 70 | } |
71 | 71 | |
72 | - // filterItems() { | |
73 | - | |
74 | - // this.auxProductos = this.articulos.filter(x => { | |
75 | - // return x.DET_LAR.toLowerCase().includes(this.searchTerm.toLowerCase()) || | |
76 | - // x.CodArt.toString().includes(this.searchTerm.toLowerCase()) || | |
77 | - // x.CodSec.toString().includes(this.searchTerm.toLowerCase()); | |
78 | - // }); | |
79 | - // } | |
80 | - | |
81 | 72 | saveInBase(imagenAguardar) { |
82 | 73 | |
83 | 74 | this.imagenService.saveInBase(imagenAguardar.imagen) |
... | ... | @@ -115,6 +106,7 @@ export class AbmImagenesComponent implements OnInit { |
115 | 106 | |
116 | 107 | if (res) { |
117 | 108 | imagenes.splice(index, 1); |
109 | + this.sortImages(this.articulos); | |
118 | 110 | } |
119 | 111 | }, error => console.error(error)); |
120 | 112 | } |
... | ... | @@ -123,11 +115,22 @@ export class AbmImagenesComponent implements OnInit { |
123 | 115 | this.disabledPaginador = true; |
124 | 116 | this.imagenService.getAllWithPaginator('', event.page) |
125 | 117 | .subscribe((res) => { |
118 | + | |
126 | 119 | this.disabledPaginador = false; |
127 | - this.articulos = res.data; | |
120 | + this.articulos = this.sortImages(res.data); | |
128 | 121 | this.paginationData = res.pagination; |
129 | - // this.filterItems(); | |
130 | 122 | }, error => console.error(error)); |
131 | 123 | } |
132 | 124 | |
125 | + sortImages(productos: Producto[]) { | |
126 | + | |
127 | + productos.reverse().forEach((producto, i) => { | |
128 | + if (producto.imagenes.length === 0) { | |
129 | + productos.unshift(producto); | |
130 | + productos.splice(i, 1); | |
131 | + } | |
132 | + }) | |
133 | + return productos; | |
134 | + } | |
135 | + | |
133 | 136 | } |