Merged PR 1506: #3895 Purchaseing Options Modal Selected branch check if correct branchType i...

#3895 Purchaseing Options Modal Selected branch check if correct branchType is selected
This commit is contained in:
Nino Righi
2023-03-08 19:29:49 +00:00
committed by Lorenz Hilpert
parent fc5cf27bd1
commit d804a744b6
6 changed files with 38 additions and 9 deletions

View File

@@ -37,3 +37,8 @@ p {
@apply mx-auto;
width: 80%;
}
::ng-deep page-pick-up-option-list .option-chip:disabled,
::ng-deep page-take-away-option-list .option-chip:disabled {
@apply bg-disabled-branch border-disabled-branch text-white;
}

View File

@@ -13,6 +13,6 @@
<ui-branch-dropdown
[branches]="branches$ | async"
[selected]="(selectedBranch$ | async)?.name"
[selected]="selectedBranch$ | async"
(selectBranch)="selectBranch($event)"
></ui-branch-dropdown>

View File

@@ -1,6 +1,7 @@
import { Component, ChangeDetectionStrategy } from '@angular/core';
import { BranchDTO } from '@swagger/checkout';
import { first } from 'rxjs/operators';
import { combineLatest } from 'rxjs';
import { first, map } from 'rxjs/operators';
import { PurchasingOptionsListModalStore } from '../purchasing-options-list-modal.store';
@Component({
@@ -11,9 +12,20 @@ import { PurchasingOptionsListModalStore } from '../purchasing-options-list-moda
})
export class PickUpOptionListComponent {
branches$ = this._store.branches$;
selectedBranch$ = this._store.selectedPickUpBranch$;
selectedBranch$ = this._store.selectedPickUpBranch$.pipe(
map((branch) => {
// Determins if branch is targetBranch
if (branch?.branchType === 1) {
return branch.name;
}
})
);
selectedOption$ = this._store.selectedFilterOption$;
optionChipDisabled$ = this._store.fetchingAvailabilities$;
optionChipDisabled$ = combineLatest([this._store.fetchingAvailabilities$, this.selectedBranch$]).pipe(
map(([fetching, selectedBranch]) => {
return fetching || !selectedBranch;
})
);
constructor(private _store: PurchasingOptionsListModalStore) {}

View File

@@ -13,6 +13,6 @@
<ui-branch-dropdown
[branches]="branches$ | async"
[selected]="(selectedBranch$ | async)?.name"
[selected]="selectedBranch$ | async"
(selectBranch)="selectBranch($event)"
></ui-branch-dropdown>

View File

@@ -1,6 +1,7 @@
import { Component, ChangeDetectionStrategy } from '@angular/core';
import { BranchDTO } from '@swagger/checkout';
import { first } from 'rxjs/operators';
import { combineLatest } from 'rxjs';
import { first, map } from 'rxjs/operators';
import { PurchasingOptionsListModalStore } from '../purchasing-options-list-modal.store';
@Component({
@@ -11,9 +12,20 @@ import { PurchasingOptionsListModalStore } from '../purchasing-options-list-moda
})
export class TakeAwayOptionListComponent {
branches$ = this._store.branches$;
selectedBranch$ = this._store.selectedTakeAwayBranch$;
selectedBranch$ = this._store.selectedTakeAwayBranch$.pipe(
map((branch) => {
// Determins if branch is targetBranch
if (branch?.branchType === 1) {
return branch.name;
}
})
);
selectedOption$ = this._store.selectedFilterOption$;
optionChipDisabled$ = this._store.fetchingAvailabilities$;
optionChipDisabled$ = combineLatest([this._store.fetchingAvailabilities$, this.selectedBranch$]).pipe(
map(([fetching, selectedBranch]) => {
return fetching || !selectedBranch;
})
);
constructor(private _store: PurchasingOptionsListModalStore) {}

View File

@@ -16,7 +16,7 @@ export class PickUpOptionComponent {
selected$: Observable<string> = this._purchasingOptionsModalStore.selectBranch.pipe(
map((branch) => {
// Determins if branch is targetBranch
if (branch.branchType === 1) {
if (branch?.branchType === 1) {
return branch.name;
}
})