Browse Source

fix(admin-ui): Preserve variant price changes between list/table views

Relates to #632
Michael Bromley 5 years ago
parent
commit
43bd77060b

+ 4 - 4
packages/admin-ui/src/lib/catalog/src/components/product-variants-list/product-variants-list.component.ts

@@ -29,11 +29,11 @@ import {
 import { DEFAULT_CHANNEL_CODE } from '@vendure/common/lib/shared-constants';
 import { DEFAULT_CHANNEL_CODE } from '@vendure/common/lib/shared-constants';
 import { notNullOrUndefined } from '@vendure/common/lib/shared-utils';
 import { notNullOrUndefined } from '@vendure/common/lib/shared-utils';
 import { PaginationInstance } from 'ngx-pagination';
 import { PaginationInstance } from 'ngx-pagination';
-import { Observable, Subscription } from 'rxjs';
+import { Subscription } from 'rxjs';
 import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
 import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
 
 
 import { AssetChange } from '../product-assets/product-assets.component';
 import { AssetChange } from '../product-assets/product-assets.component';
-import { VariantFormValue } from '../product-detail/product-detail.component';
+import { SelectedAssets, VariantFormValue } from '../product-detail/product-detail.component';
 import { UpdateProductOptionDialogComponent } from '../update-product-option-dialog/update-product-option-dialog.component';
 import { UpdateProductOptionDialogComponent } from '../update-product-option-dialog/update-product-option-dialog.component';
 
 
 export interface VariantAssetChange extends AssetChange {
 export interface VariantAssetChange extends AssetChange {
@@ -116,11 +116,11 @@ export class ProductVariantsListComponent implements OnChanges, OnInit, OnDestro
                 this.pagination.currentPage = 1;
                 this.pagination.currentPage = 1;
             }
             }
             if (this.channelPriceIncludesTax != null && Object.keys(this.variantListPrice).length === 0) {
             if (this.channelPriceIncludesTax != null && Object.keys(this.variantListPrice).length === 0) {
-                this.buildVariantListPrices(this.variants);
+                this.buildVariantListPrices(this.formArray.value);
             }
             }
         }
         }
         if ('channelPriceIncludesTax' in changes) {
         if ('channelPriceIncludesTax' in changes) {
-            this.buildVariantListPrices(this.variants);
+            this.buildVariantListPrices(this.formArray.value);
         }
         }
     }
     }
 
 

+ 2 - 2
packages/admin-ui/src/lib/catalog/src/components/product-variants-table/product-variants-table.component.ts

@@ -47,11 +47,11 @@ export class ProductVariantsTableComponent implements OnInit, OnChanges, OnDestr
     ngOnChanges(changes: SimpleChanges) {
     ngOnChanges(changes: SimpleChanges) {
         if ('variants' in changes) {
         if ('variants' in changes) {
             if (this.channelPriceIncludesTax != null && Object.keys(this.variantListPrice).length === 0) {
             if (this.channelPriceIncludesTax != null && Object.keys(this.variantListPrice).length === 0) {
-                this.buildVariantListPrices(this.variants);
+                this.buildVariantListPrices(this.formArray.value);
             }
             }
         }
         }
         if ('channelPriceIncludesTax' in changes) {
         if ('channelPriceIncludesTax' in changes) {
-            this.buildVariantListPrices(this.variants);
+            this.buildVariantListPrices(this.formArray.value);
         }
         }
     }
     }