Commit f8485d30eec9215fd601a983a699e073a35470b0

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'master'

Master(mpuebla)

See merge request !65
src/app/components/amb-imagenes/amb-imagenes.component.html
... ... @@ -51,7 +51,7 @@
51 51 <img
52 52 *ngIf="item.fromGallery"
53 53 class="fade-in img-fluid w-100"
54   - src="{{item.imagen}}">
  54 + src="{{item.base64}}">
55 55 <button
56 56 (click)="deleteImage(articulo.imagenes, index)"
57 57 type="button"
... ... @@ -92,6 +92,7 @@
92 92 [itemsPerPage]="paginationData.pageSize"
93 93 (pageChanged)="pageChanged($event)"
94 94 [boundaryLinks]="true"
  95 + [disabled]="disabledPaginador"
95 96 previousText="&lsaquo;"
96 97 nextText="&rsaquo;"
97 98 firstText="&laquo;"
src/app/components/amb-imagenes/amb-imagenes.component.ts
... ... @@ -17,6 +17,7 @@ export class AmbImagenesComponent implements OnInit {
17 17 private auxProductos: Producto[] = [];
18 18 private searchTerm: string = '';
19 19 private paginationData: any;
  20 + private disabledPaginador: boolean = false;
20 21  
21 22 constructor(private productoService: ProductoService, private http: HttpClient) { }
22 23  
... ... @@ -38,20 +39,23 @@ export class AmbImagenesComponent implements OnInit {
38 39  
39 40 this.onLoad(file)
40 41 .then(result => {
41   -
42   - articulo.imagenes.push({
43   - name: file.name,
44   - fromGallery: true,
45   - imagen: result,
46   - id_articulo: articulo.id
47   - });
48   -
49   - this.saveInBase({
50   - name: file.name,
51   - base64: result,
52   - codigo: articulo.CodArt,
53   - sector: articulo.CodSec
54   - });
  42 + // articulo.imagenes.push({
  43 + // name: file.name + articulo.CodArt + articulo.CodSec,
  44 + // fromGallery: true,
  45 + // imagen: result,
  46 + // id_articulo: articulo.id
  47 + // });
  48 + let imagenAguardar = {
  49 + imagen: {
  50 + name: `${articulo.CodSec}${articulo.CodArt}${file.name}`,
  51 + base64: result,
  52 + codigo: articulo.CodArt,
  53 + sector: articulo.CodSec,
  54 + id_articulo: articulo.id
  55 + },
  56 + articulo: articulo
  57 + };
  58 + this.saveInBase(imagenAguardar);
55 59 });
56 60 })
57 61 }
... ... @@ -65,12 +69,13 @@ export class AmbImagenesComponent implements OnInit {
65 69 });
66 70 }
67 71  
  72 + saveInBase(imagenAguardar) {
68 73  
69   - saveInBase(img) {
70   -
71   - this.productoService.saveInBase(img)
72   - .subscribe(data => {
73   -
  74 + this.productoService.saveInBase(imagenAguardar.imagen)
  75 + .subscribe(res => {
  76 + imagenAguardar.imagen['id'] = res[0];
  77 + imagenAguardar.imagen['fromGallery'] = true;
  78 + imagenAguardar.articulo.imagenes.push(imagenAguardar.imagen);
74 79 }, error => console.error(error));
75 80 }
76 81  
... ... @@ -106,13 +111,14 @@ export class AmbImagenesComponent implements OnInit {
106 111 }
107 112  
108 113 pageChanged(event: any): void {
  114 + this.disabledPaginador = true;
109 115 this.productoService.getAllWithPaginator(event.page)
110   - .subscribe((res) => {
111   -
112   - this.articulos = res.data;
113   - this.paginationData = res.pagination;
114   - this.filterItems();
115   - }, error => console.error(error));
  116 + .subscribe((res) => {
  117 + this.disabledPaginador = false;
  118 + this.articulos = res.data;
  119 + this.paginationData = res.pagination;
  120 + this.filterItems();
  121 + }, error => console.error(error));
116 122 }
117 123  
118 124 }