@wizishop/img-manager 15.0.3 → 15.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, EventEmitter, Directive, Input, Output, Pipe, Component, ViewEncapsulation, HostBinding, HostListener, ViewChild, Inject, NgModule } from '@angular/core';
3
- import { ReplaySubject, Observable, Subject, BehaviorSubject, forkJoin } from 'rxjs';
3
+ import { ReplaySubject, Observable, of, delay, tap, Subject, BehaviorSubject, forkJoin } from 'rxjs';
4
4
  import * as i3 from '@angular/common/http';
5
5
  import { HttpParams, HttpHeaders, HttpClientModule } from '@angular/common/http';
6
6
  import * as i7 from '@ngx-translate/core';
7
7
  import { TranslateModule } from '@ngx-translate/core';
8
8
  import * as i1 from '@wizishop/ng-wizi-bulma';
9
9
  import { NwbAllModule } from '@wizishop/ng-wizi-bulma';
10
- import { take, debounceTime, map, takeUntil, distinctUntilChanged, tap } from 'rxjs/operators';
10
+ import { take, debounceTime, map, takeUntil, distinctUntilChanged, tap as tap$1 } from 'rxjs/operators';
11
11
  import * as i2 from '@angular/common';
12
12
  import { DOCUMENT, CommonModule } from '@angular/common';
13
13
  import { trigger, state, style, transition, animate, query, stagger } from '@angular/animations';
@@ -209,7 +209,13 @@ class ImgManagerService {
209
209
  return header;
210
210
  }
211
211
  getShopImgList(params) {
212
- return this.http.get(`${this.imgManagerRoute}/images`, this.getOptionsHeaders(params));
212
+ if (params && this.previousParams && this.previousParams.limit === params.limit && this.previousParams.page === params.page && this.shopImgList) {
213
+ return of(this.shopImgList).pipe(delay(0));
214
+ }
215
+ return this.http.get(`${this.imgManagerRoute}/images`, this.getOptionsHeaders(params)).pipe(tap((shopImgList) => {
216
+ this.shopImgList = shopImgList;
217
+ this.previousParams = params;
218
+ }));
213
219
  }
214
220
  getShopTotalImgList(params) {
215
221
  return this.http.get(`${this.imgManagerRoute}/total/image`, this.getOptionsHeaders(params));
@@ -1279,7 +1285,7 @@ class AbstractDebounceDirective {
1279
1285
  }
1280
1286
  ngOnInit() {
1281
1287
  this.emitEvent$
1282
- .pipe(takeUntil(this.subscription$), debounceTime(this.debounceTime), distinctUntilChanged(), tap(value => this.emitChange(value)))
1288
+ .pipe(takeUntil(this.subscription$), debounceTime(this.debounceTime), distinctUntilChanged(), tap$1(value => this.emitChange(value)))
1283
1289
  .subscribe();
1284
1290
  }
1285
1291
  emitChange(value) {
@@ -3143,7 +3149,7 @@ class ImagesViewComponent {
3143
3149
  this.nbImgToDelSelected = 0;
3144
3150
  this.disable = false; // Use to disable action during server request
3145
3151
  this.isLoading = true;
3146
- this.isTotalRetieved = false;
3152
+ this.isTotalRetrieved = false;
3147
3153
  this.delListImgLoader = false;
3148
3154
  this.initComponent = true;
3149
3155
  this.failLoaded = false;
@@ -3346,7 +3352,7 @@ class ImagesViewComponent {
3346
3352
  * Set a img list in order to fill properly all the line of images displayed in mosaic.
3347
3353
  * Otherwise, the space-between css will do a bad display
3348
3354
  */
3349
- calculNbImgFake(nbImgDisplayed) {
3355
+ calculateNbImgFake(nbImgDisplayed) {
3350
3356
  const nbImgPerLine = this.stateDisplayed === 'small' || this.tabDisplayed === 'img-upload' ? this.nbMaxImgPerLine : this.nbMinImgPerLine;
3351
3357
  if (nbImgDisplayed % nbImgPerLine !== 0) {
3352
3358
  this.nbFakeImg = nbImgPerLine - nbImgDisplayed % nbImgPerLine;
@@ -3417,35 +3423,38 @@ class ImagesViewComponent {
3417
3423
  this.displayPexelsResults = false;
3418
3424
  this.setParams();
3419
3425
  this.refreshTotalImgList();
3420
- this.imgManager.getShopImgList(this.params).pipe(take(1)).subscribe((data) => {
3421
- this.initVariables(true);
3422
- const nbImgDisplayed = data.data.length;
3423
- this.calculNbImgFake(nbImgDisplayed);
3424
- this.picturesList = data.data;
3425
- this.renamePictureService.setPicturesList(this.picturesList);
3426
- this.selectImgSelected();
3427
- this.length = this.isTotalRetieved ? this.length : data.totalRecords;
3428
- this.tableFilters.totalItems = this.isTotalRetieved ? this.tableFilters.totalItems : data.totalRecords;
3429
- this.tableFilters.itemsPerPage = this.tableFilters.itemsPerPage ? this.tableFilters.itemsPerPage : this.pageSize;
3430
- // Display Pexels if no result
3431
- if (data.totalRecords === 0) {
3432
- this.displayPexelsLib();
3426
+ this.imgManager.getShopImgList(this.params).pipe(take(1)).subscribe({
3427
+ next: (data) => {
3428
+ this.initVariables(true);
3429
+ const nbImgDisplayed = data.data.length;
3430
+ this.calculateNbImgFake(nbImgDisplayed);
3431
+ this.picturesList = data.data;
3432
+ this.renamePictureService.setPicturesList(this.picturesList);
3433
+ this.selectImgSelected();
3434
+ this.length = this.isTotalRetrieved ? this.length : data.totalRecords;
3435
+ this.tableFilters.totalItems = this.isTotalRetrieved ? this.tableFilters.totalItems : data.totalRecords;
3436
+ this.tableFilters.itemsPerPage = this.tableFilters.itemsPerPage ? this.tableFilters.itemsPerPage : this.pageSize;
3437
+ // Display Pexels if no result
3438
+ if (data.totalRecords === 0) {
3439
+ this.displayPexelsLib();
3440
+ }
3441
+ },
3442
+ error: error => {
3443
+ this.alertService.openAlert(this.errorGetAllImg);
3444
+ this.initVariables(false);
3433
3445
  }
3434
- }, error => {
3435
- this.alertService.openAlert(this.errorGetAllImg);
3436
- this.initVariables(false);
3437
3446
  });
3438
3447
  }
3439
3448
  refreshTotalImgList() {
3440
3449
  const searchValue = this.tableFilters.searchValue;
3441
- if (this.isTotalRetieved && searchValue === this.previousSearchValue) {
3450
+ if (this.isTotalRetrieved && searchValue === this.previousSearchValue) {
3442
3451
  // Keep current total result
3443
3452
  return;
3444
3453
  }
3445
- this.isTotalRetieved = false;
3454
+ this.isTotalRetrieved = false;
3446
3455
  this.imgManager.getShopTotalImgList(this.params).pipe(take(1)).subscribe((data) => {
3447
3456
  this.previousSearchValue = searchValue;
3448
- this.isTotalRetieved = true;
3457
+ this.isTotalRetrieved = true;
3449
3458
  this.length = data.totalRecords;
3450
3459
  this.tableFilters.totalItems = data.totalRecords;
3451
3460
  }, error => {
@@ -4140,3 +4149,4 @@ class ImgCDNConfigDTO {
4140
4149
 
4141
4150
  export { CanvaButtonApi, CanvaService, ImgApiDto, ImgCDNConfigDTO, ImgManagerConfigDto, ImgManagerService, ImgSelectionService, RenamePictureService, WzImgManagerComponent, WzImgManagerModule };
4142
4151
  //# sourceMappingURL=wizishop-img-manager.mjs.map
4152
+ //# sourceMappingURL=wizishop-img-manager.mjs.map