Merged PR 1574: #4160 Hotfix Preselect InStore PurchasingOption Tile

#4160 Hotfix Preselect InStore PurchasingOption Tile
This commit is contained in:
Nino Righi
2023-07-06 14:34:42 +00:00
committed by Lorenz Hilpert
parent 90268b4ec1
commit 98e963d782
4 changed files with 19 additions and 6 deletions

View File

@@ -278,6 +278,7 @@ export class ArticleDetailsComponent implements OnInit, OnDestroy {
items: [item],
pickupBranch: selectedBranch,
inStoreBranch: selectedBranch,
preSelectOption: !!selectedBranch ? { option: 'in-store', showOptionOnly: true } : undefined,
})
.afterClosed$.subscribe(async (result) => {
if (result?.data === 'continue') {

View File

@@ -5,13 +5,15 @@
<div class="rounded p-4 shadow-card mt-4 grid grid-flow-col gap-4 justify-center items-center relative">
<ng-container *ngIf="!(isDownloadOnly$ | async)">
<ng-container *ngIf="!(isGiftCardOnly$ | async)">
<app-in-store-purchase-options-tile> </app-in-store-purchase-options-tile>
<app-pickup-purchase-options-tile> </app-pickup-purchase-options-tile>
<app-in-store-purchase-options-tile *ngIf="showOption('in-store')"> </app-in-store-purchase-options-tile>
<app-pickup-purchase-options-tile *ngIf="showOption('pickup')"></app-pickup-purchase-options-tile>
</ng-container>
<app-delivery-purchase-options-tile> </app-delivery-purchase-options-tile>
<app-delivery-purchase-options-tile *ngIf="showOption('delivery')"></app-delivery-purchase-options-tile>
</ng-container>
<app-download-purchase-options-tile *ngIf="hasDownload$ | async"> </app-download-purchase-options-tile>
<ng-container *ngIf="hasDownload$ | async">
<app-download-purchase-options-tile *ngIf="showOption('download')"> </app-download-purchase-options-tile>
</ng-container>
</div>
<shared-purchase-options-list-header></shared-purchase-options-list-header>
<div class="shared-purchase-options-modal__items -mx-4">

View File

@@ -12,7 +12,7 @@ import {
InStorePurchaseOptionTileComponent,
PickupPurchaseOptionTileComponent,
} from './purchase-options-tile';
import { isGiftCard, Item, PurchaseOptionsStore } from './store';
import { isGiftCard, Item, PurchaseOption, PurchaseOptionsStore } from './store';
import { delay, map, shareReplay, skip, switchMap, takeUntil } from 'rxjs/operators';
import { KeyValueDTOOfStringAndString } from '@swagger/cat';
@@ -97,6 +97,11 @@ export class PurchaseOptionsModalComponent implements OnInit, OnDestroy {
this.items$.pipe(takeUntil(this._onDestroy$), skip(1), delay(100)).subscribe((items) => {
if (items.length === 0) {
this._uiModalRef.close();
return;
}
if (!!this._uiModalRef.data?.preSelectOption?.option) {
this.store.setPurchaseOption(this._uiModalRef.data?.preSelectOption?.option);
}
});
}
@@ -108,6 +113,10 @@ export class PurchaseOptionsModalComponent implements OnInit, OnDestroy {
itemTrackBy: TrackByFunction<Item> = (_, item) => item.id;
showOption(option: PurchaseOption): boolean {
return this._uiModalRef.data?.preSelectOption?.showOptionOnly ? this._uiModalRef.data?.preSelectOption?.option === option : true;
}
async save(action: string) {
if (this.saving) {
return;

View File

@@ -1,6 +1,6 @@
import { ItemDTO } from '@swagger/cat';
import { ShoppingCartItemDTO, BranchDTO } from '@swagger/checkout';
import { ActionType } from './store';
import { ActionType, PurchaseOption } from './store';
export interface PurchaseOptionsModalData {
processId: number;
@@ -8,4 +8,5 @@ export interface PurchaseOptionsModalData {
items: Array<ItemDTO | ShoppingCartItemDTO>;
pickupBranch?: BranchDTO;
inStoreBranch?: BranchDTO;
preSelectOption?: { option: PurchaseOption; showOptionOnly?: boolean };
}