@vendure/admin-ui 1.9.0 → 1.9.1

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.
@@ -1420,27 +1420,27 @@ class ProductDetailComponent extends BaseDetailComponent {
1420
1420
  ngOnInit() {
1421
1421
  this.init();
1422
1422
  this.product$ = this.entity$;
1423
- this.totalItems$ = this.product$.pipe(map(product => product.variantList.totalItems));
1424
- this.paginationConfig$ = combineLatest(this.totalItems$, this.itemsPerPage$, this.currentPage$).pipe(map(([totalItems, itemsPerPage, currentPage]) => ({
1425
- totalItems,
1426
- itemsPerPage,
1427
- currentPage,
1428
- })));
1429
- const variants$ = this.product$.pipe(map(product => product.variantList.items));
1430
- const filterTerm$ = this.filterInput.valueChanges.pipe(startWith(''), debounceTime(200), shareReplay());
1423
+ const filterTerm$ = this.filterInput.valueChanges.pipe(startWith(''), debounceTime(200), shareReplay(), tap(() => this.currentPage$.next(1)));
1431
1424
  const initialVariants$ = this.product$.pipe(map(p => p.variantList.items));
1432
- const updatedVariants$ = combineLatest(filterTerm$, this.currentPage$, this.itemsPerPage$).pipe(skipUntil(initialVariants$), skip(1), switchMap(([term, currentPage, itemsPerPage]) => {
1425
+ const variantsList$ = combineLatest(filterTerm$, this.currentPage$, this.itemsPerPage$).pipe(skipUntil(initialVariants$), skip(1), debounceTime(100), switchMap(([term, currentPage, itemsPerPage]) => {
1433
1426
  return this.dataService.product
1434
1427
  .getProductVariants(Object.assign(Object.assign({ skip: (currentPage - 1) * itemsPerPage, take: itemsPerPage }, (term
1435
1428
  ? { filter: { name: { contains: term }, sku: { contains: term } } }
1436
1429
  : {})), { filterOperator: LogicalOperator.OR }), this.id)
1437
- .mapStream(({ productVariants }) => productVariants.items);
1430
+ .mapStream(({ productVariants }) => productVariants);
1438
1431
  }), shareReplay({ bufferSize: 1, refCount: true }));
1432
+ const updatedVariants$ = variantsList$.pipe(map(result => result.items));
1439
1433
  this.variants$ = merge(initialVariants$, updatedVariants$).pipe(tap(variants => {
1440
1434
  for (const variant of variants) {
1441
1435
  this.productVariantMap.set(variant.id, variant);
1442
1436
  }
1443
1437
  }));
1438
+ this.totalItems$ = merge(this.product$.pipe(map(product => product.variantList.totalItems)), variantsList$.pipe(map(result => result.totalItems)));
1439
+ this.paginationConfig$ = combineLatest(this.totalItems$, this.itemsPerPage$, this.currentPage$).pipe(map(([totalItems, itemsPerPage, currentPage]) => ({
1440
+ totalItems,
1441
+ itemsPerPage,
1442
+ currentPage,
1443
+ })));
1444
1444
  this.taxCategories$ = this.productDetailService.getTaxCategories().pipe(takeUntil(this.destroy$));
1445
1445
  this.activeTab$ = this.route.paramMap.pipe(map(qpm => qpm.get('tab')));
1446
1446
  combineLatest(updatedVariants$, this.languageCode$)
@@ -4417,7 +4417,7 @@ class ProductVariantsListComponent {
4417
4417
  }
4418
4418
  onAssetChange(variantId, event) {
4419
4419
  this.assetChange.emit(Object.assign({ variantId }, event));
4420
- const index = this.variants.findIndex(v => v.id === variantId);
4420
+ const index = this.formArray.controls.findIndex(c => c.value.id === variantId);
4421
4421
  this.formArray.at(index).markAsDirty();
4422
4422
  }
4423
4423
  toggleSelectAll() {