|
@@ -75,7 +75,8 @@ export interface SelectedAssets {
|
|
|
styleUrls: ['./product-detail.component.scss'],
|
|
styleUrls: ['./product-detail.component.scss'],
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
|
})
|
|
})
|
|
|
-export class ProductDetailComponent extends BaseDetailComponent<ProductWithVariants.Fragment>
|
|
|
|
|
|
|
+export class ProductDetailComponent
|
|
|
|
|
+ extends BaseDetailComponent<ProductWithVariants.Fragment>
|
|
|
implements OnInit, OnDestroy {
|
|
implements OnInit, OnDestroy {
|
|
|
activeTab$: Observable<TabName>;
|
|
activeTab$: Observable<TabName>;
|
|
|
product$: Observable<ProductWithVariants.Fragment>;
|
|
product$: Observable<ProductWithVariants.Fragment>;
|
|
@@ -259,14 +260,16 @@ export class ProductDetailComponent extends BaseDetailComponent<ProductWithVaria
|
|
|
* If creating a new product, automatically generate the slug based on the product name.
|
|
* If creating a new product, automatically generate the slug based on the product name.
|
|
|
*/
|
|
*/
|
|
|
updateSlug(nameValue: string) {
|
|
updateSlug(nameValue: string) {
|
|
|
- this.isNew$.pipe(take(1)).subscribe(isNew => {
|
|
|
|
|
- if (isNew) {
|
|
|
|
|
|
|
+ combineLatest(this.entity$, this.languageCode$)
|
|
|
|
|
+ .pipe(take(1))
|
|
|
|
|
+ .subscribe(([entity, languageCode]) => {
|
|
|
const slugControl = this.detailForm.get(['product', 'slug']);
|
|
const slugControl = this.detailForm.get(['product', 'slug']);
|
|
|
- if (slugControl && slugControl.pristine) {
|
|
|
|
|
|
|
+ const currentTranslation = entity.translations.find(t => t.languageCode === languageCode);
|
|
|
|
|
+ const currentSlugIsEmpty = !currentTranslation || !currentTranslation.slug;
|
|
|
|
|
+ if (slugControl && slugControl.pristine && currentSlugIsEmpty) {
|
|
|
slugControl.setValue(normalizeString(`${nameValue}`, '-'));
|
|
slugControl.setValue(normalizeString(`${nameValue}`, '-'));
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
selectProductFacetValue() {
|
|
selectProductFacetValue() {
|