#1982 Artikellink => Fehler

This commit is contained in:
Lorenz Hilpert
2021-07-07 14:53:37 +02:00
parent 0b5cdd7e19
commit 691d18f296
4 changed files with 25 additions and 17 deletions

View File

@@ -16,6 +16,7 @@ import { ProductImageService } from 'apps/cdn/product-image/src/public-api';
import { ModalAvailabilitiesComponent } from '@modal/availabilities';
import { slideYAnimation } from './slide.animation';
import { BreadcrumbService } from '@core/breadcrumb';
import { ItemDTO } from '@swagger/cat';
@Component({
selector: 'page-article-details',
@@ -83,23 +84,32 @@ export class ArticleDetailsComponent implements OnInit, OnDestroy {
this.subscriptions.add(this.store.loadItemById(id$));
this.subscriptions.add(this.store.loadItemByEan(ean$));
this.subscriptions.add(
this.store.item$.pipe(filter((item) => !!item)).subscribe((item) =>
this.breadcrumb.addBreadcrumbIfNotExists({
key: this.application.activatedProcessId,
name: item.product?.name,
path: `/product/details/${item.id}`,
params: this.activatedRoute.snapshot.queryParams,
tags: ['catalog', 'details', `${item.id}`],
})
)
);
this.subscriptions.add(this.store.item$.pipe(filter((item) => !!item)).subscribe((item) => this.updateBreadcrumb(item)));
}
ngOnDestroy() {
this.subscriptions.unsubscribe();
}
async updateBreadcrumb(item: ItemDTO) {
const crumbs = await this.breadcrumb
.getBreadcrumbsByKeyAndTags$(this.application.activatedProcessId, ['catalog', 'details', `${item.id}`])
.pipe(first())
.toPromise();
for (const crumb of crumbs) {
await this.breadcrumb.removeBreadcrumbsAfter(crumb.id);
}
this.breadcrumb.addBreadcrumbIfNotExists({
key: this.application.activatedProcessId,
name: item.product?.name,
path: `/product/details/${item.id}`,
params: this.activatedRoute.snapshot.queryParams,
tags: ['catalog', 'details', `${item.id}`],
});
}
async print() {
const item = await this.store.item$.pipe(first()).toPromise();
this.uiModal.open({

View File

@@ -252,7 +252,7 @@ export class ArticleDetailsStore extends ComponentStore<ArticleDetailsState> {
tapResponse<ResponseArgsOfItemDTO>(
(response) => this.patchState({ item: response.result, fetchingItem: false }),
(err) => {
console.log('loadItemById failed', err);
console.error('loadItemById failed', err);
this.patchState({ item: undefined, fetchingItem: false });
}
)
@@ -267,7 +267,7 @@ export class ArticleDetailsStore extends ComponentStore<ArticleDetailsState> {
tapResponse<ResponseArgsOfItemDTO>(
(response) => this.patchState({ item: response.result, fetchingItem: false }),
(err) => {
console.log('loadItemByEan failed', err);
console.error('loadItemByEan failed', err);
this.patchState({ item: undefined, fetchingItem: false });
}
)

View File

@@ -116,7 +116,7 @@
<img [src]="item?.product?.ean | productImage: 50:50:true" alt="product-image" />
</div>
<div class="product-name">
<a [queryParams]="{ type: 'ean' }" [routerLink]="['/product', 'details', item?.product?.ean]">{{ item?.product?.name }}</a>
<a [routerLink]="['/product', 'details', 'ean', item?.product?.ean]">{{ item?.product?.name }}</a>
</div>
<div
class="product-misc-container"

View File

@@ -59,9 +59,7 @@
<div class="row between">
<div class="product-name">
<img class="thumbnail" [src]="order.product?.ean | productImage: 30:50:true" />
<a class="name" [queryParams]="{ type: 'ean' }" [routerLink]="['/product', 'details', order?.product?.ean]">{{
order?.product?.name
}}</a>
<a class="name" [routerLink]="['/product', 'details', 'ean', order?.product?.ean]">{{ order?.product?.name }}</a>
</div>
<div class="product-details">