[HIMA-848] fixed error display for case of scanning not correct customer card barcode

This commit is contained in:
Eraldo Hasanaj
2020-02-24 15:07:39 +01:00
parent c8b49d7bf0
commit d7eb4a2cb6
2 changed files with 43 additions and 42 deletions

View File

@@ -21,8 +21,8 @@ export class ErrorComponent implements OnInit, OnDestroy {
safeMode = false;
invalidAttributes: { key: string; value: string }[];
hasInvalidAttributes = false;
safeCodes = [400, 409];
validMessageCodes = [0, 400, 409, 500, 504];
safeCodes = [400, 409, 404];
validMessageCodes = [0, 400, 404, 409, 500, 504];
title = 'Irgendwas hat nicht funktioniert…';
constructor(
private modalService: ModalService,

View File

@@ -1,8 +1,8 @@
import { Component, OnInit, ViewChild, OnDestroy, ChangeDetectorRef, AfterViewInit } from '@angular/core';
import { Router } from '@angular/router';
import { Store, Select } from '@ngxs/store';
import { Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { Observable, Subject, of } from 'rxjs';
import { takeUntil, catchError } from 'rxjs/operators';
import { CustomerInfoDTO } from 'swagger/lib/crm/models/customer-info-dto';
import { CustomerCardScannerScanditComponent } from 'shared/lib/customer-card-scanner';
import { CustomerService } from 'apps/sales/src/app/core/services/customer.service';
@@ -13,17 +13,14 @@ import { Breadcrumb } from '../../../../core/models/breadcrumb.model';
import { AddBreadcrumb } from '../../../../core/store/actions/breadcrumb.actions';
import { ProcessSelectors } from '../../../../core/store/selectors/process.selectors';
import { CustomerCardManualEntryComponent } from '../../components/customer-card-manual-entry/customer-card-manual-entry.component';
import {
CustomerCardSearchEmptyModalComponent
} from '../../components/customer-card-search-empty-modal/customer-card-search-empty-modal.component';
import {
CustomerCardSearchErrorModalComponent
} from '../../components/customer-card-search-error-modal/customer-card-search-error-modal.component';
import { CustomerCardSearchEmptyModalComponent } from '../../components/customer-card-search-empty-modal/customer-card-search-empty-modal.component';
import { CustomerCardSearchErrorModalComponent } from '../../components/customer-card-search-error-modal/customer-card-search-error-modal.component';
import { ErrorService } from 'apps/sales/src/app/core/error/component/error.service';
@Component({
selector: 'app-customer-card-barcode-search',
templateUrl: 'customer-card-barcode-search.component.html',
styleUrls: ['customer-card-barcode-search.component.scss'],
styleUrls: ['customer-card-barcode-search.component.scss']
})
export class CustomerCardBarcodeSearchComponent implements OnInit, OnDestroy, AfterViewInit {
@ViewChild('scanner') scanner: CustomerCardScannerScanditComponent;
@@ -43,7 +40,8 @@ export class CustomerCardBarcodeSearchComponent implements OnInit, OnDestroy, Af
private router: Router,
protected customerService: CustomerService,
private cdrf: ChangeDetectorRef,
private windowRef: WindowRef
private windowRef: WindowRef,
private errorService: ErrorService
) {}
ngOnInit() {
@@ -74,35 +72,38 @@ export class CustomerCardBarcodeSearchComponent implements OnInit, OnDestroy, Af
this.customerService
.validateScannedCustomer(barcode)
.pipe(takeUntil(this.destroy$))
.subscribe((customers: CustomerInfoDTO[]) => {
if (customers.length > 0) {
this.store.dispatch(
new AddBreadcrumb(
{
name: (barcode.length > 12 ? barcode.substring(0, 12) + '...' : barcode) + ` (${customers.length} Ergebnisse)`,
path: '/customer/results',
queryParams: { scan: true },
},
'customer'
)
);
this.store.dispatch(
new AddCustomerSearch({
query: barcode,
skip: 0,
take: 5,
firstLoad: true,
})
);
this.store.dispatch(new ChangeCurrentRoute('/customer/results'));
this.router.navigate(['/customer/results'], { queryParams: { scan: true } });
} else {
this.scanner.scanToggle();
this.searchCardEmptyModal.openDialog();
.subscribe(
(customers: CustomerInfoDTO[]) => {
if (customers.length > 0) {
this.store.dispatch(
new AddBreadcrumb(
{
name: (barcode.length > 12 ? barcode.substring(0, 12) + '...' : barcode) + ` (${customers.length} Ergebnisse)`,
path: '/customer/results',
queryParams: { scan: true }
},
'customer'
)
);
this.store.dispatch(
new AddCustomerSearch({
query: barcode,
skip: 0,
take: 5,
firstLoad: true
})
);
this.store.dispatch(new ChangeCurrentRoute('/customer/results'));
this.router.navigate(['/customer/results'], { queryParams: { scan: true } });
} else {
this.scanner.scanToggle();
this.searchCardEmptyModal.openDialog();
}
},
e => {
this.errorService.addErrors(e.status, e.message, undefined);
}
}, e => {
this.searchCardErrorModal.openDialog(`${e.status} ${e.statusText}`, e.message);
});
);
}
details(data: string): void {
@@ -116,7 +117,7 @@ export class CustomerCardBarcodeSearchComponent implements OnInit, OnDestroy, Af
const newProcess = <Process>{
id: 1,
name: 'Vorgang 1',
currentRoute: '/customer/search',
currentRoute: '/customer/search'
};
this.store.dispatch(new AddProcess(newProcess));
@@ -124,7 +125,7 @@ export class CustomerCardBarcodeSearchComponent implements OnInit, OnDestroy, Af
new AddBreadcrumb(
<Breadcrumb>{
name: 'Kundenkarte scannen',
path: '/customer/search',
path: '/customer/search'
},
'customer'
)