Artikel Scannen nach hinzufügen des artikels

This commit is contained in:
Lorenz Hilpert
2021-02-03 15:55:02 +01:00
parent 2d38e738b3
commit e5fd01b0c6
3 changed files with 41 additions and 7 deletions

View File

@@ -202,11 +202,11 @@
</div>
</div>
<div class="modal-footer">
<button class="btn-outline" [disabled]="(addItemsToCartDisabled || loading) && !isDownload">
<button class="btn-outline" [disabled]="addItemsToCartDisabled || loading" (click)="scanArticle()">
Artikel scannen
</button>
<button class="btn-outline" (click)="continueSearch()" [disabled]="(addItemsToCartDisabled || loading) && !isDownload">
<button class="btn-outline" (click)="continueSearch()" [disabled]="addItemsToCartDisabled || loading">
Weiter suchen
</button>
<app-button

View File

@@ -7,7 +7,7 @@ import { DeliveryOption } from '../../../../core/models/delivery-option.model';
import { ChangeCurrentRoute } from '../../../../core/store/actions/process.actions';
import { SetCartEntry } from '../../../../core/store/actions/cart-entry.actions';
import { Subject, Observable, of } from 'rxjs';
import { tap, map, filter, take, first } from 'rxjs/operators';
import { tap, map, filter, take, first, takeUntil } from 'rxjs/operators';
import { AddBreadcrumb, PopLastBreadcrumbs } from '../../../../core/store/actions/breadcrumb.actions';
import { Breadcrumb } from '../../../../core/models/breadcrumb.model';
import { BranchSelectors } from '../../../../core/store/selectors/branch.selector';
@@ -29,6 +29,7 @@ import { CartService } from '@domain/cart';
import { UiModalService } from '@ui/modal';
import { ApplicationService } from '@core/application';
import { CheckoutService } from '@domain/checkout';
import { NativeContainerService } from 'native-container';
@Component({
selector: 'app-checkout',
@@ -231,7 +232,8 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
private cdrf: ChangeDetectorRef,
private applicationService: ApplicationService,
private checkoutService: CheckoutService,
private actions: Actions
private actions: Actions,
private nativeContainer: NativeContainerService
) {}
ngOnInit() {
@@ -732,4 +734,24 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
}
}, 0);
}
async scanArticle() {
let query = '';
if (this.nativeContainer.isUiWebview()?.isNative) {
const result = await this.nativeContainer
.openScanner('scanBook')
.pipe(
takeUntil(this.destroy$),
filter((message) => message.status !== 'IN_PROGRESS'),
take(1)
)
.toPromise();
query = result.data;
}
this.store.dispatch(new ChangeCurrentRoute('/product/search', true, { query }));
this.router.navigate(['/product/search'], { queryParams: { query } });
}
}

View File

@@ -14,7 +14,7 @@ import {
} from '../../../../../../core/store/actions/process.actions';
import { LoadRecentProducts, SetProductCachedResults } from '../../../../../../core/store/actions/product.actions';
import { AfterViewInit, Component, Input, OnInit, ViewChild, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { Select, Store } from '@ngxs/store';
import { AutocompleteState } from '../../../../../../core/store/state/autocomplete.state';
import { LoadAutocomplete, CancelPendingAutocomplete } from '../../../../../../core/store/actions/autocomplete.actions';
@@ -83,7 +83,13 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('searchInput', { static: true }) searchInput: SearchInputComponent;
constructor(private store: Store, private router: Router, private productService: ProductService, private appService: AppService) {}
constructor(
private store: Store,
private router: Router,
private productService: ProductService,
private appService: AppService,
private activatedRoute: ActivatedRoute
) {}
ngOnInit() {
this.isIPad = this.appService.isIPadEnv();
@@ -116,11 +122,17 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
this.allFilters = allFilters;
});
let query = this.activatedRoute.snapshot.queryParams['query'];
this.store
.select(AppState.getCurrentProcessId)
.pipe(takeUntil(this.destroy$))
.subscribe((t) => {
if (!this.inputForProcess[t]) {
if (!!query) {
this.searchInput.updateInput(query);
this.searchInput.search.emit(query);
query = '';
} else if (!this.inputForProcess[t]) {
this.inputForProcess = { ...this.inputForProcess, [t]: ' ' };
this.searchInput.clear();
} else if (this.inputForProcess[t] !== ' ') {