mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
swagger libs refactoring
This commit is contained in:
362
angular.json
362
angular.json
@@ -27,13 +27,8 @@
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"libs/ui/tsconfig.lib.json",
|
||||
"libs/ui/tsconfig.spec.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
"tsConfig": ["libs/ui/tsconfig.lib.json", "libs/ui/tsconfig.spec.json"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,9 +54,7 @@
|
||||
"apps/sales/src/manifest.webmanifest",
|
||||
"apps/sales/src/silent-refresh.html"
|
||||
],
|
||||
"styles": [
|
||||
"apps/sales/src/styles.scss"
|
||||
],
|
||||
"styles": ["apps/sales/src/styles.scss"],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
@@ -144,27 +137,16 @@
|
||||
"polyfills": "apps/sales/src/polyfills.ts",
|
||||
"tsConfig": "apps/sales/tsconfig.spec.json",
|
||||
"karmaConfig": "apps/sales/karma.conf.js",
|
||||
"styles": [
|
||||
"apps/sales/src/styles.scss"
|
||||
],
|
||||
"styles": ["apps/sales/src/styles.scss"],
|
||||
"scripts": [],
|
||||
"assets": [
|
||||
"apps/sales/src/favicon.ico",
|
||||
"apps/sales/src/assets",
|
||||
"apps/sales/src/manifest.webmanifest"
|
||||
]
|
||||
"assets": ["apps/sales/src/favicon.ico", "apps/sales/src/assets", "apps/sales/src/manifest.webmanifest"]
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"apps/sales/tsconfig.app.json",
|
||||
"apps/sales/tsconfig.spec.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
"tsConfig": ["apps/sales/tsconfig.app.json", "apps/sales/tsconfig.spec.json"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,114 +175,7 @@
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": "apps/sales-e2e/tsconfig.e2e.json",
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"swagger": {
|
||||
"root": "libs/swagger",
|
||||
"sourceRoot": "libs/swagger/src",
|
||||
"projectType": "library",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||
"options": {
|
||||
"tsConfig": "libs/swagger/tsconfig.lib.json",
|
||||
"project": "libs/swagger/ng-package.json"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "libs/swagger/src/test.ts",
|
||||
"tsConfig": "libs/swagger/tsconfig.spec.json",
|
||||
"karmaConfig": "libs/swagger/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"libs/swagger/tsconfig.lib.json",
|
||||
"libs/swagger/tsconfig.spec.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"mock": {
|
||||
"root": "libs/mock",
|
||||
"sourceRoot": "libs/mock/src",
|
||||
"projectType": "library",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||
"options": {
|
||||
"tsConfig": "libs/mock/tsconfig.lib.json",
|
||||
"project": "libs/mock/ng-package.json"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "libs/mock/src/test.ts",
|
||||
"tsConfig": "libs/mock/tsconfig.spec.json",
|
||||
"karmaConfig": "libs/mock/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"libs/mock/tsconfig.lib.json",
|
||||
"libs/mock/tsconfig.spec.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"shared": {
|
||||
"root": "libs/shared",
|
||||
"sourceRoot": "libs/shared/src",
|
||||
"projectType": "library",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||
"options": {
|
||||
"tsConfig": "libs/shared/tsconfig.lib.json",
|
||||
"project": "libs/shared/ng-package.json"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "libs/shared/src/test.ts",
|
||||
"tsConfig": "libs/shared/tsconfig.spec.json",
|
||||
"karmaConfig": "libs/shared/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"libs/shared/tsconfig.lib.json",
|
||||
"libs/shared/tsconfig.spec.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,17 +204,222 @@
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"libs/sso/tsconfig.lib.json",
|
||||
"libs/sso/tsconfig.spec.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
"tsConfig": ["libs/sso/tsconfig.lib.json", "libs/sso/tsconfig.spec.json"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@swagger/availability": {
|
||||
"root": "apps/swagger/availability",
|
||||
"sourceRoot": "apps/swagger/availability/src",
|
||||
"projectType": "library",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||
"options": {
|
||||
"tsConfig": "apps/swagger/availability/tsconfig.lib.json",
|
||||
"project": "apps/swagger/availability/ng-package.json"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "apps/swagger/availability/src/test.ts",
|
||||
"tsConfig": "apps/swagger/availability/tsconfig.spec.json",
|
||||
"karmaConfig": "apps/swagger/availability/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": ["apps/swagger/availability/tsconfig.lib.json", "apps/swagger/availability/tsconfig.spec.json"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@swagger/checkout": {
|
||||
"root": "apps/swagger/checkout",
|
||||
"sourceRoot": "apps/swagger/checkout/src",
|
||||
"projectType": "library",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||
"options": {
|
||||
"tsConfig": "apps/swagger/checkout/tsconfig.lib.json",
|
||||
"project": "apps/swagger/checkout/ng-package.json"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "apps/swagger/checkout/src/test.ts",
|
||||
"tsConfig": "apps/swagger/checkout/tsconfig.spec.json",
|
||||
"karmaConfig": "apps/swagger/checkout/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": ["apps/swagger/checkout/tsconfig.lib.json", "apps/swagger/checkout/tsconfig.spec.json"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@swagger/crm": {
|
||||
"root": "apps/swagger/crm",
|
||||
"sourceRoot": "apps/swagger/crm/src",
|
||||
"projectType": "library",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||
"options": {
|
||||
"tsConfig": "apps/swagger/crm/tsconfig.lib.json",
|
||||
"project": "apps/swagger/crm/ng-package.json"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "apps/swagger/crm/src/test.ts",
|
||||
"tsConfig": "apps/swagger/crm/tsconfig.spec.json",
|
||||
"karmaConfig": "apps/swagger/crm/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": ["apps/swagger/crm/tsconfig.lib.json", "apps/swagger/crm/tsconfig.spec.json"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@swagger/isa": {
|
||||
"root": "apps/swagger/isa",
|
||||
"sourceRoot": "apps/swagger/isa/src",
|
||||
"projectType": "library",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||
"options": {
|
||||
"tsConfig": "apps/swagger/isa/tsconfig.lib.json",
|
||||
"project": "apps/swagger/isa/ng-package.json"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "apps/swagger/isa/src/test.ts",
|
||||
"tsConfig": "apps/swagger/isa/tsconfig.spec.json",
|
||||
"karmaConfig": "apps/swagger/isa/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": ["apps/swagger/isa/tsconfig.lib.json", "apps/swagger/isa/tsconfig.spec.json"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@swagger/oms": {
|
||||
"root": "apps/swagger/oms",
|
||||
"sourceRoot": "apps/swagger/oms/src",
|
||||
"projectType": "library",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||
"options": {
|
||||
"tsConfig": "apps/swagger/oms/tsconfig.lib.json",
|
||||
"project": "apps/swagger/oms/ng-package.json"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "apps/swagger/oms/src/test.ts",
|
||||
"tsConfig": "apps/swagger/oms/tsconfig.spec.json",
|
||||
"karmaConfig": "apps/swagger/oms/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": ["apps/swagger/oms/tsconfig.lib.json", "apps/swagger/oms/tsconfig.spec.json"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@swagger/print": {
|
||||
"root": "apps/swagger/print",
|
||||
"sourceRoot": "apps/swagger/print/src",
|
||||
"projectType": "library",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||
"options": {
|
||||
"tsConfig": "apps/swagger/print/tsconfig.lib.json",
|
||||
"project": "apps/swagger/print/ng-package.json"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "apps/swagger/print/src/test.ts",
|
||||
"tsConfig": "apps/swagger/print/tsconfig.spec.json",
|
||||
"karmaConfig": "apps/swagger/print/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": ["apps/swagger/print/tsconfig.lib.json", "apps/swagger/print/tsconfig.spec.json"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@swagger/cat": {
|
||||
"root": "apps/swagger/cat",
|
||||
"sourceRoot": "apps/swagger/cat/src",
|
||||
"projectType": "library",
|
||||
"prefix": "lib",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||
"options": {
|
||||
"tsConfig": "apps/swagger/cat/tsconfig.lib.json",
|
||||
"project": "apps/swagger/cat/ng-package.json"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "apps/swagger/cat/src/test.ts",
|
||||
"tsConfig": "apps/swagger/cat/tsconfig.spec.json",
|
||||
"karmaConfig": "apps/swagger/cat/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": ["apps/swagger/cat/tsconfig.lib.json", "apps/swagger/cat/tsconfig.spec.json"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "sales"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import {
|
||||
ApiConfiguration,
|
||||
AvConfiguration,
|
||||
CheckoutConfiguration,
|
||||
CrmConfiguration,
|
||||
IsaConfiguration,
|
||||
OmsConfiguration,
|
||||
PrintConfiguration
|
||||
} from 'swagger';
|
||||
|
||||
import { PrintConfiguration } from '@swagger/print';
|
||||
import { OmsConfiguration } from '@swagger/oms';
|
||||
import { IsaConfiguration } from '@swagger/isa';
|
||||
import { CrmConfiguration } from '@swagger/crm';
|
||||
import { CheckoutConfiguration } from '@swagger/checkout';
|
||||
import { AvConfiguration } from '@swagger/availability';
|
||||
import { CatConfiguration } from '@swagger/cat';
|
||||
|
||||
import { AppConfiguration } from './app-configuration';
|
||||
|
||||
export function apiConfigurationFactory(config: AppConfiguration) {
|
||||
export function catConfigurationFactory(config: AppConfiguration) {
|
||||
return config.swagger.api;
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ export function printConfigurationFactory(config: AppConfiguration) {
|
||||
|
||||
@NgModule({
|
||||
providers: [
|
||||
{ provide: ApiConfiguration, useFactory: apiConfigurationFactory, deps: [AppConfiguration] },
|
||||
{ provide: CatConfiguration, useFactory: catConfigurationFactory, deps: [AppConfiguration] },
|
||||
{ provide: AvConfiguration, useFactory: avConfigurationFactory, deps: [AppConfiguration] },
|
||||
{ provide: CheckoutConfiguration, useFactory: checkoutConfigurationFactory, deps: [AppConfiguration] },
|
||||
{ provide: CrmConfiguration, useFactory: crmConfigurationFactory, deps: [AppConfiguration] },
|
||||
{ provide: IsaConfiguration, useFactory: isaConfigurationFactory, deps: [AppConfiguration] },
|
||||
{ provide: OmsConfiguration, useFactory: omsConfigurationFactory, deps: [AppConfiguration] },
|
||||
{ provide: PrintConfiguration, useFactory: printConfigurationFactory, deps: [AppConfiguration] }
|
||||
]
|
||||
{ provide: PrintConfiguration, useFactory: printConfigurationFactory, deps: [AppConfiguration] },
|
||||
],
|
||||
})
|
||||
export class AppSwaggerModule {}
|
||||
|
||||
@@ -15,7 +15,7 @@ import { BreadcrumbsState } from '../../core/store/state/breadcrumbs.state';
|
||||
@Component({
|
||||
selector: 'app-header',
|
||||
templateUrl: './header.component.html',
|
||||
styleUrls: ['./header.component.scss']
|
||||
styleUrls: ['./header.component.scss'],
|
||||
})
|
||||
export class HeaderComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('logOut') logOutDialog: LogOutComponent;
|
||||
@@ -35,15 +35,15 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
||||
selectedBackground: '#1F466C',
|
||||
selectedText: '#ffffff',
|
||||
unSelectedbackground: '#edeff0',
|
||||
unSelectedText: '#000000'
|
||||
unSelectedText: '#000000',
|
||||
},
|
||||
secondChoiceColor: <DoubleChoiceSwitchColor>{
|
||||
selectedBackground: '#596470',
|
||||
selectedText: '#ffffff',
|
||||
unSelectedbackground: '#E6EFF9',
|
||||
unSelectedText: '#000000'
|
||||
unSelectedText: '#000000',
|
||||
},
|
||||
isFirstSwitchedOn: true
|
||||
isFirstSwitchedOn: true,
|
||||
};
|
||||
|
||||
this.moduleSwitcherService.moduleSwitcher$.pipe(takeUntil(this.destroy$)).subscribe((activeModule: ModuleSwitcher) => {
|
||||
@@ -66,7 +66,6 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
||||
const activeModule = model.isFirstSwitchedOn ? ModuleSwitcher.Customer : ModuleSwitcher.Branch;
|
||||
const currentProcess = model.isFirstSwitchedOn === true ? currentCustomerProcess : branchProcess;
|
||||
const hasRemissionBreadcrumbs = this.store.selectSnapshot(BreadcrumbsState.hasRemissionBreadcrumbs);
|
||||
console.log('hasRemissionBreadcrumbs', hasRemissionBreadcrumbs);
|
||||
this.moduleSwitcherService.switch(activeModule, currentProcess, !hasRemissionBreadcrumbs);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,14 +93,14 @@ export class ProcessHeaderComponent implements OnInit, OnDestroy {
|
||||
distinctUntilChanged((prev, curr) => this.processComperer(prev, curr))
|
||||
)
|
||||
.subscribe(
|
||||
data => {
|
||||
(data) => {
|
||||
this.processes = data;
|
||||
this.cdr.detectChanges();
|
||||
if (this.panel.nativeElement.children.length > 0) {
|
||||
this.scrollableArrows();
|
||||
}
|
||||
},
|
||||
err => console.log(err)
|
||||
(err) => console.error(err)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -126,12 +126,12 @@ export class ProcessHeaderComponent implements OnInit, OnDestroy {
|
||||
return false;
|
||||
}
|
||||
const prevStr = JSON.stringify(
|
||||
prev.map(t => {
|
||||
prev.map((t) => {
|
||||
return { new: t.new, name: t.name };
|
||||
})
|
||||
);
|
||||
const currStr = JSON.stringify(
|
||||
curr.map(t => {
|
||||
curr.map((t) => {
|
||||
return { new: t.new, name: t.name };
|
||||
})
|
||||
);
|
||||
|
||||
@@ -8,16 +8,16 @@ import {
|
||||
OrganisationDTO,
|
||||
CommunicationDetailsDTO,
|
||||
AssignedPayerDTO,
|
||||
} from 'libs/swagger/src/lib/crm/models';
|
||||
import { CustomerInfoDTO } from 'swagger/lib/crm/models/customer-info-dto';
|
||||
CustomerInfoDTO,
|
||||
ShippingAddressDTO,
|
||||
PayerDTO,
|
||||
CustomerDTO,
|
||||
} from '@swagger/crm';
|
||||
import { NotificationChannels } from '../models/notification-channels.enum';
|
||||
import { ShippingAddressDTO } from 'swagger/lib/crm/models/shipping-address-dto';
|
||||
import { EntityDTOContainerOfBranchDTO } from 'swagger/lib/checkout/models/entity-dtocontainer-of-branch-dto';
|
||||
import { EntityDTOContainerOfBranchDTO } from '@swagger/checkout';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { BACKEND_API_TIMESTAMP_FORMAT } from '../utils/app.formats';
|
||||
import { PayerDTO } from 'swagger/lib/crm/models/payer-dto';
|
||||
import { CustomerDTO } from 'swagger/lib/crm/models/customer-dto';
|
||||
import { KeyValueDTOOfStringAndString } from 'swagger';
|
||||
import { KeyValueDTOOfStringAndString } from '@swagger/cat';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CustomerMapping {
|
||||
@@ -60,9 +60,7 @@ export class CustomerMapping {
|
||||
zipCode: customer.delivery_addres.zip + '',
|
||||
street: customer.delivery_addres.street,
|
||||
streetNumber: customer.delivery_addres.streetNo + '',
|
||||
info: customer.delivery_addres.note
|
||||
? customer.delivery_addres.note
|
||||
: null,
|
||||
info: customer.delivery_addres.note ? customer.delivery_addres.note : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -73,9 +71,7 @@ export class CustomerMapping {
|
||||
zipCode: customer.invoice_address.zip + '',
|
||||
street: customer.invoice_address.street,
|
||||
streetNumber: customer.invoice_address.streetNo + '',
|
||||
info: customer.invoice_address.note
|
||||
? customer.invoice_address.note
|
||||
: null,
|
||||
info: customer.invoice_address.note ? customer.invoice_address.note : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,20 +84,14 @@ export class CustomerMapping {
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
Array.isArray(customer.poossible_delivery_addresses) &&
|
||||
customer.poossible_delivery_addresses.length > 0
|
||||
) {
|
||||
if (Array.isArray(customer.poossible_delivery_addresses) && customer.poossible_delivery_addresses.length > 0) {
|
||||
customer.poossible_delivery_addresses.forEach((adrs: Address) => {
|
||||
addresses.push(this.addressesItem(adrs));
|
||||
shippingAddresses.push(this.addressesItem(adrs));
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
Array.isArray(customer.poossible_invoice_addresses) &&
|
||||
customer.poossible_invoice_addresses.length > 0
|
||||
) {
|
||||
if (Array.isArray(customer.poossible_invoice_addresses) && customer.poossible_invoice_addresses.length > 0) {
|
||||
customer.poossible_invoice_addresses.forEach((adrs: Address) => {
|
||||
if (adrs) {
|
||||
addresses.push(this.addressesItem(adrs));
|
||||
@@ -188,9 +178,7 @@ export class CustomerMapping {
|
||||
}
|
||||
}
|
||||
|
||||
private addressesItem(
|
||||
address: Address
|
||||
): EntityDTOContainerOfShippingAddressDTO {
|
||||
private addressesItem(address: Address): EntityDTOContainerOfShippingAddressDTO {
|
||||
if (!address) {
|
||||
return;
|
||||
}
|
||||
@@ -226,9 +214,7 @@ export class CustomerMapping {
|
||||
|
||||
customerInfoDTOtoUser(customerInfo: CustomerInfoDTO): User {
|
||||
if (isNullOrUndefined(customerInfo)) {
|
||||
throw new Error(
|
||||
'argument customerInfo:CustomerInfoDTO is null or undefined.'
|
||||
);
|
||||
throw new Error('argument customerInfo:CustomerInfoDTO is null or undefined.');
|
||||
}
|
||||
|
||||
const id = customerInfo.id;
|
||||
@@ -274,14 +260,10 @@ export class CustomerMapping {
|
||||
first_name: customerInfo.firstName,
|
||||
last_name: customerInfo.lastName,
|
||||
city: customerInfo.address.city ? customerInfo.address.city : undefined,
|
||||
zip: customerInfo.address.zipCode
|
||||
? customerInfo.address.zipCode
|
||||
: undefined,
|
||||
zip: customerInfo.address.zipCode ? customerInfo.address.zipCode : undefined,
|
||||
country: customerInfo.address.country,
|
||||
street: customerInfo.address.street,
|
||||
streetNo: customerInfo.address.streetNumber
|
||||
? +customerInfo.address.streetNumber
|
||||
: undefined,
|
||||
streetNo: customerInfo.address.streetNumber ? +customerInfo.address.streetNumber : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -352,9 +334,7 @@ export class CustomerMapping {
|
||||
|
||||
customerDTOtoUser(customerDto: CustomerDTO): User {
|
||||
if (isNullOrUndefined(customerDto)) {
|
||||
throw new Error(
|
||||
'argument customerDto:CustomerInfoDTO is null or undefined.'
|
||||
);
|
||||
throw new Error('argument customerDto:CustomerInfoDTO is null or undefined.');
|
||||
}
|
||||
|
||||
const id = customerDto.id;
|
||||
@@ -385,8 +365,7 @@ export class CustomerMapping {
|
||||
let notificationEmail = false;
|
||||
if (customerDto.notificationChannels) {
|
||||
notificationSms =
|
||||
customerDto.notificationChannels === NotificationChannels.Sms ||
|
||||
customerDto.notificationChannels === NotificationChannels.EmailSms;
|
||||
customerDto.notificationChannels === NotificationChannels.Sms || customerDto.notificationChannels === NotificationChannels.EmailSms;
|
||||
notificationEmail =
|
||||
customerDto.notificationChannels === NotificationChannels.Email ||
|
||||
customerDto.notificationChannels === NotificationChannels.EmailSms;
|
||||
@@ -443,9 +422,7 @@ export class CustomerMapping {
|
||||
mobile_number: mobileNumber,
|
||||
newUser: newUser,
|
||||
customer_card: false,
|
||||
createdInBranch: customerDto.createdInBranch
|
||||
? customerDto.createdInBranch.id
|
||||
: null,
|
||||
createdInBranch: customerDto.createdInBranch ? customerDto.createdInBranch.id : null,
|
||||
newsletter: false, // missing info from API
|
||||
shop: false,
|
||||
notificationSms: notificationSms,
|
||||
@@ -465,13 +442,9 @@ export class CustomerMapping {
|
||||
};
|
||||
}
|
||||
|
||||
fromShippingAddressDtoToAddress(
|
||||
shippingAddress: ShippingAddressDTO
|
||||
): Address {
|
||||
fromShippingAddressDtoToAddress(shippingAddress: ShippingAddressDTO): Address {
|
||||
if (isNullOrUndefined(shippingAddress)) {
|
||||
throw new Error(
|
||||
'argument shippingAddress:ShippingAddressDTO is null or undefined.'
|
||||
);
|
||||
throw new Error('argument shippingAddress:ShippingAddressDTO is null or undefined.');
|
||||
}
|
||||
|
||||
let gender = '';
|
||||
@@ -524,10 +497,7 @@ export class CustomerMapping {
|
||||
};
|
||||
}
|
||||
|
||||
fromAddressToShippingAddressDTO(
|
||||
address: Address,
|
||||
forUpdate: boolean
|
||||
): ShippingAddressDTO {
|
||||
fromAddressToShippingAddressDTO(address: Address, forUpdate: boolean): ShippingAddressDTO {
|
||||
if (isNullOrUndefined(address)) {
|
||||
throw new Error('argument address:Address is null or undefined.');
|
||||
}
|
||||
@@ -559,10 +529,7 @@ export class CustomerMapping {
|
||||
lastName: address.last_name,
|
||||
gender: this.getGender(address.gender),
|
||||
status: 1,
|
||||
isDefault: this.datePipe.transform(
|
||||
new Date(),
|
||||
BACKEND_API_TIMESTAMP_FORMAT
|
||||
),
|
||||
isDefault: this.datePipe.transform(new Date(), BACKEND_API_TIMESTAMP_FORMAT),
|
||||
organisation: <OrganisationDTO>{
|
||||
name: address.company_name,
|
||||
department: address.company_department,
|
||||
@@ -617,10 +584,7 @@ export class CustomerMapping {
|
||||
lastName: address.last_name,
|
||||
gender: this.getGender(address.gender),
|
||||
status: 1,
|
||||
isDefault: this.datePipe.transform(
|
||||
new Date(),
|
||||
BACKEND_API_TIMESTAMP_FORMAT
|
||||
),
|
||||
isDefault: this.datePipe.transform(new Date(), BACKEND_API_TIMESTAMP_FORMAT),
|
||||
address: _address,
|
||||
payerNumber: address.payer_number,
|
||||
payerStatus: address.payer_status,
|
||||
@@ -635,9 +599,7 @@ export class CustomerMapping {
|
||||
|
||||
fromAssignedPayerDtoToAddress(assignedPayers: AssignedPayerDTO): Address {
|
||||
if (isNullOrUndefined(assignedPayers)) {
|
||||
throw new Error(
|
||||
'argument shippingAddress:ShippingAddressDTO is null or undefined.'
|
||||
);
|
||||
throw new Error('argument shippingAddress:ShippingAddressDTO is null or undefined.');
|
||||
}
|
||||
|
||||
let id = null;
|
||||
@@ -650,11 +612,7 @@ export class CustomerMapping {
|
||||
}
|
||||
|
||||
let gender = '';
|
||||
if (
|
||||
!!assignedPayers.payer &&
|
||||
!!assignedPayers.payer.data &&
|
||||
!!assignedPayers.payer.data.gender
|
||||
) {
|
||||
if (!!assignedPayers.payer && !!assignedPayers.payer.data && !!assignedPayers.payer.data.gender) {
|
||||
gender = this.getGenderFromCode(assignedPayers.payer.data.gender);
|
||||
}
|
||||
|
||||
@@ -663,11 +621,7 @@ export class CustomerMapping {
|
||||
let street = '';
|
||||
let streetNo = null;
|
||||
let zip: string = null;
|
||||
if (
|
||||
!!assignedPayers.payer &&
|
||||
!!assignedPayers.payer.data &&
|
||||
!!assignedPayers.payer.data.address
|
||||
) {
|
||||
if (!!assignedPayers.payer && !!assignedPayers.payer.data && !!assignedPayers.payer.data.address) {
|
||||
country = assignedPayers.payer.data.address.country;
|
||||
city = assignedPayers.payer.data.address.city;
|
||||
street = assignedPayers.payer.data.address.street;
|
||||
@@ -689,11 +643,7 @@ export class CustomerMapping {
|
||||
let company_name = null;
|
||||
let company_department = null;
|
||||
let company_tax_number = null;
|
||||
if (
|
||||
!!assignedPayers.payer &&
|
||||
!!assignedPayers.payer.data &&
|
||||
!!assignedPayers.payer.data.organisation
|
||||
) {
|
||||
if (!!assignedPayers.payer && !!assignedPayers.payer.data && !!assignedPayers.payer.data.organisation) {
|
||||
company_name = assignedPayers.payer.data.organisation.name;
|
||||
company_department = assignedPayers.payer.data.organisation.department;
|
||||
company_tax_number = assignedPayers.payer.data.organisation.vatId;
|
||||
@@ -756,9 +706,7 @@ export class CustomerMapping {
|
||||
zipCode: customer.delivery_addres.zip + '',
|
||||
street: customer.delivery_addres.street,
|
||||
streetNumber: customer.delivery_addres.streetNo + '',
|
||||
info: customer.delivery_addres.note
|
||||
? customer.delivery_addres.note
|
||||
: null,
|
||||
info: customer.delivery_addres.note ? customer.delivery_addres.note : null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { OrderByDTO, OptionDTO } from 'swagger';
|
||||
import { OrderByDTO, OptionDTO } from '@swagger/cat';
|
||||
import { FilterItem } from '../models/filter-item.model';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { InputDTO, UISettingsDTO, QueryTokenDTO, InputType, OrderByDTO } from 'swagger';
|
||||
import { InputDTO, UISettingsDTO, QueryTokenDTO, OrderByDTO } from '@swagger/cat';
|
||||
import { Filter } from '../models/filter.model';
|
||||
import { FilterItemMapping } from './filter-item.mapping';
|
||||
import { FilterItem } from '../models/filter-item.model';
|
||||
@@ -13,20 +13,20 @@ export class FilterMapping {
|
||||
let max: number;
|
||||
|
||||
if (input.options != null && input.options.values) {
|
||||
(max = input.options.max), (items = input.options.values.map(item => this.filterItemMapping.fromOptionDto(item)));
|
||||
(max = input.options.max), (items = input.options.values.map((item) => this.filterItemMapping.fromOptionDto(item)));
|
||||
}
|
||||
|
||||
if (input.value != null) {
|
||||
if (max == null) {
|
||||
const selectedValues = input.value.split(';');
|
||||
for (const selected of selectedValues) {
|
||||
const idx = items.findIndex(f => f.id === selected);
|
||||
const idx = items.findIndex((f) => f.id === selected);
|
||||
if (idx >= 0) {
|
||||
items[idx].selected = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const idx = items.findIndex(f => f.id === input.value);
|
||||
const idx = items.findIndex((f) => f.id === input.value);
|
||||
if (idx >= 0) {
|
||||
items[idx].selected = true;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export class FilterMapping {
|
||||
id: input.key,
|
||||
name: input.label,
|
||||
max,
|
||||
items
|
||||
items,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ export class FilterMapping {
|
||||
const filters: Filter[] = [];
|
||||
|
||||
const filteredSettings = settings.filter
|
||||
.filter(f => f.type === InputType.Bool && f.options)
|
||||
.filter(f => f.options && Array.isArray(f.options.values));
|
||||
.filter((f) => f.type === 2 && f.options)
|
||||
.filter((f) => f.options && Array.isArray(f.options.values));
|
||||
|
||||
for (const filter of filteredSettings) {
|
||||
filters.push(this.fromInputDto(filter));
|
||||
@@ -59,7 +59,7 @@ export class FilterMapping {
|
||||
id: 'orderBy',
|
||||
max: 1,
|
||||
name: 'Sortierung',
|
||||
items: settings.orderBy.map(o => this.filterItemMapping.fromOrderByDto(o))
|
||||
items: settings.orderBy.map((o) => this.filterItemMapping.fromOrderByDto(o)),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -67,26 +67,26 @@ export class FilterMapping {
|
||||
}
|
||||
|
||||
toQueryTokenDto(target: QueryTokenDTO, source: Filter[], archive: boolean, negative: boolean) {
|
||||
const orderBy = source.find(f => f.id === 'orderBy');
|
||||
const orderBy = source.find((f) => f.id === 'orderBy');
|
||||
if (orderBy != null) {
|
||||
target.orderBy = orderBy.items
|
||||
.filter(i => i.selected)
|
||||
.filter((i) => i.selected)
|
||||
.map(
|
||||
m =>
|
||||
(m) =>
|
||||
({
|
||||
by: m.id,
|
||||
desc: m.desc
|
||||
desc: m.desc,
|
||||
} as OrderByDTO)
|
||||
);
|
||||
}
|
||||
|
||||
const filter = source.filter(f => f.id !== 'orderBy').filter(f => f.items && f.items.some(s => s.selected));
|
||||
const filter = source.filter((f) => f.id !== 'orderBy').filter((f) => f.items && f.items.some((s) => s.selected));
|
||||
if (Array.isArray(filter)) {
|
||||
const kvps = filter.map(fil => {
|
||||
const kvps = filter.map((fil) => {
|
||||
const key = fil.id;
|
||||
const value = fil.items
|
||||
.filter(f => f.selected)
|
||||
.map(f => (negative && fil.id !== 'stock' ? '!' + f.id : f.id))
|
||||
.filter((f) => f.selected)
|
||||
.map((f) => (negative && fil.id !== 'stock' ? '!' + f.id : f.id))
|
||||
.join(';');
|
||||
return [key, value];
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Product } from '../models/product.model';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { AvailabilityDTO, ItemDTO, AvailabilityType, PriceDTO } from 'swagger';
|
||||
import { ItemDTO, PriceDTO } from '@swagger/cat';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
@@ -58,7 +58,7 @@ export class ProductMapping {
|
||||
type: item.product.formatDetail,
|
||||
typeIcon: item.product.format,
|
||||
location: item.product.productGroup,
|
||||
publicationDate: item.product.publicationDate,
|
||||
publicationDate: new Date(item.product.publicationDate),
|
||||
ean: item.product.ean,
|
||||
imageId: item.imageId,
|
||||
edition: item.product.edition,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RecommendationItem } from '../models/recommendation.model';
|
||||
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { OrderItemListItemDTO } from 'swagger/lib/oms/models/order-item-list-item-dto';
|
||||
import { OrderItemListItemDTO, OrderDTO } from '@swagger/oms';
|
||||
import { ShelfOrder } from '../models/shelf-order.model';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { ShelfCustomerOrders } from '../models/shelf-customer-orders.model';
|
||||
import { Gender } from 'swagger/lib/oms/models/gender';
|
||||
import { ShlefOrderItem } from '../models/shelf-order-item.model';
|
||||
import { CollectingShelfOrder } from '../models/collecting-shelf-order.model';
|
||||
import { OrderDTO } from 'swagger/lib/oms/models/order-dto';
|
||||
import { CollectingShelfService } from '../services/collecting-shelf.service';
|
||||
|
||||
export const orderStatusMapper: { [id: number]: string } = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { BranchInfoDTO } from 'swagger/lib/isa/models/branch-info-dto';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { BranchInfoDTO } from '@swagger/isa';
|
||||
|
||||
export interface BookData {
|
||||
id: number;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BranchType } from 'swagger/lib/checkout/models/branch-type';
|
||||
import { BranchType } from '@swagger/checkout';
|
||||
|
||||
export const BranchTypeCode: { [key: string]: BranchType } = {
|
||||
NotSet: 0,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AddressDTO } from 'swagger/lib/checkout/models/address-dto';
|
||||
import { AvailabilityDTO } from 'swagger/lib/availability/models/availability-dto';
|
||||
import { AddressDTO } from '@swagger/checkout';
|
||||
import { AvailabilityDTO } from '@swagger/availability';
|
||||
|
||||
export interface CartEntry {
|
||||
bookId: number;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { BranchInfoDTO } from 'swagger/lib/isa/models/branch-info-dto';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { BranchInfoDTO } from '@swagger/isa';
|
||||
|
||||
export interface Cart {
|
||||
cartId: number;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { OrderType } from 'swagger/lib/oms/models/order-type';
|
||||
import { OrderItemProcessingStatusValue } from 'swagger/lib/oms/models/order-item-processing-status-value';
|
||||
import { ProductDTO } from 'swagger/lib/oms/models/product-dto';
|
||||
import { Gender } from 'swagger/lib/oms/models/gender';
|
||||
// tslint:disable-next-line: max-line-length
|
||||
import { KeyValueDTOOfOrderItemProcessingStatusValueAndString } from 'swagger/lib/oms/models/key-value-dtoof-order-item-processing-status-value-and-string';
|
||||
import {
|
||||
OrderType,
|
||||
OrderItemProcessingStatusValue,
|
||||
ProductDTO,
|
||||
Gender,
|
||||
KeyValueDTOOfOrderItemProcessingStatusValueAndString,
|
||||
} from '@swagger/oms';
|
||||
import { ShelfOrderItemLevel } from './shelf-order-item-level.enum';
|
||||
|
||||
export interface CollectingShelfOrder {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ShippingTarget } from 'swagger/lib/checkout/models/shipping-target';
|
||||
import { ShippingTarget } from '@swagger/checkout';
|
||||
export class DeliveryOption {
|
||||
static TAKE_NOW = 'Rücklage';
|
||||
static DELIVERY = 'Versand';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OrderItemListItemDTO } from 'swagger/lib/oms/models/order-item-list-item-dto';
|
||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { GoodsInSearch } from './GoodsInSearch.model';
|
||||
|
||||
export interface GoodsIn {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ProductDTO } from 'libs/swagger/src/lib/oms/models';
|
||||
import { ProductDTO } from '@swagger/oms';
|
||||
|
||||
export interface OrderItem {
|
||||
id: number;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Search } from './search.model';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { CustomerSearch } from './customer-search.model';
|
||||
import { DisplayOrderDTO } from 'libs/swagger/src/lib/oms/models/display-order-dto';
|
||||
import { DisplayOrderDTO } from '@swagger/oms';
|
||||
import { ProductSerachFilters } from './product-search-filters.model';
|
||||
import { ShelfSearch } from './shelf-search.modal';
|
||||
import { ProcessUserData } from './process-user-data.model';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CheckoutType } from './checkout-type.enum';
|
||||
import { AvailabilityDTO } from 'swagger/lib/availability/models/availability-dto';
|
||||
import { AvailabilityDTO } from '@swagger/availability';
|
||||
|
||||
export interface ProductAvailability {
|
||||
itemId: number;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
|
||||
export interface ProductDetails {
|
||||
item: ItemDTO;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
|
||||
export interface ProductSearchResult {
|
||||
itemsDTO: { [key: number]: ItemDTO };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Gender } from 'swagger/lib/oms/models/gender';
|
||||
import { Gender } from '@swagger/oms';
|
||||
import { ShelfOrder } from './shelf-order.model';
|
||||
|
||||
export class ShelfCustomerOrders {
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import { OrderType } from 'swagger/lib/oms/models/order-type';
|
||||
import { OrderItemProcessingStatusValue } from 'swagger/lib/oms/models/order-item-processing-status-value';
|
||||
import { ProductDTO } from 'swagger/lib/oms/models/product-dto';
|
||||
// tslint:disable-next-line: max-line-length
|
||||
import { KeyValueDTOOfOrderItemProcessingStatusValueAndString } from 'swagger/lib/oms/models/key-value-dtoof-order-item-processing-status-value-and-string';
|
||||
import { ProductDTO } from '@swagger/oms';
|
||||
|
||||
export interface ShlefOrderItem {
|
||||
orderItemId?: number;
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
import { EntityStatus } from 'swagger/lib/oms/models/entity-status';
|
||||
import { OrderType } from 'swagger/lib/oms/models/order-type';
|
||||
import { EnvironmentChannel } from 'swagger/lib/oms/models/environment-channel';
|
||||
import { EntityDTOContainerOfBranchDTO } from 'swagger/lib/oms/models/entity-dtocontainer-of-branch-dto';
|
||||
import { OrderProcessingStatus } from 'swagger/lib/oms/models/order-processing-status';
|
||||
import { EntityDTOContainerOfOrderItemDTO } from 'swagger/lib/oms/models/entity-dtocontainer-of-order-item-dto';
|
||||
import { BuyerDTO } from 'swagger/lib/oms/models/buyer-dto';
|
||||
import { NotificationChannel } from 'swagger/lib/oms/models/notification-channel';
|
||||
import { EntityDTOContainerOfShippingAddressDTO } from 'swagger/lib/oms/models/entity-dtocontainer-of-shipping-address-dto';
|
||||
import { EntityDTOContainerOfLogisticianDTO } from 'swagger/lib/oms/models/entity-dtocontainer-of-logistician-dto';
|
||||
import { EntityDTOContainerOfPayerDTO } from 'swagger/lib/oms/models/entity-dtocontainer-of-payer-dto';
|
||||
import { PaymentType } from 'swagger/lib/oms/models/payment-type';
|
||||
import { EntityDTOContainerOfPaymentDTO } from 'swagger/lib/oms/models/entity-dtocontainer-of-payment-dto';
|
||||
import { PaymentStatus } from 'swagger/lib/oms/models/payment-status';
|
||||
import { ValidationStatus } from 'swagger/lib/oms/models/validation-status';
|
||||
import { TermsOfDeliveryDTO } from 'swagger/lib/oms/models/terms-of-delivery-dto';
|
||||
import {
|
||||
EntityStatus,
|
||||
OrderType,
|
||||
EnvironmentChannel,
|
||||
EntityDTOContainerOfBranchDTO,
|
||||
OrderProcessingStatus,
|
||||
EntityDTOContainerOfOrderItemDTO,
|
||||
BuyerDTO,
|
||||
NotificationChannel,
|
||||
EntityDTOContainerOfShippingAddressDTO,
|
||||
EntityDTOContainerOfLogisticianDTO,
|
||||
EntityDTOContainerOfPayerDTO,
|
||||
PaymentType,
|
||||
EntityDTOContainerOfPaymentDTO,
|
||||
PaymentStatus,
|
||||
ValidationStatus,
|
||||
TermsOfDeliveryDTO,
|
||||
} from '@swagger/oms';
|
||||
|
||||
export interface ShelfOrder {
|
||||
id?: number;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { CartEntry } from './cart-entry.model';
|
||||
import { User } from './user.model';
|
||||
import { Process } from './process.model';
|
||||
import { ItemDTO, ListResponseArgsOfItemDTO } from 'swagger';
|
||||
import { ItemDTO, ListResponseArgsOfItemDTO } from '@swagger/cat';
|
||||
import { RecentArticleSearch } from './recent-article-search.model';
|
||||
import { ProcessBreadcrumb } from './process-breadcrumb.model';
|
||||
import { ModuleSwitcher } from './app-switcher.enum';
|
||||
import { Filter } from './filter.model';
|
||||
import { ProcessSelectedFilters } from './process-selected-filters.model';
|
||||
import { CollectingShelfOrder } from './collecting-shelf-order.model';
|
||||
import { OrderDTO } from 'swagger/lib/oms/models/order-dto';
|
||||
import { OrderDTO } from '@swagger/oms';
|
||||
import { FilterType } from './filter-type.enum';
|
||||
import { CustomerSearchResponse } from './customer-search-response.model';
|
||||
import { GoodsIn } from './goods-in.model';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { VATType } from 'libs/swagger/src/lib/checkout/models';
|
||||
import { VATType } from '@swagger/checkout';
|
||||
|
||||
export const VatType: { [key: string]: VATType } = {
|
||||
NotSet: 0,
|
||||
|
||||
@@ -25,7 +25,7 @@ declare let ga: Function;
|
||||
export const NOT_IDLE_REMISSION_REMINDER_MINUTES = 20;
|
||||
export const IDLE_REMISSION_REMINDER_MINUTES = 40;
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AppService implements OnDestroy {
|
||||
destroy$ = new Subject();
|
||||
@@ -75,7 +75,7 @@ export class AppService implements OnDestroy {
|
||||
|
||||
this.ssoService
|
||||
.registerAuthentication()
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
})
|
||||
.then(() => {
|
||||
@@ -125,7 +125,7 @@ export class AppService implements OnDestroy {
|
||||
private addMetas() {
|
||||
const zommingPreventionTag = <MetaDefinition>{
|
||||
name: 'viewport',
|
||||
content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'
|
||||
content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no',
|
||||
};
|
||||
this.meta.addTag(zommingPreventionTag);
|
||||
}
|
||||
@@ -168,10 +168,10 @@ export class AppService implements OnDestroy {
|
||||
this.store
|
||||
.select(RemissionSelectors.shouldRemindForRemission)
|
||||
.pipe(
|
||||
filter(data => !isNullOrUndefined(data) && !this.remissionReminderActivate),
|
||||
filter((data) => !isNullOrUndefined(data) && !this.remissionReminderActivate),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(status => {
|
||||
.subscribe((status) => {
|
||||
this.remissionReminderActivate = true;
|
||||
const shouldRemind = this.checkRemissionReminder(status);
|
||||
if (shouldRemind) {
|
||||
@@ -195,7 +195,7 @@ export class AppService implements OnDestroy {
|
||||
private registerTimedRemissionReminder(minutes: number) {
|
||||
const emittingTime = 1000 * 60 * minutes;
|
||||
const timer$: Observable<number> = timer(emittingTime, emittingTime);
|
||||
timer$.pipe(takeUntil(this.timerClear$)).subscribe(interval => {
|
||||
timer$.pipe(takeUntil(this.timerClear$)).subscribe((interval) => {
|
||||
this.remissionReminder$.next();
|
||||
});
|
||||
}
|
||||
@@ -220,10 +220,10 @@ export class AppService implements OnDestroy {
|
||||
this.store
|
||||
.select(RemissionSelectors.shouldRemindForRemission)
|
||||
.pipe(
|
||||
filter(data => !isNullOrUndefined(data)),
|
||||
filter((data) => !isNullOrUndefined(data)),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(status => {
|
||||
.subscribe((status) => {
|
||||
const isNotAtRemission = !this.router.url.includes('remission');
|
||||
(status && isNotAtRemission).ifTrue(() => {
|
||||
this.registerNotIdleRemissionReminder();
|
||||
@@ -250,23 +250,6 @@ export class AppService implements OnDestroy {
|
||||
this.timerClear$.next();
|
||||
}
|
||||
|
||||
private testHttpCall() {
|
||||
this.http
|
||||
.get('https://www.mocky.io/v2/5d1e00a230000080a4d72461')
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
catchError(error => {
|
||||
console.log('Error Cought', error);
|
||||
return of(undefined);
|
||||
})
|
||||
)
|
||||
.subscribe(response => {
|
||||
if (!isNullOrUndefined(response)) {
|
||||
console.log('Response', response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public isIPadEnv() {
|
||||
const navigator = this.windowRef.nativeWindow.navigator as Navigator;
|
||||
const standalone = (navigator as any).standalone,
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { StoreCheckoutService, OrderService } from 'swagger';
|
||||
import { BranchQueryTokenDTO } from 'swagger/lib/checkout/models/branch-query-token-dto';
|
||||
import { map, filter } from 'rxjs/operators';
|
||||
import { BranchQueryTokenDTO, StoreCheckoutService, BranchDTO } from '@swagger/checkout';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { BranchDTO } from 'swagger/lib/checkout/models/branch-dto';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { OrderService } from '@swagger/oms';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -21,15 +20,15 @@ export class BranchService {
|
||||
},
|
||||
};
|
||||
return this.checkoutService.StoreCheckoutQueryBranches(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
return response.result;
|
||||
}),
|
||||
map(branches => {
|
||||
map((branches) => {
|
||||
return branches && branches.length > 0
|
||||
? branches.filter(branch => {
|
||||
? branches.filter((branch) => {
|
||||
if (
|
||||
branch &&
|
||||
!isNullOrUndefined(branch.isOnline) &&
|
||||
@@ -53,7 +52,7 @@ export class BranchService {
|
||||
return this.orderService
|
||||
.OrderGetBranches({})
|
||||
.pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { StoreCheckoutService, OrderCheckoutService } from 'swagger';
|
||||
import { map, filter, switchMap, tap, catchError } from 'rxjs/operators';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { ShoppingCartDTO } from 'swagger/lib/checkout/models/shopping-cart-dto';
|
||||
import { ResponseArgsOfShoppingCartDTO } from 'swagger/lib/checkout/models/response-args-of-shopping-cart-dto';
|
||||
import { AddToShoppingCartDTO } from 'swagger/lib/checkout/models/add-to-shopping-cart-dto';
|
||||
import { ResponseArgsOfCheckoutDTO } from 'swagger/lib/checkout/models/response-args-of-checkout-dto';
|
||||
import { ResponseArgsOfIEnumerableOfBranchDTO } from 'swagger/lib/checkout/models/response-args-of-ienumerable-of-branch-dto';
|
||||
import { BranchDTO } from 'libs/swagger/src/lib/crm/models';
|
||||
import { CheckoutDTO } from 'swagger/lib/checkout/models/checkout-dto';
|
||||
import { ResponseArgsOfIEnumerableOfDisplayOrderDTO } from 'swagger/lib/oms/models/response-args-of-ienumerable-of-display-order-dto';
|
||||
import { DisplayOrderDTO } from 'swagger/lib/oms/models/display-order-dto';
|
||||
import { ResponseArgsOfPaymentDTO } from 'swagger/lib/checkout/models/response-args-of-payment-dto';
|
||||
import { PaymentDTO } from 'swagger/lib/checkout/models/payment-dto';
|
||||
import { BuyerDTO, PayerDTO, ResponseArgsOfDestinationDTO, DestinationDTO } from 'libs/swagger/src/lib/checkout/models';
|
||||
import { SupplierDTO } from 'swagger/lib/checkout/models/supplier-dto';
|
||||
import {
|
||||
ShoppingCartDTO,
|
||||
ResponseArgsOfShoppingCartDTO,
|
||||
AddToShoppingCartDTO,
|
||||
ResponseArgsOfCheckoutDTO,
|
||||
ResponseArgsOfIEnumerableOfBranchDTO,
|
||||
CheckoutDTO,
|
||||
ResponseArgsOfPaymentDTO,
|
||||
PaymentDTO,
|
||||
SupplierDTO,
|
||||
EntityDTOContainerOfDestinationDTO,
|
||||
AvailabilityDTO,
|
||||
UpdateShoppingCartItemDTO,
|
||||
} from '@swagger/checkout';
|
||||
import { BranchDTO } from '@swagger/crm';
|
||||
import {
|
||||
ResponseArgsOfIEnumerableOfDisplayOrderDTO,
|
||||
DisplayOrderDTO,
|
||||
ResponseArgsOfSupplierOrderResult,
|
||||
OrderCheckoutService,
|
||||
} from '@swagger/oms';
|
||||
import { BuyerDTO, PayerDTO, ResponseArgsOfDestinationDTO, DestinationDTO } from '@swagger/checkout';
|
||||
import { NotificationChannels } from '../models/notification-channels.enum';
|
||||
import { EntityDTOContainerOfDestinationDTO } from 'swagger/lib/checkout/models/entity-dtocontainer-of-destination-dto';
|
||||
import { AvailabilityDTO } from 'swagger/lib/checkout/models/availability-dto';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { HttpClient, HttpRequest, HttpResponse } from '@angular/common/http';
|
||||
import { ResponseArgsOfSupplierOrderResult } from 'swagger/lib/oms/models/response-args-of-supplier-order-result';
|
||||
import { DeliveryType } from '../models/delivery-option.model';
|
||||
import { UpdateShoppingCartItemDTO } from 'swagger/lib/checkout/models/update-shopping-cart-item-dto';
|
||||
import { StoreCheckoutService } from '@swagger/checkout';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CheckoutService {
|
||||
constructor(private checkOutService: StoreCheckoutService, private orderService: OrderCheckoutService, private http: HttpClient) {}
|
||||
@@ -46,11 +50,11 @@ export class CheckoutService {
|
||||
addItemToCart(shoppingCartId: number, items: AddToShoppingCartDTO[]): Observable<ShoppingCartDTO> {
|
||||
const params: StoreCheckoutService.StoreCheckoutAddItemToShoppingCartParams = {
|
||||
shoppingCartId,
|
||||
items
|
||||
items,
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutAddItemToShoppingCart(params).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
return of({ error: error });
|
||||
}),
|
||||
map((response: any) => {
|
||||
@@ -70,7 +74,7 @@ export class CheckoutService {
|
||||
const params: StoreCheckoutService.StoreCheckoutUpdateShoppingCartItemParams = {
|
||||
shoppingCartId,
|
||||
shoppingCartItemId,
|
||||
values: updatedShoppingCartItem
|
||||
values: updatedShoppingCartItem,
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutUpdateShoppingCartItem(params).pipe(
|
||||
@@ -93,8 +97,8 @@ export class CheckoutService {
|
||||
shoppingCartId,
|
||||
shoppingCartItemId,
|
||||
values: {
|
||||
destination
|
||||
}
|
||||
destination,
|
||||
},
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutUpdateShoppingCartItem(params).pipe(
|
||||
@@ -121,8 +125,8 @@ export class CheckoutService {
|
||||
values: {
|
||||
quantity,
|
||||
destination,
|
||||
availability
|
||||
}
|
||||
availability,
|
||||
},
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutUpdateShoppingCartItem(params).pipe(
|
||||
@@ -151,13 +155,13 @@ export class CheckoutService {
|
||||
// ORDER
|
||||
createOrder(checkoutId: number): Observable<{ failedItemIds: { id: number; type: number }[]; displayOrder: DisplayOrderDTO[] }> {
|
||||
const params: OrderCheckoutService.OrderCheckoutCreateOrderParams = {
|
||||
checkoutId
|
||||
checkoutId,
|
||||
};
|
||||
|
||||
return this.orderService.OrderCheckoutCreateOrderResponse(params).pipe(
|
||||
map(_r => {
|
||||
map((_r) => {
|
||||
if (_r.status === 207) {
|
||||
const partialOrders = Object.keys(_r.body.invalidProperties).map(t => +t);
|
||||
const partialOrders = Object.keys(_r.body.invalidProperties).map((t) => +t);
|
||||
return { partialOrders: partialOrders, response: _r.body as ResponseArgsOfIEnumerableOfDisplayOrderDTO };
|
||||
}
|
||||
return { response: _r.body as ResponseArgsOfIEnumerableOfDisplayOrderDTO };
|
||||
@@ -171,8 +175,8 @@ export class CheckoutService {
|
||||
}
|
||||
const failedItemsIds = this.reOrder(orders);
|
||||
const items: { id: number; type: number }[] = [];
|
||||
response.result.forEach(t => {
|
||||
t.items.forEach(i => {
|
||||
response.result.forEach((t) => {
|
||||
t.items.forEach((i) => {
|
||||
const isDelivery = t.orderType === DeliveryType['ShippingAddress'];
|
||||
const isTakeNow = i.subsetItems[0].supplierLabel === 'F' ? true : false;
|
||||
if (failedItemsIds && failedItemsIds.includes(i.id)) {
|
||||
@@ -182,7 +186,7 @@ export class CheckoutService {
|
||||
});
|
||||
return {
|
||||
failedItemIds: items,
|
||||
displayOrder: response.result
|
||||
displayOrder: response.result,
|
||||
};
|
||||
} else {
|
||||
const response = r.response as ResponseArgsOfIEnumerableOfDisplayOrderDTO;
|
||||
@@ -199,13 +203,13 @@ export class CheckoutService {
|
||||
createPartialOrder(orderId: number): Observable<{ failedItemIds: { id: number; type: number }[]; displayOrder: DisplayOrderDTO[] }> {
|
||||
const req = new HttpRequest<any>('GET', 'http://127.0.0.1:5000/api/partialorders');
|
||||
return this.http.request<any>(req).pipe(
|
||||
filter(_r => _r instanceof HttpResponse),
|
||||
map(_r => {
|
||||
filter((_r) => _r instanceof HttpResponse),
|
||||
map((_r) => {
|
||||
return _r as HttpResponse<ResponseArgsOfIEnumerableOfDisplayOrderDTO>;
|
||||
}),
|
||||
map(_r => {
|
||||
map((_r) => {
|
||||
if (_r.status === 207) {
|
||||
const partialOrders = Object.keys(_r.body.invalidProperties).map(t => +t);
|
||||
const partialOrders = Object.keys(_r.body.invalidProperties).map((t) => +t);
|
||||
return { partialOrders: partialOrders, response: _r.body as ResponseArgsOfIEnumerableOfDisplayOrderDTO };
|
||||
}
|
||||
return { response: _r.body as ResponseArgsOfIEnumerableOfDisplayOrderDTO };
|
||||
@@ -220,10 +224,10 @@ export class CheckoutService {
|
||||
const failedItemsIds = this.reOrder(orders);
|
||||
const items: { id: number; type: number }[] = [
|
||||
{ id: 42216778, type: 2 },
|
||||
{ id: 42216778, type: 1 }
|
||||
{ id: 42216778, type: 1 },
|
||||
];
|
||||
response.result.forEach(t => {
|
||||
t.items.forEach(i => {
|
||||
response.result.forEach((t) => {
|
||||
t.items.forEach((i) => {
|
||||
const isDelivery = t.orderType === DeliveryType['ShippingAddress'];
|
||||
const isTakeNow = i.subsetItems[0].supplierLabel === 'F' ? true : false;
|
||||
if (failedItemsIds && failedItemsIds.includes(i.id)) {
|
||||
@@ -233,7 +237,7 @@ export class CheckoutService {
|
||||
});
|
||||
return {
|
||||
failedItemIds: items,
|
||||
displayOrder: response.result
|
||||
displayOrder: response.result,
|
||||
};
|
||||
} else {
|
||||
const response = r.response as ResponseArgsOfIEnumerableOfDisplayOrderDTO;
|
||||
@@ -252,26 +256,26 @@ export class CheckoutService {
|
||||
return failedItemsIds;
|
||||
}
|
||||
let processedOrders = 0;
|
||||
orders.forEach(order => {
|
||||
orders.forEach((order) => {
|
||||
this.orderService
|
||||
.OrderCheckoutOrderAtSupplierResponse(order)
|
||||
.pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
const resp = new HttpResponse<ResponseArgsOfSupplierOrderResult>({ status: error.status });
|
||||
return of(resp) as Observable<any>;
|
||||
}),
|
||||
map(r => {
|
||||
map((r) => {
|
||||
return r as HttpResponse<ResponseArgsOfSupplierOrderResult>;
|
||||
}),
|
||||
map(r => {
|
||||
map((r) => {
|
||||
return { status: r.status, response: r.body as ResponseArgsOfSupplierOrderResult };
|
||||
})
|
||||
)
|
||||
.toPromise()
|
||||
.catch(r => {
|
||||
.catch((r) => {
|
||||
return r;
|
||||
})
|
||||
.then(r => {
|
||||
.then((r) => {
|
||||
processedOrders++;
|
||||
const status = r.status;
|
||||
const reorderResponse = r.response;
|
||||
@@ -279,7 +283,7 @@ export class CheckoutService {
|
||||
if (reorderResponse.result && reorderResponse.result.failed && reorderResponse.result.failed.length > 0) {
|
||||
const items = reorderResponse.result.failed;
|
||||
if (items) {
|
||||
items.forEach(it => {
|
||||
items.forEach((it) => {
|
||||
if (it && it.itemId) {
|
||||
failedItemsIds.push(it.itemId);
|
||||
}
|
||||
@@ -297,7 +301,7 @@ export class CheckoutService {
|
||||
// CHECKOUT
|
||||
createCheckout(shoppingCartId: number): Observable<CheckoutDTO> {
|
||||
const params: StoreCheckoutService.StoreCheckoutCreateOrRefreshCheckoutParams = {
|
||||
shoppingCartId
|
||||
shoppingCartId,
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutCreateOrRefreshCheckout(params).pipe(
|
||||
@@ -313,7 +317,7 @@ export class CheckoutService {
|
||||
|
||||
getPayments(checkoutId: number): Observable<PaymentDTO> {
|
||||
const params: StoreCheckoutService.StoreCheckoutGetCheckoutPaymentParams = {
|
||||
checkoutId
|
||||
checkoutId,
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutGetCheckoutPayment(params).pipe(
|
||||
@@ -333,7 +337,7 @@ export class CheckoutService {
|
||||
): Observable<CheckoutDTO> {
|
||||
const params: StoreCheckoutService.StoreCheckoutSetPaymentTypeParams = {
|
||||
checkoutId,
|
||||
paymentType
|
||||
paymentType,
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutSetPaymentType(params).pipe(
|
||||
@@ -350,7 +354,7 @@ export class CheckoutService {
|
||||
setBuyer(checkoutId: number, buyerDTO: BuyerDTO): Observable<CheckoutDTO> {
|
||||
const params: StoreCheckoutService.StoreCheckoutSetBuyerParams = {
|
||||
checkoutId,
|
||||
buyerDTO
|
||||
buyerDTO,
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutSetBuyer(params).pipe(
|
||||
@@ -367,7 +371,7 @@ export class CheckoutService {
|
||||
setPayer(checkoutId: number, payerDTO: PayerDTO): Observable<CheckoutDTO> {
|
||||
const params: StoreCheckoutService.StoreCheckoutSetPayerParams = {
|
||||
checkoutId,
|
||||
payerDTO
|
||||
payerDTO,
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutSetPayer(params).pipe(
|
||||
@@ -385,7 +389,7 @@ export class CheckoutService {
|
||||
const params: StoreCheckoutService.StoreCheckoutUpdateDestinationParams = {
|
||||
destinationId: destiantionId,
|
||||
destinationDTO: shippingAddress,
|
||||
checkoutId: checkoutId
|
||||
checkoutId: checkoutId,
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutUpdateDestination(params).pipe(
|
||||
@@ -401,7 +405,7 @@ export class CheckoutService {
|
||||
|
||||
getSuppliers(): Observable<SupplierDTO[]> {
|
||||
return this.checkOutService.StoreCheckoutGetSuppliers({}).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -414,11 +418,11 @@ export class CheckoutService {
|
||||
setNotificationChannel(checkoutId: number, notificationChannels: NotificationChannels) {
|
||||
const params = <StoreCheckoutService.StoreCheckoutSetNotificationChannelsParams>{
|
||||
checkoutId,
|
||||
notificationChannel: notificationChannels
|
||||
notificationChannel: notificationChannels,
|
||||
};
|
||||
|
||||
return this.checkOutService.StoreCheckoutSetNotificationChannels(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { OrderService, ReceiptService } from 'swagger';
|
||||
import { Suchparameter } from 'swagger/lib/oms/models/suchparameter';
|
||||
import {
|
||||
Suchparameter,
|
||||
ListResponseArgsOfOrderItemListItemDTO,
|
||||
OrderDTO,
|
||||
OrderItemDTO,
|
||||
OrderItemSubsetDTO,
|
||||
ValueTupleOfOrderItemSubsetDTOAndOrderItemSubsetDTO,
|
||||
StatusValues,
|
||||
ReceiptListItemDTO,
|
||||
OrderItemListItemDTO,
|
||||
OrderService,
|
||||
ReceiptService,
|
||||
VATDTO,
|
||||
SupplierDTO,
|
||||
} from '@swagger/oms';
|
||||
import { map, filter } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ShelfMapping } from '../mappings/shelf.mapping';
|
||||
import { CollectingShelfOrder } from '../models/collecting-shelf-order.model';
|
||||
import { OrderDTO } from 'swagger/lib/oms/models/order-dto';
|
||||
import { OrderItemDTO } from 'swagger/lib/oms/models/order-item-dto';
|
||||
import { OrderItemSubsetDTO } from 'swagger/lib/oms/models/order-item-subset-dto';
|
||||
import { ShelfOrder } from '../models/shelf-order.model';
|
||||
// tslint:disable-next-line: max-line-length
|
||||
import { ValueTupleOfOrderItemSubsetDTOAndOrderItemSubsetDTO } from 'swagger/lib/oms/models/value-tuple-of-order-item-subset-dtoand-order-item-subset-dto';
|
||||
import { StatusValues } from 'swagger/lib/oms/models/status-values';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { BACKEND_API_TIMESTAMP_FORMAT } from '../utils/app.formats';
|
||||
import { ReceiptListItemDTO } from 'swagger/lib/oms/models/receipt-list-item-dto';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { ListResponseArgsOfOrderItemListItemDTO } from 'swagger/lib/oms/models/list-response-args-of-order-item-list-item-dto';
|
||||
import { VATDTO } from 'swagger/lib/oms/models/vatdto';
|
||||
import { SupplierDTO } from 'swagger/lib/oms/models/supplier-dto';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { CollectingShelfSelectors } from '../store/selectors/collecting-shelf.selector';
|
||||
import { OrderItemListItemDTO } from 'swagger/lib/oms/models/order-item-list-item-dto';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -48,7 +49,7 @@ export class CollectingShelfService {
|
||||
take: take,
|
||||
};
|
||||
return this.omsService.OrderWarenausgabe(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -61,7 +62,7 @@ export class CollectingShelfService {
|
||||
}
|
||||
|
||||
searchShelfCached() {
|
||||
return this.store.select(CollectingShelfSelectors.getCachedResults).pipe(filter(data => !isNullOrUndefined(data)));
|
||||
return this.store.select(CollectingShelfSelectors.getCachedResults).pipe(filter((data) => !isNullOrUndefined(data)));
|
||||
}
|
||||
|
||||
searchShelfHasResults(input: string, branchNumber: string): Observable<number> {
|
||||
@@ -71,7 +72,7 @@ export class CollectingShelfService {
|
||||
hitsOnly: true,
|
||||
};
|
||||
return this.omsService.OrderWarenausgabe(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -88,7 +89,7 @@ export class CollectingShelfService {
|
||||
take: 10,
|
||||
};
|
||||
return this.omsService.OrderWarenausgabe(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -99,7 +100,7 @@ export class CollectingShelfService {
|
||||
|
||||
getOrderByOrderId(orderId: number): Observable<OrderDTO> {
|
||||
return this.omsService.OrderGetOrder(orderId).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -114,7 +115,7 @@ export class CollectingShelfService {
|
||||
|
||||
getOrderItemByOrderItemId(orderItemId: number): Observable<OrderItemDTO> {
|
||||
return this.omsService.OrderGetOrderItem(orderItemId).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -125,7 +126,7 @@ export class CollectingShelfService {
|
||||
|
||||
getOrderItemSubsetByOrderItemSubsetId(orderItemSubsetId: number): Observable<OrderItemSubsetDTO> {
|
||||
return this.omsService.OrderGetOrderItemSubset(orderItemSubsetId).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -136,11 +137,11 @@ export class CollectingShelfService {
|
||||
|
||||
getOrdersByCompartmentNumber(compartmentNumbers: string[], orderId: number): Observable<OrderDTO> {
|
||||
return this.omsService.OrderGetOrdersByCompartment(compartmentNumbers).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
return response.result ? response.result.find(o => +o.id === +orderId) : null;
|
||||
return response.result ? response.result.find((o) => +o.id === +orderId) : null;
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -164,7 +165,7 @@ export class CollectingShelfService {
|
||||
},
|
||||
};
|
||||
return this.omsService.OrderChangeStatus(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -190,7 +191,7 @@ export class CollectingShelfService {
|
||||
},
|
||||
};
|
||||
return this.omsService.OrderChangeStatus(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -210,7 +211,7 @@ export class CollectingShelfService {
|
||||
},
|
||||
};
|
||||
return this.omsService.OrderPatchOrderItemSubset(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -230,7 +231,7 @@ export class CollectingShelfService {
|
||||
},
|
||||
};
|
||||
return this.omsService.OrderPatchOrderItemSubset(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -246,7 +247,7 @@ export class CollectingShelfService {
|
||||
orderItem,
|
||||
};
|
||||
return this.omsService.OrderPatchOrderItem(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -268,7 +269,7 @@ export class CollectingShelfService {
|
||||
orderItemSubset,
|
||||
};
|
||||
return this.omsService.OrderPatchOrderItemSubset(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -290,7 +291,7 @@ export class CollectingShelfService {
|
||||
orderItemSubset,
|
||||
};
|
||||
return this.omsService.OrderPatchOrderItemSubset(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -305,7 +306,7 @@ export class CollectingShelfService {
|
||||
receiptType: 64,
|
||||
};
|
||||
return this.receiptService.ReceiptReceiptsByOrderId(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -320,7 +321,7 @@ export class CollectingShelfService {
|
||||
code,
|
||||
};
|
||||
return this.omsService.OrderGetStockStatusCodes(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -331,7 +332,7 @@ export class CollectingShelfService {
|
||||
|
||||
getGrossPriceVats() {
|
||||
return this.omsService.OrderGetVATs({}).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -342,7 +343,7 @@ export class CollectingShelfService {
|
||||
|
||||
getSuppliers() {
|
||||
return this.omsService.OrderGetSuppilers({}).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -358,7 +359,7 @@ export class CollectingShelfService {
|
||||
if (index === 0 && !firstBatch) {
|
||||
const olderOrders = this.store.selectSnapshot(CollectingShelfSelectors.getShelfOrders);
|
||||
if (olderOrders && olderOrders.length > 0) {
|
||||
const filteredOrders = olderOrders.filter(t => t.orderId === order.orderId);
|
||||
const filteredOrders = olderOrders.filter((t) => t.orderId === order.orderId);
|
||||
if (
|
||||
order.compartmentCode &&
|
||||
order.processingStatus &&
|
||||
|
||||
@@ -1,28 +1,30 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CustomerService as CustomerApiService, QueryTokenDTO, PayerService } from 'swagger';
|
||||
import { map, switchMap, tap, catchError, share } from 'rxjs/operators';
|
||||
import { Observable, of, combineLatest, Subject, BehaviorSubject } from 'rxjs';
|
||||
import { QueryTokenDTO } from '@swagger/cat';
|
||||
import { CustomerService as CustomerApiService, PayerService } from '@swagger/crm';
|
||||
import { map, switchMap, catchError } from 'rxjs/operators';
|
||||
import { Observable, of, combineLatest, BehaviorSubject } from 'rxjs';
|
||||
import { CustomerMapping } from '../mappings/customer.mapping';
|
||||
import { CustomerSearchResponse } from '../models/customer-search-response.model';
|
||||
import { User, Address } from '../models/user.model';
|
||||
import { CustomerDTO } from 'swagger/lib/crm/models/customer-dto';
|
||||
import { ResponseArgsOfCustomerDTO } from 'swagger/lib/crm/models/response-args-of-customer-dto';
|
||||
import { ResponseArgsOfBoolean } from 'swagger/lib/crm/models/response-args-of-boolean';
|
||||
import { ListResponseArgsOfCustomerInfoDTO } from 'swagger/lib/crm/models/list-response-args-of-customer-info-dto';
|
||||
import { ShippingAddressDTO } from 'swagger/lib/crm/models/shipping-address-dto';
|
||||
import { AssignedPayerDTO } from 'swagger/lib/crm/models/assigned-payer-dto';
|
||||
import {
|
||||
CustomerDTO,
|
||||
AddressDTO,
|
||||
ResponseArgsOfCustomerDTO,
|
||||
ResponseArgsOfBoolean,
|
||||
ListResponseArgsOfCustomerInfoDTO,
|
||||
ShippingAddressDTO,
|
||||
PayerDTO,
|
||||
ResponseArgsOfIEnumerableOfCustomerInfoDTO,
|
||||
CustomerInfoDTO,
|
||||
} from '@swagger/crm';
|
||||
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { ResponseArgsOfPayerDTO } from 'swagger/lib/oms/models/response-args-of-payer-dto';
|
||||
import { PayerDTO } from 'swagger/lib/crm/models/payer-dto';
|
||||
import { CountryDTO } from 'swagger/lib/checkout/models/country-dto';
|
||||
import { ResponseArgsOfPayerDTO } from '@swagger/oms';
|
||||
import { Country } from '../models/country.model';
|
||||
import { ResponseArgsOfIEnumerableOfCustomerInfoDTO } from 'swagger/lib/crm/models/response-args-of-ienumerable-of-customer-info-dto';
|
||||
import { CustomerInfoDTO } from 'swagger/lib/crm/models/customer-info-dto';
|
||||
import { CustomerFilters } from '../../modules/customer';
|
||||
import { AddressDTO } from 'swagger/lib/crm/models/address-dto';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CustomerService {
|
||||
addAddressError$ = new BehaviorSubject<any>(null);
|
||||
@@ -56,7 +58,7 @@ export class CustomerService {
|
||||
const customer: CustomerDTO = this.mapper.fromUserSimple(user);
|
||||
const params: CustomerApiService.CustomerUpdateCustomerParams = {
|
||||
customer: customer,
|
||||
customerId: customer.id
|
||||
customerId: customer.id,
|
||||
};
|
||||
|
||||
return this.customerService.CustomerUpdateCustomer(params).pipe(
|
||||
@@ -72,7 +74,7 @@ export class CustomerService {
|
||||
|
||||
deleteCustomer(customerId: number): Observable<boolean> {
|
||||
const params: CustomerApiService.CustomerDeleteCustomerParams = {
|
||||
customerId
|
||||
customerId,
|
||||
};
|
||||
|
||||
return this.customerService.CustomerDeleteCustomer(params).pipe(
|
||||
@@ -101,7 +103,7 @@ export class CustomerService {
|
||||
: false;
|
||||
const params: QueryTokenDTO = {
|
||||
input: {
|
||||
qs: searchTerm
|
||||
qs: searchTerm,
|
||||
},
|
||||
fuzzy: fuzzy ? 1 : 0,
|
||||
skip: skip,
|
||||
@@ -112,9 +114,9 @@ export class CustomerService {
|
||||
? {
|
||||
['bonuscard']: !isNullOrUndefined(filter.bonuscard) ? String(filter.bonuscard) : undefined,
|
||||
['guestaccount']: !isNullOrUndefined(filter.guestaccount) ? String(filter.guestaccount) : undefined,
|
||||
['onlineshop']: !isNullOrUndefined(filter.onlineshop) ? String(filter.onlineshop) : undefined
|
||||
['onlineshop']: !isNullOrUndefined(filter.onlineshop) ? String(filter.onlineshop) : undefined,
|
||||
}
|
||||
: undefined
|
||||
: undefined,
|
||||
};
|
||||
|
||||
return this.customerService.CustomerListCustomers(params).pipe(
|
||||
@@ -123,9 +125,9 @@ export class CustomerService {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
return {
|
||||
customers: response.result.map(t => this.mapper.customerInfoDTOtoUser(t)),
|
||||
customers: response.result.map((t) => this.mapper.customerInfoDTOtoUser(t)),
|
||||
hits: response.hits,
|
||||
message: response.message
|
||||
message: response.message,
|
||||
};
|
||||
})
|
||||
);
|
||||
@@ -138,18 +140,18 @@ export class CustomerService {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
return {
|
||||
shippingAddresses: response.result.shippingAddresses.map(addressEnity => addressEnity.id),
|
||||
user: this.mapper.customerDTOtoUser(response.result)
|
||||
shippingAddresses: response.result.shippingAddresses.map((addressEnity) => addressEnity.id),
|
||||
user: this.mapper.customerDTOtoUser(response.result),
|
||||
};
|
||||
}),
|
||||
switchMap(customerResult => {
|
||||
switchMap((customerResult) => {
|
||||
const user = customerResult.user;
|
||||
if (!customerResult.shippingAddresses || customerResult.shippingAddresses.length === 0) {
|
||||
return of(customerResult.user);
|
||||
}
|
||||
const observablesOfShippingAddresses = customerResult.shippingAddresses.map(t => {
|
||||
const observablesOfShippingAddresses = customerResult.shippingAddresses.map((t) => {
|
||||
return this.customerService.CustomerGetShippingaddress(t).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -162,7 +164,7 @@ export class CustomerService {
|
||||
switchMap((address: ShippingAddressDTO[]) => {
|
||||
const updatedUser = user;
|
||||
if (!!address) {
|
||||
const addresses = address.map(t => {
|
||||
const addresses = address.map((t) => {
|
||||
return { ...this.mapper.fromShippingAddressDtoToAddress(t), synced: true };
|
||||
});
|
||||
const defaultAddresses = addresses.reduce((ad1, ad2) => {
|
||||
@@ -181,15 +183,15 @@ export class CustomerService {
|
||||
switchMap((customer: User) => {
|
||||
const updateCustomer = customer;
|
||||
return this.customerService.CustomerGetAssignedPayersByCustomerId(customer.id).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
return { customer: customer, assignedPayers: response.result };
|
||||
}),
|
||||
switchMap(response => {
|
||||
switchMap((response) => {
|
||||
if (Array.isArray(response.assignedPayers) && response.assignedPayers.length > 0) {
|
||||
const invoiceAddresses = response.assignedPayers.map(t => {
|
||||
const invoiceAddresses = response.assignedPayers.map((t) => {
|
||||
return { ...this.mapper.fromAssignedPayerDtoToAddress(t), synced: true };
|
||||
});
|
||||
const defaultAddresses = invoiceAddresses.reduce((ad1, ad2) => {
|
||||
@@ -210,7 +212,7 @@ export class CustomerService {
|
||||
|
||||
getCustomerById(customerId: number): Observable<User> {
|
||||
const params = {
|
||||
customerId: customerId
|
||||
customerId: customerId,
|
||||
};
|
||||
return this.getCustomer(this.customerService.CustomerGetCustomer(params));
|
||||
}
|
||||
@@ -221,7 +223,7 @@ export class CustomerService {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
return { customers: response.result.map(t => this.mapper.customerInfoDTOtoUser(t)), hits: 0 };
|
||||
return { customers: response.result.map((t) => this.mapper.customerInfoDTOtoUser(t)), hits: 0 };
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -244,11 +246,11 @@ export class CustomerService {
|
||||
const params = {
|
||||
shippingAddressId: shippingAddress.id,
|
||||
customerId: customerId,
|
||||
isDefault: true
|
||||
isDefault: true,
|
||||
};
|
||||
if (shippingAddress.synced === true) {
|
||||
return this.customerService.CustomerModifyShippingAddressFlag(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -257,9 +259,9 @@ export class CustomerService {
|
||||
);
|
||||
} else {
|
||||
return this.addShippingAddress(customerId, { ...shippingAddress, id: null }).pipe(
|
||||
switchMap(addResponse => {
|
||||
switchMap(() => {
|
||||
return this.customerService.CustomerModifyShippingAddressFlag(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -279,10 +281,10 @@ export class CustomerService {
|
||||
const params = {
|
||||
payerId: invoiceAddress.id,
|
||||
customerId: customerId,
|
||||
isDefault: true
|
||||
isDefault: true,
|
||||
};
|
||||
return this.customerService.CustomerModifyPayerReference(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -295,10 +297,10 @@ export class CustomerService {
|
||||
const params = {
|
||||
payerId: payerDto.id,
|
||||
customerId: customerId,
|
||||
isDefault: true
|
||||
isDefault: true,
|
||||
};
|
||||
return this.customerService.CustomerModifyPayerReference(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -315,10 +317,10 @@ export class CustomerService {
|
||||
const params = {
|
||||
shippingAddressId: shippingAddress.id,
|
||||
shippingAddress: this.mapper.fromAddressToShippingAddressDTO(shippingAddress, !isNullOrUndefined(shippingAddress.id)),
|
||||
customerId: customerId
|
||||
customerId: customerId,
|
||||
};
|
||||
return this.customerService.CustomerUpdateShippingAddress(params).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
if (error && error.error && error.error.error) {
|
||||
throw new Error(error.error.message);
|
||||
}
|
||||
@@ -333,7 +335,7 @@ export class CustomerService {
|
||||
}
|
||||
return of(undefined);
|
||||
}),
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response) {
|
||||
this.addAddressError$.next(undefined);
|
||||
return response.result;
|
||||
@@ -343,10 +345,10 @@ export class CustomerService {
|
||||
} else {
|
||||
const params = {
|
||||
shippingAddress: this.mapper.fromAddressToShippingAddressDTO(shippingAddress, !isNullOrUndefined(shippingAddress.id)),
|
||||
customerId: customerId
|
||||
customerId: customerId,
|
||||
};
|
||||
return this.customerService.CustomerCreateShippingAddress(params).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
if (error && error.error && error.error.error) {
|
||||
throw new Error(error.error.message);
|
||||
}
|
||||
@@ -361,7 +363,7 @@ export class CustomerService {
|
||||
}
|
||||
return of(undefined);
|
||||
}),
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response) {
|
||||
this.addAddressError$.next(undefined);
|
||||
return response.result;
|
||||
@@ -378,7 +380,7 @@ export class CustomerService {
|
||||
}
|
||||
if (isNullOrUndefined(incoiceAddress.id)) {
|
||||
return this.payerService.PayerCreatePayer(payerDto).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
if (error && error.error && error.error.error) {
|
||||
throw new Error(error.error.message);
|
||||
}
|
||||
@@ -400,10 +402,10 @@ export class CustomerService {
|
||||
const referenceParamsparams = {
|
||||
customerId: customerId,
|
||||
payerId: payerResponse.result.id,
|
||||
isDefault: true
|
||||
isDefault: true,
|
||||
};
|
||||
return this.customerService.CustomerAddPayerReference(referenceParamsparams).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -416,10 +418,10 @@ export class CustomerService {
|
||||
} else {
|
||||
const updatePayerParams = {
|
||||
payerId: incoiceAddress.id,
|
||||
payer: payerDto
|
||||
payer: payerDto,
|
||||
};
|
||||
return this.payerService.PayerUpdatePayer(updatePayerParams).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
if (error && error.error && error.error.error) {
|
||||
throw new Error(error.error.message);
|
||||
}
|
||||
@@ -434,7 +436,7 @@ export class CustomerService {
|
||||
}
|
||||
return of(undefined);
|
||||
}),
|
||||
map(response => {
|
||||
map((response) => {
|
||||
this.addAddressError$.next(undefined);
|
||||
return response ? response.result : null;
|
||||
})
|
||||
@@ -444,7 +446,7 @@ export class CustomerService {
|
||||
|
||||
getCountries(): Observable<Country[]> {
|
||||
return this.customerService.CustomerGetCountries({}).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -455,11 +457,11 @@ export class CustomerService {
|
||||
|
||||
getBonusCards(customerId: number) {
|
||||
return this.customerService.CustomerGetBonuscards(customerId).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
console.error('Error getting customer cards', error);
|
||||
return of(undefined);
|
||||
}),
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response && response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -470,13 +472,13 @@ export class CustomerService {
|
||||
|
||||
emailExists(email: string) {
|
||||
return this.customerService.CustomerEmailExists(email).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response && response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
return response && response.result;
|
||||
}),
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
console.error(error);
|
||||
return of(undefined);
|
||||
})
|
||||
@@ -485,7 +487,7 @@ export class CustomerService {
|
||||
|
||||
addressValid(address: AddressDTO): Observable<any> {
|
||||
return this.customerService.CustomerValidateAddress(address).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
console.error(error);
|
||||
return of(error);
|
||||
}),
|
||||
|
||||
@@ -3,9 +3,9 @@ import { map, catchError } from 'rxjs/operators';
|
||||
import { FeedMapping } from 'apps/sales/src/app/core/mappings/feed.mapping';
|
||||
import { Observable } from 'rxjs';
|
||||
import { FeedCard } from '../models/feed-card.model';
|
||||
import { InfoService } from 'swagger';
|
||||
import { ListResponseArgsOfFeedDTO } from 'swagger/lib/isa/models/list-response-args-of-feed-dto';
|
||||
import { ListResponseArgsOfFeedDTO } from '@swagger/isa';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { InfoService } from '@swagger/isa';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -16,6 +16,6 @@ export class DashboardFeedService {
|
||||
info(): Observable<FeedCard[]> {
|
||||
return this.infoService
|
||||
.InfoInfo({ take: null, skip: null })
|
||||
.pipe(map((feed: ListResponseArgsOfFeedDTO) => feed.result.map(t => this.feedMapping.fromFeedDTO(t))));
|
||||
.pipe(map((feed: ListResponseArgsOfFeedDTO) => feed.result.map((t) => this.feedMapping.fromFeedDTO(t))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import { Filter } from '../models/filter.model';
|
||||
import { FilterItem } from '../models/filter-item.model';
|
||||
import { FilterMapping } from '../mappings/filter.mapping';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SearchService, ResponseArgsOfUISettingsDTO } from 'swagger';
|
||||
import { SearchService, ResponseArgsOfUISettingsDTO } from '@swagger/cat';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class FilterService {
|
||||
constructor(private service: SearchService, private filterMapping: FilterMapping) {}
|
||||
@@ -75,11 +75,11 @@ export class FilterService {
|
||||
return { ...item, selected: !item.selected };
|
||||
}
|
||||
return { ...item };
|
||||
})
|
||||
}),
|
||||
];
|
||||
let selected = 0;
|
||||
let isSelectEvent = false;
|
||||
updatedItems.forEach(t => {
|
||||
updatedItems.forEach((t) => {
|
||||
if (t.selected) {
|
||||
selected++;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ export class FilterService {
|
||||
return { ...item, selected: false };
|
||||
}
|
||||
return { ...item };
|
||||
})
|
||||
}),
|
||||
];
|
||||
}
|
||||
return updatedItems;
|
||||
@@ -123,7 +123,7 @@ export class FilterService {
|
||||
map((data: ResponseArgsOfUISettingsDTO) => {
|
||||
const result = {
|
||||
...data.result,
|
||||
filter: data.result.filter.filter(f => f.key === 'format' || f.key === 'dbhwgr' || f.key === 'region' || f.key === 'stock')
|
||||
filter: data.result.filter.filter((f) => f.key === 'format' || f.key === 'dbhwgr' || f.key === 'region' || f.key === 'stock'),
|
||||
};
|
||||
|
||||
return this.filterMapping.fromUiSettingsDto(result);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { OrderService } from 'swagger';
|
||||
import { Suchparameter } from 'swagger/lib/oms/models/suchparameter';
|
||||
import { Suchparameter, OrderService } from '@swagger/oms';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { GoodsInSelectors } from '../store/selectors/goods-in.selectors';
|
||||
@@ -19,7 +18,7 @@ export class GoodsInService {
|
||||
take,
|
||||
};
|
||||
return this.omsService.OrderWareneingangsuche(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { SearchService } from 'swagger';
|
||||
import { SearchService } from '@swagger/cat';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { of, Observable } from 'rxjs';
|
||||
|
||||
@@ -11,24 +11,24 @@ export class ImageService {
|
||||
|
||||
getImageUrlFromBackend(ean: string, size: { width: number; height: number } = { width: 150, height: 150 }): Observable<string> {
|
||||
return this.catService.SearchSettings().pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
sessionStorage.setItem('ImageUrlTemplate', response.result.imageUrl);
|
||||
return response.result.imageUrl;
|
||||
}),
|
||||
map(url => url.replace('{ean}', ean)),
|
||||
map(url => url.replace('150x150', `${size.width}x${size.height}`)),
|
||||
map((url) => url.replace('{ean}', ean)),
|
||||
map((url) => url.replace('150x150', `${size.width}x${size.height}`)),
|
||||
catchError(() => of(''))
|
||||
);
|
||||
}
|
||||
|
||||
getThumbnailUrlFromBackend(ean: string, size: { width: number; height: number } = { width: 150, height: 150 }): Observable<string> {
|
||||
return this.catService.SearchSettings().pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
sessionStorage.setItem('ThumbnailUrlTemplate', response.result.thumbnailImageUrl);
|
||||
return response.result.thumbnailImageUrl;
|
||||
}),
|
||||
map(url => url.replace('{ean}', ean)),
|
||||
map(url => url.replace('150x150', `${size.width}x${size.height}`)),
|
||||
map((url) => url.replace('{ean}', ean)),
|
||||
map((url) => url.replace('150x150', `${size.width}x${size.height}`)),
|
||||
catchError(() => of(''))
|
||||
);
|
||||
}
|
||||
@@ -37,8 +37,8 @@ export class ImageService {
|
||||
const imageUrlTemplate = sessionStorage.getItem('ImageUrlTemplate');
|
||||
if (imageUrlTemplate) {
|
||||
return of(imageUrlTemplate).pipe(
|
||||
map(url => url.replace('{ean}', ean)),
|
||||
map(url => url.replace('150x150', `${size.width}x${size.height}`)),
|
||||
map((url) => url.replace('{ean}', ean)),
|
||||
map((url) => url.replace('150x150', `${size.width}x${size.height}`)),
|
||||
catchError(() => of(''))
|
||||
);
|
||||
}
|
||||
@@ -49,8 +49,8 @@ export class ImageService {
|
||||
const thumbnailUrlTemplate = sessionStorage.getItem('ThumbnailUrlTemplate');
|
||||
if (thumbnailUrlTemplate) {
|
||||
return of(thumbnailUrlTemplate).pipe(
|
||||
map(url => url.replace('{ean}', ean)),
|
||||
map(url => url.replace('150x150', `${size.width}x${size.height}`)),
|
||||
map((url) => url.replace('{ean}', ean)),
|
||||
map((url) => url.replace('150x150', `${size.width}x${size.height}`)),
|
||||
catchError(() => of(''))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { UserStateService } from 'swagger';
|
||||
import { Log } from 'swagger/lib/isa/models/log';
|
||||
import { UserStateService } from '@swagger/isa';
|
||||
import { Log } from '@swagger/isa';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
|
||||
@Injectable({
|
||||
@@ -29,7 +29,7 @@ export class LoggingService {
|
||||
this.userStateService
|
||||
.UserStateSaveLog(log)
|
||||
.toPromise()
|
||||
.catch(err => console.error('Logging failed: ', err));
|
||||
.catch((err) => console.error('Logging failed: ', err));
|
||||
}
|
||||
|
||||
private logHttpError(message: string, error: HttpErrorResponse, logType: LogType) {
|
||||
@@ -41,7 +41,7 @@ export class LoggingService {
|
||||
this.userStateService
|
||||
.UserStateSaveLog(log)
|
||||
.toPromise()
|
||||
.catch(err => console.error('Logging failed: ', err));
|
||||
.catch((err) => console.error('Logging failed: ', err));
|
||||
}
|
||||
|
||||
private logOtherError(message: string, error: any, logType: LogType) {
|
||||
@@ -53,7 +53,7 @@ export class LoggingService {
|
||||
this.userStateService
|
||||
.UserStateSaveLog(log)
|
||||
.toPromise()
|
||||
.catch(err => console.error('Logging failed: ', err));
|
||||
.catch((err) => console.error('Logging failed: ', err));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ListResponseArgsOfOrderListItemDTO } from 'swagger/lib/oms/models/list-response-args-of-order-list-item-dto';
|
||||
import { ListResponseArgsOfOrderListItemDTO, ResponseArgsOfOrderDTO, OrderDTO, OrderListItemDTO } from '@swagger/oms';
|
||||
import { Observable } from 'rxjs';
|
||||
import { OrderService } from 'swagger';
|
||||
import { ResponseArgsOfOrderDTO } from 'swagger/lib/oms/models/response-args-of-order-dto';
|
||||
import { OrderDTO } from 'swagger/lib/oms/models/order-dto';
|
||||
import { OrderListItemDTO } from 'swagger/lib/oms/models/order-list-item-dto';
|
||||
import { OrderService } from '@swagger/oms';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class OrdersService {
|
||||
constructor(private orderService: OrderService) {}
|
||||
@@ -17,7 +14,7 @@ export class OrdersService {
|
||||
const params: OrderService.OrderGetOrdersByBuyerNumberParams = {
|
||||
buyerNumber: customerId,
|
||||
skip: 0,
|
||||
take: 99999
|
||||
take: 99999,
|
||||
};
|
||||
|
||||
return this.orderService.OrderGetOrdersByBuyerNumber(params).pipe(
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
CatalogPrintService,
|
||||
OMSPrintService,
|
||||
CheckoutPrintService,
|
||||
PrintService,
|
||||
ItemDTO
|
||||
} from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { map, catchError, timeout, filter, switchMap } from 'rxjs/operators';
|
||||
import { Printer } from '../models/printer.model';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { PrintRequestOfIEnumerableOfItemDTO } from 'swagger/lib/print/models/print-request-of-ienumerable-of-item-dto';
|
||||
import { PrintRequestOfIEnumerableOfItemDTO, PrintRequestOfIEnumerableOfLong, ResponseArgs } from '@swagger/print';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { PrintRequestOfIEnumerableOfLong } from 'swagger/lib/print/models/print-request-of-ienumerable-of-long';
|
||||
import { ResponseArgs } from 'swagger/lib/print/models/response-args';
|
||||
import { OMSPrintService, CheckoutPrintService, CatalogPrintService, PrintService } from '@swagger/print';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PrinterService {
|
||||
constructor(
|
||||
@@ -29,15 +22,13 @@ export class PrinterService {
|
||||
getAvailablePrinters(): Observable<Printer[] | { error: string }> {
|
||||
return this.printService.PrintPrinters().pipe(
|
||||
timeout(20000),
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
return of({ error });
|
||||
}),
|
||||
map((response: any) => {
|
||||
if (response.error && response.error.status === 503) {
|
||||
return {
|
||||
error: response.message
|
||||
? response.message
|
||||
: 'Das Backend ist derzeit nicht erreichbar'
|
||||
error: response.message ? response.message : 'Das Backend ist derzeit nicht erreichbar',
|
||||
};
|
||||
}
|
||||
if (response.error && response.error.name === 'TimeoutError') {
|
||||
@@ -45,20 +36,16 @@ export class PrinterService {
|
||||
}
|
||||
if (response.error) {
|
||||
return {
|
||||
error: response.message
|
||||
? response.message
|
||||
: response.error.message
|
||||
? response.error.message
|
||||
: 'Ein Fehler ist aufgetreten'
|
||||
error: response.message ? response.message : response.error.message ? response.error.message : 'Ein Fehler ist aufgetreten',
|
||||
};
|
||||
}
|
||||
return response.result.map(
|
||||
t =>
|
||||
(t) =>
|
||||
<Printer>{
|
||||
key: t.key,
|
||||
value: t.value,
|
||||
description: t.description,
|
||||
selected: t.selected
|
||||
selected: t.selected,
|
||||
}
|
||||
);
|
||||
})
|
||||
@@ -68,15 +55,13 @@ export class PrinterService {
|
||||
getAvailablePrintersDev() {
|
||||
return this.http.get('http://127.0.0.1:5000/api/printers').pipe(
|
||||
timeout(20000),
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
return of({ error });
|
||||
}),
|
||||
map((response: any) => {
|
||||
if (response.error && response.error.status === 503) {
|
||||
return {
|
||||
error: response.message
|
||||
? response.message
|
||||
: 'Das Backend ist derzeit nicht erreichbar'
|
||||
error: response.message ? response.message : 'Das Backend ist derzeit nicht erreichbar',
|
||||
};
|
||||
}
|
||||
if (response.error && response.error.name === 'TimeoutError') {
|
||||
@@ -84,43 +69,28 @@ export class PrinterService {
|
||||
}
|
||||
if (response.error) {
|
||||
return {
|
||||
error: response.message
|
||||
? response.message
|
||||
: response.error.message
|
||||
? response.error.message
|
||||
: 'Ein Fehler ist aufgetreten'
|
||||
error: response.message ? response.message : response.error.message ? response.error.message : 'Ein Fehler ist aufgetreten',
|
||||
};
|
||||
}
|
||||
return response.result.map(
|
||||
t =>
|
||||
(t) =>
|
||||
<Printer>{
|
||||
key: t.key,
|
||||
value: t.value,
|
||||
description: t.description,
|
||||
selected: t.selected
|
||||
selected: t.selected,
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
async testPrinting() {
|
||||
const printers = await this.getAvailablePrinters().toPromise();
|
||||
const printer = printers[0];
|
||||
if (printer) {
|
||||
console.log('Printers', printers);
|
||||
}
|
||||
}
|
||||
|
||||
async printOrder(orderIds: number[], printer: string): Promise<ResponseArgs> {
|
||||
const params = <any>{
|
||||
printer: printer,
|
||||
data: orderIds
|
||||
data: orderIds,
|
||||
};
|
||||
const response = await this.oMSPrintService
|
||||
.OMSPrintAbholscheinById(params)
|
||||
.pipe(timeout(20000))
|
||||
.toPromise();
|
||||
const response = await this.oMSPrintService.OMSPrintAbholscheinById(params).pipe(timeout(20000)).toPromise();
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -128,12 +98,9 @@ export class PrinterService {
|
||||
async printProduct(item: ItemDTO, printer: string): Promise<ResponseArgs> {
|
||||
const params = <PrintRequestOfIEnumerableOfItemDTO>{
|
||||
printer: printer,
|
||||
data: [item]
|
||||
data: [item],
|
||||
};
|
||||
const response = await this.catalogPrintService
|
||||
.CatalogPrintArtikelDetail(params)
|
||||
.pipe(timeout(20000))
|
||||
.toPromise();
|
||||
const response = await this.catalogPrintService.CatalogPrintArtikelDetail(params).pipe(timeout(20000)).toPromise();
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -141,12 +108,9 @@ export class PrinterService {
|
||||
async printCart(cartId: number, printer: string): Promise<ResponseArgs> {
|
||||
const params = <any>{
|
||||
printer: printer,
|
||||
data: cartId
|
||||
data: cartId,
|
||||
};
|
||||
const response = await this.checkoutPrintService
|
||||
.CheckoutPrintWarenkorbById(params)
|
||||
.pipe(timeout(20000))
|
||||
.toPromise();
|
||||
const response = await this.checkoutPrintService.CheckoutPrintWarenkorbById(params).pipe(timeout(20000)).toPromise();
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -154,14 +118,14 @@ export class PrinterService {
|
||||
async printGoodsInLabel(subsetItemIds: number[]): Promise<ResponseArgs> {
|
||||
const response = await this.getAvailablePrinters()
|
||||
.pipe(
|
||||
filter(data => Array.isArray(data)),
|
||||
filter((data) => Array.isArray(data)),
|
||||
switchMap((printers: Printer[]) => {
|
||||
if (printers && printers.length > 0) {
|
||||
const printer = printers.find(p => p.selected);
|
||||
const printer = printers.find((p) => p.selected);
|
||||
if (printer) {
|
||||
const params = <PrintRequestOfIEnumerableOfLong>{
|
||||
data: subsetItemIds,
|
||||
printer: printer.key
|
||||
printer: printer.key,
|
||||
};
|
||||
return this.oMSPrintService.OMSPrintAbholfachetikett(params);
|
||||
} else {
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AvailabilityService, StockRequest, StockInfoDTO, ItemDTO } from 'swagger';
|
||||
import { AvailabilityRequestDTO } from 'swagger/lib/availability/models/availability-request-dto';
|
||||
import { StockRequest, StockInfoDTO, ItemDTO, StockService } from '@swagger/cat';
|
||||
import { AvailabilityRequestDTO, AvailabilityDTO, ResponseArgsOfIEnumerableOfAvailabilityDTO } from '@swagger/availability';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { AvailabilityDTO } from 'swagger/lib/availability/models/availability-dto';
|
||||
// tslint:disable-next-line: max-line-length
|
||||
import { ResponseArgsOfIEnumerableOfAvailabilityDTO } from 'swagger/lib/availability/models/response-args-of-ienumerable-of-availability-dto';
|
||||
import { CheckoutType } from '../models/checkout-type.enum';
|
||||
import { StockService } from 'swagger';
|
||||
import { AvailabilityService } from '@swagger/availability';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -32,7 +29,7 @@ export class ProductAvailabilityService {
|
||||
},
|
||||
];
|
||||
return this.availabilityService.AvailabilityStoreAvailability(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
console.error(response.message);
|
||||
}
|
||||
@@ -57,7 +54,7 @@ export class ProductAvailabilityService {
|
||||
},
|
||||
];
|
||||
return this.availabilityService.AvailabilityShippingAvailability(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
console.error(response.message);
|
||||
}
|
||||
@@ -72,7 +69,7 @@ export class ProductAvailabilityService {
|
||||
itemIds,
|
||||
};
|
||||
return this.stockService.StockInStock(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -98,10 +95,10 @@ export class ProductAvailabilityService {
|
||||
},
|
||||
];
|
||||
return this.availabilityService.AvailabilityStoreAvailability(params).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
return of({ error: error, message: error.message, type: CheckoutType.store });
|
||||
}),
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
console.error(response.message);
|
||||
return { error: response.error, message: response.message, type: CheckoutType.store };
|
||||
@@ -128,10 +125,10 @@ export class ProductAvailabilityService {
|
||||
},
|
||||
];
|
||||
return this.availabilityService.AvailabilityShippingAvailability(params).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
return of({ error: error, message: error.message, type: CheckoutType.delivery });
|
||||
}),
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
console.error(response.message);
|
||||
return { error: response.error, message: response.message, type: CheckoutType.delivery };
|
||||
|
||||
@@ -12,27 +12,21 @@ import {
|
||||
AutocompleteTokenDTO,
|
||||
AutocompleteDTO,
|
||||
QueryTokenDTO,
|
||||
ResponseArgsOfItemDTO
|
||||
} from 'swagger';
|
||||
ResponseArgsOfItemDTO,
|
||||
} from '@swagger/cat';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { ProductSelectors } from '../store/selectors/product.selector';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ProductService {
|
||||
constructor(
|
||||
private searchService: SearchService,
|
||||
private filterMapping: FilterMapping,
|
||||
private store: Store
|
||||
) {}
|
||||
constructor(private searchService: SearchService, private filterMapping: FilterMapping, private store: Store) {}
|
||||
|
||||
persistLastSearchToLocalStorage(param: string) {
|
||||
// get recent searches from local storage
|
||||
const recentSearches: RecentArticleSearch[] = JSON.parse(
|
||||
localStorage.getItem('recent_searches')
|
||||
);
|
||||
const recentSearches: RecentArticleSearch[] = JSON.parse(localStorage.getItem('recent_searches'));
|
||||
/*
|
||||
* check if there are search items in local storage, if there are not add search to local storage
|
||||
* else check if current search already exists in loacl storage, if exist delete it (deletion is made becouse
|
||||
@@ -41,30 +35,28 @@ export class ProductService {
|
||||
*/
|
||||
if (recentSearches) {
|
||||
const searches = [
|
||||
...recentSearches.filter(data => {
|
||||
...recentSearches.filter((data) => {
|
||||
return data.name !== param;
|
||||
}),
|
||||
<RecentArticleSearch>{
|
||||
id: recentSearches[recentSearches.length - 1].id + 1,
|
||||
name: param
|
||||
}
|
||||
name: param,
|
||||
},
|
||||
];
|
||||
localStorage.setItem('recent_searches', JSON.stringify(searches));
|
||||
} else {
|
||||
const searches = [
|
||||
<RecentArticleSearch>{
|
||||
id: 1,
|
||||
name: param
|
||||
}
|
||||
name: param,
|
||||
},
|
||||
];
|
||||
localStorage.setItem('recent_searches', JSON.stringify(searches));
|
||||
}
|
||||
}
|
||||
|
||||
getRecentSearches(): Observable<RecentArticleSearch[]> {
|
||||
const recentSearches: RecentArticleSearch[] = JSON.parse(
|
||||
localStorage.getItem('recent_searches')
|
||||
);
|
||||
const recentSearches: RecentArticleSearch[] = JSON.parse(localStorage.getItem('recent_searches'));
|
||||
return of(recentSearches);
|
||||
}
|
||||
// placeholder service method for calling product search API
|
||||
@@ -80,15 +72,10 @@ export class ProductService {
|
||||
input: this.createSearchInput(search),
|
||||
skip: search.skip,
|
||||
take: search.take,
|
||||
hitsOnly: search.hits
|
||||
hitsOnly: search.hits,
|
||||
};
|
||||
|
||||
const queryWithFilters = this.filterMapping.toQueryTokenDto(
|
||||
queryToken,
|
||||
search.fitlers,
|
||||
search.archiveFilter,
|
||||
false
|
||||
);
|
||||
const queryWithFilters = this.filterMapping.toQueryTokenDto(queryToken, search.fitlers, search.archiveFilter, false);
|
||||
return this.searchService.SearchSearch(queryWithFilters).pipe(
|
||||
map((response: ListResponseArgsOfItemDTO) => {
|
||||
if (response.error) {
|
||||
@@ -96,7 +83,7 @@ export class ProductService {
|
||||
}
|
||||
return response;
|
||||
}),
|
||||
map(response => response.hits)
|
||||
map((response) => response.hits)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -106,15 +93,10 @@ export class ProductService {
|
||||
const queryToken = <QueryTokenDTO>{
|
||||
input: this.createSearchInput(search),
|
||||
skip: search.skip,
|
||||
take: search.take
|
||||
take: search.take,
|
||||
};
|
||||
|
||||
const queryWithFilters = this.filterMapping.toQueryTokenDto(
|
||||
queryToken,
|
||||
search.fitlers,
|
||||
search.archiveFilter,
|
||||
false
|
||||
);
|
||||
const queryWithFilters = this.filterMapping.toQueryTokenDto(queryToken, search.fitlers, search.archiveFilter, false);
|
||||
return this.searchService.SearchSearch(queryWithFilters).pipe(
|
||||
map((response: ListResponseArgsOfItemDTO) => {
|
||||
if (response.error) {
|
||||
@@ -122,33 +104,21 @@ export class ProductService {
|
||||
}
|
||||
return response;
|
||||
}),
|
||||
map(response => response.result)
|
||||
map((response) => response.result)
|
||||
);
|
||||
}
|
||||
|
||||
searchItemsWithPagination(
|
||||
search: Search,
|
||||
skip,
|
||||
size,
|
||||
filters,
|
||||
isNegativeFiltering: boolean
|
||||
): Observable<ListResponseArgsOfItemDTO> {
|
||||
searchItemsWithPagination(search: Search, skip, size, filters, isNegativeFiltering: boolean): Observable<ListResponseArgsOfItemDTO> {
|
||||
const queryToken = <QueryTokenDTO>{
|
||||
input: this.createSearchInput(search),
|
||||
skip: skip,
|
||||
take: size
|
||||
take: size,
|
||||
};
|
||||
|
||||
const queryWithFilters = this.filterMapping.toQueryTokenDto(
|
||||
queryToken,
|
||||
filters,
|
||||
search.archiveFilter,
|
||||
isNegativeFiltering
|
||||
);
|
||||
const queryWithFilters = this.filterMapping.toQueryTokenDto(queryToken, filters, search.archiveFilter, isNegativeFiltering);
|
||||
return this.searchService.SearchSearch(queryWithFilters).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
console.log(response.error, response);
|
||||
throw new Error(response.message);
|
||||
}
|
||||
this.persistLastSearchToLocalStorage(search.query);
|
||||
@@ -164,7 +134,7 @@ export class ProductService {
|
||||
|
||||
getItemById(id: number): Observable<any> {
|
||||
return this.searchService.SearchDetail(id).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
@@ -186,29 +156,25 @@ export class ProductService {
|
||||
|
||||
getItemByIds(ids: number[]): Observable<ItemDTO[]> {
|
||||
return this.searchService.SearchById(ids).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
throw new Error(response.message);
|
||||
}
|
||||
return response;
|
||||
}),
|
||||
map(response => response.result)
|
||||
map((response) => response.result)
|
||||
);
|
||||
}
|
||||
|
||||
complete(
|
||||
input: string,
|
||||
take: number,
|
||||
type: string
|
||||
): Observable<AutocompleteDTO[]> {
|
||||
complete(input: string, take: number, type: string): Observable<AutocompleteDTO[]> {
|
||||
return this.searchService
|
||||
.SearchAutocomplete(<AutocompleteTokenDTO>{
|
||||
input,
|
||||
take,
|
||||
type
|
||||
type,
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
console.error(response.message);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { SearchService, ResponseArgsOfIEnumerableOfItemDTO, ItemDTO } from 'swagger';
|
||||
import { SearchService, ItemDTO } from '@swagger/cat';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@@ -15,7 +15,7 @@ export class RecommandationService {
|
||||
digId: digId + '',
|
||||
};
|
||||
return this.searchService.SearchGetRecommendations(params).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response.error) {
|
||||
console.error(response.message);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { UserStateService as UserStateServiceAPI, ResponseArgs } from 'swagger';
|
||||
import { UserState } from 'swagger/lib/isa/models/user-state';
|
||||
import { ResponseArgsOfUserState } from 'swagger/lib/isa/models/response-args-of-user-state';
|
||||
import { ResponseArgs } from '@swagger/cat';
|
||||
import { UserStateService as UserStateServiceAPI } from '@swagger/isa';
|
||||
import { UserState, ResponseArgsOfUserState } from '@swagger/isa';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserStateService {
|
||||
constructor(private userStateService: UserStateServiceAPI) {}
|
||||
|
||||
saveUserState(userData: string): Observable<string> {
|
||||
const us: UserState = {
|
||||
content: userData
|
||||
content: userData,
|
||||
};
|
||||
|
||||
return this.userStateService.UserStateSetUserState(us).pipe(
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserService } from './user.service';
|
||||
|
||||
describe('UserService', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
});
|
||||
@@ -1,93 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { User } from '../../core/models/user.model';
|
||||
import { usersMock } from 'mock';
|
||||
import { Observable, of } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserService {
|
||||
constructor() {
|
||||
localStorage.setItem('users', JSON.stringify(usersMock));
|
||||
}
|
||||
|
||||
searchUser(params: string): Observable<User[]> {
|
||||
let mockedUsers = JSON.parse(localStorage.getItem('users'));
|
||||
if (!mockedUsers) {
|
||||
localStorage.setItem('users', JSON.stringify(usersMock));
|
||||
mockedUsers = usersMock;
|
||||
}
|
||||
const foundUsersFromFirstName: User[] = [];
|
||||
const foundUsersFromLastName: User[] = [];
|
||||
const foundUsersFromEmail: User[] = [];
|
||||
const splitedParams = params.split(' ');
|
||||
|
||||
mockedUsers.forEach((user: User) => {
|
||||
splitedParams.forEach((word: string) => {
|
||||
if (word) {
|
||||
const lastName = user.last_name ? user.last_name : null;
|
||||
if (lastName && lastName.toLowerCase().indexOf(word.toLowerCase()) >= 0) {
|
||||
const userExists = foundUsersFromLastName.filter((userAdded: User) => userAdded.id === user.id);
|
||||
if (userExists.length === 0) {
|
||||
foundUsersFromLastName.push(user);
|
||||
}
|
||||
}
|
||||
|
||||
const firstName = user.first_name ? user.first_name : null;
|
||||
if (firstName && firstName.toLowerCase().indexOf(word.toLowerCase()) >= 0) {
|
||||
const userExists = foundUsersFromFirstName.filter((userAdded: User) => userAdded.id === user.id);
|
||||
const userFoundWithLastName = foundUsersFromLastName.filter((userAdded: User) => userAdded.id === user.id);
|
||||
if (userExists.length === 0 && userFoundWithLastName.length === 0) {
|
||||
foundUsersFromFirstName.push(user);
|
||||
}
|
||||
}
|
||||
|
||||
if (user.email) {
|
||||
const email = user.email ? user.email : null;
|
||||
if (email.trim().toLowerCase() === word.trim().toLowerCase()) {
|
||||
const userExists = foundUsersFromFirstName.filter((userAdded: User) => userAdded.id === user.id);
|
||||
const userFoundWithLastName = foundUsersFromLastName.filter((userAdded: User) => userAdded.id === user.id);
|
||||
if (userExists.length === 0 && userFoundWithLastName.length === 0) {
|
||||
foundUsersFromEmail.push(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
const orderedLastName = foundUsersFromLastName.sort(this.sortLastNameAlphabeticallyAsc);
|
||||
const orderedFirstName = foundUsersFromFirstName.sort(this.sortFirsNameAlphabeticallyAsc);
|
||||
const orderedEmail = foundUsersFromEmail.sort(this.sortEmailAlphabeticallyAsc);
|
||||
const result = [
|
||||
...orderedLastName,
|
||||
...orderedFirstName.filter(user => orderedLastName.findIndex(t => t === user) === -1),
|
||||
...orderedEmail.filter(
|
||||
user => orderedLastName.findIndex(t => t === user) === -1 && orderedFirstName.findIndex(t => t === user) === -1
|
||||
),
|
||||
];
|
||||
return of(result);
|
||||
}
|
||||
|
||||
addUser(user: User) {
|
||||
const mockedUsers = JSON.parse(localStorage.getItem('users'));
|
||||
localStorage.setItem('users', JSON.stringify([...mockedUsers, user]));
|
||||
}
|
||||
|
||||
sortLastNameAlphabeticallyAsc(a: User, b: User) {
|
||||
const aLastName = a.last_name ? a.last_name : null;
|
||||
const bLastName = b.last_name ? b.last_name : null;
|
||||
return ('' + aLastName).localeCompare(bLastName);
|
||||
}
|
||||
|
||||
sortFirsNameAlphabeticallyAsc(a: User, b: User) {
|
||||
const aLastName = a.first_name ? a.first_name : null;
|
||||
const bLastName = b.first_name ? b.first_name : null;
|
||||
return ('' + aLastName).localeCompare(bLastName);
|
||||
}
|
||||
|
||||
sortEmailAlphabeticallyAsc(a: User, b: User) {
|
||||
const aEmail = a.email ? a.email : null;
|
||||
const bEmail = b.email ? b.email : null;
|
||||
return ('' + aEmail).localeCompare(bEmail);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BranchDTO } from 'libs/swagger/src/lib/checkout/models';
|
||||
import { BranchDTO } from '@swagger/checkout';
|
||||
|
||||
export const LOAD_BRANCHES = '[BRANCH] Load all branches';
|
||||
export const LOAD_USER_BRANCH = '[BRANCH] Load user branch';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AvailabilityDTO } from 'swagger/lib/availability/models/availability-dto';
|
||||
import { AvailabilityDTO } from '@swagger/cat';
|
||||
import { CartEntry } from '../../models/cart-entry.model';
|
||||
import { AddressDTO } from 'swagger/lib/checkout/models/address-dto';
|
||||
import { AddressDTO } from '@swagger/checkout';
|
||||
export const SET_CART_ENTRY = '[CARTENTRY] Set cart entry';
|
||||
export const UPDATE_CART_ENTRY_QUANTITY = '[CARTENTRY] update cart item quantity';
|
||||
export const DELETE_CART_ENTRY = '[CARTENTRY] Delete cart entry';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { User } from '../../models/user.model';
|
||||
import { NotificationChannels } from '../../models/notification-channels.enum';
|
||||
import { EnvironmentChannel } from 'swagger/lib/oms/models/environment-channel';
|
||||
import { EnvironmentChannel } from '@swagger/oms';
|
||||
|
||||
export const SET_CART = '[CART] Set cart entry to cart';
|
||||
export const DELETE_PRODUCT_CART = '[CART] Delete product from cart';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CollectingShelfOrder } from '../../models/collecting-shelf-order.model';
|
||||
import { OrderDTO } from 'swagger/lib/oms/models/order-dto';
|
||||
import { OrderDTO } from '@swagger/oms';
|
||||
|
||||
export const SET_SHELF_ORDERS = '[COLLECTING-SHELF] Set orders';
|
||||
export const RELOAD_COLECTING_SHELF_DATA = '[COLLECTING-SHELF] Reload Collecting Shelf data';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Filter } from '../../models/filter.model';
|
||||
import { FilterItem } from 'mock/lib/models/filter-item.model';
|
||||
import { ProcessSelectedFilters } from '../../models/process-selected-filters.model';
|
||||
import { FilterType } from '../../models/filter-type.enum';
|
||||
import { FilterItem } from '../../models/filter-item.model';
|
||||
|
||||
export const LOAD_FILTERS = '[FILTERS] Load';
|
||||
export const RESET_FILTERS = '[FILTERS] Reset';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GoodsIn } from '../../models/goods-in.model';
|
||||
import { OrderItemListItemDTO } from 'swagger/lib/oms/models/order-item-list-item-dto';
|
||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { GoodsInSearch } from '../../models/GoodsInSearch.model';
|
||||
|
||||
export const SET = '[GOODS-IN] Set';
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Process } from '../../models/process.model';
|
||||
import { ProcessUserData } from '../../models/process-user-data.model';
|
||||
import { Search } from '../../models/search.model';
|
||||
import { CustomerSearch } from '../../models/customer-search.model';
|
||||
import { DisplayOrderDTO } from 'libs/swagger/src/lib/oms/models/display-order-dto';
|
||||
import { DisplayOrderDTO } from '@swagger/oms';
|
||||
import { RecentArticleSearch } from '../../models/recent-article-search.model';
|
||||
import { ProductSerachFilters } from '../../models/product-search-filters.model';
|
||||
import { ShelfSearch } from '../../models/shelf-search.modal';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
|
||||
export const ADD_PROCESS = '[PROCESS] Add';
|
||||
export const DELETE_PROCESS = '[PROCESS] Delete';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ItemDTO, ListResponseArgsOfItemDTO } from 'swagger';
|
||||
import { ItemDTO, ListResponseArgsOfItemDTO } from '@swagger/cat';
|
||||
import { Search } from '../../models/search.model';
|
||||
|
||||
export const LOAD_RECENT_PRODUCTS = '[PRODUCTS] Load recent';
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import { Selector } from '@ngxs/store';
|
||||
import { BranchState, BranchesStateModel } from '../state/branches.state';
|
||||
import { mapToIterable } from '../../utils/app.utils';
|
||||
import { BranchDTO } from 'swagger/lib/checkout/models/branch-dto';
|
||||
import { BranchProcessState, BranchProcessStateModel } from '../state/branch-process.state';
|
||||
|
||||
export class BranchProcessSelectors {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Selector } from '@ngxs/store';
|
||||
import { BranchState, BranchesStateModel } from '../state/branches.state';
|
||||
import { mapToIterable } from '../../utils/app.utils';
|
||||
import { BranchDTO } from 'swagger/lib/checkout/models/branch-dto';
|
||||
import { BranchDTO } from '@swagger/checkout';
|
||||
|
||||
export class BranchSelectors {
|
||||
@Selector([BranchState])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AppState, AppStateModel } from '../state/app.state';
|
||||
import { Selector } from '@ngxs/store';
|
||||
import { OrderDTO } from 'swagger/lib/oms/models/order-dto';
|
||||
import { OrderDTO } from '@swagger/oms';
|
||||
import { CollectingShelfStateModel, CollectingShelfState } from '../state/collecting-shelf.state';
|
||||
import { CollectingShelfOrder } from '../../models/collecting-shelf-order.model';
|
||||
import { mapToIterable } from '../../utils/app.utils';
|
||||
|
||||
@@ -15,17 +15,16 @@ import { AppState, AppStateModel } from '../state/app.state';
|
||||
import { CartEntryStateModel, CartEntryState } from '../state/cart-entry.state';
|
||||
import { BranchesStateModel, BranchState } from '../state/branches.state';
|
||||
import { Cart } from '../../models/cart.model';
|
||||
import { DisplayOrderDTO } from 'swagger/lib/oms/models/display-order-dto';
|
||||
import { DisplayOrderDTO, DisplayOrderItemDTO } from '@swagger/oms';
|
||||
import { DeliveryType, DeliveryOption } from '../../models/delivery-option.model';
|
||||
import { OrderItem } from '../../models/order-item';
|
||||
import { ProcessCartConfirmed } from '../../models/process-cart-confirmed.model';
|
||||
import { DisplayOrderItemDTO } from 'swagger/lib/oms/models/display-order-item-dto';
|
||||
import { User } from '../../models/user.model';
|
||||
import { FilterItem } from '../../models/filter-item.model';
|
||||
import { CollectingShelfState, CollectingShelfStateModel } from '../state/collecting-shelf.state';
|
||||
import { mapToIterable, undefinedToEmptyStringOrValue } from '../../utils/app.utils';
|
||||
import { CollectingShelfOrder } from '../../models/collecting-shelf-order.model';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { Process } from '../../models/process.model';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { FilterType } from '../../models/filter-type.enum';
|
||||
@@ -59,12 +58,12 @@ export class SharedSelectors {
|
||||
|
||||
if (currentProcess && currentProcessId && breadcrumbs.activeCrumbs && breadcrumbs.activeCrumbs[currentProcessId]) {
|
||||
const activeCrumbs = breadcrumbs.activeCrumbs[currentProcessId];
|
||||
const currentBreadcrumbs = breadcrumbs.processesBreadcrumbs[activeCrumbs].find(t => t.processId === currentProcessId);
|
||||
const currentBreadcrumbs = breadcrumbs.processesBreadcrumbs[activeCrumbs].find((t) => t.processId === currentProcessId);
|
||||
const detailsCustomer = customer.customers[currentProcess.detailsCustomer];
|
||||
return {
|
||||
processId: currentProcessId,
|
||||
customer: detailsCustomer,
|
||||
breadcrumbs: currentBreadcrumbs ? currentBreadcrumbs.breadcrumbs : null
|
||||
breadcrumbs: currentBreadcrumbs ? currentBreadcrumbs.breadcrumbs : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -131,7 +130,7 @@ export class SharedSelectors {
|
||||
if (currentProcess && currentProcess.cartId) {
|
||||
const cartEntryIds = cart.carts[currentProcess.cartId];
|
||||
if (cartEntryIds && cartEntryIds.hasItems()) {
|
||||
cartEntryIds.forEach(entryId => {
|
||||
cartEntryIds.forEach((entryId) => {
|
||||
if (entryId) {
|
||||
const entry = cartEntry.cartEntries[entryId];
|
||||
if (entry.deliveryType === option) {
|
||||
@@ -156,7 +155,7 @@ export class SharedSelectors {
|
||||
if (currentProcess && currentProcess.cartId) {
|
||||
const cartEntryIds = cart.carts[currentProcess.cartId];
|
||||
if (cartEntryIds && cartEntryIds.hasItems()) {
|
||||
cartEntryIds.forEach(entryId => {
|
||||
cartEntryIds.forEach((entryId) => {
|
||||
if (entryId) {
|
||||
const entry = cartEntry.cartEntries[entryId];
|
||||
if (entry.deliveryType === DeliveryOption.DOWNLOAD) {
|
||||
@@ -198,7 +197,7 @@ export class SharedSelectors {
|
||||
if (currentProcess && currentProcess.cartId) {
|
||||
const cartEntryIds = cart.carts[currentProcess.cartId];
|
||||
if (cartEntryIds && cartEntryIds.hasItems()) {
|
||||
cartEntryIds.forEach(entryId => {
|
||||
cartEntryIds.forEach((entryId) => {
|
||||
if (entryId) {
|
||||
const entry = cartEntry.cartEntries[entryId];
|
||||
if (entry && entry.bookId) {
|
||||
@@ -231,7 +230,7 @@ export class SharedSelectors {
|
||||
if (currentProcess && currentProcess.cartId) {
|
||||
const cartEntryIds = cart.carts[currentProcess.cartId];
|
||||
if (cartEntryIds && cartEntryIds.hasItems()) {
|
||||
cartEntryIds.forEach(entryId => {
|
||||
cartEntryIds.forEach((entryId) => {
|
||||
if (entryId) {
|
||||
const entry = cartEntry.cartEntries[entryId];
|
||||
if (entry && entry.bookId) {
|
||||
@@ -287,14 +286,14 @@ export class SharedSelectors {
|
||||
deliveryPrice: cartEntry.deliveryPrice,
|
||||
downloadPrice: cartEntry.downloadPrice,
|
||||
deliveryDate: cartEntry.deliveryDate,
|
||||
pickUpDate: cartEntry.pickUpDate
|
||||
pickUpDate: cartEntry.pickUpDate,
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
cart: cartData,
|
||||
customer: currentCustomer,
|
||||
promotionPoints: promotionPoints
|
||||
promotionPoints: promotionPoints,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -329,11 +328,11 @@ export class SharedSelectors {
|
||||
const filterType = filterState.filterType[currentProcessId];
|
||||
const processesSelectedFilters =
|
||||
filterType === FilterType.Negative ? filterState.negativeProcessesSelectedFilters : filterState.processesSelectedFilters;
|
||||
const currentProcessSelectedFilters = processesSelectedFilters.find(f => f.processId === currentProcessId);
|
||||
const currentProcessSelectedFilters = processesSelectedFilters.find((f) => f.processId === currentProcessId);
|
||||
if (currentProcessSelectedFilters) {
|
||||
const filter: Filter[] = [];
|
||||
currentProcessSelectedFilters.selectedFilters.map(f => {
|
||||
if (f.items && f.items.filter(t => t.selected === true) && f.items.filter(t => t.selected === true).length > 0) {
|
||||
currentProcessSelectedFilters.selectedFilters.map((f) => {
|
||||
if (f.items && f.items.filter((t) => t.selected === true) && f.items.filter((t) => t.selected === true).length > 0) {
|
||||
filter.push(f);
|
||||
}
|
||||
});
|
||||
@@ -353,7 +352,7 @@ export class SharedSelectors {
|
||||
const filterType = filterState.filterType[currentProcessId];
|
||||
const processesSelectedFilters =
|
||||
filterType === FilterType.Negative ? filterState.negativeProcessesSelectedFilters : filterState.processesSelectedFilters;
|
||||
const currentProcessSelectedFilters = processesSelectedFilters.find(f => f.processId === currentProcessId);
|
||||
const currentProcessSelectedFilters = processesSelectedFilters.find((f) => f.processId === currentProcessId);
|
||||
return currentProcessSelectedFilters ? currentProcessSelectedFilters.selectedFilters : null;
|
||||
}
|
||||
}
|
||||
@@ -374,13 +373,13 @@ export class SharedSelectors {
|
||||
const currentProcess = process.processes[processId];
|
||||
|
||||
if (currentProcess) {
|
||||
const customers = currentProcess.customerIds.map(t => {
|
||||
const customers = currentProcess.customerIds.map((t) => {
|
||||
return customer.customers[t];
|
||||
});
|
||||
|
||||
return {
|
||||
processId,
|
||||
customers
|
||||
customers,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -395,7 +394,7 @@ export class SharedSelectors {
|
||||
const currentProducts = products.products[currentProcessId];
|
||||
|
||||
return {
|
||||
itemsDTO: currentProducts ? currentProducts : null
|
||||
itemsDTO: currentProducts ? currentProducts : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -409,7 +408,7 @@ export class SharedSelectors {
|
||||
|
||||
if (currentProcessId && breadcrumbs.activeCrumbs && breadcrumbs.activeCrumbs[currentProcessId]) {
|
||||
const activeCrumbs = breadcrumbs.activeCrumbs[currentProcessId];
|
||||
const currentBreadcrumbs = breadcrumbs.processesBreadcrumbs[activeCrumbs].find(t => t.processId === currentProcessId);
|
||||
const currentBreadcrumbs = breadcrumbs.processesBreadcrumbs[activeCrumbs].find((t) => t.processId === currentProcessId);
|
||||
return currentBreadcrumbs ? currentBreadcrumbs.breadcrumbs : null;
|
||||
}
|
||||
|
||||
@@ -482,7 +481,7 @@ export class SharedSelectors {
|
||||
isDownload: isDownload,
|
||||
orderDate: item.orderDate,
|
||||
targetBranchName: targetBranchName,
|
||||
targetBranchAddress: targetBranchAddress
|
||||
targetBranchAddress: targetBranchAddress,
|
||||
};
|
||||
|
||||
if (order.orderType === DeliveryType['ShippingAddress']) {
|
||||
@@ -510,7 +509,7 @@ export class SharedSelectors {
|
||||
orderIds: orderIds,
|
||||
isTakeNowOnly: takeNowItems && cartData && takeNowItems.length === cartData.length ? true : false,
|
||||
isPickUpOnly: pickUpItems && cartData && pickUpItems.length === cartData.length ? true : false,
|
||||
promotionPoints: promotionPoints
|
||||
promotionPoints: promotionPoints,
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -536,14 +535,14 @@ export class SharedSelectors {
|
||||
const processesSelectedFilters =
|
||||
filterType === FilterType.Negative ? state.negativeProcessesSelectedFilters : state.processesSelectedFilters;
|
||||
const processFilters = processesSelectedFilters[currenProcessId];
|
||||
return state.filters.map(filter => {
|
||||
return state.filters.map((filter) => {
|
||||
return <Filter>{
|
||||
...filter,
|
||||
items: filter.items.map(item => {
|
||||
items: filter.items.map((item) => {
|
||||
if (processFilters) {
|
||||
const selectedFilter = processFilters.selectedFilters.find(f => f.id === filter.id);
|
||||
const selectedFilter = processFilters.selectedFilters.find((f) => f.id === filter.id);
|
||||
if (selectedFilter) {
|
||||
const selectedItem = selectedFilter.items.find(i => i.id === item.id);
|
||||
const selectedItem = selectedFilter.items.find((i) => i.id === item.id);
|
||||
if (selectedItem) {
|
||||
return <FilterItem>{ ...item, selected: selectedItem.selected };
|
||||
} else {
|
||||
@@ -555,7 +554,7 @@ export class SharedSelectors {
|
||||
} else {
|
||||
return <FilterItem>{ ...item, selected: false };
|
||||
}
|
||||
})
|
||||
}),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { State, Selector, Action, StateContext, Actions, ofAction } from '@ngxs/
|
||||
import { LoadAutocomplete, CancelPendingAutocomplete } from '../actions/autocomplete.actions';
|
||||
import { ProductService } from '../../services/product.service';
|
||||
import { tap, map, takeUntil } from 'rxjs/operators';
|
||||
import { AutocompleteDTO } from 'swagger';
|
||||
import { AutocompleteDTO } from '@swagger/cat';
|
||||
import { AutocompleteResults } from '../../models/autocomplete-results.model';
|
||||
import { timer } from 'rxjs';
|
||||
|
||||
@@ -15,8 +15,8 @@ export class AutocompleteStateModel {
|
||||
@State<AutocompleteStateModel>({
|
||||
name: 'autocomplete',
|
||||
defaults: {
|
||||
result: []
|
||||
}
|
||||
result: [],
|
||||
},
|
||||
})
|
||||
export class AutocompleteState {
|
||||
constructor(private productService: ProductService, private actions$: Actions) {}
|
||||
@@ -31,7 +31,9 @@ export class AutocompleteState {
|
||||
return this.productService.complete(payload, 1, type).pipe(
|
||||
takeUntil(timer(2000)), // Use a timer instead of a timeout to prevent the stream from throwing an error
|
||||
map((items: AutocompleteDTO[]) => items.slice(0, AUTOCOMPLETE_MAX_ITEMS)),
|
||||
map((items: AutocompleteDTO[]) => items && items.map(t => <AutocompleteResults>{ display: t.display, type: t.type, query: t.query })),
|
||||
map(
|
||||
(items: AutocompleteDTO[]) => items && items.map((t) => <AutocompleteResults>{ display: t.display, type: t.type, query: t.query })
|
||||
),
|
||||
takeUntil(this.actions$.pipe(ofAction(CancelPendingAutocomplete))),
|
||||
tap((result: AutocompleteResults[]) => {
|
||||
if (result) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { State, Action, StateContext, Store } from '@ngxs/store';
|
||||
import * as actions from '../actions/branch.actions';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { CheckoutService } from '../../services/checkout.service';
|
||||
import { BranchDTO } from 'swagger/lib/checkout/models/branch-dto';
|
||||
import { BranchDTO } from '@swagger/checkout';
|
||||
import { SsoService } from 'sso';
|
||||
|
||||
export class BranchesStateModel {
|
||||
@@ -55,7 +55,7 @@ export class BranchState {
|
||||
}
|
||||
if (payload && payload.length > 0) {
|
||||
const branches = { ...state.branches };
|
||||
payload.forEach(branch => {
|
||||
payload.forEach((branch) => {
|
||||
const branchExists = branches[branch.id];
|
||||
if (!branchExists) {
|
||||
branches[branch.id] = branch;
|
||||
|
||||
@@ -4,33 +4,32 @@ import { CartEntry } from '../../models/cart-entry.model';
|
||||
import { SetCartData } from '../actions/cart.actions';
|
||||
import { BranchSelectors } from '../selectors/branch.selector';
|
||||
import { DeliveryOption, DeliveryType } from '../../models/delivery-option.model';
|
||||
import { ShippingTarget } from 'swagger/lib/checkout/models/shipping-target';
|
||||
import { BranchDTO } from 'swagger/lib/checkout/models/branch-dto';
|
||||
import { EntityDTOContainerOfDestinationDTO } from 'swagger/lib/checkout/models/entity-dtocontainer-of-destination-dto';
|
||||
import { AddToShoppingCartDTO } from 'swagger/lib/checkout/models/add-to-shopping-cart-dto';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import {
|
||||
ShippingTarget,
|
||||
BranchDTO,
|
||||
EntityDTOContainerOfDestinationDTO,
|
||||
AddToShoppingCartDTO,
|
||||
ShoppingCartDTO,
|
||||
AvailabilityDTO as UpdateDestinationAvailability,
|
||||
DestinationDTO,
|
||||
AddressDTO,
|
||||
UpdateShoppingCartItemDTO,
|
||||
} from '@swagger/checkout';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { ProcessSelectors } from '../selectors/process.selectors';
|
||||
import { CheckoutService } from '../../services/checkout.service';
|
||||
import { ProductSelectors } from '../selectors/product.selector';
|
||||
import { AvailabilityDTO } from 'swagger/lib/availability/models/availability-dto';
|
||||
import { AvailabilityDTO } from '@swagger/availability';
|
||||
import { tap, map, flatMap, concatMap, switchMap } from 'rxjs/operators';
|
||||
import { ShoppingCartDTO } from 'swagger/lib/checkout/models/shopping-cart-dto';
|
||||
import { mapToIterable } from '../../utils/app.utils';
|
||||
import { Observable, of, from } from 'rxjs';
|
||||
import { UserStateSyncData } from '../../models/user-state-sync.model';
|
||||
import { AppUserDataSync } from '../actions/app.actions';
|
||||
import { AvailabilityDTO as UpdateDestinationAvailability } from 'swagger/lib/checkout/models/availability-dto';
|
||||
import { SupplierDTO } from 'swagger/lib/oms/models/supplier-dto';
|
||||
import { ShippingAddressDTO } from 'swagger/lib/oms/models/shipping-address-dto';
|
||||
import { SupplierDTO, ShippingAddressDTO } from '@swagger/oms';
|
||||
import { isArray } from 'util';
|
||||
import { DestinationDTO } from 'swagger/lib/checkout/models/destination-dto';
|
||||
import { AddressDTO } from 'swagger/lib/checkout/models/address-dto';
|
||||
import { User } from '../../models/user.model';
|
||||
import { CustomerMapping } from '../../mappings/customer.mapping';
|
||||
import { CustomerSelectors } from '../selectors/customer.selectors';
|
||||
import { CartState } from './cart.state';
|
||||
import { Process } from '../../models/process.model';
|
||||
import { UpdateShoppingCartItemDTO } from 'swagger/lib/checkout/models/update-shopping-cart-item-dto';
|
||||
|
||||
export class CartEntryStateModel {
|
||||
cartEntries: { [key: number]: CartEntry };
|
||||
@@ -39,8 +38,8 @@ export class CartEntryStateModel {
|
||||
@State<CartEntryStateModel>({
|
||||
name: 'cartEntries',
|
||||
defaults: {
|
||||
cartEntries: {}
|
||||
}
|
||||
cartEntries: {},
|
||||
},
|
||||
})
|
||||
export class CartEntryState {
|
||||
constructor(private store: Store, private checkoutService: CheckoutService, private customerMapping: CustomerMapping) {}
|
||||
@@ -71,7 +70,7 @@ export class CartEntryState {
|
||||
deliveryType,
|
||||
products[bookId],
|
||||
quantity,
|
||||
availability,
|
||||
availability as any,
|
||||
currentProcess.cartId,
|
||||
ctx,
|
||||
branches[branch],
|
||||
@@ -94,10 +93,10 @@ export class CartEntryState {
|
||||
const existingItemId = this.itemExistInCart(state.cartEntries, bookId, oldDeliveryType, oldBranch, currentProcess.cartId);
|
||||
const newBranch = branches[branch];
|
||||
|
||||
let itemToUpdate = { ...state.cartEntries[existingItemId] };
|
||||
let cartEntries = { ...state.cartEntries };
|
||||
const destination = this.createDestinationObject(deliveryType, newBranch, availability);
|
||||
const ava: UpdateDestinationAvailability = this.availibilityObjectForUpdate(availability, deliveryType);
|
||||
const itemToUpdate = { ...state.cartEntries[existingItemId] };
|
||||
const cartEntries = { ...state.cartEntries };
|
||||
const destination = this.createDestinationObject(deliveryType, newBranch, availability as any);
|
||||
const ava: UpdateDestinationAvailability = this.availibilityObjectForUpdate(availability as any, deliveryType);
|
||||
|
||||
itemToUpdate.quantity = itemToUpdate.quantity;
|
||||
itemToUpdate.deliveryType = deliveryType;
|
||||
@@ -132,7 +131,7 @@ export class CartEntryState {
|
||||
return this.checkoutService.updateItemInCart(currentProcess.cartId, existingItemId, destination, itemToUpdate.quantity, ava).pipe(
|
||||
tap(() => {
|
||||
ctx.patchState({
|
||||
cartEntries
|
||||
cartEntries,
|
||||
});
|
||||
this.syncApiState(cartEntries);
|
||||
})
|
||||
@@ -148,10 +147,10 @@ export class CartEntryState {
|
||||
const cartEntries = { ...state.cartEntries };
|
||||
if (cartEntriesIds && isArray(cartEntriesIds)) {
|
||||
return from(cartEntriesIds).pipe(
|
||||
concatMap(cartEntryId =>
|
||||
concatMap((cartEntryId) =>
|
||||
this.checkoutService
|
||||
.updateDestinationForItemInCart(currentProcess.cartId, cartEntryId, <EntityDTOContainerOfDestinationDTO>{
|
||||
data: <DestinationDTO>{ shippingAddress: address }
|
||||
data: <DestinationDTO>{ shippingAddress: address },
|
||||
})
|
||||
.pipe(
|
||||
tap(() => {
|
||||
@@ -159,7 +158,7 @@ export class CartEntryState {
|
||||
cartEntries[cartEntryId] = cartEntry;
|
||||
|
||||
ctx.patchState({
|
||||
cartEntries
|
||||
cartEntries,
|
||||
});
|
||||
|
||||
this.syncApiState(cartEntries);
|
||||
@@ -179,19 +178,19 @@ export class CartEntryState {
|
||||
const state = ctx.getState();
|
||||
const currentProcess = this.store.selectSnapshot(ProcessSelectors.getCurrentProcess);
|
||||
|
||||
let cartEntries = { ...state.cartEntries };
|
||||
let updateEntry = { ...cartEntries[cartEntryId] };
|
||||
const cartEntries = { ...state.cartEntries };
|
||||
const updateEntry = { ...cartEntries[cartEntryId] };
|
||||
updateEntry.quantity = quantity;
|
||||
updateEntry.orderTypeChanged = false;
|
||||
updateEntry.avaMessage = availabilityMsg;
|
||||
if (availability) {
|
||||
updateEntry.availability = availability;
|
||||
updateEntry.availability = availability as any;
|
||||
}
|
||||
|
||||
cartEntries[cartEntryId] = updateEntry;
|
||||
|
||||
ctx.patchState({
|
||||
cartEntries
|
||||
cartEntries,
|
||||
});
|
||||
|
||||
const products = this.store.selectSnapshot(ProductSelectors.getProducts);
|
||||
@@ -201,10 +200,10 @@ export class CartEntryState {
|
||||
products[updateEntry.bookId],
|
||||
quantity,
|
||||
branches[updateEntry.branch],
|
||||
updateEntry.availability ? updateEntry.availability : products[updateEntry.bookId].catalogAvailability,
|
||||
(updateEntry.availability ? updateEntry.availability : products[updateEntry.bookId].catalogAvailability) as any, // TODO: Typisierung
|
||||
products[updateEntry.bookId].promoPoints
|
||||
).pipe(
|
||||
switchMap(updatedItem => this.checkoutService.updateQuantityForItemInCart(currentProcess.cartId, cartEntryId, updatedItem)),
|
||||
switchMap((updatedItem) => this.checkoutService.updateQuantityForItemInCart(currentProcess.cartId, cartEntryId, updatedItem)),
|
||||
tap(() => {
|
||||
this.syncApiState(cartEntries);
|
||||
})
|
||||
@@ -215,7 +214,7 @@ export class CartEntryState {
|
||||
deleteCartItem(ctx: StateContext<CartEntryStateModel>, { cartEntryId, hardDelete }: actions.DeleteCartEntry) {
|
||||
const state = ctx.getState();
|
||||
const currentProcess = this.store.selectSnapshot(ProcessSelectors.getCurrentProcess);
|
||||
let cartEntries = { ...state.cartEntries };
|
||||
const cartEntries = { ...state.cartEntries };
|
||||
const cartEntry = cartEntries[cartEntryId];
|
||||
|
||||
if (hardDelete && currentProcess) {
|
||||
@@ -226,15 +225,15 @@ export class CartEntryState {
|
||||
products[cartEntry.bookId],
|
||||
0,
|
||||
branches[cartEntry.branch],
|
||||
cartEntry.availability ? cartEntry.availability : products[cartEntry.bookId].catalogAvailability,
|
||||
(cartEntry.availability ? cartEntry.availability : products[cartEntry.bookId].catalogAvailability) as any, // TODO: Typisierung
|
||||
products[cartEntry.bookId].promoPoints
|
||||
).pipe(
|
||||
switchMap(updatedItem => this.checkoutService.updateQuantityForItemInCart(currentProcess.cartId, cartEntryId, updatedItem)),
|
||||
switchMap((updatedItem) => this.checkoutService.updateQuantityForItemInCart(currentProcess.cartId, cartEntryId, updatedItem)),
|
||||
tap(() => {
|
||||
delete cartEntries[cartEntryId];
|
||||
|
||||
ctx.patchState({
|
||||
cartEntries
|
||||
cartEntries,
|
||||
});
|
||||
this.syncApiState(cartEntries);
|
||||
})
|
||||
@@ -260,14 +259,14 @@ export class CartEntryState {
|
||||
price: ava.price,
|
||||
supplierProductNumber: ava.supplierProductNumber,
|
||||
estimatedShippingDate: ava.at,
|
||||
supplier: { id: ava.supplierId }
|
||||
supplier: { id: ava.supplierId },
|
||||
};
|
||||
} else if (deliveryType === DeliveryOption.TAKE_NOW) {
|
||||
data = {
|
||||
ssc: ava.ssc,
|
||||
availabilityType: ava.status,
|
||||
price: ava.price,
|
||||
supplier: { id: ava.supplierId }
|
||||
supplier: { id: ava.supplierId },
|
||||
};
|
||||
} else {
|
||||
data = {
|
||||
@@ -278,7 +277,7 @@ export class CartEntryState {
|
||||
inStock: ava.qty,
|
||||
price: ava.price,
|
||||
estimatedShippingDate: ava.at,
|
||||
supplier: { id: ava.supplierId }
|
||||
supplier: { id: ava.supplierId },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -287,7 +286,7 @@ export class CartEntryState {
|
||||
|
||||
private syncApiState(cartEntries: { [key: number]: CartEntry }) {
|
||||
const userSyncData: UserStateSyncData = {
|
||||
cartEntries
|
||||
cartEntries,
|
||||
};
|
||||
const userData = JSON.stringify(userSyncData);
|
||||
this.store.dispatch(new AppUserDataSync(userData));
|
||||
@@ -301,7 +300,7 @@ export class CartEntryState {
|
||||
cartId: number
|
||||
): null | number {
|
||||
const existingCartEntriesIds = this.store.selectSnapshot(CartState.getCartEntries)(cartId);
|
||||
const existingEntries = existingCartEntriesIds.map(id => cartEntries[id]);
|
||||
const existingEntries = existingCartEntriesIds.map((id) => cartEntries[id]);
|
||||
const updateItem = existingEntries.find(
|
||||
(cartitem: CartEntry) => cartitem.bookId === bookId && cartitem.deliveryType === deliveryType && cartitem.branch === branch
|
||||
);
|
||||
@@ -338,7 +337,7 @@ export class CartEntryState {
|
||||
if (deliveryType === DeliveryOption.TAKE_NOW) {
|
||||
getBranchSupplierId$ = this.checkoutService
|
||||
.getSuppliers()
|
||||
.pipe(map(suppliers => suppliers.find(supplier => supplier.supplierNumber === 'F').id));
|
||||
.pipe(map((suppliers) => suppliers.find((supplier) => supplier.supplierNumber === 'F').id));
|
||||
}
|
||||
|
||||
const addItemToCart$ = (item: AddToShoppingCartDTO) =>
|
||||
@@ -353,7 +352,7 @@ export class CartEntryState {
|
||||
|
||||
const state = ctx.getState();
|
||||
|
||||
let cartEntries = { ...state.cartEntries };
|
||||
const cartEntries = { ...state.cartEntries };
|
||||
cartEntries[newItemId] = {
|
||||
quantity: quantity,
|
||||
bookId: book.id,
|
||||
@@ -387,12 +386,12 @@ export class CartEntryState {
|
||||
availability.price.value.value
|
||||
? availability.price.value.value
|
||||
: undefined,
|
||||
availability
|
||||
availability,
|
||||
};
|
||||
|
||||
// Update local state
|
||||
ctx.patchState({
|
||||
cartEntries
|
||||
cartEntries,
|
||||
});
|
||||
|
||||
this.syncApiState(cartEntries);
|
||||
@@ -405,8 +404,8 @@ export class CartEntryState {
|
||||
if (deliveryType === DeliveryOption.DOWNLOAD) {
|
||||
const customer = this.store.selectSnapshot(CustomerSelectors.getCurrentProcessActiveUser);
|
||||
return this.checkoutService.getSuppliers().pipe(
|
||||
map(suppliers => suppliers.find(supplier => supplier.supplierNumber === 'DIG')),
|
||||
map(supplier =>
|
||||
map((suppliers) => suppliers.find((supplier) => supplier.supplierNumber === 'DIG')),
|
||||
map((supplier) =>
|
||||
this.createObjectForDonwload(
|
||||
deliveryType,
|
||||
book,
|
||||
@@ -418,12 +417,12 @@ export class CartEntryState {
|
||||
customer ? customer : null
|
||||
)
|
||||
),
|
||||
flatMap(item => addItemToCart$(item))
|
||||
flatMap((item) => addItemToCart$(item))
|
||||
);
|
||||
} else {
|
||||
return getBranchSupplierId$.pipe(
|
||||
map(supplierId => this.createObjectForAPI(deliveryType, book, quantity, availability, supplierId, branch, promoPoints)),
|
||||
flatMap(item => addItemToCart$(item))
|
||||
map((supplierId) => this.createObjectForAPI(deliveryType, book, quantity, availability, supplierId, branch, promoPoints)),
|
||||
flatMap((item) => addItemToCart$(item))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -442,7 +441,7 @@ export class CartEntryState {
|
||||
const item: AddToShoppingCartDTO = {
|
||||
product: {
|
||||
...book.product,
|
||||
catalogProductNumber: book.id
|
||||
catalogProductNumber: String(book.id),
|
||||
},
|
||||
quantity: quantity,
|
||||
destination: destination,
|
||||
@@ -454,9 +453,9 @@ export class CartEntryState {
|
||||
sscText: availability.sscText ? availability.sscText : null,
|
||||
estimatedShippingDate: availability.at ? availability.at : null,
|
||||
supplierProductNumber: availability.supplierProductNumber ? availability.supplierProductNumber : null,
|
||||
isPrebooked: availability.isPrebooked
|
||||
isPrebooked: availability.isPrebooked,
|
||||
},
|
||||
promotion: { points: promoPoints }
|
||||
promotion: { points: promoPoints },
|
||||
};
|
||||
|
||||
return item;
|
||||
@@ -477,7 +476,7 @@ export class CartEntryState {
|
||||
const item: AddToShoppingCartDTO = {
|
||||
product: {
|
||||
...book.product,
|
||||
catalogProductNumber: book.id
|
||||
catalogProductNumber: String(book.id),
|
||||
},
|
||||
quantity: quantity,
|
||||
destination: destination,
|
||||
@@ -489,9 +488,9 @@ export class CartEntryState {
|
||||
sscText: availability.sscText ? availability.sscText : null,
|
||||
estimatedShippingDate: availability.at ? availability.at : null,
|
||||
supplierProductNumber: availability.supplierProductNumber ? availability.supplierProductNumber : null,
|
||||
isPrebooked: availability.isPrebooked
|
||||
isPrebooked: availability.isPrebooked,
|
||||
},
|
||||
promotion: { points: promoPoints }
|
||||
promotion: { points: promoPoints },
|
||||
};
|
||||
|
||||
return item;
|
||||
@@ -518,8 +517,8 @@ export class CartEntryState {
|
||||
destination = {
|
||||
data: {
|
||||
target: targetType,
|
||||
targetBranch: { id: branch.id }
|
||||
}
|
||||
targetBranch: { id: branch.id },
|
||||
},
|
||||
};
|
||||
} else if (targetType === DeliveryType['Download']) {
|
||||
const address = customer ? (customer.delivery_addres ? customer.delivery_addres : customer.invoice_address) : null;
|
||||
@@ -533,17 +532,17 @@ export class CartEntryState {
|
||||
? <ShippingAddressDTO>{
|
||||
firstName: customer.first_name,
|
||||
lastName: customer.last_name,
|
||||
address: addressDto
|
||||
address: addressDto,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
destination = {
|
||||
data: {
|
||||
target: targetType,
|
||||
logistician: { id: availability.logisticianId }
|
||||
}
|
||||
logistician: { id: availability.logisticianId },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -561,8 +560,8 @@ export class CartEntryState {
|
||||
let item$: Observable<AddToShoppingCartDTO>;
|
||||
if (deliveryType === DeliveryOption.DOWNLOAD) {
|
||||
item$ = this.checkoutService.getSuppliers().pipe(
|
||||
map(suppliers => suppliers.find(supplier => supplier.supplierNumber === 'DIG')),
|
||||
flatMap(supplier => {
|
||||
map((suppliers) => suppliers.find((supplier) => supplier.supplierNumber === 'DIG')),
|
||||
flatMap((supplier) => {
|
||||
const customer = this.store.selectSnapshot(CustomerSelectors.getCurrentProcessActiveUser);
|
||||
return of(
|
||||
this.createObjectForDonwload(
|
||||
@@ -580,8 +579,8 @@ export class CartEntryState {
|
||||
);
|
||||
} else if (deliveryType === DeliveryOption.TAKE_NOW) {
|
||||
item$ = this.checkoutService.getSuppliers().pipe(
|
||||
map(suppliers => suppliers.find(supplier => supplier.supplierNumber === 'F').id),
|
||||
flatMap(supplierId => {
|
||||
map((suppliers) => suppliers.find((supplier) => supplier.supplierNumber === 'F').id),
|
||||
flatMap((supplierId) => {
|
||||
return of(this.createObjectForAPI(deliveryType, book, quantity, availability, supplierId, branch, promoPoints));
|
||||
})
|
||||
);
|
||||
@@ -589,13 +588,13 @@ export class CartEntryState {
|
||||
return of(this.createObjectForAPI(deliveryType, book, quantity, availability, availability.supplierId, branch, promoPoints));
|
||||
}
|
||||
return item$.pipe(
|
||||
map(it => {
|
||||
map((it) => {
|
||||
return <UpdateShoppingCartItemDTO>{
|
||||
quantity: it.quantity,
|
||||
retailPrice: it.retailPrice,
|
||||
destination: it.destination,
|
||||
availability: it.availability,
|
||||
promotion: it.promotion
|
||||
promotion: it.promotion,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
@@ -5,19 +5,14 @@ import { DeleteCartEntry } from '../actions/cart-entry.actions';
|
||||
import { ProcessSelectors } from '../selectors/process.selectors';
|
||||
import { CheckoutService } from '../../services/checkout.service';
|
||||
import { tap, catchError } from 'rxjs/operators';
|
||||
import { ShoppingCartDTO } from 'swagger/lib/checkout/models/shopping-cart-dto';
|
||||
import { DisplayOrderDTO } from 'swagger/lib/oms/models/display-order-dto';
|
||||
import { PaymentDTO } from 'swagger/lib/checkout/models/payment-dto';
|
||||
import { CheckoutDTO } from 'swagger/lib/checkout/models/checkout-dto';
|
||||
import { BuyerDTO } from 'swagger/lib/checkout/models/buyer-dto';
|
||||
import { ShoppingCartDTO, PaymentDTO, CheckoutDTO, BuyerDTO, PayerDTO } from '@swagger/checkout';
|
||||
import { DisplayOrderDTO, EnvironmentChannel } from '@swagger/oms';
|
||||
import { User } from '../../models/user.model';
|
||||
import { CustomerMapping } from '../../mappings/customer.mapping';
|
||||
import { PayerDTO } from 'swagger/lib/checkout/models/payer-dto';
|
||||
import { OrganisationDTO } from 'swagger/lib/crm/models/organisation-dto';
|
||||
import { DestinationDTO } from 'libs/swagger/src/lib/checkout/models';
|
||||
import { OrganisationDTO } from '@swagger/crm';
|
||||
import { DestinationDTO } from '@swagger/checkout';
|
||||
import { UserStateSyncData } from '../../models/user-state-sync.model';
|
||||
import { AppUserDataSync } from '../actions/app.actions';
|
||||
import { EnvironmentChannel } from 'swagger/lib/oms/models/environment-channel';
|
||||
import { of } from 'rxjs';
|
||||
import { ErrorService } from '../../error/component/error.service';
|
||||
import { Router } from '@angular/router';
|
||||
@@ -32,8 +27,8 @@ export class CartStateModel {
|
||||
@State<CartStateModel>({
|
||||
name: 'cart',
|
||||
defaults: {
|
||||
carts: {}
|
||||
}
|
||||
carts: {},
|
||||
},
|
||||
})
|
||||
export class CartState {
|
||||
constructor(
|
||||
@@ -97,7 +92,7 @@ export class CartState {
|
||||
allCarts[cartId] = cartEntries.filter((id: number) => id !== cartEntryId);
|
||||
|
||||
ctx.patchState({
|
||||
carts: allCarts
|
||||
carts: allCarts,
|
||||
});
|
||||
|
||||
this.syncApiState(allCarts);
|
||||
@@ -120,7 +115,7 @@ export class CartState {
|
||||
delete carts[cartId];
|
||||
|
||||
ctx.patchState({
|
||||
carts
|
||||
carts,
|
||||
});
|
||||
|
||||
this.syncApiState(carts);
|
||||
@@ -132,7 +127,7 @@ export class CartState {
|
||||
tap((order: { failedItemIds: { id: number; type: number }[]; displayOrder: DisplayOrderDTO[] }) => {
|
||||
this.store.dispatch(new SetFinishedOrderData(order));
|
||||
}),
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
const status = error.status;
|
||||
const message = error && error.error ? error.error.message : undefined;
|
||||
const invalidProperties =
|
||||
@@ -147,7 +142,7 @@ export class CartState {
|
||||
openCart() {
|
||||
const newBread: Breadcrumb = {
|
||||
name: 'Warenkorb',
|
||||
path: '/cart/review'
|
||||
path: '/cart/review',
|
||||
};
|
||||
|
||||
this.store.dispatch(new AddBreadcrumb(newBread, 'shoppingCart'));
|
||||
@@ -217,7 +212,7 @@ export class CartState {
|
||||
|
||||
private syncApiState(carts: { [key: number]: number[] }) {
|
||||
const userSyncData: UserStateSyncData = {
|
||||
carts
|
||||
carts,
|
||||
};
|
||||
const userData = JSON.stringify(userSyncData);
|
||||
this.store.dispatch(new AppUserDataSync(userData));
|
||||
@@ -237,7 +232,7 @@ export class CartState {
|
||||
lastName: transformed.lastName,
|
||||
organisation: transformed.organisation,
|
||||
source: transformed.id,
|
||||
title: transformed.title
|
||||
title: transformed.title,
|
||||
};
|
||||
|
||||
return buyerDTO;
|
||||
@@ -252,7 +247,7 @@ export class CartState {
|
||||
organisation = {
|
||||
name: invoice.company_name,
|
||||
department: invoice.company_department,
|
||||
vatId: invoice.company_tax_number
|
||||
vatId: invoice.company_tax_number,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -262,7 +257,7 @@ export class CartState {
|
||||
country: invoice.country,
|
||||
zipCode: invoice.zip + '',
|
||||
street: invoice.street,
|
||||
info: invoice.note ? invoice.note : null
|
||||
info: invoice.note ? invoice.note : null,
|
||||
},
|
||||
communicationDetails: transformed.communicationDetails,
|
||||
firstName: invoice.first_name,
|
||||
@@ -273,7 +268,7 @@ export class CartState {
|
||||
payerStatus: invoice.payer_status,
|
||||
payerType: 8, // B2C
|
||||
title: invoice.title,
|
||||
source: invoice.id
|
||||
source: invoice.id,
|
||||
};
|
||||
|
||||
return payerDTO;
|
||||
@@ -296,10 +291,10 @@ export class CartState {
|
||||
firstName: delivery.first_name,
|
||||
lastName: delivery.last_name,
|
||||
address: transformed.address,
|
||||
source: delivery.id
|
||||
source: delivery.id,
|
||||
},
|
||||
target: target ? target : 2,
|
||||
id: destinationId
|
||||
id: destinationId,
|
||||
};
|
||||
|
||||
return destinationDTO;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import { ShelfCustomerOrders } from '../../models/shelf-customer-orders.model';
|
||||
import { State, Action, StateContext, Store } from '@ngxs/store';
|
||||
import * as actions from '../actions/collecting-shelf.action';
|
||||
import { AppState } from './app.state';
|
||||
import { UserStateSyncData } from '../../models/user-state-sync.model';
|
||||
import { AppUserDataSync } from '../actions/app.actions';
|
||||
import { CollectingShelfOrder } from '../../models/collecting-shelf-order.model';
|
||||
import { mapToIterable } from '../../utils/app.utils';
|
||||
import { ShelfOrderItemLevel } from '../../models/shelf-order-item-level.enum';
|
||||
import { OrderDTO } from 'swagger/lib/oms/models/order-dto';
|
||||
import { OrderDTO } from '@swagger/oms';
|
||||
|
||||
export interface CollectingShelfStateModel {
|
||||
orders: { [key: number]: { [key: number]: CollectingShelfOrder } };
|
||||
|
||||
@@ -47,7 +47,7 @@ export class CustomerState {
|
||||
const state = ctx.getState();
|
||||
let customers = {};
|
||||
let customerIds: number[] = [];
|
||||
_customers.forEach(t => {
|
||||
_customers.forEach((t) => {
|
||||
if (state.customers[t.id] && customers[t.id]) {
|
||||
return;
|
||||
}
|
||||
@@ -68,18 +68,18 @@ export class CustomerState {
|
||||
return;
|
||||
}
|
||||
const currentCustomers = state.customers;
|
||||
const newCustomers = payload.filter(t => t !== undefined);
|
||||
const newCustomers = payload.filter((t) => t !== undefined);
|
||||
const currentCustomerIds = this.store.selectSnapshot(ProcessSelectors.getCustomerIds);
|
||||
const customerIds = [];
|
||||
let customers = currentCustomers;
|
||||
if (!!currentCustomerIds) {
|
||||
currentCustomerIds.forEach(t => customerIds.push(t));
|
||||
currentCustomerIds.forEach((t) => customerIds.push(t));
|
||||
}
|
||||
newCustomers.forEach((customer: User) => {
|
||||
if (currentCustomers[customer.id] === undefined) {
|
||||
customers = { ...customers, [customer.id]: customer };
|
||||
}
|
||||
if (customerIds.find(t => t === customer.id) === undefined) {
|
||||
if (customerIds.find((t) => t === customer.id) === undefined) {
|
||||
customerIds.push(customer.id);
|
||||
}
|
||||
});
|
||||
@@ -113,7 +113,7 @@ export class CustomerState {
|
||||
let customerApi$: Observable<User>;
|
||||
let isOnline = false;
|
||||
if (payload) {
|
||||
payload.features.forEach(feature => {
|
||||
payload.features.forEach((feature) => {
|
||||
if (feature.key === 'onlineshop' || feature.key === 'guestaccount') {
|
||||
isOnline = true;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export class CustomerState {
|
||||
)
|
||||
);
|
||||
}),
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
this.store.dispatch(
|
||||
new SetOnlineCustomerCreationStatus({
|
||||
error: true,
|
||||
@@ -170,26 +170,26 @@ export class CustomerState {
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload.features && payload.features.findIndex(v => v.key === 'onlineshop') >= 0) {
|
||||
const customers = {...state.customers, [id]: {...payload, id: id, error: null}};
|
||||
ctx.patchState({customers});
|
||||
if (payload.features && payload.features.findIndex((v) => v.key === 'onlineshop') >= 0) {
|
||||
const customers = { ...state.customers, [id]: { ...payload, id: id, error: null } };
|
||||
ctx.patchState({ customers });
|
||||
this.syncApiState(customers, state.lastCreatedCustomerId, state.cachedCustomerSearch);
|
||||
return;
|
||||
}
|
||||
|
||||
return this.customerService.updateCustomer(payload).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
console.error(error);
|
||||
const customers = {...state.customers, [id]: {...state.customers[id], id: id, error: error}};
|
||||
ctx.patchState({customers});
|
||||
const customers = { ...state.customers, [id]: { ...state.customers[id], id: id, error: error } };
|
||||
ctx.patchState({ customers });
|
||||
return of(undefined);
|
||||
}),
|
||||
tap(addedCustomer => {
|
||||
tap((addedCustomer) => {
|
||||
if (!addedCustomer) {
|
||||
return;
|
||||
}
|
||||
const customers = {...state.customers, [id]: {...payload, id: id, error: null}};
|
||||
ctx.patchState({customers});
|
||||
const customers = { ...state.customers, [id]: { ...payload, id: id, error: null } };
|
||||
ctx.patchState({ customers });
|
||||
if (addBreadcrumb) {
|
||||
this.store.dispatch(
|
||||
new AddBreadcrumb(
|
||||
@@ -240,11 +240,7 @@ export class CustomerState {
|
||||
this.store.dispatch(new RemoveCustomerId(payload));
|
||||
this.syncApiState(customers, state.lastCreatedCustomerId, state.cachedCustomerSearch);
|
||||
|
||||
return this.customerService.deleteCustomer(payload).pipe(
|
||||
tap((deleted: boolean) => {
|
||||
console.log('User deleted with API', deleted);
|
||||
})
|
||||
);
|
||||
return this.customerService.deleteCustomer(payload);
|
||||
}
|
||||
|
||||
@Action(actions.SetDefaultShippingAddress)
|
||||
@@ -259,11 +255,11 @@ export class CustomerState {
|
||||
return;
|
||||
}
|
||||
return shipping$.pipe(
|
||||
tap(response => {
|
||||
tap((response) => {
|
||||
const customer = currentCustomers[customerId];
|
||||
const updatedCustomer = {
|
||||
...customer,
|
||||
delivery_addres: customer.poossible_delivery_addresses.find(t => t.id === shippingAddress.id),
|
||||
delivery_addres: customer.poossible_delivery_addresses.find((t) => t.id === shippingAddress.id),
|
||||
};
|
||||
const customers = { ...currentCustomers, [updatedCustomer.id]: updatedCustomer };
|
||||
ctx.patchState({ customers });
|
||||
@@ -284,11 +280,11 @@ export class CustomerState {
|
||||
return;
|
||||
}
|
||||
return invoice$.pipe(
|
||||
tap(response => {
|
||||
tap((response) => {
|
||||
const customer = currentCustomers[customerId];
|
||||
const updatedCustomer = {
|
||||
...customer,
|
||||
invoice_address: customer.poossible_invoice_addresses.find(t => t.id === invoiceAddress.id),
|
||||
invoice_address: customer.poossible_invoice_addresses.find((t) => t.id === invoiceAddress.id),
|
||||
};
|
||||
const customers = { ...currentCustomers, [updatedCustomer.id]: updatedCustomer };
|
||||
ctx.patchState({ customers });
|
||||
@@ -306,7 +302,7 @@ export class CustomerState {
|
||||
const currentCustomers = state.customers;
|
||||
const address = { ...shippingAddress, synced: true };
|
||||
return this.customerService.addShippingAddress(customerId, address).pipe(
|
||||
tap(response => {
|
||||
tap((response) => {
|
||||
const isUpdate = !isNullOrUndefined(address.id);
|
||||
const customer = currentCustomers[customerId];
|
||||
let updatedCustomer: User;
|
||||
@@ -314,8 +310,8 @@ export class CustomerState {
|
||||
updatedCustomer = <User>{
|
||||
...customer,
|
||||
delivery_addres: address,
|
||||
poossible_delivery_addresses: [...customer.poossible_delivery_addresses.filter(t => t.id !== address.id), address],
|
||||
poossible_invoice_addresses: [...customer.poossible_invoice_addresses.filter(t => t.id !== address.id), address],
|
||||
poossible_delivery_addresses: [...customer.poossible_delivery_addresses.filter((t) => t.id !== address.id), address],
|
||||
poossible_invoice_addresses: [...customer.poossible_invoice_addresses.filter((t) => t.id !== address.id), address],
|
||||
};
|
||||
} else {
|
||||
updatedCustomer = <User>{
|
||||
@@ -342,7 +338,7 @@ export class CustomerState {
|
||||
const currentCustomers = state.customers;
|
||||
const address = { ...invoiceAddress, synced: true };
|
||||
return this.customerService.addInvoiceAddress(customerId, address).pipe(
|
||||
tap(response => {
|
||||
tap((response) => {
|
||||
const isUpdate = !isNullOrUndefined(address.id);
|
||||
const customer = currentCustomers[customerId];
|
||||
let updatedCustomer: User;
|
||||
@@ -350,8 +346,8 @@ export class CustomerState {
|
||||
updatedCustomer = <User>{
|
||||
...customer,
|
||||
invoice_address: address,
|
||||
poossible_delivery_addresses: [...customer.poossible_delivery_addresses.filter(t => t && t.id !== address.id), address],
|
||||
poossible_invoice_addresses: [...customer.poossible_invoice_addresses.filter(t => t && t.id !== address.id), address],
|
||||
poossible_delivery_addresses: [...customer.poossible_delivery_addresses.filter((t) => t && t.id !== address.id), address],
|
||||
poossible_invoice_addresses: [...customer.poossible_invoice_addresses.filter((t) => t && t.id !== address.id), address],
|
||||
};
|
||||
} else {
|
||||
updatedCustomer = <User>{
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from '../actions/product.actions';
|
||||
import { Breadcrumb } from '../../models/breadcrumb.model';
|
||||
import { AddBreadcrumbNoDub } from '../actions/breadcrumb.actions';
|
||||
import { ItemDTO, ListResponseArgsOfItemDTO } from 'swagger';
|
||||
import { ItemDTO, ListResponseArgsOfItemDTO } from '@swagger/cat';
|
||||
import { AppState } from './app.state';
|
||||
import { UserStateSyncData } from '../../models/user-state-sync.model';
|
||||
import { AppUserDataSync } from '../actions/app.actions';
|
||||
|
||||
@@ -5,10 +5,7 @@ import * as actions from '../actions/remission.actions';
|
||||
import { UserStateSyncData } from '../../models/user-state-sync.model';
|
||||
import { AppUserDataSync } from '../actions/app.actions';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import {
|
||||
RemissionResourceType,
|
||||
RemissionTargetType,
|
||||
} from '../../../modules/remission/models/remission-resource-type.model';
|
||||
import { RemissionResourceType, RemissionTargetType } from '../../../modules/remission/models/remission-resource-type.model';
|
||||
import { RemissionService, RemissionProcess } from '@isa/remission';
|
||||
import { RemissionFinishingProcessStatus } from '../../../modules/remission/models/remission-finishing-process-status.enum';
|
||||
import get from 'lodash/get';
|
||||
@@ -28,16 +25,10 @@ export class RemissionStateModel {
|
||||
},
|
||||
})
|
||||
export class RemissionState {
|
||||
constructor(
|
||||
private store: Store,
|
||||
private remissionService: RemissionService
|
||||
) {}
|
||||
constructor(private store: Store, private remissionService: RemissionService) {}
|
||||
|
||||
@Action(actions.SetRemissionCreated)
|
||||
setRemissionCreated(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ status }: actions.SetRemissionCreated
|
||||
) {
|
||||
setRemissionCreated(ctx: StateContext<RemissionStateModel>, { status }: actions.SetRemissionCreated) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const remission: Remission = {
|
||||
@@ -49,10 +40,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionStarted)
|
||||
setRemissionStarted(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ status }: actions.SetRemissionStarted
|
||||
) {
|
||||
setRemissionStarted(ctx: StateContext<RemissionStateModel>, { status }: actions.SetRemissionStarted) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const remission: Remission = {
|
||||
@@ -64,10 +52,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionCompleted)
|
||||
setRemissionCompleted(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ status }: actions.SetRemissionCompleted
|
||||
) {
|
||||
setRemissionCompleted(ctx: StateContext<RemissionStateModel>, { status }: actions.SetRemissionCompleted) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const remission: Remission = {
|
||||
@@ -79,19 +64,14 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionProcess)
|
||||
setRemissionProcess(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ remissionProcess, initialValue }: actions.SetRemissionProcess
|
||||
) {
|
||||
setRemissionProcess(ctx: StateContext<RemissionStateModel>, { remissionProcess, initialValue }: actions.SetRemissionProcess) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const filter = get(remissionProcess, 'filter.filter', null);
|
||||
const remissionWithEmptyFilters =
|
||||
filter === null ||
|
||||
Object.keys(filter).every((sourceKey) =>
|
||||
Object.keys(filter[sourceKey]).every(
|
||||
(targetKey) => Object.keys(filter[sourceKey][targetKey]).length === 0
|
||||
)
|
||||
Object.keys(filter[sourceKey]).every((targetKey) => Object.keys(filter[sourceKey][targetKey]).length === 0)
|
||||
);
|
||||
const remission: Remission = {
|
||||
...currentRemission,
|
||||
@@ -120,10 +100,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionFinishedProcessStatus)
|
||||
setRemissionFinishedProcessStatus(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ status }: actions.SetRemissionFinishedProcessStatus
|
||||
) {
|
||||
setRemissionFinishedProcessStatus(ctx: StateContext<RemissionStateModel>, { status }: actions.SetRemissionFinishedProcessStatus) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const remission: Remission = {
|
||||
@@ -135,10 +112,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionScannedContainerId)
|
||||
setRemissionScannedContainerId(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ containerId }: actions.SetRemissionScannedContainerId
|
||||
) {
|
||||
setRemissionScannedContainerId(ctx: StateContext<RemissionStateModel>, { containerId }: actions.SetRemissionScannedContainerId) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const remission: Remission = {
|
||||
@@ -150,10 +124,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionTarget)
|
||||
setRemissionTarget(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ target, source }: actions.SetRemissionTarget
|
||||
) {
|
||||
setRemissionTarget(ctx: StateContext<RemissionStateModel>, { target, source }: actions.SetRemissionTarget) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
let remission: Remission;
|
||||
@@ -166,10 +137,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionSource)
|
||||
setRemissionSource(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ source }: actions.SetRemissionSource
|
||||
) {
|
||||
setRemissionSource(ctx: StateContext<RemissionStateModel>, { source }: actions.SetRemissionSource) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const remission: Remission = {
|
||||
@@ -188,10 +156,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionProducts)
|
||||
setRemissionProducts(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ products }: actions.SetRemissionProducts
|
||||
) {
|
||||
setRemissionProducts(ctx: StateContext<RemissionStateModel>, { products }: actions.SetRemissionProducts) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const remission: Remission = {
|
||||
@@ -203,10 +168,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionSearchedProduct)
|
||||
setRemissionSearchedProduct(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ product }: actions.SetRemissionSearchedProduct
|
||||
) {
|
||||
setRemissionSearchedProduct(ctx: StateContext<RemissionStateModel>, { product }: actions.SetRemissionSearchedProduct) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const remission: Remission = {
|
||||
@@ -222,7 +184,6 @@ export class RemissionState {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const remission: Remission = { ...currentRemission, blockReminder: false };
|
||||
console.log(remission);
|
||||
ctx.patchState({ remission });
|
||||
this.syncApiState(remission);
|
||||
}
|
||||
@@ -245,10 +206,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.CompleteRemissionShippingDocument)
|
||||
completeRemissionShippingDocument(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ shippingDocument }: actions.SetRemissionShippingDocument
|
||||
) {
|
||||
completeRemissionShippingDocument(ctx: StateContext<RemissionStateModel>, { shippingDocument }: actions.SetRemissionShippingDocument) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const currentRemissionProcess = currentRemission.remissionProcess;
|
||||
@@ -258,9 +216,7 @@ export class RemissionState {
|
||||
|
||||
if (currentRemissionProcess.shippingDocuments) {
|
||||
const shippingDocumentAlreadyExists =
|
||||
currentRemissionProcess.shippingDocuments.findIndex(
|
||||
(sd) => sd.id === shippingDocument.id
|
||||
) !== -1;
|
||||
currentRemissionProcess.shippingDocuments.findIndex((sd) => sd.id === shippingDocument.id) !== -1;
|
||||
if (shippingDocumentAlreadyExists) {
|
||||
updatedRemissionProcess = {
|
||||
...updatedRemissionProcess,
|
||||
@@ -280,8 +236,7 @@ export class RemissionState {
|
||||
}
|
||||
const remission: Remission = {
|
||||
...currentRemission,
|
||||
remissionFinishingProcessStatus:
|
||||
RemissionFinishingProcessStatus.containerScanned,
|
||||
remissionFinishingProcessStatus: RemissionFinishingProcessStatus.containerScanned,
|
||||
remissionProcess: updatedRemissionProcess,
|
||||
};
|
||||
ctx.patchState({ remission });
|
||||
@@ -289,10 +244,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.DeleteRemissionShippingDocument)
|
||||
deleteShippingDocument(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ remissionProcessId }: actions.DeleteRemissionShippingDocument
|
||||
) {
|
||||
deleteShippingDocument(ctx: StateContext<RemissionStateModel>, { remissionProcessId }: actions.DeleteRemissionShippingDocument) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
|
||||
@@ -308,10 +260,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionShippingDocument)
|
||||
setRemissionShippingDocument(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ shippingDocument }: actions.SetRemissionShippingDocument
|
||||
) {
|
||||
setRemissionShippingDocument(ctx: StateContext<RemissionStateModel>, { shippingDocument }: actions.SetRemissionShippingDocument) {
|
||||
const state = ctx.getState();
|
||||
const currentRemission = state.remission;
|
||||
const currentRemissionProcess = currentRemission.remissionProcess;
|
||||
@@ -319,9 +268,7 @@ export class RemissionState {
|
||||
|
||||
if (currentRemissionProcess.shippingDocuments) {
|
||||
const shippingDocumentAlreadyExists =
|
||||
currentRemissionProcess.shippingDocuments.findIndex(
|
||||
(sd) => sd.id === shippingDocument.id
|
||||
) !== -1;
|
||||
currentRemissionProcess.shippingDocuments.findIndex((sd) => sd.id === shippingDocument.id) !== -1;
|
||||
if (shippingDocumentAlreadyExists) {
|
||||
updatedRemissionProcess = {
|
||||
...currentRemission.remissionProcess,
|
||||
@@ -337,19 +284,13 @@ export class RemissionState {
|
||||
} else {
|
||||
updatedRemissionProcess = {
|
||||
...currentRemission.remissionProcess,
|
||||
shippingDocuments: [
|
||||
...currentRemission.remissionProcess.shippingDocuments,
|
||||
shippingDocument,
|
||||
],
|
||||
shippingDocuments: [...currentRemission.remissionProcess.shippingDocuments, shippingDocument],
|
||||
};
|
||||
}
|
||||
} else {
|
||||
updatedRemissionProcess = {
|
||||
...currentRemission.remissionProcess,
|
||||
shippingDocuments: [
|
||||
...currentRemission.remissionProcess.shippingDocuments,
|
||||
shippingDocument,
|
||||
],
|
||||
shippingDocuments: [...currentRemission.remissionProcess.shippingDocuments, shippingDocument],
|
||||
};
|
||||
}
|
||||
const remission: Remission = {
|
||||
@@ -422,10 +363,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.ReloadRemission)
|
||||
reload(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ remission }: actions.ReloadRemission
|
||||
) {
|
||||
reload(ctx: StateContext<RemissionStateModel>, { remission }: actions.ReloadRemission) {
|
||||
ctx.patchState({
|
||||
remission: {
|
||||
...remission,
|
||||
@@ -437,10 +375,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetAllOpenExistingRemissions)
|
||||
setAllOpenExistingRemissions(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ remissionProcesses }: actions.SetAllOpenExistingRemissions
|
||||
) {
|
||||
setAllOpenExistingRemissions(ctx: StateContext<RemissionStateModel>, { remissionProcesses }: actions.SetAllOpenExistingRemissions) {
|
||||
const state = ctx.getState();
|
||||
const currentExistingRemissions = state.existingRemissions;
|
||||
const existingRemissions: RemissionExistingOverview = {
|
||||
@@ -452,10 +387,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetAllExistingRemissions)
|
||||
setAllExistingRemissions(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ remissionProcesses }: actions.SetAllExistingRemissions
|
||||
) {
|
||||
setAllExistingRemissions(ctx: StateContext<RemissionStateModel>, { remissionProcesses }: actions.SetAllExistingRemissions) {
|
||||
const state = ctx.getState();
|
||||
const currentExistingRemissions = state.existingRemissions;
|
||||
const existingRemissions: RemissionExistingOverview = {
|
||||
@@ -475,10 +407,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionFilter)
|
||||
setRemissionFilter(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ filter }: actions.SetRemissionFilter
|
||||
) {
|
||||
setRemissionFilter(ctx: StateContext<RemissionStateModel>, { filter }: actions.SetRemissionFilter) {
|
||||
const state = ctx.getState();
|
||||
const remissionState = state.remission;
|
||||
|
||||
@@ -500,10 +429,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.RequestUpdateRemissionFilter)
|
||||
setIsLoadingFilters(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ filter }: actions.RequestUpdateRemissionFilter
|
||||
) {
|
||||
setIsLoadingFilters(ctx: StateContext<RemissionStateModel>, { filter }: actions.RequestUpdateRemissionFilter) {
|
||||
const state = ctx.getState();
|
||||
const remissionState = state.remission;
|
||||
|
||||
@@ -515,10 +441,8 @@ export class RemissionState {
|
||||
...remissionState.remissionProcess,
|
||||
filter: {
|
||||
...remissionState.remissionProcess.filter,
|
||||
source:
|
||||
filter.source || remissionState.remissionProcess.filter.source,
|
||||
target:
|
||||
filter.target || remissionState.remissionProcess.filter.target,
|
||||
source: filter.source || remissionState.remissionProcess.filter.source,
|
||||
target: filter.target || remissionState.remissionProcess.filter.target,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -532,10 +456,7 @@ export class RemissionState {
|
||||
}
|
||||
|
||||
@Action(actions.SetRemissionIsLoading)
|
||||
setIsLoading(
|
||||
ctx: StateContext<RemissionStateModel>,
|
||||
{ isLoading }: actions.SetRemissionIsLoading
|
||||
) {
|
||||
setIsLoading(ctx: StateContext<RemissionStateModel>, { isLoading }: actions.SetRemissionIsLoading) {
|
||||
const state = ctx.getState();
|
||||
|
||||
ctx.patchState({
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { VATDTO } from 'swagger/lib/oms/models/vatdto';
|
||||
import { SupplierDTO } from '@swagger/oms';
|
||||
import { State, Action, StateContext, Selector } from '@ngxs/store';
|
||||
import { CollectingShelfService } from '../../services/collecting-shelf.service';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import * as actions from '../actions/suppliers.actions';
|
||||
import { SupplierDTO } from 'swagger/lib/oms/models/supplier-dto';
|
||||
|
||||
export class SupplierStateModel {
|
||||
suppliers: { [id: number]: SupplierDTO };
|
||||
@@ -24,7 +23,7 @@ export class SupplierState {
|
||||
}
|
||||
|
||||
@Action(actions.LoadSuppliers)
|
||||
loadSuppliers(ctx: StateContext<SupplierStateModel>, { }: actions.LoadSuppliers) {
|
||||
loadSuppliers(ctx: StateContext<SupplierStateModel>, {}: actions.LoadSuppliers) {
|
||||
return this.shelfService.getSuppliers().pipe(
|
||||
tap((_suppliers: SupplierDTO[]) => {
|
||||
const state = ctx.getState();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { VATDTO } from 'swagger/lib/oms/models/vatdto';
|
||||
import { VATDTO } from '@swagger/oms';
|
||||
import { State, Action, StateContext, Selector } from '@ngxs/store';
|
||||
import { CollectingShelfService } from '../../services/collecting-shelf.service';
|
||||
import { tap } from 'rxjs/operators';
|
||||
@@ -23,7 +23,7 @@ export class VatState {
|
||||
}
|
||||
|
||||
@Action(actions.LoadVats)
|
||||
loadVats(ctx: StateContext<VatStateModel>, { }: actions.LoadVats) {
|
||||
loadVats(ctx: StateContext<VatStateModel>, {}: actions.LoadVats) {
|
||||
return this.shelfService.getGrossPriceVats().pipe(
|
||||
tap((vats: VATDTO[]) => {
|
||||
ctx.patchState({ vats });
|
||||
|
||||
@@ -13,12 +13,12 @@ import { BarcodeScannerScanditComponent } from 'shared/lib/barcode-scanner';
|
||||
import { AddBreadcrumb } from '../../../../core/store/actions/breadcrumb.actions';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { ProcessSelectors } from '../../../../core/store/selectors/process.selectors';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
|
||||
@Component({
|
||||
selector: 'app-barcode-search',
|
||||
templateUrl: 'barcode-search.component.html',
|
||||
styleUrls: ['barcode-search.component.scss']
|
||||
styleUrls: ['barcode-search.component.scss'],
|
||||
})
|
||||
export class BarcodeSearchComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('scanner') scanner: BarcodeScannerScanditComponent;
|
||||
@@ -42,7 +42,7 @@ export class BarcodeSearchComponent implements OnInit, OnDestroy {
|
||||
fitlers: [],
|
||||
take: 10,
|
||||
skip: 0,
|
||||
firstLoad: true
|
||||
firstLoad: true,
|
||||
};
|
||||
this.productService
|
||||
.searchItems(search)
|
||||
@@ -64,7 +64,7 @@ export class BarcodeSearchComponent implements OnInit, OnDestroy {
|
||||
const newProcess = <Process>{
|
||||
id: 1,
|
||||
name: 'Vorgang 1',
|
||||
currentRoute: '/product/search'
|
||||
currentRoute: '/product/search',
|
||||
};
|
||||
|
||||
this.store.dispatch(new AddProcess(newProcess));
|
||||
@@ -72,7 +72,7 @@ export class BarcodeSearchComponent implements OnInit, OnDestroy {
|
||||
new AddBreadcrumb(
|
||||
<Breadcrumb>{
|
||||
name: 'Artikelsuche',
|
||||
path: '/product/search'
|
||||
path: '/product/search',
|
||||
},
|
||||
'product',
|
||||
true
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Router } from '@angular/router';
|
||||
import { Store, Select } from '@ngxs/store';
|
||||
import { Observable, Subject, of } from 'rxjs';
|
||||
import { takeUntil, catchError } from 'rxjs/operators';
|
||||
import { CustomerInfoDTO } from 'swagger/lib/crm/models/customer-info-dto';
|
||||
import { CustomerInfoDTO } from '@swagger/crm';
|
||||
import { CustomerCardScannerScanditComponent } from 'shared/lib/customer-card-scanner';
|
||||
import { CustomerService } from 'apps/sales/src/app/core/services/customer.service';
|
||||
import { WindowRef } from 'apps/sales/src/app/core/services/window-ref.service';
|
||||
@@ -20,7 +20,7 @@ import { ErrorService } from 'apps/sales/src/app/core/error/component/error.serv
|
||||
@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;
|
||||
@@ -80,7 +80,7 @@ export class CustomerCardBarcodeSearchComponent implements OnInit, OnDestroy, Af
|
||||
{
|
||||
name: (barcode.length > 12 ? barcode.substring(0, 12) + '...' : barcode) + ` (${customers.length} Ergebnisse)`,
|
||||
path: '/customer/results',
|
||||
queryParams: { scan: true }
|
||||
queryParams: { scan: true },
|
||||
},
|
||||
'customer'
|
||||
)
|
||||
@@ -90,7 +90,7 @@ export class CustomerCardBarcodeSearchComponent implements OnInit, OnDestroy, Af
|
||||
query: barcode,
|
||||
skip: 0,
|
||||
take: 5,
|
||||
firstLoad: true
|
||||
firstLoad: true,
|
||||
})
|
||||
);
|
||||
this.store.dispatch(new ChangeCurrentRoute('/customer/results'));
|
||||
@@ -100,7 +100,7 @@ export class CustomerCardBarcodeSearchComponent implements OnInit, OnDestroy, Af
|
||||
this.searchCardEmptyModal.openDialog();
|
||||
}
|
||||
},
|
||||
e => {
|
||||
(e) => {
|
||||
this.errorService.addErrors(e.status, e.message, undefined);
|
||||
}
|
||||
);
|
||||
@@ -117,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));
|
||||
@@ -125,7 +125,7 @@ export class CustomerCardBarcodeSearchComponent implements OnInit, OnDestroy, Af
|
||||
new AddBreadcrumb(
|
||||
<Breadcrumb>{
|
||||
name: 'Kundenkarte scannen',
|
||||
path: '/customer/search'
|
||||
path: '/customer/search',
|
||||
},
|
||||
'customer'
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
ViewChild,
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
OnDestroy
|
||||
OnDestroy,
|
||||
} from '@angular/core';
|
||||
import { ModalService } from '@libs/ui';
|
||||
import { Store, Select } from '@ngxs/store';
|
||||
@@ -15,9 +15,9 @@ import { ProductAvailabilityService } from '../../../../core/services/product-av
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { BranchSelectors } from '../../../../core/store/selectors/branch.selector';
|
||||
import { Observable, Subject, of, forkJoin } from 'rxjs';
|
||||
import { BranchDTO } from 'swagger/lib/checkout/models/branch-dto';
|
||||
import { BranchDTO } from '@swagger/checkout';
|
||||
import { DeliveryOption } from '../../../../core/models/delivery-option.model';
|
||||
import { AvailabilityDTO } from 'swagger/lib/availability/models/availability-dto';
|
||||
import { AvailabilityDTO } from '@swagger/availability';
|
||||
import { ProductAvailability } from '../../../../core/models/product-availability.model';
|
||||
import { CheckoutType } from '../../../../core/models/checkout-type.enum';
|
||||
import { takeUntil, map, filter, tap, take } from 'rxjs/operators';
|
||||
@@ -28,7 +28,7 @@ import { isNullOrUndefined } from 'util';
|
||||
import { BranchService } from '../../../../core/services/branch.service';
|
||||
import { CheckoutService } from 'apps/sales/src/app/core/services/checkout.service';
|
||||
import { SearchDropdownComponent } from '@libs/ui/lib/search-dropdown';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { allowedAvailabilityStatusCodes } from '../../../../core/utils/product.util';
|
||||
import { ViewRef_ } from '@angular/core/src/view';
|
||||
|
||||
@@ -42,7 +42,7 @@ export interface ProcessAvailibilityMapper {
|
||||
selector: 'app-change-order-type',
|
||||
templateUrl: './change-order-type.component.html',
|
||||
styleUrls: ['./change-order-type.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
@Select(BranchSelectors.getBranches) branches$: Observable<{ [key: number]: BranchDTO }>;
|
||||
@@ -63,7 +63,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
deliveryOptions = {
|
||||
delivery: DeliveryOption.DELIVERY,
|
||||
now: DeliveryOption.TAKE_NOW,
|
||||
pick_up: DeliveryOption.PICK_UP
|
||||
pick_up: DeliveryOption.PICK_UP,
|
||||
};
|
||||
|
||||
branches: string[] = [];
|
||||
@@ -87,7 +87,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
_deliveryPrice: number;
|
||||
|
||||
get takeNowAvailable() {
|
||||
if (this.availability.filter(t => t.type === CheckoutType.takeNow).length > 0) {
|
||||
if (this.availability.filter((t) => t.type === CheckoutType.takeNow).length > 0) {
|
||||
return of(true);
|
||||
}
|
||||
return of(false);
|
||||
@@ -96,7 +96,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
get storeAvailable() {
|
||||
if (
|
||||
this.availability.filter(
|
||||
t =>
|
||||
(t) =>
|
||||
t.type === CheckoutType.store &&
|
||||
(allowedAvailabilityStatusCodes(t.status) || (t.av && t.av.ssc === '830' && t.av.supplier === 'G'))
|
||||
).length > 0
|
||||
@@ -107,7 +107,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
get shippingAvailable() {
|
||||
if (this.availability.filter(t => t.type === CheckoutType.delivery && allowedAvailabilityStatusCodes(t.status)).length > 0) {
|
||||
if (this.availability.filter((t) => t.type === CheckoutType.delivery && allowedAvailabilityStatusCodes(t.status)).length > 0) {
|
||||
return of(true);
|
||||
}
|
||||
return of(false);
|
||||
@@ -149,7 +149,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
this.currency = this.book.catalogAvailability.price.value.currency;
|
||||
this.branches$
|
||||
.pipe(
|
||||
filter(branchData => objectNotNull(branchData)),
|
||||
filter((branchData) => objectNotNull(branchData)),
|
||||
takeUntil(this.destroy$),
|
||||
take(1)
|
||||
)
|
||||
@@ -160,7 +160,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
this.checkoutService
|
||||
.getSuppliers()
|
||||
.pipe(
|
||||
map(suppliers => suppliers.find(supplier => supplier.supplierNumber === 'F').id),
|
||||
map((suppliers) => suppliers.find((supplier) => supplier.supplierNumber === 'F').id),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
.subscribe((suplierId: number) => {
|
||||
@@ -178,7 +178,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
if (!this._item || !this._item.branch) {
|
||||
return;
|
||||
}
|
||||
const userBranch = branches.find(t => t.id === this._item.branch.id);
|
||||
const userBranch = branches.find((t) => t.id === this._item.branch.id);
|
||||
if (!!userBranch) {
|
||||
this.selectedBranch = userBranch;
|
||||
this.currentLocation = userBranch.name;
|
||||
@@ -200,7 +200,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
if (!!userBranch) {
|
||||
this.filteredBranches = this.branchesData
|
||||
.sort((a: BranchDTO, b: BranchDTO) => this.branchSorterFn(a, b, userBranch))
|
||||
.map(t => t.name);
|
||||
.map((t) => t.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
if (!this._item || !this._item.branch) {
|
||||
return;
|
||||
}
|
||||
const branch = branches.find(t => t.id === this._item.branch.id);
|
||||
const branch = branches.find((t) => t.id === this._item.branch.id);
|
||||
|
||||
// Make call to API for all availabilities
|
||||
const storeAvailability = this.productAvailabilityService.getStoreAvailabilityWithCheck(item, ean, branch.id).pipe(
|
||||
@@ -260,15 +260,15 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
|
||||
// Map data to be the same
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
const userBranch = branches.find(t => t.branchNumber === userBranchNumber);
|
||||
const userBranch = branches.find((t) => t.branchNumber === userBranchNumber);
|
||||
if (!userBranch) {
|
||||
return;
|
||||
}
|
||||
const takeNowAvailability = this.productAvailabilityService.getStockInfo([userBranch.id], [item.id]).pipe(
|
||||
takeUntil(this.destroy$),
|
||||
map(av => {
|
||||
map((av) => {
|
||||
const takeNowAv: AvailabilityDTO[] = [];
|
||||
av.forEach(availibility => {
|
||||
av.forEach((availibility) => {
|
||||
const quantity = availibility.inStock.toString();
|
||||
if (+quantity > 0) {
|
||||
for (let x = 0; x < +quantity; x++) {
|
||||
@@ -278,7 +278,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
qty: +quantity,
|
||||
ssc: '999',
|
||||
price: this._item.book.catalogAvailability.price,
|
||||
supplierId: this.takeNowSuplierId
|
||||
supplierId: this.takeNowSuplierId,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -287,7 +287,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
return {
|
||||
branchId: userBranch.id,
|
||||
type: CheckoutType.takeNow,
|
||||
av: takeNowAv
|
||||
av: takeNowAv,
|
||||
};
|
||||
})
|
||||
);
|
||||
@@ -320,36 +320,36 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
item.av.forEach(av => {
|
||||
item.av.forEach((av) => {
|
||||
this.availability.push({
|
||||
itemId: av.itemId,
|
||||
branchId: item.branchId,
|
||||
quantity: item.av.length,
|
||||
type: item.type,
|
||||
av: preferredAvailability,
|
||||
status: av.status
|
||||
status: av.status,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
branchSearch(term: string) {
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
const userBranch = this.branchesData.find(t => t.branchNumber === userBranchNumber);
|
||||
const userBranch = this.branchesData.find((t) => t.branchNumber === userBranchNumber);
|
||||
if (isNullOrUndefined(term) || term.length < 1) {
|
||||
this.filteredBranches = this.branchesData
|
||||
.sort((a: BranchDTO, b: BranchDTO) => this.branchSorterFn(a, b, userBranch))
|
||||
.map(t => t.name);
|
||||
.map((t) => t.name);
|
||||
return;
|
||||
}
|
||||
this.branchService
|
||||
.searchBranches(term, 0, null)
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
map(branches => {
|
||||
map((branches) => {
|
||||
// this.store.dispatch(new AddBranchesIfNotLoaded(branches));
|
||||
return branches.map(t => t.name);
|
||||
return branches.map((t) => t.name);
|
||||
}),
|
||||
tap(branchName => (this.filteredBranches = branchName))
|
||||
tap((branchName) => (this.filteredBranches = branchName))
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
@@ -367,7 +367,7 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
storeBranches(): Observable<number[]> {
|
||||
return of(this.availability.filter(t => t.type === CheckoutType.store).map(t => t.branchId));
|
||||
return of(this.availability.filter((t) => t.type === CheckoutType.store).map((t) => t.branchId));
|
||||
}
|
||||
|
||||
selectLocation(location: string) {
|
||||
@@ -375,25 +375,25 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
this.searchingNewBranch = true;
|
||||
const branch = this.branchesData.find((b: BranchDTO) => b.name === location);
|
||||
// reset store availability
|
||||
this.availability = [...this.availability.filter(t => t.type !== CheckoutType.store)];
|
||||
this.availability = [...this.availability.filter((t) => t.type !== CheckoutType.store)];
|
||||
this.productAvailabilityService
|
||||
.getStoreAvailability(this.book, this.book.product.ean, branch.id)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(response => {
|
||||
.subscribe((response) => {
|
||||
if (response.av.length > 0) {
|
||||
this.currentLocation = location;
|
||||
this.filteredBranches = [location, ...this.branches.filter(t => t !== location)];
|
||||
this.filteredBranches = [location, ...this.branches.filter((t) => t !== location)];
|
||||
this.selectedBranch = branch;
|
||||
const preferedAv = response.av.find(t => t.preferred === 1);
|
||||
const preferedAv = response.av.find((t) => t.preferred === 1);
|
||||
this.currentPickUpDate = this.datePipe.transform(new Date(preferedAv.at), 'dd.MM.yy');
|
||||
response.av.forEach(t => {
|
||||
response.av.forEach((t) => {
|
||||
this.availability.push({
|
||||
itemId: t.itemId,
|
||||
branchId: branch.id,
|
||||
quantity: response.av.length,
|
||||
type: CheckoutType.store,
|
||||
av: preferedAv ? preferedAv : response.av[0],
|
||||
status: t.status
|
||||
status: t.status,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -409,21 +409,21 @@ export class ChangeOrderTypeComponent implements OnInit, OnDestroy {
|
||||
return;
|
||||
}
|
||||
if (action === DeliveryOption.TAKE_NOW) {
|
||||
this.currentAvailability = this.availability.find(t => t.type === CheckoutType.takeNow).av;
|
||||
this.currentAvailability = this.availability.find((t) => t.type === CheckoutType.takeNow).av;
|
||||
this.deliveryType = DeliveryOption.TAKE_NOW;
|
||||
// when on Rucklage the branche should be the user branch
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
if (this.branchesData) {
|
||||
const userBranch = this.branchesData.find(t => t.branchNumber === userBranchNumber);
|
||||
const userBranch = this.branchesData.find((t) => t.branchNumber === userBranchNumber);
|
||||
if (userBranch) {
|
||||
this.selectedBranch = userBranch;
|
||||
}
|
||||
}
|
||||
} else if (action === DeliveryOption.PICK_UP) {
|
||||
this.currentAvailability = this.availability.find(t => t.type === CheckoutType.store).av;
|
||||
this.currentAvailability = this.availability.find((t) => t.type === CheckoutType.store).av;
|
||||
this.deliveryType = DeliveryOption.PICK_UP;
|
||||
} else {
|
||||
this.currentAvailability = this.availability.find(t => t.type === CheckoutType.delivery).av;
|
||||
this.currentAvailability = this.availability.find((t) => t.type === CheckoutType.delivery).av;
|
||||
this.deliveryType = DeliveryOption.DELIVERY;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ import { DeleteDropdownComponent } from '@libs/ui';
|
||||
import { allowedAvailabilityStatusCodes } from 'apps/sales/src/app/core/utils/product.util';
|
||||
import { DeliveryOption } from 'apps/sales/src/app/core/models/delivery-option.model';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { AvailabilityDTO } from 'swagger';
|
||||
import { AvailabilityDTO } from '@swagger/cat';
|
||||
|
||||
@Component({
|
||||
selector: 'app-delivery-cart-row',
|
||||
templateUrl: './delivery-cart-row.component.html',
|
||||
styleUrls: ['./delivery-cart-row.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class DeliveryCartRowComponent implements OnInit {
|
||||
@ViewChild('changeOrder') changeOrderDialog: ChangeOrderTypeComponent;
|
||||
@@ -78,7 +78,7 @@ export class DeliveryCartRowComponent implements OnInit {
|
||||
}
|
||||
|
||||
onQuantityChanged(quantity: number, showError: boolean = false) {
|
||||
this.validateSelectedQuantity(quantity).subscribe(av => {
|
||||
this.validateSelectedQuantity(quantity).subscribe((av) => {
|
||||
if (quantity > av.qty) {
|
||||
this.store.dispatch(
|
||||
new UpdateCartEntryQuantity(av.qty, this.item.cartEntryId, av.av, `Achtung, Maximal ${av.qty} Exemplare bestellbar.`)
|
||||
@@ -96,7 +96,7 @@ export class DeliveryCartRowComponent implements OnInit {
|
||||
|
||||
validateSelectedQuantity(quantity: number): Observable<{ qty: number; av: AvailabilityDTO }> {
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
const branchobj = this.store.selectSnapshot(BranchSelectors.getBranchesIterable).find(t => t.branchNumber === userBranchNumber);
|
||||
const branchobj = this.store.selectSnapshot(BranchSelectors.getBranchesIterable).find((t) => t.branchNumber === userBranchNumber);
|
||||
const book = this.item.book;
|
||||
return this.availabilityService.getShippingAvailabilityWithCheck(book, book.product.ean, branchobj.id, quantity).pipe(
|
||||
map((response: any) => {
|
||||
@@ -104,7 +104,7 @@ export class DeliveryCartRowComponent implements OnInit {
|
||||
return { qty: 0, av: null };
|
||||
}
|
||||
if (response && response.av) {
|
||||
const preferedAv = response.av.find(t => t && t.preferred === 1);
|
||||
const preferedAv = response.av.find((t) => t && t.preferred === 1);
|
||||
let preferredQty = 0;
|
||||
if (preferedAv) {
|
||||
if (allowedAvailabilityStatusCodes(preferedAv.status)) {
|
||||
|
||||
@@ -10,11 +10,9 @@ import { ProcessSelectors } from '../../../../core/store/selectors/process.selec
|
||||
import { Observable, Subject, of, forkJoin } from 'rxjs';
|
||||
import { takeUntil, switchMap, filter, map } from 'rxjs/operators';
|
||||
import { CheckoutService } from '../../../../core/services/checkout.service';
|
||||
import { CheckoutDTO } from 'swagger/lib/checkout/models/checkout-dto';
|
||||
import { CheckoutDTO, EntityDTOContainerOfDestinationDTO } from '@swagger/checkout';
|
||||
import { SetPaymentTypeToCheckout, SetDestinationToCheckout, SetNotificationChannel } from '../../../../core/store/actions/cart.actions';
|
||||
import { User } from '../../../../core/models/user.model';
|
||||
import { EntityDTOContainerOfDestinationDTO } from 'swagger/lib/checkout/models/entity-dtocontainer-of-destination-dto';
|
||||
import { NotificationChannels } from 'apps/sales/src/app/core/models/notification-channels.enum';
|
||||
import { CustomerSelectors } from 'apps/sales/src/app/core/store/selectors/customer.selectors';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { SharedSelectors } from 'apps/sales/src/app/core/store/selectors/shared.selectors';
|
||||
@@ -49,7 +47,7 @@ export class PayMethodComponent implements OnInit, OnDestroy {
|
||||
ngOnInit() {
|
||||
this.process$
|
||||
.pipe(
|
||||
filter(x => !!x),
|
||||
filter((x) => !!x),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
.subscribe((process: Process) => {
|
||||
@@ -60,7 +58,7 @@ export class PayMethodComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.customer$
|
||||
.pipe(
|
||||
filter(x => !!x),
|
||||
filter((x) => !!x),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
.subscribe((customer: User) => {
|
||||
@@ -103,7 +101,7 @@ export class PayMethodComponent implements OnInit, OnDestroy {
|
||||
switchMap((checkout: CheckoutDTO) => {
|
||||
return this.setNotificationChannel(checkout, this.customer, this.delivery || this.download);
|
||||
}),
|
||||
switchMap(response => {
|
||||
switchMap((response) => {
|
||||
if (this.delivery || this.download) {
|
||||
const deliveryShippingDestionation = response.checkout.destinations.find(
|
||||
(dest: EntityDTOContainerOfDestinationDTO) => this.delivery && dest.data.target === 2
|
||||
@@ -202,7 +200,7 @@ export class PayMethodComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
}
|
||||
}),
|
||||
switchMap(([apiResponse, data]) => {
|
||||
switchMap(([, data]) => {
|
||||
if (data.finished) {
|
||||
return forkJoin(of({}), of({ checkout: data.checkout, delivery: data.delivery, finished: true }));
|
||||
} else if (!data.finished && data.downloadDestinationNedded && !isNullOrUndefined(data.downloadDestinationDTO)) {
|
||||
@@ -224,7 +222,7 @@ export class PayMethodComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
}
|
||||
}),
|
||||
switchMap(([apiResponse, data]) => {
|
||||
switchMap(([, data]) => {
|
||||
if (data.finished) {
|
||||
return of({});
|
||||
} else {
|
||||
@@ -257,8 +255,9 @@ export class PayMethodComponent implements OnInit, OnDestroy {
|
||||
const notificationChannel = this.customerMap.getNotificationChannels(user);
|
||||
return this.store.dispatch(new SetNotificationChannel(checkout.id, notificationChannel)).pipe(
|
||||
map(() => {
|
||||
return {checkout, customer, delivery};
|
||||
}));
|
||||
return { checkout, customer, delivery };
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
EventEmitter,
|
||||
ChangeDetectorRef,
|
||||
ViewChild,
|
||||
OnDestroy
|
||||
OnDestroy,
|
||||
} from '@angular/core';
|
||||
import { ProductAvailabilityService } from '../../../../core/services/product-availability.service';
|
||||
import { map, tap, take, takeUntil } from 'rxjs/operators';
|
||||
@@ -22,13 +22,13 @@ import { DeleteDropdownComponent } from '@libs/ui';
|
||||
import { allowedAvailabilityStatusCodes } from 'apps/sales/src/app/core/utils/product.util';
|
||||
import { DeliveryOption } from 'apps/sales/src/app/core/models/delivery-option.model';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { AvailabilityDTO } from 'swagger';
|
||||
import { AvailabilityDTO } from '@swagger/cat';
|
||||
|
||||
@Component({
|
||||
selector: 'app-pick-up-cart-row',
|
||||
templateUrl: './pick-up-cart-row.component.html',
|
||||
styleUrls: ['./pick-up-cart-row.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class PickUpCartRowComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('changeOrder') changeOrderDialog: ChangeOrderTypeComponent;
|
||||
@@ -87,9 +87,7 @@ export class PickUpCartRowComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async onQuantityChanged(quantity: number, showError: boolean = false) {
|
||||
const av = await this.validateSelectedQuantity(quantity)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.toPromise();
|
||||
const av = await this.validateSelectedQuantity(quantity).pipe(takeUntil(this.destroy$)).toPromise();
|
||||
|
||||
if (quantity > 999) {
|
||||
this.setQuantityError(quantity, 999);
|
||||
@@ -112,7 +110,7 @@ export class PickUpCartRowComponent implements OnInit, OnDestroy {
|
||||
return { qty: 0, av: null };
|
||||
}
|
||||
if (resp && resp.av) {
|
||||
const preferedAv = resp.av.find(t => t && t.preferred === 1);
|
||||
const preferedAv = resp.av.find((t) => t && t.preferred === 1);
|
||||
let preferredQty = 0;
|
||||
if (preferedAv) {
|
||||
if (allowedAvailabilityStatusCodes(preferedAv.status)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BranchInfoDTO } from './../../../../../../../../libs/swagger/src/lib/isa/models/branch-info-dto';
|
||||
import { BranchInfoDTO } from '@swagger/isa';
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { undefinedToEmptyStringOrValue } from 'apps/sales/src/app/core/utils/app.utils';
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ import { isNullOrUndefined } from 'util';
|
||||
import { AddBreadcrumb } from 'apps/sales/src/app/core/store/actions/breadcrumb.actions';
|
||||
import { cartItem } from 'apps/sales/src/app/shared/animations/cart-item.animation';
|
||||
import { DeleteProductFromCart } from 'apps/sales/src/app/core/store/actions/cart.actions';
|
||||
import { BranchInfoDTO } from 'swagger/lib/isa/models/branch-info-dto';
|
||||
import { BranchInfoDTO } from '@swagger/isa';
|
||||
|
||||
@Component({
|
||||
selector: 'app-pick-up-cart',
|
||||
templateUrl: './pick-up-cart.component.html',
|
||||
styleUrls: ['./pick-up-cart.component.scss'],
|
||||
animations: [cartItem]
|
||||
animations: [cartItem],
|
||||
})
|
||||
export class PickUpCartComponent implements OnInit, OnDestroy {
|
||||
@Select(SharedSelectors.getCart) cartData$: Observable<ProcessCart>;
|
||||
@@ -37,16 +37,16 @@ export class PickUpCartComponent implements OnInit, OnDestroy {
|
||||
ngOnInit() {
|
||||
this.pickUp$ = this.cartData$.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
filter(c => isArrayMinLength(c, 'cart', 0)),
|
||||
map(review => review.cart),
|
||||
filter((c) => isArrayMinLength(c, 'cart', 0)),
|
||||
map((review) => review.cart),
|
||||
map(deliveryFilter(DeliveryOption.PICK_UP)),
|
||||
map(cart => cartToCartReviewArray(cart))
|
||||
map((cart) => cartToCartReviewArray(cart))
|
||||
);
|
||||
|
||||
this.affiliates$ = this.pickUp$.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
filter(c => !isNullOrUndefined(c) && c.length > 0),
|
||||
map(carts => {
|
||||
filter((c) => !isNullOrUndefined(c) && c.length > 0),
|
||||
map((carts) => {
|
||||
const groups = this.groupByBranch(carts);
|
||||
return groups;
|
||||
})
|
||||
@@ -83,7 +83,7 @@ export class PickUpCartComponent implements OnInit, OnDestroy {
|
||||
new AddBreadcrumb(
|
||||
{
|
||||
name: item.product.name ? item.product.name.substring(0, 12) + (item.product.name.length > 12 ? '...' : '') : '',
|
||||
path: '/product/details/' + item.id
|
||||
path: '/product/details/' + item.id,
|
||||
},
|
||||
'product'
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ export interface OrderData {
|
||||
selector: 'app-cart-confirmation',
|
||||
templateUrl: './cart-confirmation.component.html',
|
||||
styleUrls: ['./cart-confirmation.component.scss'],
|
||||
animations: [shrinkTitleAnimation, shrinkSecondaryAnimation, shrinkMainCard]
|
||||
animations: [shrinkTitleAnimation, shrinkSecondaryAnimation, shrinkMainCard],
|
||||
})
|
||||
export class CartConfirmationComponent implements OnInit, OnDestroy {
|
||||
@Select(SharedSelectors.getConfirmedCart) cartData$: Observable<ProcessCartConfirmed>;
|
||||
@@ -73,7 +73,7 @@ export class CartConfirmationComponent implements OnInit, OnDestroy {
|
||||
ngOnInit() {
|
||||
this.customer$
|
||||
.pipe(
|
||||
filter(data => !isNullOrUndefined(data)),
|
||||
filter((data) => !isNullOrUndefined(data)),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
.subscribe((customerData: User) => {
|
||||
@@ -85,7 +85,7 @@ export class CartConfirmationComponent implements OnInit, OnDestroy {
|
||||
this.cartData$
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
filter(data => isArrayOfMinLengthDefined(data, 'cart', 0)),
|
||||
filter((data) => isArrayOfMinLengthDefined(data, 'cart', 0)),
|
||||
distinctUntilChanged((prev, curr) => prev && curr && JSON.stringify(prev) === JSON.stringify(curr))
|
||||
)
|
||||
.subscribe((processCart: ProcessCartConfirmed) => this.processOrder(processCart));
|
||||
@@ -102,7 +102,6 @@ export class CartConfirmationComponent implements OnInit, OnDestroy {
|
||||
|
||||
private processOrder(processCart: ProcessCartConfirmed) {
|
||||
this.orders = [];
|
||||
console.log(processCart);
|
||||
if (processCart) {
|
||||
this.failedItemsIds = processCart.failedItemIds;
|
||||
this.isPickUpOnly = processCart.isPickUpOnly;
|
||||
@@ -125,7 +124,7 @@ export class CartConfirmationComponent implements OnInit, OnDestroy {
|
||||
items: this.booksFromOrder.filter((itemInOrder: OrderItem) => itemInOrder.orderNumber === orderNumber),
|
||||
orderDate: order.orderDate,
|
||||
targetBranchName: order.targetBranchName,
|
||||
targetBranchAddress: order.targetBranchAddress
|
||||
targetBranchAddress: order.targetBranchAddress,
|
||||
});
|
||||
|
||||
if (order.orderType === DeliveryType['ShippingAddress']) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import { cartPaymentType } from 'apps/sales/src/app/shared/animations/cart-payme
|
||||
import { ErrorService } from 'apps/sales/src/app/core/error/component/error.service';
|
||||
import { CustomerFeatures } from 'apps/sales/src/app/core/models/customer-features.model';
|
||||
import { CartService } from '../services/cart.service';
|
||||
import { BranchInfoDTO } from 'swagger/lib/isa/models/branch-info-dto';
|
||||
import { BranchInfoDTO } from '@swagger/isa';
|
||||
import { AppState } from 'apps/sales/src/app/core/store/state/app.state';
|
||||
|
||||
export interface CartReviewItem extends BookData {
|
||||
@@ -33,10 +33,10 @@ export interface CartReviewItem extends BookData {
|
||||
cartId: number;
|
||||
}
|
||||
|
||||
export const deliveryFilter = (deliveryOption: string) => (items: Cart[]) => items.filter(b => b.deliveryType === deliveryOption);
|
||||
export const deliveryFilter = (deliveryOption: string) => (items: Cart[]) => items.filter((b) => b.deliveryType === deliveryOption);
|
||||
export const cartToCartReviewArray = (cart: Cart[]) => {
|
||||
return cart
|
||||
.filter(d => !!d)
|
||||
.filter((d) => !!d)
|
||||
.map((bookInCart: Cart) => {
|
||||
if (bookInCart) {
|
||||
const currency = bookInCart.book.catalogAvailability.price.value.currency;
|
||||
@@ -59,7 +59,7 @@ export const cartToCartReviewArray = (cart: Cart[]) => {
|
||||
deliveryPrice: bookInCart.deliveryPrice,
|
||||
deliveryDate: bookInCart.deliveryDate,
|
||||
downloadPrice: bookInCart.downloadPrice,
|
||||
pickUpDate: bookInCart.pickUpDate
|
||||
pickUpDate: bookInCart.pickUpDate,
|
||||
} as CartReviewItem;
|
||||
}
|
||||
});
|
||||
@@ -69,7 +69,7 @@ export const cartToCartReviewArray = (cart: Cart[]) => {
|
||||
selector: 'app-cart-new',
|
||||
templateUrl: './cart-review.component.html',
|
||||
styleUrls: ['./cart-review.component.scss'],
|
||||
animations: [removeItemCartAnimation, cartPaymentType]
|
||||
animations: [removeItemCartAnimation, cartPaymentType],
|
||||
})
|
||||
export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
@Select(SharedSelectors.getCart) cartData$: Observable<ProcessCart>;
|
||||
@@ -99,7 +99,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
delivery: false,
|
||||
pickUp: false,
|
||||
takeNow: false,
|
||||
download: false
|
||||
download: false,
|
||||
};
|
||||
|
||||
destroy$ = new Subject();
|
||||
@@ -108,7 +108,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
|
||||
total = {
|
||||
price: 0,
|
||||
items: 0
|
||||
items: 0,
|
||||
};
|
||||
|
||||
customer: User;
|
||||
@@ -124,8 +124,8 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
) {
|
||||
this.deliveryCount$ = this.cartData$.pipe(
|
||||
startWith(-1),
|
||||
filter(c => isArrayMinLength(c, 'cart', 0) || c === -1),
|
||||
map(c => {
|
||||
filter((c) => isArrayMinLength(c, 'cart', 0) || c === -1),
|
||||
map((c) => {
|
||||
if (c === -1) {
|
||||
return c;
|
||||
} else {
|
||||
@@ -133,7 +133,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
return data.cart;
|
||||
}
|
||||
}),
|
||||
map(c => {
|
||||
map((c) => {
|
||||
if (c === -1) {
|
||||
return c;
|
||||
} else {
|
||||
@@ -141,7 +141,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
return deliveryFilter(DeliveryOption.DELIVERY)(data);
|
||||
}
|
||||
}),
|
||||
map(i => {
|
||||
map((i) => {
|
||||
if (i === -1) {
|
||||
return i;
|
||||
} else {
|
||||
@@ -150,7 +150,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}),
|
||||
pairwise(),
|
||||
map(value => {
|
||||
map((value) => {
|
||||
if (value[0] !== -1) {
|
||||
this.lastDeliveryLength = value[0];
|
||||
} else {
|
||||
@@ -162,8 +162,8 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
this.takeNowCount$ = this.cartData$.pipe(
|
||||
startWith(-1),
|
||||
filter(c => isArrayMinLength(c, 'cart', 0) || c === -1),
|
||||
map(c => {
|
||||
filter((c) => isArrayMinLength(c, 'cart', 0) || c === -1),
|
||||
map((c) => {
|
||||
if (c === -1) {
|
||||
return c;
|
||||
} else {
|
||||
@@ -171,7 +171,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
return data.cart;
|
||||
}
|
||||
}),
|
||||
map(c => {
|
||||
map((c) => {
|
||||
if (c === -1) {
|
||||
return c;
|
||||
} else {
|
||||
@@ -179,7 +179,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
return deliveryFilter(DeliveryOption.TAKE_NOW)(data);
|
||||
}
|
||||
}),
|
||||
map(i => {
|
||||
map((i) => {
|
||||
if (i === -1) {
|
||||
return i;
|
||||
} else {
|
||||
@@ -188,7 +188,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}),
|
||||
pairwise(),
|
||||
map(value => {
|
||||
map((value) => {
|
||||
if (value[0] !== -1) {
|
||||
this.lastTakeNowLength = value[0];
|
||||
} else {
|
||||
@@ -199,26 +199,26 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
})
|
||||
);
|
||||
this.pickUpCount$ = this.cartData$.pipe(
|
||||
filter(c => isArrayMinLength(c, 'cart', 0)),
|
||||
map(c => c.cart),
|
||||
filter((c) => isArrayMinLength(c, 'cart', 0)),
|
||||
map((c) => c.cart),
|
||||
map(deliveryFilter(DeliveryOption.PICK_UP)),
|
||||
map(i => i.length)
|
||||
map((i) => i.length)
|
||||
);
|
||||
this.downloadCount$ = this.cartData$.pipe(
|
||||
filter(c => isArrayMinLength(c, 'cart', 0)),
|
||||
map(c => c.cart),
|
||||
filter((c) => isArrayMinLength(c, 'cart', 0)),
|
||||
map((c) => c.cart),
|
||||
map(deliveryFilter(DeliveryOption.DOWNLOAD)),
|
||||
map(i => i.length)
|
||||
map((i) => i.length)
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.cartData$
|
||||
.pipe(
|
||||
filter(x => !!x),
|
||||
filter((x) => !!x),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
.subscribe(data => {
|
||||
.subscribe((data) => {
|
||||
if (data.cart.length > 0) {
|
||||
this.loaded = true;
|
||||
this.customer = data.customer;
|
||||
@@ -237,7 +237,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
this.errorService
|
||||
.recovery$()
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(status => {
|
||||
.subscribe((status) => {
|
||||
if (this.continueBtn) {
|
||||
this.continueBtn.stopLoading();
|
||||
}
|
||||
@@ -298,17 +298,17 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private checkDeliveryOptions(books) {
|
||||
this.paymentOption.delivery = books.some(book => book.deliveryType === DeliveryOption.DELIVERY);
|
||||
this.paymentOption.pickUp = books.some(book => book.deliveryType === DeliveryOption.PICK_UP);
|
||||
this.paymentOption.takeNow = books.some(book => book.deliveryType === DeliveryOption.TAKE_NOW);
|
||||
this.paymentOption.download = books.some(book => book.deliveryType === DeliveryOption.DOWNLOAD);
|
||||
this.paymentOption.delivery = books.some((book) => book.deliveryType === DeliveryOption.DELIVERY);
|
||||
this.paymentOption.pickUp = books.some((book) => book.deliveryType === DeliveryOption.PICK_UP);
|
||||
this.paymentOption.takeNow = books.some((book) => book.deliveryType === DeliveryOption.TAKE_NOW);
|
||||
this.paymentOption.download = books.some((book) => book.deliveryType === DeliveryOption.DOWNLOAD);
|
||||
}
|
||||
|
||||
recalculate(cart: Cart[]) {
|
||||
let totalSum = 0;
|
||||
let totalQuantity = 0;
|
||||
|
||||
cart.forEach(book => {
|
||||
cart.forEach((book) => {
|
||||
let price = book.book.catalogAvailability.price.value.value;
|
||||
if (book.deliveryType === DeliveryOption.PICK_UP && book.pickUpPrice) {
|
||||
price = book.pickUpPrice;
|
||||
@@ -340,7 +340,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
let newBread: Breadcrumb;
|
||||
newBread = {
|
||||
name: 'Kundensuche',
|
||||
path: 'customer/search'
|
||||
path: 'customer/search',
|
||||
};
|
||||
this.navigate(newBread, 'customer');
|
||||
}
|
||||
@@ -351,7 +351,7 @@ export class CartReviewComponent implements OnInit, OnDestroy {
|
||||
new AddBreadcrumb(
|
||||
<Breadcrumb>{
|
||||
name: 'Artikelsuche',
|
||||
path: '/product/search'
|
||||
path: '/product/search',
|
||||
},
|
||||
'product',
|
||||
true
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
OnDestroy,
|
||||
HostListener,
|
||||
Renderer,
|
||||
ChangeDetectorRef,
|
||||
ViewChild,
|
||||
AfterViewInit,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
FormGroup,
|
||||
FormBuilder,
|
||||
Validators,
|
||||
AbstractControl,
|
||||
} from '@angular/forms';
|
||||
import { Component, OnInit, OnDestroy, HostListener, Renderer, ChangeDetectorRef, ViewChild, AfterViewInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators, AbstractControl } from '@angular/forms';
|
||||
import { Store, Select } from '@ngxs/store';
|
||||
import {
|
||||
ChangeCurrentRoute,
|
||||
@@ -22,36 +8,14 @@ import {
|
||||
SetOnlineCustomerCreationStatus,
|
||||
ClearPartOfCustomerCreationStatus,
|
||||
} from '../../../../core/store/actions/process.actions';
|
||||
import {
|
||||
User,
|
||||
Address,
|
||||
Features,
|
||||
Organisation,
|
||||
} from '../../../../core/models/user.model';
|
||||
import { User, Address, Features, Organisation } from '../../../../core/models/user.model';
|
||||
import { Router } from '@angular/router';
|
||||
import {
|
||||
Process,
|
||||
CustomerFormState,
|
||||
} from '../../../../core/models/process.model';
|
||||
import { Process, CustomerFormState } from '../../../../core/models/process.model';
|
||||
import { Breadcrumb } from '../../../../core/models/breadcrumb.model';
|
||||
import { Observable, Subject, of } from 'rxjs';
|
||||
import { AddBreadcrumb } from '../../../../core/store/actions/breadcrumb.actions';
|
||||
import {
|
||||
AddUser,
|
||||
SetUserDetails,
|
||||
} from '../../../../core/store/actions/customer.actions';
|
||||
import {
|
||||
takeUntil,
|
||||
distinctUntilChanged,
|
||||
switchMap,
|
||||
map,
|
||||
filter,
|
||||
tap,
|
||||
share,
|
||||
debounceTime,
|
||||
take,
|
||||
catchError,
|
||||
} from 'rxjs/operators';
|
||||
import { AddUser, SetUserDetails } from '../../../../core/store/actions/customer.actions';
|
||||
import { takeUntil, distinctUntilChanged, switchMap, map, filter, tap, share, debounceTime, take, catchError } from 'rxjs/operators';
|
||||
import { CustomValidators } from '../../../../shared/validation/custom-validation';
|
||||
import { GENDERS, TIITLES } from '../../dropdown-values';
|
||||
import { ProcessSelectors } from '../../../../core/store/selectors/process.selectors';
|
||||
@@ -59,30 +23,19 @@ import { SharedSelectors } from '../../../../core/store/selectors/shared.selecto
|
||||
import { EditCustomerData } from '../../../../core/models/edit-customer.model';
|
||||
import { CountrySelector } from '../../../../core/store/selectors/countries.selector';
|
||||
import { Country } from '../../../../core/models/country.model';
|
||||
import {
|
||||
isoDateFromString,
|
||||
scrollToFirstInvalidElement,
|
||||
isEmptyString,
|
||||
} from '../../../../core/utils/app.utils';
|
||||
import { isoDateFromString, scrollToFirstInvalidElement, isEmptyString } from '../../../../core/utils/app.utils';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { DeliveryOption } from 'apps/sales/src/app/core/models/delivery-option.model';
|
||||
import { CustomerService } from 'apps/sales/src/app/core/services/customer.service';
|
||||
import { AddressDTO } from 'swagger/lib/crm/models/address-dto';
|
||||
import { AddressDTO } from '@swagger/crm';
|
||||
import { ButtonComponent, SelectComponent } from '@libs/ui';
|
||||
import { AppService } from 'apps/sales/src/app/core/services/app.service';
|
||||
import { AddressSugestionsComponent } from '../address-sugestions/address-sugestions.component';
|
||||
import { ViewRef_ } from '@angular/core/src/view';
|
||||
import { ErrorService } from 'apps/sales/src/app/core/error/component/error.service';
|
||||
import { FormsSelectors } from 'apps/sales/src/app/core/store/selectors/forms.selectors';
|
||||
import {
|
||||
SaveFormState,
|
||||
DeleteFormState,
|
||||
} from 'apps/sales/src/app/core/store/actions/forms.actions';
|
||||
import {
|
||||
USER_FORM_STATE_KEY,
|
||||
USER_EXTRAS_FORM_STATE_KEY,
|
||||
USER_ERRORS_FORM_STATE_KEY,
|
||||
} from 'apps/sales/src/app/core/utils/app.constants';
|
||||
import { SaveFormState, DeleteFormState } from 'apps/sales/src/app/core/store/actions/forms.actions';
|
||||
import { USER_FORM_STATE_KEY, USER_EXTRAS_FORM_STATE_KEY, USER_ERRORS_FORM_STATE_KEY } from 'apps/sales/src/app/core/utils/app.constants';
|
||||
import { AppSelectors } from 'apps/sales/src/app/core/store/selectors/app.selectors';
|
||||
|
||||
@Component({
|
||||
@@ -92,18 +45,10 @@ import { AppSelectors } from 'apps/sales/src/app/core/store/selectors/app.select
|
||||
})
|
||||
export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
@Select(ProcessSelectors.getProcesses) processes$: Observable<Process[]>;
|
||||
@Select(ProcessSelectors.getCurrentProcess) currentProcess$: Observable<
|
||||
Process
|
||||
>;
|
||||
@Select(SharedSelectors.getCustomerEditData) customerEditData$: Observable<
|
||||
EditCustomerData
|
||||
>;
|
||||
@Select(CountrySelector.getCountriesIterable) countries$: Observable<
|
||||
Country[]
|
||||
>;
|
||||
@Select(CountrySelector.getDeutchlandIterable) deutchland$: Observable<
|
||||
Country[]
|
||||
>;
|
||||
@Select(ProcessSelectors.getCurrentProcess) currentProcess$: Observable<Process>;
|
||||
@Select(SharedSelectors.getCustomerEditData) customerEditData$: Observable<EditCustomerData>;
|
||||
@Select(CountrySelector.getCountriesIterable) countries$: Observable<Country[]>;
|
||||
@Select(CountrySelector.getDeutchlandIterable) deutchland$: Observable<Country[]>;
|
||||
@ViewChild('postBtn') postBtn: ButtonComponent;
|
||||
@ViewChild('landDD') landDD: SelectComponent;
|
||||
@ViewChild('suggestions') suggestions: AddressSugestionsComponent;
|
||||
@@ -113,8 +58,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
submitted = false;
|
||||
processes: Process[] = [];
|
||||
id: number;
|
||||
headerText =
|
||||
'Wenn Sie möchten legen wir Ihnen gerne ein Onlinekonto an. Dort können Sie Ihre Bestellungen einsehen.';
|
||||
headerText = 'Wenn Sie möchten legen wir Ihnen gerne ein Onlinekonto an. Dort können Sie Ihre Bestellungen einsehen.';
|
||||
|
||||
countryList: Country[];
|
||||
|
||||
@@ -251,11 +195,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
'Um Ihnen das ebook bereitstellen zu können, brauchen Sie ein Onlinekonto bei Hugendubel. Wir richten es Ihnen gerne sofort ein.';
|
||||
});
|
||||
|
||||
(
|
||||
this.cartHasItemsForDelivery &&
|
||||
!this.cartHasItemsForDownload &&
|
||||
!this.onlineChecked
|
||||
).ifTrue(this.guestCheckboxInitialization);
|
||||
(this.cartHasItemsForDelivery && !this.cartHasItemsForDownload && !this.onlineChecked).ifTrue(this.guestCheckboxInitialization);
|
||||
};
|
||||
|
||||
guestCheckboxInitialization = () => {
|
||||
@@ -269,15 +209,10 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
if (process) {
|
||||
this.backendValidation = false;
|
||||
clearTimeout(this.errorTimer);
|
||||
if (
|
||||
process.onlineCustomerCreationError &&
|
||||
process.onlineCustomerCreationError.error === true
|
||||
) {
|
||||
if (process.onlineCustomerCreationError && process.onlineCustomerCreationError.error === true) {
|
||||
this.buildCreateForm(this.fb);
|
||||
this.errorTimer = setTimeout(() => {
|
||||
this.onlineCustomerCreationErrorHandler(
|
||||
process.onlineCustomerCreationError.invalidProperties
|
||||
);
|
||||
this.onlineCustomerCreationErrorHandler(process.onlineCustomerCreationError.invalidProperties);
|
||||
}, 1000);
|
||||
this.loaded = true;
|
||||
return;
|
||||
@@ -285,21 +220,13 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
this.formState = process.customerFormState;
|
||||
this.canBeSetToActiveUser = !process.closeDirectlyTab;
|
||||
if (process.customerFormState === CustomerFormState.MISSING_DELIVERY) {
|
||||
this.userForm = this.buildSetDeliveryAddressForm(
|
||||
this.fb,
|
||||
this.customer.customer
|
||||
);
|
||||
this.userForm = this.buildSetDeliveryAddressForm(this.fb, this.customer.customer);
|
||||
this.id = this.customer.customer.id;
|
||||
this.submitted = true;
|
||||
this.btnText = 'Weiter';
|
||||
this.create = false;
|
||||
} else if (
|
||||
process.customerFormState === CustomerFormState.MISSING_ONLINE
|
||||
) {
|
||||
this.userForm = this.buildSetDeliveryAddressForm(
|
||||
this.fb,
|
||||
this.customer.customer
|
||||
);
|
||||
} else if (process.customerFormState === CustomerFormState.MISSING_ONLINE) {
|
||||
this.userForm = this.buildSetDeliveryAddressForm(this.fb, this.customer.customer);
|
||||
this.id = this.customer.customer.id;
|
||||
this.submitted = true;
|
||||
this.btnText = 'Weiter';
|
||||
@@ -320,59 +247,44 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
|
||||
private listenFormChanges() {
|
||||
this.destroyForm$.next();
|
||||
this.userForm.valueChanges
|
||||
.pipe(takeUntil(this.destroyForm$))
|
||||
.subscribe((v) => {
|
||||
const formStateString = JSON.stringify(v);
|
||||
const errors = {};
|
||||
Object.keys(v).forEach((field) => {
|
||||
errors[field] = this.userForm.get(field).errors;
|
||||
});
|
||||
this.store.dispatch(
|
||||
new SaveFormState(USER_FORM_STATE_KEY, formStateString)
|
||||
);
|
||||
this.store.dispatch(
|
||||
new SaveFormState(USER_ERRORS_FORM_STATE_KEY, JSON.stringify(errors))
|
||||
);
|
||||
this.userForm.valueChanges.pipe(takeUntil(this.destroyForm$)).subscribe((v) => {
|
||||
const formStateString = JSON.stringify(v);
|
||||
const errors = {};
|
||||
Object.keys(v).forEach((field) => {
|
||||
errors[field] = this.userForm.get(field).errors;
|
||||
});
|
||||
this.store.dispatch(new SaveFormState(USER_FORM_STATE_KEY, formStateString));
|
||||
this.store.dispatch(new SaveFormState(USER_ERRORS_FORM_STATE_KEY, JSON.stringify(errors)));
|
||||
});
|
||||
}
|
||||
|
||||
onlineCustomerCreationErrorHandler(invalidProperties: any) {
|
||||
if (
|
||||
isNullOrUndefined(invalidProperties) ||
|
||||
isNullOrUndefined(this.userForm)
|
||||
) {
|
||||
if (isNullOrUndefined(invalidProperties) || isNullOrUndefined(this.userForm)) {
|
||||
return;
|
||||
}
|
||||
if (invalidProperties.Email) {
|
||||
this.userForm
|
||||
.get('email')
|
||||
.setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalidProperties.Email,
|
||||
});
|
||||
this.userForm.get('email').setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalidProperties.Email,
|
||||
});
|
||||
this.backendValidation = true;
|
||||
} else {
|
||||
this.userForm.get('email').setErrors(undefined);
|
||||
}
|
||||
if (invalidProperties.FirstName) {
|
||||
this.userForm
|
||||
.get('firstName')
|
||||
.setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalidProperties.FirstName,
|
||||
});
|
||||
this.userForm.get('firstName').setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalidProperties.FirstName,
|
||||
});
|
||||
this.backendValidation = true;
|
||||
} else {
|
||||
this.userForm.get('firstName').setErrors(undefined);
|
||||
}
|
||||
if (invalidProperties.LastName) {
|
||||
this.userForm
|
||||
.get('lastName')
|
||||
.setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalidProperties.LastName,
|
||||
});
|
||||
this.userForm.get('lastName').setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalidProperties.LastName,
|
||||
});
|
||||
this.backendValidation = true;
|
||||
} else {
|
||||
this.userForm.get('lastName').setErrors(undefined);
|
||||
@@ -384,15 +296,8 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
if (key !== 'Email' && key !== 'FirstName' && key !== 'LastName') {
|
||||
showErrorPopUp = true;
|
||||
}
|
||||
if (
|
||||
keysChecked === Object.keys(invalidProperties).length &&
|
||||
showErrorPopUp
|
||||
) {
|
||||
this.errorService.addErrors(
|
||||
400,
|
||||
null,
|
||||
JSON.stringify(invalidProperties)
|
||||
);
|
||||
if (keysChecked === Object.keys(invalidProperties).length && showErrorPopUp) {
|
||||
this.errorService.addErrors(400, null, JSON.stringify(invalidProperties));
|
||||
}
|
||||
});
|
||||
scrollToFirstInvalidElement();
|
||||
@@ -401,12 +306,9 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
setValidations() {
|
||||
this.deliveryAndGuestOrOnline =
|
||||
this.cartHasItemsForDelivery && (this.guestChecked || this.onlineChecked);
|
||||
this.deliveryAndGuestOrOnline = this.cartHasItemsForDelivery && (this.guestChecked || this.onlineChecked);
|
||||
this.pickUpOrTakeNowAndOnline =
|
||||
(this.cartHasItemsForPickUp || this.cartHasItemsForTakeNow) &&
|
||||
this.onlineChecked &&
|
||||
!this.deliveryAndGuestOrOnline;
|
||||
(this.cartHasItemsForPickUp || this.cartHasItemsForTakeNow) && this.onlineChecked && !this.deliveryAndGuestOrOnline;
|
||||
this.downloadAndOnline = this.cartHasItemsForDownload && this.onlineChecked;
|
||||
(
|
||||
this.deliveryAndGuestOrOnline ||
|
||||
@@ -414,20 +316,14 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
this.downloadAndOnline ||
|
||||
this.onlineChecked ||
|
||||
this.guestChecked
|
||||
).ifTrue(
|
||||
this.deliveryAndGuestValidationsOrpickUpOrTakeNowAndOnlineValidations
|
||||
);
|
||||
).ifTrue(this.deliveryAndGuestValidationsOrpickUpOrTakeNowAndOnlineValidations);
|
||||
this.onlineChecked.ifTrue(this.onlineExtraValidations);
|
||||
}
|
||||
|
||||
deliveryAndGuestValidationsOrpickUpOrTakeNowAndOnlineValidations = () => {
|
||||
this.userForm
|
||||
.get('gender')
|
||||
.setValidators([Validators.required, CustomValidators.validateGender]);
|
||||
this.userForm.get('gender').setValidators([Validators.required, CustomValidators.validateGender]);
|
||||
this.userForm.get('gender').updateValueAndValidity();
|
||||
this.userForm
|
||||
.get('email')
|
||||
.setValidators([Validators.required, CustomValidators.validateEmail]);
|
||||
this.userForm.get('email').setValidators([Validators.required, CustomValidators.validateEmail]);
|
||||
this.userForm.get('email').updateValueAndValidity();
|
||||
this.userForm.get('address').setValidators([Validators.required]);
|
||||
this.userForm.get('address').updateValueAndValidity();
|
||||
@@ -478,9 +374,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
};
|
||||
|
||||
onlineExtraValidations = () => {
|
||||
this.userForm
|
||||
.get('email')
|
||||
.setAsyncValidators(this.validateIfEmailExists.bind(this));
|
||||
this.userForm.get('email').setAsyncValidators(this.validateIfEmailExists.bind(this));
|
||||
this.userForm.get('email').updateValueAndValidity();
|
||||
};
|
||||
|
||||
@@ -500,11 +394,8 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
this.userForm.get('city').updateValueAndValidity();
|
||||
this.userForm.get('country').clearValidators();
|
||||
this.userForm.get('country').updateValueAndValidity();
|
||||
this.deliveryAndGuestOrOnline =
|
||||
this.cartHasItemsForDelivery && (this.guestChecked || this.onlineChecked);
|
||||
this.pickUpOrTakeNowAndOnline =
|
||||
(this.cartHasItemsForPickUp || this.cartHasItemsForTakeNow) &&
|
||||
this.onlineChecked;
|
||||
this.deliveryAndGuestOrOnline = this.cartHasItemsForDelivery && (this.guestChecked || this.onlineChecked);
|
||||
this.pickUpOrTakeNowAndOnline = (this.cartHasItemsForPickUp || this.cartHasItemsForTakeNow) && this.onlineChecked;
|
||||
};
|
||||
|
||||
validateIfEmailExists(control: AbstractControl) {
|
||||
@@ -540,12 +431,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
errors[field] = this.userForm.get(field).errors;
|
||||
}
|
||||
});
|
||||
this.store.dispatch(
|
||||
new SaveFormState(
|
||||
USER_ERRORS_FORM_STATE_KEY,
|
||||
JSON.stringify(errors)
|
||||
)
|
||||
);
|
||||
this.store.dispatch(new SaveFormState(USER_ERRORS_FORM_STATE_KEY, JSON.stringify(errors)));
|
||||
result$.next(result);
|
||||
});
|
||||
}, 2000);
|
||||
@@ -625,21 +511,11 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
const addressesLength = address.length;
|
||||
address.forEach((add) => {
|
||||
processedItems++;
|
||||
const street = add.street
|
||||
? add.street
|
||||
: (this.userForm.get('address').value as string);
|
||||
const streetNo = add.streetNumber
|
||||
? add.streetNumber
|
||||
: (this.userForm.get('streetNo').value as string);
|
||||
const zipCode = add.zipCode
|
||||
? add.zipCode
|
||||
: (this.userForm.get('zipCode').value as string);
|
||||
const city = add.city
|
||||
? add.city
|
||||
: (this.userForm.get('city').value as string);
|
||||
const countryValue = add.country
|
||||
? add.country
|
||||
: (this.userForm.get('country').value as string);
|
||||
const street = add.street ? add.street : (this.userForm.get('address').value as string);
|
||||
const streetNo = add.streetNumber ? add.streetNumber : (this.userForm.get('streetNo').value as string);
|
||||
const zipCode = add.zipCode ? add.zipCode : (this.userForm.get('zipCode').value as string);
|
||||
const city = add.city ? add.city : (this.userForm.get('city').value as string);
|
||||
const countryValue = add.country ? add.country : (this.userForm.get('country').value as string);
|
||||
|
||||
if (city && street && streetNo && zipCode && countryValue) {
|
||||
this.addressSuggestions.push({
|
||||
@@ -653,10 +529,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
zip: zipCode,
|
||||
});
|
||||
}
|
||||
if (
|
||||
processedItems === addressesLength &&
|
||||
this.addressSuggestions.length === addressesLength
|
||||
) {
|
||||
if (processedItems === addressesLength && this.addressSuggestions.length === addressesLength) {
|
||||
this.openSuggestions();
|
||||
}
|
||||
});
|
||||
@@ -689,48 +562,38 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
|
||||
invalidAddressMapping(invalid: any) {
|
||||
if (invalid.City) {
|
||||
this.userForm
|
||||
.get('city')
|
||||
.setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalid.City,
|
||||
});
|
||||
this.userForm.get('city').setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalid.City,
|
||||
});
|
||||
this.submitted = true;
|
||||
}
|
||||
if (invalid.Street) {
|
||||
this.userForm
|
||||
.get('address')
|
||||
.setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalid.Street,
|
||||
});
|
||||
this.userForm.get('address').setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalid.Street,
|
||||
});
|
||||
this.submitted = true;
|
||||
}
|
||||
if (invalid.streetNumber) {
|
||||
this.userForm
|
||||
.get('streetNo')
|
||||
.setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalid.streetNumber,
|
||||
});
|
||||
this.userForm.get('streetNo').setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalid.streetNumber,
|
||||
});
|
||||
this.submitted = true;
|
||||
}
|
||||
if (invalid.ZipCode) {
|
||||
this.userForm
|
||||
.get('zipCode')
|
||||
.setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalid.ZipCode,
|
||||
});
|
||||
this.userForm.get('zipCode').setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalid.ZipCode,
|
||||
});
|
||||
this.submitted = true;
|
||||
}
|
||||
if (invalid.Country) {
|
||||
this.userForm
|
||||
.get('country')
|
||||
.setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalid.Country,
|
||||
});
|
||||
this.userForm.get('country').setErrors({
|
||||
backendValidation: true,
|
||||
backendValidationMsg: invalid.Country,
|
||||
});
|
||||
this.submitted = true;
|
||||
}
|
||||
if (invalid.General) {
|
||||
@@ -793,9 +656,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
.toPromise()
|
||||
.then(() => {
|
||||
const currentRoute = 'cart/review';
|
||||
this.store.dispatch(
|
||||
new UpdateCustomerFormState(CustomerFormState.CREATE)
|
||||
);
|
||||
this.store.dispatch(new UpdateCustomerFormState(CustomerFormState.CREATE));
|
||||
this.store.dispatch(new ChangeCurrentRoute(currentRoute));
|
||||
this.postBtn.stopLoading();
|
||||
this.router.navigate([currentRoute]);
|
||||
@@ -803,11 +664,9 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
loadProcesses() {
|
||||
this.processes$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((data: Process[]) => {
|
||||
this.processes = data;
|
||||
});
|
||||
this.processes$.pipe(takeUntil(this.destroy$)).subscribe((data: Process[]) => {
|
||||
this.processes = data;
|
||||
});
|
||||
}
|
||||
|
||||
createProcess() {
|
||||
@@ -850,9 +709,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
setAddressValidators = () => {
|
||||
this.userForm.valueChanges
|
||||
.pipe(distinctUntilChanged(), take(1))
|
||||
.subscribe(this.addressValidatorForSimpleCustomer);
|
||||
this.userForm.valueChanges.pipe(distinctUntilChanged(), take(1)).subscribe(this.addressValidatorForSimpleCustomer);
|
||||
};
|
||||
|
||||
get f() {
|
||||
@@ -921,12 +778,10 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
genderSelect(gender: string) {
|
||||
console.log('gender', gender);
|
||||
this.updateDataForSelectedOption('gender', gender, 'Andrede');
|
||||
}
|
||||
|
||||
titelSelect(title: string) {
|
||||
console.log('title', title);
|
||||
this.updateDataForSelectedOption('title', title, 'Titel');
|
||||
}
|
||||
|
||||
@@ -940,29 +795,15 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
null,
|
||||
this.userForm.get('firstName').value,
|
||||
this.userForm.get('lastName').value,
|
||||
this.userForm.get('address').value
|
||||
? this.userForm.get('address').value
|
||||
: '',
|
||||
this.userForm.get('streetNo').value
|
||||
? this.userForm.get('streetNo').value
|
||||
: '',
|
||||
+this.userForm.get('zipCode').value
|
||||
? this.userForm.get('zipCode').value
|
||||
: '',
|
||||
this.userForm.get('address').value ? this.userForm.get('address').value : '',
|
||||
this.userForm.get('streetNo').value ? this.userForm.get('streetNo').value : '',
|
||||
+this.userForm.get('zipCode').value ? this.userForm.get('zipCode').value : '',
|
||||
this.userForm.get('city').value ? this.userForm.get('city').value : '',
|
||||
this.userForm.get('country').value
|
||||
? this.getCountryCode(this.userForm.get('country').value)
|
||||
: '',
|
||||
this.userForm.get('company').value
|
||||
? this.userForm.get('company').value
|
||||
: '',
|
||||
this.userForm.get('department').value
|
||||
? this.userForm.get('department').value
|
||||
: '',
|
||||
this.userForm.get('country').value ? this.getCountryCode(this.userForm.get('country').value) : '',
|
||||
this.userForm.get('company').value ? this.userForm.get('company').value : '',
|
||||
this.userForm.get('department').value ? this.userForm.get('department').value : '',
|
||||
this.userForm.get('note').value ? this.userForm.get('note').value : '',
|
||||
this.userForm.get('tax_number').value
|
||||
? this.userForm.get('tax_number').value
|
||||
: '',
|
||||
this.userForm.get('tax_number').value ? this.userForm.get('tax_number').value : '',
|
||||
this.userForm.get('title').value ? this.userForm.get('title').value : '',
|
||||
this.userForm.get('gender').value ? this.userForm.get('gender').value : ''
|
||||
);
|
||||
@@ -993,18 +834,10 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
let organisation: Organisation;
|
||||
if (this.showCompanyFields) {
|
||||
organisation = {
|
||||
name: this.userForm.get('company').value
|
||||
? this.userForm.get('company').value
|
||||
: undefined,
|
||||
department: this.userForm.get('department').value
|
||||
? this.userForm.get('department').value
|
||||
: undefined,
|
||||
extraAddress: this.userForm.get('note').value
|
||||
? this.userForm.get('note').value
|
||||
: undefined,
|
||||
vatId: this.userForm.get('tax_number').value
|
||||
? this.userForm.get('tax_number').value
|
||||
: undefined,
|
||||
name: this.userForm.get('company').value ? this.userForm.get('company').value : undefined,
|
||||
department: this.userForm.get('department').value ? this.userForm.get('department').value : undefined,
|
||||
extraAddress: this.userForm.get('note').value ? this.userForm.get('note').value : undefined,
|
||||
vatId: this.userForm.get('tax_number').value ? this.userForm.get('tax_number').value : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1012,26 +845,16 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
id: this.id,
|
||||
first_name: this.userForm.get('firstName').value,
|
||||
last_name: this.userForm.get('lastName').value,
|
||||
title: this.userForm.get('title').value
|
||||
? this.userForm.get('title').value
|
||||
: '',
|
||||
gender: this.userForm.get('gender').value
|
||||
? this.userForm.get('gender').value
|
||||
: '',
|
||||
mobile_number: this.userForm.get('mobile').value
|
||||
? this.userForm.get('mobile').value.replace(' ', '')
|
||||
: '',
|
||||
phone_number: this.userForm.get('telephone').value
|
||||
? this.userForm.get('telephone').value.replace(' ', '')
|
||||
: '',
|
||||
title: this.userForm.get('title').value ? this.userForm.get('title').value : '',
|
||||
gender: this.userForm.get('gender').value ? this.userForm.get('gender').value : '',
|
||||
mobile_number: this.userForm.get('mobile').value ? this.userForm.get('mobile').value.replace(' ', '') : '',
|
||||
phone_number: this.userForm.get('telephone').value ? this.userForm.get('telephone').value.replace(' ', '') : '',
|
||||
date_of_birth: isoDateFromString(this.userForm.get('dateOfBirth').value),
|
||||
delivery_addres: address,
|
||||
poossible_invoice_addresses: [address],
|
||||
invoice_address: address,
|
||||
poossible_delivery_addresses: [address],
|
||||
email: this.userForm.get('email').value
|
||||
? this.userForm.get('email').value.trim()
|
||||
: '',
|
||||
email: this.userForm.get('email').value ? this.userForm.get('email').value.trim() : '',
|
||||
shop: Math.floor(Math.random() * 6) + 1 > 3 ? true : false,
|
||||
newUser: true,
|
||||
features: features,
|
||||
@@ -1041,11 +864,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
return data;
|
||||
}
|
||||
|
||||
private updateDataForSelectedOption(
|
||||
field: string,
|
||||
value: string,
|
||||
defaultValue: string
|
||||
) {
|
||||
private updateDataForSelectedOption(field: string, value: string, defaultValue: string) {
|
||||
if (value !== defaultValue) {
|
||||
this.userForm.get(field).patchValue(value);
|
||||
} else {
|
||||
@@ -1055,9 +874,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
|
||||
private buildSetDeliveryAddressForm(fb: FormBuilder, customer: User) {
|
||||
let country = this.getProperty(customer, 'delivery_addres.country');
|
||||
const countriesList = this.store.selectSnapshot(
|
||||
CountrySelector.getCountriesIterable
|
||||
);
|
||||
const countriesList = this.store.selectSnapshot(CountrySelector.getCountriesIterable);
|
||||
if (countriesList) {
|
||||
const countryObj = countriesList.find((c) => c.key === country);
|
||||
if (countryObj !== undefined) {
|
||||
@@ -1065,53 +882,22 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
return fb.group({
|
||||
firstName: [
|
||||
this.getProperty(customer, 'first_name'),
|
||||
Validators.required,
|
||||
],
|
||||
firstName: [this.getProperty(customer, 'first_name'), Validators.required],
|
||||
lastName: [this.getProperty(customer, 'last_name'), Validators.required],
|
||||
email: [
|
||||
this.getProperty(customer, 'email'),
|
||||
[CustomValidators.validateEmail, Validators.required],
|
||||
],
|
||||
address: [
|
||||
this.getProperty(customer, 'delivery_addres.street'),
|
||||
Validators.required,
|
||||
],
|
||||
streetNo: [
|
||||
this.getProperty(customer, 'delivery_addres.streetNo'),
|
||||
Validators.required,
|
||||
],
|
||||
zipCode: [
|
||||
this.getProperty(customer, 'delivery_addres.zip'),
|
||||
Validators.required,
|
||||
],
|
||||
city: [
|
||||
this.getProperty(customer, 'delivery_addres.city'),
|
||||
Validators.required,
|
||||
],
|
||||
dateOfBirth: [
|
||||
this.getProperty(customer, 'date_of_birth'),
|
||||
CustomValidators.validateDateOfBirth,
|
||||
],
|
||||
mobile: [
|
||||
this.getProperty(customer, 'mobile_number'),
|
||||
CustomValidators.validateTelephone,
|
||||
],
|
||||
telephone: [
|
||||
this.getProperty(customer, 'phone_number'),
|
||||
CustomValidators.validateTelephone,
|
||||
],
|
||||
email: [this.getProperty(customer, 'email'), [CustomValidators.validateEmail, Validators.required]],
|
||||
address: [this.getProperty(customer, 'delivery_addres.street'), Validators.required],
|
||||
streetNo: [this.getProperty(customer, 'delivery_addres.streetNo'), Validators.required],
|
||||
zipCode: [this.getProperty(customer, 'delivery_addres.zip'), Validators.required],
|
||||
city: [this.getProperty(customer, 'delivery_addres.city'), Validators.required],
|
||||
dateOfBirth: [this.getProperty(customer, 'date_of_birth'), CustomValidators.validateDateOfBirth],
|
||||
mobile: [this.getProperty(customer, 'mobile_number'), CustomValidators.validateTelephone],
|
||||
telephone: [this.getProperty(customer, 'phone_number'), CustomValidators.validateTelephone],
|
||||
country: [country, Validators.required],
|
||||
gender: [this.getProperty(customer, 'gender')],
|
||||
title: [this.getProperty(customer, 'title')],
|
||||
company: [this.getProperty(customer, 'delivery_addres.company_name')],
|
||||
department: [
|
||||
this.getProperty(customer, 'delivery_addres.company_department'),
|
||||
],
|
||||
tax_number: [
|
||||
this.getProperty(customer, 'delivery_addres.company_tax_number'),
|
||||
],
|
||||
department: [this.getProperty(customer, 'delivery_addres.company_department')],
|
||||
tax_number: [this.getProperty(customer, 'delivery_addres.company_tax_number')],
|
||||
note: [this.getProperty(customer, 'delivery_addres.note')],
|
||||
});
|
||||
}
|
||||
@@ -1123,34 +909,16 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
.subscribe((value) => {
|
||||
const data = value ? JSON.parse(value) : undefined;
|
||||
this.userForm = fb.group({
|
||||
firstName: [
|
||||
this.getProperty(data, 'firstName') || '',
|
||||
Validators.required,
|
||||
],
|
||||
lastName: [
|
||||
this.getProperty(data, 'lastName') || '',
|
||||
Validators.required,
|
||||
],
|
||||
email: [
|
||||
this.getProperty(data, 'email') || '',
|
||||
CustomValidators.validateEmail,
|
||||
],
|
||||
firstName: [this.getProperty(data, 'firstName') || '', Validators.required],
|
||||
lastName: [this.getProperty(data, 'lastName') || '', Validators.required],
|
||||
email: [this.getProperty(data, 'email') || '', CustomValidators.validateEmail],
|
||||
address: [this.getProperty(data, 'address') || ''],
|
||||
streetNo: [this.getProperty(data, 'streetNo') || ''],
|
||||
zipCode: [this.getProperty(data, 'zipCode') || ''],
|
||||
city: [this.getProperty(data, 'city') || ''],
|
||||
dateOfBirth: [
|
||||
this.getProperty(data, 'dateOfBirth') || '',
|
||||
CustomValidators.validateDateOfBirth,
|
||||
],
|
||||
mobile: [
|
||||
this.getProperty(data, 'mobile') || '',
|
||||
CustomValidators.validateTelephone,
|
||||
],
|
||||
telephone: [
|
||||
this.getProperty(data, 'telephone') || '',
|
||||
CustomValidators.validateTelephone,
|
||||
],
|
||||
dateOfBirth: [this.getProperty(data, 'dateOfBirth') || '', CustomValidators.validateDateOfBirth],
|
||||
mobile: [this.getProperty(data, 'mobile') || '', CustomValidators.validateTelephone],
|
||||
telephone: [this.getProperty(data, 'telephone') || '', CustomValidators.validateTelephone],
|
||||
country: [this.getProperty(data, 'country') || ''],
|
||||
gender: [this.getProperty(data, 'gender') || ''],
|
||||
title: [this.getProperty(data, 'title') || ''],
|
||||
@@ -1187,10 +955,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
|
||||
private updateFieldState(field: any) {
|
||||
if (field) {
|
||||
if (
|
||||
this.userForm.get(field) &&
|
||||
this.userForm.get(field).value.length > 0
|
||||
) {
|
||||
if (this.userForm.get(field) && this.userForm.get(field).value.length > 0) {
|
||||
this.userForm.get(field).markAsDirty();
|
||||
} else {
|
||||
this.userForm.get(field).markAsUntouched();
|
||||
@@ -1199,22 +964,12 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private loadExtrasState() {
|
||||
const value = this.store.selectSnapshot(FormsSelectors.getFormState)(
|
||||
USER_EXTRAS_FORM_STATE_KEY
|
||||
);
|
||||
const value = this.store.selectSnapshot(FormsSelectors.getFormState)(USER_EXTRAS_FORM_STATE_KEY);
|
||||
const data = value ? JSON.parse(value) : undefined;
|
||||
const guest = data
|
||||
? (this.getProperty(data, 'guest') as boolean)
|
||||
: undefined;
|
||||
const online = data
|
||||
? (this.getProperty(data, 'online') as boolean)
|
||||
: undefined;
|
||||
const submitted = data
|
||||
? (this.getProperty(data, 'submitted') as boolean)
|
||||
: undefined;
|
||||
const guestDisabled = data
|
||||
? (this.getProperty(data, 'guestDisabled') as boolean)
|
||||
: undefined;
|
||||
const guest = data ? (this.getProperty(data, 'guest') as boolean) : undefined;
|
||||
const online = data ? (this.getProperty(data, 'online') as boolean) : undefined;
|
||||
const submitted = data ? (this.getProperty(data, 'submitted') as boolean) : undefined;
|
||||
const guestDisabled = data ? (this.getProperty(data, 'guestDisabled') as boolean) : undefined;
|
||||
setTimeout(() => {
|
||||
if (guest !== this.guestChecked && !isNullOrUndefined(guest)) {
|
||||
this.toggleGuest(false);
|
||||
@@ -1227,19 +982,14 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
} else {
|
||||
this.submitted = false;
|
||||
}
|
||||
if (
|
||||
guestDisabled !== this.guestDisabled &&
|
||||
!isNullOrUndefined(guestDisabled)
|
||||
) {
|
||||
if (guestDisabled !== this.guestDisabled && !isNullOrUndefined(guestDisabled)) {
|
||||
this.guestDisabled = guestDisabled;
|
||||
}
|
||||
}, 400);
|
||||
}
|
||||
|
||||
private loadErrorsState() {
|
||||
const value = this.store.selectSnapshot(FormsSelectors.getFormState)(
|
||||
USER_ERRORS_FORM_STATE_KEY
|
||||
);
|
||||
const value = this.store.selectSnapshot(FormsSelectors.getFormState)(USER_ERRORS_FORM_STATE_KEY);
|
||||
if (value) {
|
||||
const data = JSON.parse(value);
|
||||
setTimeout(() => {
|
||||
@@ -1286,11 +1036,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
if (this.guestDisabled) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
this.cartHasItemsForDelivery &&
|
||||
this.guestChecked &&
|
||||
!this.onlineChecked
|
||||
) {
|
||||
if (this.cartHasItemsForDelivery && this.guestChecked && !this.onlineChecked) {
|
||||
return;
|
||||
}
|
||||
this.guestChecked = !this.guestChecked;
|
||||
@@ -1310,11 +1056,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
toggleOnline(saveState = true) {
|
||||
if (
|
||||
this.cartHasItemsForDelivery &&
|
||||
!this.guestChecked &&
|
||||
this.onlineChecked
|
||||
) {
|
||||
if (this.cartHasItemsForDelivery && !this.guestChecked && this.onlineChecked) {
|
||||
return;
|
||||
}
|
||||
if (this.onlineChecked && this.cartHasItemsForDownload) {
|
||||
@@ -1376,11 +1118,7 @@ export class CreateCustomerCardComponent implements OnInit, OnDestroy {
|
||||
|
||||
detectChanges() {
|
||||
setTimeout(() => {
|
||||
if (
|
||||
this.cdrf !== null &&
|
||||
this.cdrf !== undefined &&
|
||||
!(this.cdrf as ViewRef_).destroyed
|
||||
) {
|
||||
if (this.cdrf !== null && this.cdrf !== undefined && !(this.cdrf as ViewRef_).destroyed) {
|
||||
this.cdrf.detectChanges();
|
||||
}
|
||||
}, 0);
|
||||
|
||||
@@ -1,43 +1,21 @@
|
||||
import { Store, Select } from '@ngxs/store';
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
OnDestroy,
|
||||
Input,
|
||||
ViewChild,
|
||||
ChangeDetectorRef,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
FormGroup,
|
||||
FormBuilder,
|
||||
Validators,
|
||||
AbstractControl,
|
||||
} from '@angular/forms';
|
||||
import { Component, OnInit, OnDestroy, Input, ViewChild, ChangeDetectorRef } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators, AbstractControl } from '@angular/forms';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { Subject, Observable, of } from 'rxjs';
|
||||
import { SharedSelectors } from '../../../../core/store/selectors/shared.selectors';
|
||||
import { EditCustomerData } from '../../../../core/models/edit-customer.model';
|
||||
import {
|
||||
takeUntil,
|
||||
distinctUntilChanged,
|
||||
take,
|
||||
map,
|
||||
filter,
|
||||
switchMap,
|
||||
} from 'rxjs/operators';
|
||||
import { takeUntil, distinctUntilChanged, take, map, filter, switchMap } from 'rxjs/operators';
|
||||
import { User, Address } from '../../../../core/models/user.model';
|
||||
import { ChangeCurrentRoute } from 'apps/sales/src/app/core/store/actions/process.actions';
|
||||
import {
|
||||
AddNewShippingAddress,
|
||||
AddNewInvoiceAddress,
|
||||
} from 'apps/sales/src/app/core/store/actions/customer.actions';
|
||||
import { AddNewShippingAddress, AddNewInvoiceAddress } from 'apps/sales/src/app/core/store/actions/customer.actions';
|
||||
import { GENDERS, TIITLES } from '../../dropdown-values';
|
||||
import { CountrySelector } from 'apps/sales/src/app/core/store/selectors/countries.selector';
|
||||
import { Country } from 'apps/sales/src/app/core/models/country.model';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { scrollToFirstInvalidElement } from 'apps/sales/src/app/core/utils/app.utils';
|
||||
import { AddressSugestionsComponent } from '../address-sugestions/address-sugestions.component';
|
||||
import { AddressDTO } from 'swagger/lib/crm/models/address-dto';
|
||||
import { AddressDTO } from '@swagger/crm';
|
||||
import { CustomerService } from 'apps/sales/src/app/core/services/customer.service';
|
||||
import { ErrorService } from 'apps/sales/src/app/core/error/component/error.service';
|
||||
import { ButtonComponent } from '@libs/ui';
|
||||
@@ -57,12 +35,8 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
@Input() title: string;
|
||||
@Input() addressId: string;
|
||||
@Input() isBillingForm = true;
|
||||
@Select(SharedSelectors.getCustomerEditData) customerEditData$: Observable<
|
||||
EditCustomerData
|
||||
>;
|
||||
@Select(CountrySelector.getCountriesIterable) countries$: Observable<
|
||||
Country[]
|
||||
>;
|
||||
@Select(SharedSelectors.getCustomerEditData) customerEditData$: Observable<EditCustomerData>;
|
||||
@Select(CountrySelector.getCountriesIterable) countries$: Observable<Country[]>;
|
||||
@ViewChild('suggestions') suggestions: AddressSugestionsComponent;
|
||||
@ViewChild('postBtn') postBtn: ButtonComponent;
|
||||
form: FormGroup;
|
||||
@@ -108,13 +82,9 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
this.customer = this.customerInput;
|
||||
|
||||
if (this.isBillingForm) {
|
||||
this.selecetedAddress = this.customerInput.poossible_invoice_addresses.find(
|
||||
(address: Address) => address.id === +this.addressId
|
||||
);
|
||||
this.selecetedAddress = this.customerInput.poossible_invoice_addresses.find((address: Address) => address.id === +this.addressId);
|
||||
} else {
|
||||
this.selecetedAddress = this.customerInput.poossible_delivery_addresses.find(
|
||||
(address: Address) => address.id === +this.addressId
|
||||
);
|
||||
this.selecetedAddress = this.customerInput.poossible_delivery_addresses.find((address: Address) => address.id === +this.addressId);
|
||||
}
|
||||
this.buildForm(this.fb, this.selecetedAddress);
|
||||
this.onFormChange();
|
||||
@@ -143,13 +113,11 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
this.countryList = data;
|
||||
});
|
||||
|
||||
this.route.queryParams
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((queryParams) => {
|
||||
if (queryParams && queryParams['notEditable']) {
|
||||
this.notEditable = true;
|
||||
}
|
||||
});
|
||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((queryParams) => {
|
||||
if (queryParams && queryParams['notEditable']) {
|
||||
this.notEditable = true;
|
||||
}
|
||||
});
|
||||
|
||||
this.setCompanyValidators();
|
||||
}
|
||||
@@ -158,9 +126,7 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
// store address form data on changes
|
||||
this.form.valueChanges.pipe(takeUntil(this.destroy$)).subscribe((v) => {
|
||||
const formStateString = JSON.stringify(v);
|
||||
this.store.dispatch(
|
||||
new SaveFormState(ADDRESS_FORM_STATE_KEY, formStateString)
|
||||
);
|
||||
this.store.dispatch(new SaveFormState(ADDRESS_FORM_STATE_KEY, formStateString));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -189,15 +155,8 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
if (key !== 'FirstName' && key !== 'LastName') {
|
||||
showErrorPopUp = true;
|
||||
}
|
||||
if (
|
||||
keysChecked === Object.keys(invalidProperties).length &&
|
||||
showErrorPopUp
|
||||
) {
|
||||
this.errorService.addErrors(
|
||||
409,
|
||||
null,
|
||||
JSON.stringify(invalidProperties)
|
||||
);
|
||||
if (keysChecked === Object.keys(invalidProperties).length && showErrorPopUp) {
|
||||
this.errorService.addErrors(409, null, JSON.stringify(invalidProperties));
|
||||
}
|
||||
});
|
||||
scrollToFirstInvalidElement();
|
||||
@@ -257,12 +216,7 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
if (this.isBillingForm) {
|
||||
this.store
|
||||
.dispatch(
|
||||
new AddNewInvoiceAddress(
|
||||
updatedCustomer.id,
|
||||
updatedCustomer.invoice_address
|
||||
)
|
||||
)
|
||||
.dispatch(new AddNewInvoiceAddress(updatedCustomer.id, updatedCustomer.invoice_address))
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
switchMap(() => {
|
||||
@@ -274,25 +228,16 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
this.addAddressErrorHandler(invalidProperties);
|
||||
this.postBtn.stopLoading();
|
||||
} else {
|
||||
const queryParams = this.notEditable
|
||||
? { notEditable: true }
|
||||
: undefined;
|
||||
const queryParams = this.notEditable ? { notEditable: true } : undefined;
|
||||
const currentRoute = `customer/edit/${this.customer.id}/billing`;
|
||||
this.store.dispatch(
|
||||
new ChangeCurrentRoute(currentRoute, false, queryParams)
|
||||
);
|
||||
this.store.dispatch(new ChangeCurrentRoute(currentRoute, false, queryParams));
|
||||
this.postBtn.stopLoading();
|
||||
this.router.navigate([currentRoute], { queryParams: queryParams });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.store
|
||||
.dispatch(
|
||||
new AddNewShippingAddress(
|
||||
updatedCustomer.id,
|
||||
updatedCustomer.delivery_addres
|
||||
)
|
||||
)
|
||||
.dispatch(new AddNewShippingAddress(updatedCustomer.id, updatedCustomer.delivery_addres))
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
switchMap(() => {
|
||||
@@ -304,13 +249,9 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
this.addAddressErrorHandler(invalidProperties);
|
||||
this.postBtn.stopLoading();
|
||||
} else {
|
||||
const queryParams = this.notEditable
|
||||
? { notEditable: true }
|
||||
: undefined;
|
||||
const queryParams = this.notEditable ? { notEditable: true } : undefined;
|
||||
const currentRoute = `customer/edit/${this.customer.id}/delivery`;
|
||||
this.store.dispatch(
|
||||
new ChangeCurrentRoute(currentRoute, false, queryParams)
|
||||
);
|
||||
this.store.dispatch(new ChangeCurrentRoute(currentRoute, false, queryParams));
|
||||
this.postBtn.stopLoading();
|
||||
this.router.navigate([currentRoute], { queryParams: queryParams });
|
||||
}
|
||||
@@ -383,9 +324,7 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
countryKey(country: string) {
|
||||
return this.store
|
||||
.selectSnapshot(CountrySelector.getCountriesIterable)
|
||||
.find((t) => t.value === country).key;
|
||||
return this.store.selectSnapshot(CountrySelector.getCountriesIterable).find((t) => t.value === country).key;
|
||||
}
|
||||
|
||||
private updateUserData(): User {
|
||||
@@ -393,29 +332,25 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
let updatedCustomer: User = { ...this.customer };
|
||||
|
||||
if (this.isBillingForm) {
|
||||
updatedCustomer.poossible_invoice_addresses = updatedCustomer.poossible_invoice_addresses.map(
|
||||
(address: Address) => {
|
||||
if (address.id === +this.addressId) {
|
||||
return updateAddress;
|
||||
}
|
||||
|
||||
return address;
|
||||
updatedCustomer.poossible_invoice_addresses = updatedCustomer.poossible_invoice_addresses.map((address: Address) => {
|
||||
if (address.id === +this.addressId) {
|
||||
return updateAddress;
|
||||
}
|
||||
);
|
||||
|
||||
return address;
|
||||
});
|
||||
|
||||
if (updatedCustomer.invoice_address.id === updateAddress.id) {
|
||||
updatedCustomer.invoice_address = updateAddress;
|
||||
}
|
||||
} else {
|
||||
updatedCustomer.poossible_delivery_addresses = updatedCustomer.poossible_delivery_addresses.map(
|
||||
(address: Address) => {
|
||||
if (address.id === +this.addressId) {
|
||||
return updateAddress;
|
||||
}
|
||||
|
||||
return address;
|
||||
updatedCustomer.poossible_delivery_addresses = updatedCustomer.poossible_delivery_addresses.map((address: Address) => {
|
||||
if (address.id === +this.addressId) {
|
||||
return updateAddress;
|
||||
}
|
||||
);
|
||||
|
||||
return address;
|
||||
});
|
||||
|
||||
if (updatedCustomer.delivery_addres.id === updateAddress.id) {
|
||||
updatedCustomer.delivery_addres = updateAddress;
|
||||
@@ -430,16 +365,10 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
let updatedCustomer: User = { ...this.customer };
|
||||
|
||||
if (this.isBillingForm) {
|
||||
updatedCustomer.poossible_invoice_addresses = [
|
||||
...updatedCustomer.poossible_invoice_addresses,
|
||||
newAddress,
|
||||
];
|
||||
updatedCustomer.poossible_invoice_addresses = [...updatedCustomer.poossible_invoice_addresses, newAddress];
|
||||
updatedCustomer.invoice_address = newAddress;
|
||||
} else {
|
||||
updatedCustomer.poossible_delivery_addresses = [
|
||||
...updatedCustomer.poossible_delivery_addresses,
|
||||
newAddress,
|
||||
];
|
||||
updatedCustomer.poossible_delivery_addresses = [...updatedCustomer.poossible_delivery_addresses, newAddress];
|
||||
updatedCustomer.delivery_addres = newAddress;
|
||||
}
|
||||
|
||||
@@ -488,13 +417,9 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
this.form.get('city').value,
|
||||
this.countryKey(this.form.get('country').value),
|
||||
this.form.get('company').value ? this.form.get('company').value : null,
|
||||
this.form.get('department').value
|
||||
? this.form.get('department').value
|
||||
: null,
|
||||
this.form.get('department').value ? this.form.get('department').value : null,
|
||||
this.form.get('note').value ? this.form.get('note').value : null,
|
||||
this.form.get('tax_number').value
|
||||
? this.form.get('tax_number').value
|
||||
: null,
|
||||
this.form.get('tax_number').value ? this.form.get('tax_number').value : null,
|
||||
this.form.get('title').value ? this.form.get('title').value : null,
|
||||
this.form.get('gender').value ? this.form.get('gender').value : null
|
||||
);
|
||||
@@ -502,11 +427,7 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
return data;
|
||||
}
|
||||
|
||||
private updateDataForSelectedOption(
|
||||
field: string,
|
||||
value: string,
|
||||
defaultValue: string
|
||||
) {
|
||||
private updateDataForSelectedOption(field: string, value: string, defaultValue: string) {
|
||||
if (value !== defaultValue) {
|
||||
this.form.get(field).patchValue(value);
|
||||
} else {
|
||||
@@ -527,95 +448,33 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
.subscribe((value) => {
|
||||
const savedAddress = value ? JSON.parse(value) : undefined;
|
||||
this.form = fb.group({
|
||||
id: [
|
||||
address ? address.id : this.getProperty(savedAddress, 'id') || '',
|
||||
],
|
||||
firstName: [
|
||||
address
|
||||
? address.first_name
|
||||
: this.getProperty(savedAddress, 'firstName') || '',
|
||||
Validators.required,
|
||||
],
|
||||
lastName: [
|
||||
address
|
||||
? address.last_name
|
||||
: this.getProperty(savedAddress, 'lastName') || '',
|
||||
Validators.required,
|
||||
],
|
||||
id: [address ? address.id : this.getProperty(savedAddress, 'id') || ''],
|
||||
firstName: [address ? address.first_name : this.getProperty(savedAddress, 'firstName') || '', Validators.required],
|
||||
lastName: [address ? address.last_name : this.getProperty(savedAddress, 'lastName') || '', Validators.required],
|
||||
address: [
|
||||
address
|
||||
? address.street
|
||||
? address.street
|
||||
: ''
|
||||
: this.getProperty(savedAddress, 'address') || '',
|
||||
address ? (address.street ? address.street : '') : this.getProperty(savedAddress, 'address') || '',
|
||||
Validators.required,
|
||||
],
|
||||
streetNo: [
|
||||
address
|
||||
? address.streetNo
|
||||
? address.streetNo
|
||||
: ''
|
||||
: this.getProperty(savedAddress, 'streetNo') || '',
|
||||
Validators.required,
|
||||
],
|
||||
zipCode: [
|
||||
address
|
||||
? address.zip
|
||||
? address.zip
|
||||
: ''
|
||||
: this.getProperty(savedAddress, 'zipCode') || '',
|
||||
Validators.required,
|
||||
],
|
||||
city: [
|
||||
address
|
||||
? address.city
|
||||
? address.city
|
||||
: ''
|
||||
: this.getProperty(savedAddress, 'city') || '',
|
||||
Validators.required,
|
||||
],
|
||||
country: [
|
||||
this.getProperty(savedAddress, 'country') ||
|
||||
this.getCountryFromAddress(address),
|
||||
address ? (address.streetNo ? address.streetNo : '') : this.getProperty(savedAddress, 'streetNo') || '',
|
||||
Validators.required,
|
||||
],
|
||||
zipCode: [address ? (address.zip ? address.zip : '') : this.getProperty(savedAddress, 'zipCode') || '', Validators.required],
|
||||
city: [address ? (address.city ? address.city : '') : this.getProperty(savedAddress, 'city') || '', Validators.required],
|
||||
country: [this.getProperty(savedAddress, 'country') || this.getCountryFromAddress(address), Validators.required],
|
||||
gender: [
|
||||
address
|
||||
? address.gender
|
||||
: this.getProperty(savedAddress, 'gender') || '',
|
||||
address ? address.gender : this.getProperty(savedAddress, 'gender') || '',
|
||||
[Validators.required, CustomValidators.validateGender],
|
||||
],
|
||||
company: [
|
||||
address
|
||||
? address.company_name
|
||||
? address.company_name
|
||||
: ''
|
||||
: this.getProperty(savedAddress, 'company') || '',
|
||||
],
|
||||
company: [address ? (address.company_name ? address.company_name : '') : this.getProperty(savedAddress, 'company') || ''],
|
||||
department: [
|
||||
address
|
||||
? address.company_department
|
||||
? address.company_department
|
||||
: ''
|
||||
: this.getProperty(savedAddress, 'department') || '',
|
||||
address ? (address.company_department ? address.company_department : '') : this.getProperty(savedAddress, 'department') || '',
|
||||
],
|
||||
tax_number: [
|
||||
address
|
||||
? address.company_tax_number
|
||||
? address.company_tax_number
|
||||
: ''
|
||||
: this.getProperty(savedAddress, 'tax_number') || '',
|
||||
],
|
||||
title: [
|
||||
address
|
||||
? address.title
|
||||
: this.getProperty(savedAddress, 'title') || '',
|
||||
],
|
||||
note: [
|
||||
address
|
||||
? address.note
|
||||
: this.getProperty(savedAddress, 'note') || '',
|
||||
address ? (address.company_tax_number ? address.company_tax_number : '') : this.getProperty(savedAddress, 'tax_number') || '',
|
||||
],
|
||||
title: [address ? address.title : this.getProperty(savedAddress, 'title') || ''],
|
||||
note: [address ? address.note : this.getProperty(savedAddress, 'note') || ''],
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -625,9 +484,7 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
return '';
|
||||
}
|
||||
|
||||
const countries = this.store.selectSnapshot(
|
||||
CountrySelector.getCountriesIterable
|
||||
);
|
||||
const countries = this.store.selectSnapshot(CountrySelector.getCountriesIterable);
|
||||
const country = countries.find((t) => t.key === address.country);
|
||||
if (isNullOrUndefined(country)) {
|
||||
return address.country;
|
||||
@@ -645,21 +502,11 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
const addressesLength = address.length;
|
||||
address.forEach((add) => {
|
||||
processedItems++;
|
||||
const street = add.street
|
||||
? add.street
|
||||
: (this.form.get('address').value as string);
|
||||
const streetNo = add.streetNumber
|
||||
? add.streetNumber
|
||||
: (this.form.get('streetNo').value as string);
|
||||
const zipCode = add.zipCode
|
||||
? add.zipCode
|
||||
: (this.form.get('zipCode').value as string);
|
||||
const city = add.city
|
||||
? add.city
|
||||
: (this.form.get('city').value as string);
|
||||
const countryValue = add.country
|
||||
? add.country
|
||||
: (this.form.get('country').value as string);
|
||||
const street = add.street ? add.street : (this.form.get('address').value as string);
|
||||
const streetNo = add.streetNumber ? add.streetNumber : (this.form.get('streetNo').value as string);
|
||||
const zipCode = add.zipCode ? add.zipCode : (this.form.get('zipCode').value as string);
|
||||
const city = add.city ? add.city : (this.form.get('city').value as string);
|
||||
const countryValue = add.country ? add.country : (this.form.get('country').value as string);
|
||||
|
||||
if (city && street && streetNo && zipCode && countryValue) {
|
||||
this.addressSuggestions.push({
|
||||
@@ -673,10 +520,7 @@ export class CustomerAddressFormComponent implements OnInit, OnDestroy {
|
||||
zip: zipCode,
|
||||
});
|
||||
}
|
||||
if (
|
||||
processedItems === addressesLength &&
|
||||
this.addressSuggestions.length === addressesLength
|
||||
) {
|
||||
if (processedItems === addressesLength && this.addressSuggestions.length === addressesLength) {
|
||||
this.cdrf.detectChanges();
|
||||
this.openSuggestions();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { UpdateCurrentBreadcrumbName } from '../../../../core/store/actions/brea
|
||||
import { shrinkTitleAnimation, shrinkSecondaryAnimation, shrinkMainCard } from '../customer-loyalty-card/shrink.animation';
|
||||
import { User } from 'apps/sales/src/app/core/models/user.model';
|
||||
import { CustomerService } from 'apps/sales/src/app/core/services/customer.service';
|
||||
import { BonusCardInfoDTO } from 'swagger/lib/crm/models/bonus-card-info-dto';
|
||||
import { BonusCardInfoDTO } from '@swagger/crm';
|
||||
|
||||
@Component({
|
||||
selector: 'app-customer-loyalty-card',
|
||||
@@ -47,7 +47,7 @@ export class CustomerLoyaltyCardComponent implements OnInit, OnDestroy {
|
||||
|
||||
private cardMapping(cards: BonusCardInfoDTO[], primary: boolean) {
|
||||
return cards
|
||||
.map(card => {
|
||||
.map((card) => {
|
||||
return {
|
||||
code: card.code,
|
||||
name: `${card.firstName} ${card.lastName}`,
|
||||
@@ -57,7 +57,7 @@ export class CustomerLoyaltyCardComponent implements OnInit, OnDestroy {
|
||||
animate: false,
|
||||
};
|
||||
})
|
||||
.filter(card => card && card.isPrimary === primary && card.isActive);
|
||||
.filter((card) => card && card.isPrimary === primary && card.isActive);
|
||||
}
|
||||
|
||||
flipCard(index: number) {
|
||||
@@ -66,17 +66,14 @@ export class CustomerLoyaltyCardComponent implements OnInit, OnDestroy {
|
||||
|
||||
deletePartnerCard() {
|
||||
// TODO: implement logic when we have the API
|
||||
console.log('Delete partner card');
|
||||
}
|
||||
|
||||
addParnterCard() {
|
||||
// TODO: implement logic when we have the API
|
||||
console.log('Add partner card');
|
||||
}
|
||||
|
||||
premiupShop() {
|
||||
// TODO: implement logic when we have the API
|
||||
console.log('Premium shop redirection');
|
||||
}
|
||||
|
||||
expand() {
|
||||
|
||||
@@ -6,8 +6,7 @@ import { ChangeCurrentRoute } from 'apps/sales/src/app/core/store/actions/proces
|
||||
import { Breadcrumb } from 'apps/sales/src/app/core/models/breadcrumb.model';
|
||||
import { AddBreadcrumb } from 'apps/sales/src/app/core/store/actions/breadcrumb.actions';
|
||||
import { SetEditOrder } from 'apps/sales/src/app/core/store/actions/collecting-shelf.action';
|
||||
import { OrderDTO } from 'swagger/lib/oms/models/order-dto';
|
||||
import { ReceiptListItemDTO } from 'swagger/lib/oms/models/receipt-list-item-dto';
|
||||
import { OrderDTO, ReceiptListItemDTO } from '@swagger/oms';
|
||||
import { OrderPaymentReceipt } from 'apps/sales/src/app/core/models/order-payment-receipt.model';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { receiptType, orderPaymentType } from 'apps/sales/src/app/core/mappings/shelf.mapping';
|
||||
@@ -16,7 +15,7 @@ import { DatePipe } from '@angular/common';
|
||||
@Component({
|
||||
selector: 'app-customer-order-item-row',
|
||||
templateUrl: './customer-order-item-row.component.html',
|
||||
styleUrls: ['./customer-order-item-row.component.scss']
|
||||
styleUrls: ['./customer-order-item-row.component.scss'],
|
||||
})
|
||||
export class CustomerOrderItemRowComponent implements OnInit {
|
||||
@Input() item: CustomerOrderItem;
|
||||
@@ -59,7 +58,7 @@ export class CustomerOrderItemRowComponent implements OnInit {
|
||||
breadcrumbName = this.order.buyer.firstName + ' ' + this.order.buyer.lastName + ' Bearbeiten';
|
||||
}
|
||||
|
||||
const subItem = this.order.items.find(t => t.id === id).data.subsetItems[0].data;
|
||||
const subItem = this.order.items.find((t) => t.id === id).data.subsetItems[0].data;
|
||||
const path = `/shelf/edit/${subItem.compartmentCode ? subItem.compartmentCode : this.order.id}/${this.order.id}/${
|
||||
subItem.processingStatus
|
||||
}/${subItem.compartmentCode ? 'c' : 'o'}/customer/${this.customerId}/${subItem.id}`;
|
||||
@@ -67,7 +66,7 @@ export class CustomerOrderItemRowComponent implements OnInit {
|
||||
new AddBreadcrumb(
|
||||
<Breadcrumb>{
|
||||
name: breadcrumbName,
|
||||
path: path
|
||||
path: path,
|
||||
},
|
||||
'customer'
|
||||
)
|
||||
@@ -101,7 +100,7 @@ export class CustomerOrderItemRowComponent implements OnInit {
|
||||
placeOfPayment,
|
||||
invoiceText,
|
||||
printedDate,
|
||||
receiptType: receiptTp
|
||||
receiptType: receiptTp,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { EditCustomerData } from '../../../../core/models/edit-customer.model';
|
||||
import { Select, Store } from '@ngxs/store';
|
||||
import { OrdersService } from '../../../../core/services/order.service';
|
||||
import { switchMap, filter, takeUntil } from 'rxjs/operators';
|
||||
import { OrderListItemDTO } from 'swagger/lib/oms/models/order-list-item-dto';
|
||||
import { OrderListItemDTO } from '@swagger/oms';
|
||||
import { CustomerOrder, OrderType, OrderStatus } from '../../../../core/models/customer-order.model';
|
||||
import { AddBreadcrumb } from '../../../../core/store/actions/breadcrumb.actions';
|
||||
import { User } from '../../../../core/models/user.model';
|
||||
@@ -33,7 +33,7 @@ export class CustomerOrdersCardComponent implements OnInit, OnDestroy {
|
||||
ngOnInit() {
|
||||
this.customerEditData$
|
||||
.pipe(
|
||||
filter(data => data && !isNullOrUndefined(data.customer) && this.customerId !== data.customer.id),
|
||||
filter((data) => data && !isNullOrUndefined(data.customer) && this.customerId !== data.customer.id),
|
||||
switchMap((data: EditCustomerData) => {
|
||||
if (data.customer) {
|
||||
this.customer = data.customer;
|
||||
@@ -73,7 +73,7 @@ export class CustomerOrdersCardComponent implements OnInit, OnDestroy {
|
||||
const branches = await this.branchService.getOrderBranchList();
|
||||
if (branches && branches.length > 0) {
|
||||
orders.forEach((order: OrderListItemDTO) => {
|
||||
const branch = branches.find(t => t && t.id === order.targetBranchId);
|
||||
const branch = branches.find((t) => t && t.id === order.targetBranchId);
|
||||
customerOrders.push({
|
||||
id: order.orderId,
|
||||
date: order.orderDate,
|
||||
|
||||
@@ -3,29 +3,26 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { OrdersService } from '../../../../core/services/order.service';
|
||||
import { Observable, Subject, of } from 'rxjs';
|
||||
import { switchMap, filter, take, takeUntil, catchError, tap, map } from 'rxjs/operators';
|
||||
import { OrderDTO } from 'swagger/lib/oms/models/order-dto';
|
||||
import { OrderDTO, EntityDTOContainerOfOrderItemDTO, ReceiptListItemDTO, SupplierDTO } from '@swagger/oms';
|
||||
import { OrderStatus, OrderType, OrderItemStatus } from '../../../../core/models/customer-order.model';
|
||||
import { BranchSelectors } from '../../../../core/store/selectors/branch.selector';
|
||||
import { BranchDTO } from 'swagger/lib/crm/models/branch-dto';
|
||||
import { BranchDTO } from '@swagger/crm';
|
||||
import { Select, Store } from '@ngxs/store';
|
||||
import { EntityDTOContainerOfOrderItemDTO } from 'swagger/lib/oms/models/entity-dtocontainer-of-order-item-dto';
|
||||
import { CustomerOrderItem } from '../../../../core/models/customer-order-item';
|
||||
import { CustomerOrder } from '../../../../core/models/customer-order';
|
||||
import { objectNotNull } from '../../../../core/utils/app.utils';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { PrinterService } from 'apps/sales/src/app/core/services/printer.service';
|
||||
import { PrinterSelectionComponent } from 'apps/sales/src/app/components/printer-selection/printer-selection.component';
|
||||
import { ReceiptListItemDTO } from 'swagger/lib/oms/models/receipt-list-item-dto';
|
||||
import { CollectingShelfService } from 'apps/sales/src/app/core/services/collecting-shelf.service';
|
||||
import { SupplierState } from 'apps/sales/src/app/core/store/state/supplier.state';
|
||||
import { SupplierDTO } from 'swagger/lib/oms/models/supplier-dto';
|
||||
import { Features } from 'apps/sales/src/app/core/models/user.model';
|
||||
import { CustomerSelectors } from 'apps/sales/src/app/core/store/selectors/customer.selectors';
|
||||
|
||||
@Component({
|
||||
selector: 'app-customer-order-detail',
|
||||
templateUrl: './customer-order-detail.component.html',
|
||||
styleUrls: ['./customer-order-detail.component.scss']
|
||||
styleUrls: ['./customer-order-detail.component.scss'],
|
||||
})
|
||||
export class CustomerOrderDetailComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('printModal') printModal: PrinterSelectionComponent;
|
||||
@@ -65,13 +62,13 @@ export class CustomerOrderDetailComponent implements OnInit, OnDestroy {
|
||||
this.route.params
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
switchMap(params => {
|
||||
switchMap((params) => {
|
||||
this.orderId = +params['orderId'];
|
||||
this.customerId = params['id'];
|
||||
this.initFeatureEffects(this.customerId);
|
||||
return this.branches$;
|
||||
}),
|
||||
filter(branchData => objectNotNull(branchData)),
|
||||
filter((branchData) => objectNotNull(branchData)),
|
||||
switchMap((branches: { [key: number]: BranchDTO }) => {
|
||||
this.branches = branches;
|
||||
return of(undefined);
|
||||
@@ -97,8 +94,8 @@ export class CustomerOrderDetailComponent implements OnInit, OnDestroy {
|
||||
initFeatureEffects(customerId: number) {
|
||||
const features: Features[] = this.store.selectSnapshot(CustomerSelectors.getCustomerFeatures)(customerId);
|
||||
if (features) {
|
||||
this.onlineCustomer = !isNullOrUndefined(features.find(feature => feature.key === 'onlineshop'));
|
||||
this.guestCustomer = !isNullOrUndefined(features.find(feature => feature.key === 'guestaccount'));
|
||||
this.onlineCustomer = !isNullOrUndefined(features.find((feature) => feature.key === 'onlineshop'));
|
||||
this.guestCustomer = !isNullOrUndefined(features.find((feature) => feature.key === 'guestaccount'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +143,7 @@ export class CustomerOrderDetailComponent implements OnInit, OnDestroy {
|
||||
shippingAddress: this.getAddress(order.buyer, true),
|
||||
billingAddress: this.getAddress(order.payer),
|
||||
preordered: item.data.subsetItems[0] && item.data.subsetItems[0].data ? item.data.subsetItems[0].data.isPrebooked : false,
|
||||
invoiceText: item.data.invoiceText
|
||||
invoiceText: item.data.invoiceText,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -167,7 +164,7 @@ export class CustomerOrderDetailComponent implements OnInit, OnDestroy {
|
||||
date: order.orderDate,
|
||||
branch: branchName,
|
||||
items: orders,
|
||||
orderType: order.orderType
|
||||
orderType: order.orderType,
|
||||
};
|
||||
|
||||
this.onlyOneItemAvailable = this.takeNowItems.length + this.pickUpItems.length === 1 || this.order.items.length === 1;
|
||||
@@ -202,7 +199,7 @@ export class CustomerOrderDetailComponent implements OnInit, OnDestroy {
|
||||
|
||||
getReceiptData(orderId: number) {
|
||||
return this.shelfService.getReceipt(orderId).pipe(
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
console.error(error);
|
||||
return of(undefined);
|
||||
}),
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
import { Component, OnInit, ChangeDetectionStrategy, Input, ChangeDetectorRef, OnDestroy } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { OrderItemDTO } from 'swagger/lib/oms/models/order-item-dto';
|
||||
import { OrderItemDTO, EnvironmentChannel, LogisticianDTO, ReceiptListItemDTO, EntityDTOContainerOfBranchDTO } from '@swagger/oms';
|
||||
import { SupplierState } from 'apps/sales/src/app/core/store/state/supplier.state';
|
||||
import { filter, take, takeUntil } from 'rxjs/operators';
|
||||
import { objectNotNull } from 'apps/sales/src/app/core/utils/app.utils';
|
||||
import { OrderStatus, orderChannelMapper, receiptType } from 'apps/sales/src/app/core/mappings/shelf.mapping';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { EnvironmentChannel } from 'swagger/lib/oms/models/environment-channel';
|
||||
import { BranchSelectors } from 'apps/sales/src/app/core/store/selectors/branch.selector';
|
||||
import { LogisticianDTO } from 'swagger/lib/oms/models/logistician-dto';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { CollectingShelfService } from 'apps/sales/src/app/core/services/collecting-shelf.service';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { ReceiptListItemDTO } from 'swagger/lib/oms/models/receipt-list-item-dto';
|
||||
import { EntityDTOContainerOfBranchDTO } from 'swagger/lib/oms/models/entity-dtocontainer-of-branch-dto';
|
||||
|
||||
@Component({
|
||||
selector: 'app-goods-in-article-details',
|
||||
@@ -48,8 +44,8 @@ export class GoodsInArticleDetailsComponent implements OnInit, OnDestroy {
|
||||
|
||||
if (val.subsetItems && val.subsetItems.length > 0) {
|
||||
const quantity = val.subsetItems
|
||||
.filter(subItems => subItems && subItems.data && subItems.data.quantity)
|
||||
.map(subItems => subItems.data.quantity)
|
||||
.filter((subItems) => subItems && subItems.data && subItems.data.quantity)
|
||||
.map((subItems) => subItems.data.quantity)
|
||||
.reduce((q1, q2) => q1 + q2);
|
||||
this._article.quantity = `${quantity ? quantity : 0}x`;
|
||||
}
|
||||
@@ -82,10 +78,10 @@ export class GoodsInArticleDetailsComponent implements OnInit, OnDestroy {
|
||||
this.store
|
||||
.select(SupplierState.getSuppliers)
|
||||
.pipe(
|
||||
filter(data => objectNotNull(data)),
|
||||
filter((data) => objectNotNull(data)),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(suppliers => {
|
||||
.subscribe((suppliers) => {
|
||||
if (suppliers && suppliers[val.subsetItems[0].data.supplier.id]) {
|
||||
this._article.supplier = suppliers[val.subsetItems[0].data.supplier.id].name;
|
||||
}
|
||||
@@ -135,10 +131,10 @@ export class GoodsInArticleDetailsComponent implements OnInit, OnDestroy {
|
||||
this.store
|
||||
.select(BranchSelectors.getBranches)
|
||||
.pipe(
|
||||
filter(data => !isNullOrUndefined(data)),
|
||||
filter((data) => !isNullOrUndefined(data)),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
.subscribe(branches => {
|
||||
.subscribe((branches) => {
|
||||
if (branches && branches[val.id]) {
|
||||
this._article.targetBranch = branches[val.id].name;
|
||||
this.cdrf.detectChanges();
|
||||
@@ -246,6 +242,6 @@ export class GoodsInArticleDetailsComponent implements OnInit, OnDestroy {
|
||||
this.cdrf.detectChanges();
|
||||
}
|
||||
})
|
||||
.catch(error => {});
|
||||
.catch((error) => {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { OrderItemListItemDTO } from 'swagger/lib/oms/models/order-item-list-item-dto';
|
||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { orderStatusMapper } from 'apps/sales/src/app/core/mappings/shelf.mapping';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { Store } from '@ngxs/store';
|
||||
|
||||
@@ -4,17 +4,13 @@ import { take, switchMap, filter, takeUntil, concatMap, catchError, map } from '
|
||||
import { of, Observable, Subject } from 'rxjs';
|
||||
import { CollectingShelfService } from 'apps/sales/src/app/core/services/collecting-shelf.service';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { OrderDTO } from 'swagger/lib/oms/models/order-dto';
|
||||
import { OrderDTO, OrderItemDTO, OrderItemSubsetDTO } from '@swagger/oms';
|
||||
import { orderStatusMapper, orderChannelMapper, OrderStatus } from 'apps/sales/src/app/core/mappings/shelf.mapping';
|
||||
import { OrderItemDTO } from 'swagger/lib/oms/models/order-item-dto';
|
||||
import { OrderItemSubsetDTO } from 'swagger/lib/oms/models/order-item-subset-dto';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { SetBranchProcessCurrentPath } from 'apps/sales/src/app/core/store/actions/branch-process.actions';
|
||||
import { AddBreadcrumb } from 'apps/sales/src/app/core/store/actions/breadcrumb.actions';
|
||||
import { Breadcrumb } from 'apps/sales/src/app/core/models/breadcrumb.model';
|
||||
import { SetEditOrder } from 'apps/sales/src/app/core/store/actions/collecting-shelf.action';
|
||||
import { mapToIterable } from 'apps/sales/src/app/core/utils/app.utils';
|
||||
import { CheckboxOption } from '@libs/ui';
|
||||
import { PrinterService } from 'apps/sales/src/app/core/services/printer.service';
|
||||
import { AppService } from 'apps/sales/src/app/core/services/app.service';
|
||||
import { ViewRef_ } from '@angular/core/src/view';
|
||||
@@ -123,7 +119,7 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
.pipe(
|
||||
take(1),
|
||||
switchMap(this.paramsToOrderSwitcher),
|
||||
filter(order => !isNullOrUndefined(order))
|
||||
filter((order) => !isNullOrUndefined(order))
|
||||
)
|
||||
.subscribe(this.orderResultHandler);
|
||||
}
|
||||
@@ -162,22 +158,22 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
filterOrder(orderDTO: OrderDTO) {
|
||||
let order = orderDTO;
|
||||
if (order) {
|
||||
this.allItems = order.items.map(i => i.data);
|
||||
this.allItems = order.items.map((i) => i.data);
|
||||
order = {
|
||||
...order,
|
||||
items: [
|
||||
...order.items
|
||||
.map(item => {
|
||||
.map((item) => {
|
||||
const filteredItemsByStatus = {
|
||||
...item.data,
|
||||
subsetItems: [
|
||||
...item.data.subsetItems
|
||||
.map(subitem => {
|
||||
.map((subitem) => {
|
||||
if (subitem && subitem.data && subitem.data.processingStatus === +this.processingStatus) {
|
||||
return subitem;
|
||||
}
|
||||
})
|
||||
.filter(f => f && f.data),
|
||||
.filter((f) => f && f.data),
|
||||
],
|
||||
};
|
||||
const subitems = {
|
||||
@@ -186,7 +182,7 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
};
|
||||
return subitems;
|
||||
})
|
||||
.filter(f => f && f.data && f.id === +this.itemId && f.data.subsetItems && f.data.subsetItems.length > 0),
|
||||
.filter((f) => f && f.data && f.id === +this.itemId && f.data.subsetItems && f.data.subsetItems.length > 0),
|
||||
],
|
||||
};
|
||||
}
|
||||
@@ -196,7 +192,7 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
|
||||
sortAllItems() {
|
||||
if (this.allItems && this.allItems.length > 1) {
|
||||
const indexOfMovingItem = this.allItems.findIndex(item => +item.id === +this.itemId);
|
||||
const indexOfMovingItem = this.allItems.findIndex((item) => +item.id === +this.itemId);
|
||||
if (indexOfMovingItem === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -229,7 +225,7 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
|
||||
printLabelIfNeeded() {
|
||||
if (this.labelChecked && this.allItems && this.allItems.length > 1) {
|
||||
const subsetIds = this.allItems.map(data => data.subsetItems[0].id);
|
||||
const subsetIds = this.allItems.map((data) => data.subsetItems[0].id);
|
||||
this.printerService.printGoodsInLabel(subsetIds);
|
||||
}
|
||||
}
|
||||
@@ -245,8 +241,8 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
orderItemSubsetId: number;
|
||||
quantity: number;
|
||||
processingStatus: number;
|
||||
}> = new Observable(observer => {
|
||||
this.order.items.forEach(orderItem => {
|
||||
}> = new Observable((observer) => {
|
||||
this.order.items.forEach((orderItem) => {
|
||||
const orderItemId = orderItem.id;
|
||||
if (orderItem.data.subsetItems && orderItem.data.subsetItems[0]) {
|
||||
const orderItemSubsetId = orderItem.data.subsetItems[0].id;
|
||||
@@ -288,7 +284,7 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
) {
|
||||
let itemsProcessed = 0;
|
||||
let tag: string;
|
||||
tagsValues.forEach(key => {
|
||||
tagsValues.forEach((key) => {
|
||||
const currTag = this.tags[+key];
|
||||
if (currTag.selected) {
|
||||
tag = currTag.label;
|
||||
@@ -297,7 +293,7 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
patchingSubsetItemSequentially$
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
concatMap(data => {
|
||||
concatMap((data) => {
|
||||
return this.shelfService.changeOrderArticleStatus(
|
||||
data.orderId,
|
||||
data.orderItemId,
|
||||
@@ -307,8 +303,8 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
tag
|
||||
);
|
||||
}),
|
||||
catchError(error => {
|
||||
console.log(error);
|
||||
catchError((error) => {
|
||||
console.error(error);
|
||||
return of(undefined);
|
||||
})
|
||||
)
|
||||
@@ -329,8 +325,8 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
orderItemId: number;
|
||||
orderItemSubsetId: number;
|
||||
date: Date;
|
||||
}> = new Observable(observer => {
|
||||
items.forEach(orderItem => {
|
||||
}> = new Observable((observer) => {
|
||||
items.forEach((orderItem) => {
|
||||
const orderItemId = orderItem.id;
|
||||
if (orderItem.data && orderItem.data.subsetItems && orderItem.data.subsetItems[0]) {
|
||||
const orderItemSubsetId = orderItem.data.subsetItems[0].id;
|
||||
@@ -361,18 +357,18 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
extendingEstimatedShippingDateSequentially$
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
concatMap(data => {
|
||||
concatMap((data) => {
|
||||
return this.shelfService.updateEstimatedShippingDate(data.orderId, data.orderItemId, data.orderItemSubsetId, data.date).pipe(
|
||||
map(result => {
|
||||
map((result) => {
|
||||
return { date: data.date, result: result };
|
||||
})
|
||||
);
|
||||
}),
|
||||
catchError(error => {
|
||||
catchError((error) => {
|
||||
return of(undefined);
|
||||
})
|
||||
)
|
||||
.subscribe(response => {
|
||||
.subscribe((response) => {
|
||||
itemsProcessed++;
|
||||
if (itemsProcessed === itemLength && response) {
|
||||
this.esitmatedShippingDate = response.date;
|
||||
@@ -404,7 +400,7 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
}
|
||||
|
||||
tagUpdated(value: { label: string; selected: boolean }, tag: Tag) {
|
||||
tagsValues.forEach(key => {
|
||||
tagsValues.forEach((key) => {
|
||||
if (this.tags[key]) {
|
||||
this.tags[key].selected = false;
|
||||
}
|
||||
@@ -425,7 +421,7 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
}
|
||||
|
||||
addComment(orderItem: OrderItemDTO) {
|
||||
orderItem.subsetItems.forEach(subsetItem => {
|
||||
orderItem.subsetItems.forEach((subsetItem) => {
|
||||
this.shelfService
|
||||
.patchOrderItemSubset(this.orderId, orderItem.id, subsetItem.id, {
|
||||
...subsetItem,
|
||||
@@ -433,8 +429,8 @@ export class GoodsInOrderDetailsComponent implements OnInit, OnDestroy, AfterVie
|
||||
})
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
catchError(error => {
|
||||
console.log('Error Cought', error);
|
||||
catchError((error) => {
|
||||
console.error('Error Cought', error);
|
||||
return of(undefined);
|
||||
})
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@ import { takeUntil, filter, switchMap, tap } from 'rxjs/operators';
|
||||
import { ModuleSwitcher } from 'apps/sales/src/app/core/models/app-switcher.enum';
|
||||
import { GoodsInSelectors } from 'apps/sales/src/app/core/store/selectors/goods-in.selectors';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { OrderItemListItemDTO } from 'swagger/lib/oms/models/order-item-list-item-dto';
|
||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { SetGoodsInUseCache } from 'apps/sales/src/app/core/store/actions/goods-in.actions';
|
||||
import { GOODS_IN_SCROLL_INDEX } from 'apps/sales/src/app/core/utils/app.constants';
|
||||
import { ListRange } from '@angular/cdk/collections';
|
||||
@@ -46,13 +46,13 @@ export class GoodsInSearchResultsComponent implements OnInit, OnDestroy {
|
||||
.select(AppState.activeModule)
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
filter(activeModule => activeModule && activeModule === ModuleSwitcher.Branch),
|
||||
filter((activeModule) => activeModule && activeModule === ModuleSwitcher.Branch),
|
||||
switchMap(() => {
|
||||
return this.store.select(GoodsInSelectors.getGoodsInCurrentSearch);
|
||||
}),
|
||||
filter(data => !isNullOrUndefined(data))
|
||||
filter((data) => !isNullOrUndefined(data))
|
||||
)
|
||||
.subscribe(search => {
|
||||
.subscribe((search) => {
|
||||
this.useCache = this.store.selectSnapshot(GoodsInSelectors.getGoodsInCacheState);
|
||||
this.goodsInSearch = search;
|
||||
this.id = this.store.selectSnapshot(AppState.getCurrentProcessId);
|
||||
@@ -63,9 +63,9 @@ export class GoodsInSearchResultsComponent implements OnInit, OnDestroy {
|
||||
this.scroller.renderedRangeStream
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
filter(data => !isNullOrUndefined(data))
|
||||
filter((data) => !isNullOrUndefined(data))
|
||||
)
|
||||
.subscribe(range => {
|
||||
.subscribe((range) => {
|
||||
if (this.doScroll) {
|
||||
this.scrollToIndexCached(range);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { DataSource, CollectionViewer } from '@angular/cdk/collections';
|
||||
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { take, takeUntil, debounceTime } from 'rxjs/operators';
|
||||
import { OrderItemListItemDTO } from 'swagger/lib/oms/models/order-item-list-item-dto';
|
||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { GoodsInService } from 'apps/sales/src/app/core/services/goods-in.service';
|
||||
import { GoodsInSearch } from 'apps/sales/src/app/core/models/GoodsInSearch.model';
|
||||
import { SetGoodsInOrders } from 'apps/sales/src/app/core/store/actions/goods-in.actions';
|
||||
@@ -22,7 +22,7 @@ export class GoodsInSearchResultsDataSource extends DataSource<OrderItemListItem
|
||||
super();
|
||||
}
|
||||
connect(collectionViewer: CollectionViewer): Observable<(OrderItemListItemDTO | undefined)[]> {
|
||||
collectionViewer.viewChange.pipe(takeUntil(this.destroy$)).subscribe(range => {
|
||||
collectionViewer.viewChange.pipe(takeUntil(this.destroy$)).subscribe((range) => {
|
||||
const startPage = this.getPageForIndex(range.start);
|
||||
const endPage = this.getPageForIndex(range.end);
|
||||
for (let i = startPage; i <= endPage; i++) {
|
||||
@@ -33,7 +33,7 @@ export class GoodsInSearchResultsDataSource extends DataSource<OrderItemListItem
|
||||
}
|
||||
});
|
||||
|
||||
this.dataStream.pipe(takeUntil(this.destroy$), debounceTime(1000)).subscribe(i => {
|
||||
this.dataStream.pipe(takeUntil(this.destroy$), debounceTime(1000)).subscribe((i) => {
|
||||
this.store.dispatch(new SetGoodsInOrders([...i]));
|
||||
});
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { SearchInputComponent } from '@libs/ui';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { BranchState } from 'apps/sales/src/app/core/store/state/branches.state';
|
||||
import { BranchSelectors } from 'apps/sales/src/app/core/store/selectors/branch.selector';
|
||||
import { GoodsInService } from 'apps/sales/src/app/core/services/goods-in.service';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { OrderItemListItemDTO } from 'swagger/lib/oms/models/order-item-list-item-dto';
|
||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||
import {
|
||||
SetGoodsInOrders,
|
||||
SetGoodsInCachedOrders,
|
||||
@@ -37,7 +36,7 @@ export class GoodsInSearchComponent implements OnInit {
|
||||
this.goodsInService
|
||||
.search(input, branchNo, 0, 10)
|
||||
.pipe(take(1))
|
||||
.subscribe(data => this.searchResultHandler(data, input, branchNo));
|
||||
.subscribe((data) => this.searchResultHandler(data, input, branchNo));
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Component, OnInit, Input, ViewChild, ChangeDetectorRef, OnDestroy, Output, EventEmitter } from '@angular/core';
|
||||
import { ModalService, SearchInputComponent } from '@libs/ui';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { BranchSelectors } from 'apps/sales/src/app/core/store/selectors/branch.selector';
|
||||
import { Observable, Subject, of } from 'rxjs';
|
||||
import { BranchDTO } from 'swagger/lib/checkout/models/branch-dto';
|
||||
import { BranchDTO } from '@swagger/checkout';
|
||||
import { Select, Store } from '@ngxs/store';
|
||||
import { tap, map, switchMap, takeUntil, filter } from 'rxjs/operators';
|
||||
import { ProductAvailabilityService } from 'apps/sales/src/app/core/services/product-availability.service';
|
||||
@@ -43,15 +43,15 @@ export class BranchesAvalabilityOverviewComponent implements OnInit, OnDestroy {
|
||||
this.branches$
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
filter(branches => {
|
||||
filter((branches) => {
|
||||
if (branches && branches.length > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
map(branches => {
|
||||
return branches.filter(branch => {
|
||||
map((branches) => {
|
||||
return branches.filter((branch) => {
|
||||
if (
|
||||
branch &&
|
||||
!isNullOrUndefined(branch.isOnline) &&
|
||||
@@ -67,14 +67,14 @@ export class BranchesAvalabilityOverviewComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
});
|
||||
}),
|
||||
switchMap(branches => {
|
||||
switchMap((branches) => {
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
this.userBranch = branches.find(t => t.branchNumber === userBranchNumber);
|
||||
this.userBranch = branches.find((t) => t.branchNumber === userBranchNumber);
|
||||
return this.loadBranches(branches);
|
||||
})
|
||||
)
|
||||
.subscribe(t => {
|
||||
this.branchInfos = t.filter(b => b && b.load);
|
||||
.subscribe((t) => {
|
||||
this.branchInfos = t.filter((b) => b && b.load);
|
||||
this.filteredBranchInfos = this.loadDefaultBranches();
|
||||
});
|
||||
}
|
||||
@@ -86,7 +86,7 @@ export class BranchesAvalabilityOverviewComponent implements OnInit, OnDestroy {
|
||||
private loadDefaultBranches() {
|
||||
return this.branchInfos
|
||||
.sort((a: BranchInfoView, b: BranchInfoView) => (this.userBranch ? this.branchSorterFn(a.branch, b.branch, this.userBranch) : 1))
|
||||
.filter(branch => (this.userBranch ? branch.branch.branchNumber !== this.userBranch.branchNumber : true))
|
||||
.filter((branch) => (this.userBranch ? branch.branch.branchNumber !== this.userBranch.branchNumber : true))
|
||||
.slice(0, 8);
|
||||
}
|
||||
|
||||
@@ -103,11 +103,11 @@ export class BranchesAvalabilityOverviewComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
loadBranches(branches: BranchDTO[]) {
|
||||
const branchIds = branches.map(branch => branch.id);
|
||||
const branchIds = branches.map((branch) => branch.id);
|
||||
return this.availabilityService.getStockInfo(branchIds, [this.item.id]).pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
return response.map((stockInfo, i) => {
|
||||
const branch = branches.find(t => t.id === stockInfo.branchId);
|
||||
const branch = branches.find((t) => t.id === stockInfo.branchId);
|
||||
if (branch) {
|
||||
return <BranchInfoView>{
|
||||
name: branch.shortName,
|
||||
@@ -168,17 +168,17 @@ export class BranchesAvalabilityOverviewComponent implements OnInit, OnDestroy {
|
||||
.searchBranches(searchTerm.trim(), 0, 8)
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
switchMap(branches => {
|
||||
switchMap((branches) => {
|
||||
if (branches && branches.length > 0) {
|
||||
return this.loadBranches(branches.filter(branch => branch.branchNumber !== this.userBranch.branchNumber));
|
||||
return this.loadBranches(branches.filter((branch) => branch.branchNumber !== this.userBranch.branchNumber));
|
||||
}
|
||||
return of(null);
|
||||
})
|
||||
)
|
||||
.subscribe(t => {
|
||||
.subscribe((t) => {
|
||||
if (t) {
|
||||
this.error = undefined;
|
||||
const branchInfos = t.filter(b => b && b.load);
|
||||
const branchInfos = t.filter((b) => b && b.load);
|
||||
this.filteredBranchInfos = branchInfos
|
||||
.sort((a: BranchInfoView, b: BranchInfoView) => this.branchSorterFn(a.branch, b.branch, this.userBranch))
|
||||
.slice(0, 8);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, OnInit, Output, EventEmitter, Input, OnDestroy, ViewChild, C
|
||||
import { ModalService, ButtonComponent, DeleteDropdownComponent } from '@libs/ui';
|
||||
import { Router } from '@angular/router';
|
||||
import { Store, Select } from '@ngxs/store';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
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';
|
||||
@@ -13,8 +13,8 @@ import { Breadcrumb } from '../../../../core/models/breadcrumb.model';
|
||||
import { BranchSelectors } from '../../../../core/store/selectors/branch.selector';
|
||||
import { ProductAvailability } from '../../../../core/models/product-availability.model';
|
||||
import { CheckoutType } from '../../../../core/models/checkout-type.enum';
|
||||
import { BranchDTO } from 'swagger/lib/checkout/models/branch-dto';
|
||||
import { AvailabilityDTO } from 'swagger/lib/availability/models/availability-dto';
|
||||
import { BranchDTO } from '@swagger/checkout';
|
||||
import { AvailabilityDTO } from '@swagger/availability';
|
||||
import { mapToIterable, distance, objectNotNull } from '../../../../core/utils/app.utils';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { ProductAvailabilityService } from '../../../../core/services/product-availability.service';
|
||||
@@ -30,7 +30,7 @@ import { ViewRef_ } from '@angular/core/src/view';
|
||||
@Component({
|
||||
selector: 'app-checkout',
|
||||
templateUrl: './product-checkout.component.html',
|
||||
styleUrls: ['./product-checkout.component.scss']
|
||||
styleUrls: ['./product-checkout.component.scss'],
|
||||
})
|
||||
export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
@Select(SharedSelectors.getCart) cartData$: Observable<ProcessCart>;
|
||||
@@ -47,7 +47,7 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
deliveryOptions = {
|
||||
delivery: DeliveryOption.DELIVERY,
|
||||
now: DeliveryOption.TAKE_NOW,
|
||||
pick_up: DeliveryOption.PICK_UP
|
||||
pick_up: DeliveryOption.PICK_UP,
|
||||
};
|
||||
branches: string[] = [];
|
||||
filteredBranches: string[] = [];
|
||||
@@ -87,7 +87,7 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
@Input() availability: ProductAvailability[];
|
||||
|
||||
get takeNowAvailable() {
|
||||
if (this.availability.filter(t => t.type === CheckoutType.takeNow).length > 0) {
|
||||
if (this.availability.filter((t) => t.type === CheckoutType.takeNow).length > 0) {
|
||||
return of(true);
|
||||
}
|
||||
return of(false);
|
||||
@@ -96,7 +96,7 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
get storeAvailable() {
|
||||
if (
|
||||
this.availability.filter(
|
||||
t =>
|
||||
(t) =>
|
||||
t.type === CheckoutType.store &&
|
||||
(allowedAvailabilityStatusCodes(t.status) || (t.av && t.av.ssc === '830' && t.av.supplier === 'G'))
|
||||
).length > 0
|
||||
@@ -107,7 +107,7 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
get shippingAvailable() {
|
||||
if (this.availability.filter(t => t.type === CheckoutType.delivery && allowedAvailabilityStatusCodes(t.status)).length > 0) {
|
||||
if (this.availability.filter((t) => t.type === CheckoutType.delivery && allowedAvailabilityStatusCodes(t.status)).length > 0) {
|
||||
return of(true);
|
||||
}
|
||||
return of(false);
|
||||
@@ -204,7 +204,7 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
this.possibleItems = [1];
|
||||
this.deliveryType = DeliveryOption.DOWNLOAD;
|
||||
if (this.availability && this.availability.length > 0) {
|
||||
const currAv = this.availability.filter(t => t && t.type === CheckoutType.donwload);
|
||||
const currAv = this.availability.filter((t) => t && t.type === CheckoutType.donwload);
|
||||
if (currAv && currAv[0] && currAv[0].av) {
|
||||
this.currentAvailability = currAv[0].av;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.branches$
|
||||
.pipe(
|
||||
filter(branchData => objectNotNull(branchData)),
|
||||
filter((branchData) => objectNotNull(branchData)),
|
||||
take(1)
|
||||
)
|
||||
.subscribe((branchData: { [key: number]: BranchDTO }) => {
|
||||
@@ -256,7 +256,7 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.branchList = branches;
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
const userBranch = branches.find(t => t.branchNumber === userBranchNumber);
|
||||
const userBranch = branches.find((t) => t.branchNumber === userBranchNumber);
|
||||
if (!!userBranch) {
|
||||
this.selectedBranch = userBranch;
|
||||
this.currentLocation = userBranch.name;
|
||||
@@ -278,7 +278,7 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
if (!!userBranch) {
|
||||
this.filteredBranches = this.branchesData
|
||||
.sort((a: BranchDTO, b: BranchDTO) => this.branchSorterFn(a, b, userBranch))
|
||||
.map(t => t.name);
|
||||
.map((t) => t.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,24 +297,24 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
branchSearch(term: string) {
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
const branchList = [...this.branchesData];
|
||||
const userBranch = branchList.find(t => t.branchNumber === userBranchNumber);
|
||||
const userBranch = branchList.find((t) => t.branchNumber === userBranchNumber);
|
||||
if (isNullOrUndefined(term) || term.length < 1) {
|
||||
this.filteredBranches = branchList.sort((a: BranchDTO, b: BranchDTO) => this.branchSorterFn(a, b, userBranch)).map(t => t.name);
|
||||
this.filteredBranches = branchList.sort((a: BranchDTO, b: BranchDTO) => this.branchSorterFn(a, b, userBranch)).map((t) => t.name);
|
||||
return;
|
||||
}
|
||||
this.branchService
|
||||
.searchBranches(term, 0, null)
|
||||
.pipe(
|
||||
take(1),
|
||||
filter(branches => {
|
||||
filter((branches) => {
|
||||
if (branches && branches.length > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
map(branches => {
|
||||
return branches.filter(branch => {
|
||||
map((branches) => {
|
||||
return branches.filter((branch) => {
|
||||
if (
|
||||
branch &&
|
||||
!isNullOrUndefined(branch.isOnline) &&
|
||||
@@ -330,20 +330,20 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
});
|
||||
}),
|
||||
map(branches => {
|
||||
map((branches) => {
|
||||
this.store.dispatch(new AddBranchesIfNotLoaded(branches));
|
||||
if (branches) {
|
||||
branches.forEach(br => {
|
||||
const existsInBranchData = this.branchesData.find(t => t.branchNumber === br.branchNumber);
|
||||
branches.forEach((br) => {
|
||||
const existsInBranchData = this.branchesData.find((t) => t.branchNumber === br.branchNumber);
|
||||
if (!existsInBranchData) {
|
||||
this.branches.push(br.name);
|
||||
this.branchesData.push(br);
|
||||
}
|
||||
});
|
||||
}
|
||||
return branches.map(t => t.name);
|
||||
return branches.map((t) => t.name);
|
||||
}),
|
||||
tap(branchName => {
|
||||
tap((branchName) => {
|
||||
this.filteredBranches = branchName;
|
||||
})
|
||||
)
|
||||
@@ -351,7 +351,7 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
storeBranches(): Observable<number[]> {
|
||||
return of(this.availability.filter(t => t.type === CheckoutType.store).map(t => t.branchId));
|
||||
return of(this.availability.filter((t) => t.type === CheckoutType.store).map((t) => t.branchId));
|
||||
}
|
||||
|
||||
// STEP ONE
|
||||
@@ -360,25 +360,25 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
this.searchingNewBranch = true;
|
||||
const branch = this.branchesData.find((b: BranchDTO) => b.name === location);
|
||||
// reset store availability
|
||||
this.availability = [...this.availability.filter(t => t.type !== CheckoutType.store)];
|
||||
this.availability = [...this.availability.filter((t) => t.type !== CheckoutType.store)];
|
||||
this.productAvailabilityService
|
||||
.getStoreAvailability(this.book, this.book.product.ean, branch.id)
|
||||
.pipe(
|
||||
tap(response => {
|
||||
tap((response) => {
|
||||
if (response.av && response.av.length > 0) {
|
||||
this.currentLocation = location;
|
||||
this.filteredBranches = [location, ...this.branches.filter(t => t !== location)];
|
||||
this.filteredBranches = [location, ...this.branches.filter((t) => t !== location)];
|
||||
this.selectedBranch = branch;
|
||||
const preferedAv = response.av.find(t => t.preferred === 1);
|
||||
const preferedAv = response.av.find((t) => t.preferred === 1);
|
||||
this.currentPickUpDate = this.datePipe.transform(new Date(preferedAv.at), 'dd.MM.yy');
|
||||
response.av.forEach(t => {
|
||||
response.av.forEach((t) => {
|
||||
this.availability.push({
|
||||
itemId: t.itemId,
|
||||
branchId: branch.id,
|
||||
quantity: response.av.length,
|
||||
type: CheckoutType.store,
|
||||
av: preferedAv ? preferedAv : response.av[0],
|
||||
status: t.status
|
||||
status: t.status,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -395,27 +395,27 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
return;
|
||||
}
|
||||
if (action === DeliveryOption.TAKE_NOW) {
|
||||
this.currentAvailability = this.availability.find(t => t.type === CheckoutType.takeNow).av;
|
||||
this.currentAvailability = this.availability.find((t) => t.type === CheckoutType.takeNow).av;
|
||||
this.stepTwoImgType = 'Take_now';
|
||||
this.deliveryType = DeliveryOption.TAKE_NOW;
|
||||
this.confirmationBtnText = 'Reservieren';
|
||||
// Set user branch as selected branch
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
const userBranch = this.branchList.find(t => t.branchNumber === userBranchNumber);
|
||||
const userBranch = this.branchList.find((t) => t.branchNumber === userBranchNumber);
|
||||
if (!!userBranch) {
|
||||
this.selectedBranch = userBranch;
|
||||
this.currentLocation = userBranch.name;
|
||||
}
|
||||
} else if (action === DeliveryOption.PICK_UP) {
|
||||
if (!this.availability.find(t => t.type === CheckoutType.store)) {
|
||||
if (!this.availability.find((t) => t.type === CheckoutType.store)) {
|
||||
return;
|
||||
}
|
||||
this.currentAvailability = this.availability.find(t => t.type === CheckoutType.store).av;
|
||||
this.currentAvailability = this.availability.find((t) => t.type === CheckoutType.store).av;
|
||||
this.stepTwoImgType = 'Package_Icon';
|
||||
this.deliveryType = DeliveryOption.PICK_UP;
|
||||
this.confirmationBtnText = 'Fortfahren';
|
||||
} else {
|
||||
this.currentAvailability = this.availability.find(t => t.type === CheckoutType.delivery).av;
|
||||
this.currentAvailability = this.availability.find((t) => t.type === CheckoutType.delivery).av;
|
||||
this.stepTwoImgType = 'truck_Icon';
|
||||
this.deliveryType = DeliveryOption.DELIVERY;
|
||||
this.confirmationBtnText = 'Fortfahren';
|
||||
@@ -468,8 +468,8 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
if (this.deliveryType === DeliveryOption.TAKE_NOW) {
|
||||
return of(
|
||||
this.availability
|
||||
.filter(t => t.type === CheckoutType.takeNow)
|
||||
.map(response => {
|
||||
.filter((t) => t.type === CheckoutType.takeNow)
|
||||
.map((response) => {
|
||||
return response.quantity;
|
||||
})
|
||||
.reduce((q1, q2) => {
|
||||
@@ -480,9 +480,9 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
const storeAvailability = await this.productAvailabilityService
|
||||
.getStoreAvailability(this.book, this.book.product.ean, this.selectedBranch.id, numberOfItems)
|
||||
.pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response && response.av) {
|
||||
const preferedAv = response.av.find(t => t && t.preferred === 1);
|
||||
const preferedAv = response.av.find((t) => t && t.preferred === 1);
|
||||
let preferredQty = 0;
|
||||
if (preferedAv) {
|
||||
this.currentAvailability = preferedAv;
|
||||
@@ -507,9 +507,9 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
const shippingAvailability = await this.productAvailabilityService
|
||||
.getShippingAvailability(this.book, this.book.product.ean, +this.selectedBranch.branchNumber, numberOfItems)
|
||||
.pipe(
|
||||
map(response => {
|
||||
map((response) => {
|
||||
if (response && response.av) {
|
||||
const preferedAv = response.av.find(t => t && t.preferred === 1);
|
||||
const preferedAv = response.av.find((t) => t && t.preferred === 1);
|
||||
let preferredQty = 0;
|
||||
if (preferedAv) {
|
||||
this.currentAvailability = preferedAv;
|
||||
@@ -588,12 +588,12 @@ export class ProductCheckoutComponent implements OnInit, OnDestroy {
|
||||
if (this.customerAlredySet) {
|
||||
return {
|
||||
name: 'Warenkorb',
|
||||
path: '/cart/review'
|
||||
path: '/cart/review',
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
name: 'Kundensuche',
|
||||
path: '/customer/search'
|
||||
path: '/customer/search',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,24 @@
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
ViewChild,
|
||||
OnDestroy,
|
||||
ChangeDetectorRef,
|
||||
ElementRef,
|
||||
HostListener,
|
||||
} from '@angular/core';
|
||||
import { Component, OnInit, ViewChild, OnDestroy, ChangeDetectorRef, ElementRef, HostListener } from '@angular/core';
|
||||
import { ProductService } from '../../../../core/services/product.service';
|
||||
import { ItemDTO, ReviewDTO } from 'swagger';
|
||||
import { ItemDTO, ReviewDTO } from '@swagger/cat';
|
||||
import { Observable, of, Subject, forkJoin, combineLatest } from 'rxjs';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { PhotoGalleryComponent, ButtonComponent } from '@libs/ui';
|
||||
import {
|
||||
map,
|
||||
delay,
|
||||
takeUntil,
|
||||
switchMap,
|
||||
catchError,
|
||||
tap,
|
||||
filter,
|
||||
take,
|
||||
} from 'rxjs/operators';
|
||||
import { map, delay, takeUntil, switchMap, catchError, tap, filter, take } from 'rxjs/operators';
|
||||
import { ProductReview } from '../../../../core/models/product-review.model';
|
||||
import { ProductDisplay } from '../../../../core/models/product-display.model';
|
||||
import {
|
||||
AddBreadcrumb,
|
||||
UpdateCurrentBreadcrumbName,
|
||||
} from '../../../../core/store/actions/breadcrumb.actions';
|
||||
import { AddBreadcrumb, UpdateCurrentBreadcrumbName } from '../../../../core/store/actions/breadcrumb.actions';
|
||||
import { ProductCheckoutComponent } from '../../components/product-checkout/product-checkout.component';
|
||||
import { ProductReviewComponent } from '../../components/product-review/product-review.component';
|
||||
import { OtherFormats } from '../../../../core/models/other-formats.model';
|
||||
import {
|
||||
shrinkTitleAnimation,
|
||||
shrinkSecondaryAnimation,
|
||||
shrinkMainCard,
|
||||
} from '../product-details/shrink.animation';
|
||||
import { shrinkTitleAnimation, shrinkSecondaryAnimation, shrinkMainCard } from '../product-details/shrink.animation';
|
||||
import { ProductAvailabilityService } from '../../../../core/services/product-availability.service';
|
||||
import { AvailabilityDTO } from 'swagger/lib/availability/models/availability-dto';
|
||||
import { AvailabilityDTO } from '@swagger/availability';
|
||||
import { BranchSelectors } from '../../../../core/store/selectors/branch.selector';
|
||||
import { ProductAvailability } from '../../../../core/models/product-availability.model';
|
||||
import { CheckoutType } from '../../../../core/models/checkout-type.enum';
|
||||
import { BranchDTO } from 'swagger/lib/checkout/models/branch-dto';
|
||||
import { BranchDTO } from '@swagger/checkout';
|
||||
import { BookImagePipe } from '../../../../pipes/book-image.pipe';
|
||||
import { Review } from '../../../../core/models/review.model';
|
||||
// tslint:disable-next-line: max-line-length
|
||||
@@ -78,9 +54,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('addtocart') addToCartBtn: ButtonComponent;
|
||||
@ViewChild('recommendations') recommendations: RecommendationsComponent;
|
||||
@ViewChild('otherformats') elOtherformats: ProductOtherFormatsComponent;
|
||||
@ViewChild('panformatsel', { read: ElementRef }) public formats: ElementRef<
|
||||
any
|
||||
>;
|
||||
@ViewChild('panformatsel', { read: ElementRef }) public formats: ElementRef<any>;
|
||||
expanded = true;
|
||||
id: number;
|
||||
item: ItemDTO;
|
||||
@@ -122,8 +96,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
|
||||
fullyLoaded = false;
|
||||
|
||||
private errorMessage =
|
||||
'Verfügbarkeitsabfrage konnte nicht durchgeführt werden.';
|
||||
private errorMessage = 'Verfügbarkeitsabfrage konnte nicht durchgeführt werden.';
|
||||
|
||||
get storeError$() {
|
||||
return of(this.storeError);
|
||||
@@ -160,10 +133,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
get takeNowAvailable() {
|
||||
if (
|
||||
this.availability.filter((t) => t.type === CheckoutType.takeNow).length >
|
||||
0
|
||||
) {
|
||||
if (this.availability.filter((t) => t.type === CheckoutType.takeNow).length > 0) {
|
||||
return of(true);
|
||||
}
|
||||
return of(false);
|
||||
@@ -174,8 +144,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
this.availability.filter(
|
||||
(t) =>
|
||||
t.type === CheckoutType.store &&
|
||||
(allowedAvailabilityStatusCodes(t.status) ||
|
||||
(t.av && t.av.ssc === '830' && t.av.supplier === 'G'))
|
||||
(allowedAvailabilityStatusCodes(t.status) || (t.av && t.av.ssc === '830' && t.av.supplier === 'G'))
|
||||
).length > 0
|
||||
) {
|
||||
return of(true);
|
||||
@@ -184,23 +153,14 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
get shippingAvailable() {
|
||||
if (
|
||||
this.availability.filter(
|
||||
(t) =>
|
||||
t.type === CheckoutType.delivery &&
|
||||
allowedAvailabilityStatusCodes(t.status)
|
||||
).length > 0
|
||||
) {
|
||||
if (this.availability.filter((t) => t.type === CheckoutType.delivery && allowedAvailabilityStatusCodes(t.status)).length > 0) {
|
||||
return of(true);
|
||||
}
|
||||
return of(false);
|
||||
}
|
||||
|
||||
get downloadAvailable() {
|
||||
if (
|
||||
this.availability.filter((t) => t.type === CheckoutType.donwload).length >
|
||||
0
|
||||
) {
|
||||
if (this.availability.filter((t) => t.type === CheckoutType.donwload).length > 0) {
|
||||
return of(true);
|
||||
}
|
||||
return of(false);
|
||||
@@ -208,11 +168,8 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
|
||||
get showAvLoading() {
|
||||
if (
|
||||
((!this.storeAvLoaded || !this.shippingAvLoaded) &&
|
||||
this.product.formatIcon !== 'EB' &&
|
||||
this.product.formatIcon !== 'DL') ||
|
||||
(!this.downloadLoaded &&
|
||||
(this.product.formatIcon === 'EB' || this.product.formatIcon === 'DL'))
|
||||
((!this.storeAvLoaded || !this.shippingAvLoaded) && this.product.formatIcon !== 'EB' && this.product.formatIcon !== 'DL') ||
|
||||
(!this.downloadLoaded && (this.product.formatIcon === 'EB' || this.product.formatIcon === 'DL'))
|
||||
) {
|
||||
return of(true);
|
||||
}
|
||||
@@ -220,10 +177,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
get isDownload() {
|
||||
if (
|
||||
this.product &&
|
||||
(this.product.formatIcon === 'EB' || this.product.formatIcon === 'DL')
|
||||
) {
|
||||
if (this.product && (this.product.formatIcon === 'EB' || this.product.formatIcon === 'DL')) {
|
||||
return of(true);
|
||||
}
|
||||
return of(false);
|
||||
@@ -231,21 +185,11 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
|
||||
get productAvailable() {
|
||||
const availabilityLoaded =
|
||||
this.availability.length > 0 &&
|
||||
((this.storeAvLoaded === true && this.shippingAvLoaded === true) ||
|
||||
this.downloadLoaded === true);
|
||||
const hasTakeNow =
|
||||
this.availability.find((t) => t.type === CheckoutType.takeNow) !==
|
||||
undefined;
|
||||
const hasStore =
|
||||
this.availability.find((t) => t.type === CheckoutType.store) !==
|
||||
undefined;
|
||||
const hasShipping =
|
||||
this.availability.find((t) => t.type === CheckoutType.delivery) !==
|
||||
undefined;
|
||||
const hasDownload =
|
||||
this.availability.find((t) => t.type === CheckoutType.donwload) !==
|
||||
undefined;
|
||||
this.availability.length > 0 && ((this.storeAvLoaded === true && this.shippingAvLoaded === true) || this.downloadLoaded === true);
|
||||
const hasTakeNow = this.availability.find((t) => t.type === CheckoutType.takeNow) !== undefined;
|
||||
const hasStore = this.availability.find((t) => t.type === CheckoutType.store) !== undefined;
|
||||
const hasShipping = this.availability.find((t) => t.type === CheckoutType.delivery) !== undefined;
|
||||
const hasDownload = this.availability.find((t) => t.type === CheckoutType.donwload) !== undefined;
|
||||
const canBeBought = hasTakeNow || hasStore || hasShipping || hasDownload;
|
||||
if (canBeBought && availabilityLoaded) {
|
||||
return true;
|
||||
@@ -269,17 +213,9 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
if (this.product && !this.product.price) {
|
||||
return true;
|
||||
}
|
||||
const isDownload =
|
||||
this.product &&
|
||||
(this.product.formatIcon === 'EB' || this.product.formatIcon === 'DL');
|
||||
const isDownloadAlreadyAdded =
|
||||
isDownload && this.downloadIds.includes(this.item.id);
|
||||
if (
|
||||
this.cartHasItems &&
|
||||
this.cartHasDownload &&
|
||||
isDownload &&
|
||||
isDownloadAlreadyAdded
|
||||
) {
|
||||
const isDownload = this.product && (this.product.formatIcon === 'EB' || this.product.formatIcon === 'DL');
|
||||
const isDownloadAlreadyAdded = isDownload && this.downloadIds.includes(this.item.id);
|
||||
if (this.cartHasItems && this.cartHasDownload && isDownload && isDownloadAlreadyAdded) {
|
||||
return true;
|
||||
}
|
||||
if (isDownload && this.downloadError) {
|
||||
@@ -288,12 +224,8 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
if (
|
||||
isDownload &&
|
||||
this.downloadLoaded &&
|
||||
this.availability.filter(
|
||||
(t) =>
|
||||
t.type === CheckoutType.donwload &&
|
||||
t.quantity > 0 &&
|
||||
allowedAvailabilityStatusCodes(t.status)
|
||||
).length < 1
|
||||
this.availability.filter((t) => t.type === CheckoutType.donwload && t.quantity > 0 && allowedAvailabilityStatusCodes(t.status))
|
||||
.length < 1
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -302,12 +234,8 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
!isDownload &&
|
||||
this.storeAvLoaded &&
|
||||
this.shippingAvLoaded &&
|
||||
this.availability.filter(
|
||||
(t) =>
|
||||
t.type !== CheckoutType.donwload &&
|
||||
t.quantity > 0 &&
|
||||
allowedAvailabilityStatusCodes(t.status)
|
||||
).length < 1
|
||||
this.availability.filter((t) => t.type !== CheckoutType.donwload && t.quantity > 0 && allowedAvailabilityStatusCodes(t.status))
|
||||
.length < 1
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -395,22 +323,14 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
this.showFeatures = true;
|
||||
}
|
||||
|
||||
if (
|
||||
!this.product.fullDescription ||
|
||||
(this.product.fullDescription &&
|
||||
this.product.fullDescription.length < 1)
|
||||
) {
|
||||
if (!this.product.fullDescription || (this.product.fullDescription && this.product.fullDescription.length < 1)) {
|
||||
this.showNoDescription = true;
|
||||
}
|
||||
|
||||
this.processReviewData(item.reviews);
|
||||
this.loadBranches();
|
||||
|
||||
if (
|
||||
this.product &&
|
||||
this.product.formatIcon !== 'EB' &&
|
||||
this.product.formatIcon !== 'DL'
|
||||
) {
|
||||
if (this.product && this.product.formatIcon !== 'EB' && this.product.formatIcon !== 'DL') {
|
||||
setTimeout(() => {
|
||||
this.loadAvailability(item, item.product.ean);
|
||||
});
|
||||
@@ -429,11 +349,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private loadTempData() {
|
||||
combineLatest(
|
||||
this.store.select(SharedSelectors.getProcessSelectedItem),
|
||||
this.route.params,
|
||||
this.route.queryParams
|
||||
)
|
||||
combineLatest(this.store.select(SharedSelectors.getProcessSelectedItem), this.route.params, this.route.queryParams)
|
||||
.pipe(takeUntil(this.destroy$), this.filterTempData)
|
||||
.subscribe((item) => {
|
||||
if (this.productDetailContainer) {
|
||||
@@ -442,10 +358,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
this.item = item;
|
||||
this.product = this.productDetailMapper(item);
|
||||
this.product.fullDescription =
|
||||
this.product.fullDescription &&
|
||||
this.product.fullDescription.length > 0
|
||||
? this.product.fullDescription
|
||||
: ' ';
|
||||
this.product.fullDescription && this.product.fullDescription.length > 0 ? this.product.fullDescription : ' ';
|
||||
|
||||
if (this.product.features.length > 0) {
|
||||
this.features = this.product.features;
|
||||
@@ -454,9 +367,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
private filterTempData = (
|
||||
obs: Observable<[ItemDTO, Params, Params]>
|
||||
): Observable<ItemDTO> => {
|
||||
private filterTempData = (obs: Observable<[ItemDTO, Params, Params]>): Observable<ItemDTO> => {
|
||||
return obs.pipe(
|
||||
filter(([item, params, queryParams]) => {
|
||||
if (isNullOrUndefined(item)) {
|
||||
@@ -544,12 +455,8 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
}
|
||||
|
||||
private loadReviewData(review: ReviewDTO) {}
|
||||
|
||||
private loadBranches() {
|
||||
this.branches = this.store.selectSnapshot(
|
||||
BranchSelectors.getBranchesIterable
|
||||
);
|
||||
this.branches = this.store.selectSnapshot(BranchSelectors.getBranchesIterable);
|
||||
}
|
||||
|
||||
openBranchesAvailabilityModal() {
|
||||
@@ -605,21 +512,15 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
// text object mapping
|
||||
if (item.texts) {
|
||||
item.texts.forEach((text) => {
|
||||
const label = text.label
|
||||
? '<b>' + text.label + '</b>' + '\n' + '<br>'
|
||||
: '';
|
||||
const label = text.label ? '<b>' + text.label + '</b>' + '\n' + '<br>' : '';
|
||||
const value = text.value ? text.value + '\n' + '<br>' : '';
|
||||
fullDescription = fullDescription
|
||||
? fullDescription + label + value
|
||||
: label + value;
|
||||
fullDescription = fullDescription ? fullDescription + label + value : label + value;
|
||||
});
|
||||
}
|
||||
|
||||
// specs object mapping
|
||||
if (item.specs) {
|
||||
genre = item.specs.find((s) => s.key === this.GENRE)
|
||||
? item.specs.find((s) => s.key === this.GENRE).value
|
||||
: '';
|
||||
genre = item.specs.find((s) => s.key === this.GENRE) ? item.specs.find((s) => s.key === this.GENRE).value : '';
|
||||
recommandedAge = item.specs.find((s) => s.key === this.RECOMMANDED_AGE)
|
||||
? item.specs.find((s) => s.key === this.RECOMMANDED_AGE).value
|
||||
: '';
|
||||
@@ -635,16 +536,14 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
if (Array.isArray(item.stockInfos) && item.stockInfos.length > 0) {
|
||||
quantity = item.stockInfos[0].inStock.toString();
|
||||
if (+quantity > 0) {
|
||||
const userBranch = this.store.selectSnapshot(
|
||||
BranchSelectors.getUserBranch
|
||||
);
|
||||
const userBranch = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
for (let x = 0; x < +quantity; x++) {
|
||||
this.availability.push({
|
||||
itemId: item.id,
|
||||
branchId: +userBranch,
|
||||
quantity: +quantity,
|
||||
type: CheckoutType.takeNow,
|
||||
av: item.catalogAvailability,
|
||||
av: item.catalogAvailability as any,
|
||||
status: 0,
|
||||
});
|
||||
}
|
||||
@@ -653,9 +552,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
if (item.shelfInfos) {
|
||||
assortment = item.shelfInfos[0].assortment
|
||||
? item.shelfInfos[0].assortment
|
||||
: item.shelfInfos[0].label;
|
||||
assortment = item.shelfInfos[0].assortment ? item.shelfInfos[0].assortment : item.shelfInfos[0].label;
|
||||
}
|
||||
|
||||
if (item.family && item.family.length > 0) {
|
||||
@@ -665,9 +562,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
ean: t.product.ean,
|
||||
format: t.product.format,
|
||||
formatDetail: t.product.formatDetail,
|
||||
price: !!t.catalogAvailability
|
||||
? t.catalogAvailability.price.value.value
|
||||
: 0,
|
||||
price: !!t.catalogAvailability ? t.catalogAvailability.price.value.value : 0,
|
||||
status: !!t.catalogAvailability ? t.catalogAvailability.status : 0,
|
||||
});
|
||||
});
|
||||
@@ -687,10 +582,6 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
})
|
||||
);
|
||||
|
||||
if (!!item.reviews && item.reviews.length > 0) {
|
||||
this.loadReviewData(item.product);
|
||||
}
|
||||
|
||||
let features: Features[] = [];
|
||||
if (item.features) {
|
||||
features = item.features
|
||||
@@ -732,12 +623,8 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async loadDownloadAvailability(item: ItemDTO, ean: string) {
|
||||
const userBranchNumber = this.store.selectSnapshot(
|
||||
BranchSelectors.getUserBranch
|
||||
);
|
||||
const branch = this.store
|
||||
.selectSnapshot(BranchSelectors.getBranchesIterable)
|
||||
.find((t) => t.branchNumber === userBranchNumber);
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
const branch = this.store.selectSnapshot(BranchSelectors.getBranchesIterable).find((t) => t.branchNumber === userBranchNumber);
|
||||
if (!branch) {
|
||||
return true;
|
||||
}
|
||||
@@ -745,10 +632,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
.getShippingAvailabilityWithCheck(item, ean, branch.id)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((response) => {
|
||||
if (
|
||||
(response as { error: boolean; message: string; type: CheckoutType })
|
||||
.error
|
||||
) {
|
||||
if ((response as { error: boolean; message: string; type: CheckoutType }).error) {
|
||||
this.downloadError = true;
|
||||
this.downloadLoaded = true;
|
||||
if (this.addToCartBtn) {
|
||||
@@ -761,16 +645,10 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
av: AvailabilityDTO[];
|
||||
};
|
||||
if (successfulResponse) {
|
||||
const preferredAvailability = successfulResponse.av.find(
|
||||
(t) => t.preferred === 1 && t.supplier === 'DIG'
|
||||
);
|
||||
const preferredAvailability = successfulResponse.av.find((t) => t.preferred === 1 && t.supplier === 'DIG');
|
||||
if (preferredAvailability) {
|
||||
this.availabilityStatusText = preferredAvailability.sscText;
|
||||
if (
|
||||
preferredAvailability.price &&
|
||||
preferredAvailability.price.value &&
|
||||
preferredAvailability.price.value.value
|
||||
) {
|
||||
if (preferredAvailability.price && preferredAvailability.price.value && preferredAvailability.price.value.value) {
|
||||
this.downloadPrice = preferredAvailability.price.value.value;
|
||||
}
|
||||
this.availability.push({
|
||||
@@ -806,15 +684,10 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
|
||||
async loadAvailability(it: ItemDTO, ean: string): Promise<boolean> {
|
||||
const availabilityObservables: Observable<
|
||||
| { branchId: number; type: CheckoutType; av: AvailabilityDTO[] }
|
||||
| { error: boolean; message: string; type: CheckoutType }
|
||||
{ branchId: number; type: CheckoutType; av: AvailabilityDTO[] } | { error: boolean; message: string; type: CheckoutType }
|
||||
>[] = [];
|
||||
const userBranchNumber = this.store.selectSnapshot(
|
||||
BranchSelectors.getUserBranch
|
||||
);
|
||||
const branch = this.store
|
||||
.selectSnapshot(BranchSelectors.getBranchesIterable)
|
||||
.find((t) => t.branchNumber === userBranchNumber);
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
const branch = this.store.selectSnapshot(BranchSelectors.getBranchesIterable).find((t) => t.branchNumber === userBranchNumber);
|
||||
if (!branch) {
|
||||
return true;
|
||||
}
|
||||
@@ -873,45 +746,26 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
if (item.type === CheckoutType.delivery) {
|
||||
this.deliveryError = null;
|
||||
}
|
||||
const preferredAvailability = this.getPreferedAvailability(
|
||||
item.av
|
||||
);
|
||||
const preferredAvailability = this.getPreferedAvailability(item.av);
|
||||
if (!preferredAvailability) {
|
||||
return;
|
||||
}
|
||||
if (item.type === CheckoutType.store) {
|
||||
this.availabilityStatusText = preferredAvailability.sscText;
|
||||
this.currentPickUpDate = preferredAvailability.at
|
||||
? this.datePipe.transform(
|
||||
new Date(preferredAvailability.at),
|
||||
'dd.MM.yy'
|
||||
)
|
||||
? this.datePipe.transform(new Date(preferredAvailability.at), 'dd.MM.yy')
|
||||
: null;
|
||||
if (
|
||||
preferredAvailability.price &&
|
||||
preferredAvailability.price.value &&
|
||||
preferredAvailability.price.value.value
|
||||
) {
|
||||
if (preferredAvailability.price && preferredAvailability.price.value && preferredAvailability.price.value.value) {
|
||||
this.pickUpPrice = preferredAvailability.price.value.value;
|
||||
}
|
||||
}
|
||||
if (
|
||||
item.type === CheckoutType.delivery &&
|
||||
preferredAvailability.at
|
||||
) {
|
||||
if (item.type === CheckoutType.delivery && preferredAvailability.at) {
|
||||
this.currentDeliveryDate = preferredAvailability.at
|
||||
? this.datePipe.transform(
|
||||
new Date(preferredAvailability.at),
|
||||
'dd.MM.yy'
|
||||
)
|
||||
? this.datePipe.transform(new Date(preferredAvailability.at), 'dd.MM.yy')
|
||||
: null;
|
||||
}
|
||||
if (item.type === CheckoutType.delivery) {
|
||||
if (
|
||||
preferredAvailability.price &&
|
||||
preferredAvailability.price.value &&
|
||||
preferredAvailability.price.value.value
|
||||
) {
|
||||
if (preferredAvailability.price && preferredAvailability.price.value && preferredAvailability.price.value.value) {
|
||||
this.deliveryPrice = preferredAvailability.price.value.value;
|
||||
}
|
||||
}
|
||||
@@ -952,23 +806,19 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
if (stockInfo.length === 1) {
|
||||
return stockInfo[0].inStock;
|
||||
}
|
||||
return stockInfo
|
||||
? stockInfo.map((t) => t.inStock).reduce((s1, s2) => s1 + s2)
|
||||
: 0;
|
||||
return stockInfo ? stockInfo.map((t) => t.inStock).reduce((s1, s2) => s1 + s2) : 0;
|
||||
})
|
||||
)
|
||||
.subscribe((inStockAv) => {
|
||||
if (inStockAv) {
|
||||
this.product.quantity = inStockAv + '';
|
||||
this.availability = this.availability.filter(
|
||||
(t) => t.type !== CheckoutType.takeNow
|
||||
);
|
||||
this.availability = this.availability.filter((t) => t.type !== CheckoutType.takeNow);
|
||||
this.availability.push({
|
||||
itemId: itemId,
|
||||
branchId: branchId,
|
||||
quantity: inStockAv,
|
||||
type: CheckoutType.takeNow,
|
||||
av: { ...this.item.catalogAvailability, qty: inStockAv },
|
||||
av: { ...this.item.catalogAvailability, qty: inStockAv } as any,
|
||||
status: 0,
|
||||
});
|
||||
}
|
||||
@@ -984,9 +834,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
if (!availability) {
|
||||
return;
|
||||
}
|
||||
const preferredAvailability = availability.find(
|
||||
(ava: AvailabilityDTO) => ava.preferred === 1
|
||||
);
|
||||
const preferredAvailability = availability.find((ava: AvailabilityDTO) => ava.preferred === 1);
|
||||
return preferredAvailability; // ? preferredAvailability : availability[0];
|
||||
}
|
||||
|
||||
@@ -1000,7 +848,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
|
||||
cartActionCompleted(open: boolean) {}
|
||||
|
||||
formatDate(date: Date): string {
|
||||
formatDate(date: Date | string): string {
|
||||
if (!!date) {
|
||||
try {
|
||||
const dateToFormat = new Date(date);
|
||||
@@ -1034,12 +882,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
|
||||
expand() {
|
||||
this.expanded = !this.expanded;
|
||||
this.store.dispatch(
|
||||
new UpdateCurrentBreadcrumbName(
|
||||
this.expanded ? this.product.title : 'Empfehlungen',
|
||||
'product'
|
||||
)
|
||||
);
|
||||
this.store.dispatch(new UpdateCurrentBreadcrumbName(this.expanded ? this.product.title : 'Empfehlungen', 'product'));
|
||||
if (!this.expanded) {
|
||||
this.recommendations.loadReccomendations();
|
||||
}
|
||||
@@ -1068,10 +911,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
if (event.target.scrollTop === 0) {
|
||||
this.elOtherformats.calculateTopPosition();
|
||||
}
|
||||
if (
|
||||
event.target.scrollTop ===
|
||||
event.target.scrollHeight - event.target.offsetHeight
|
||||
) {
|
||||
if (event.target.scrollTop === event.target.scrollHeight - event.target.offsetHeight) {
|
||||
this.elOtherformats.calculateTopPosition();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||
import { debounceTime, take, takeUntil } from 'rxjs/operators';
|
||||
import { DataSource, CollectionViewer } from '@angular/cdk/collections';
|
||||
import { Store } from '@ngxs/store';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { Product } from '../../../../core/models/product.model';
|
||||
import { ProductMapping } from '../../../../core/mappings/product.mapping';
|
||||
import { ProductService } from '../../../../core/services/product.service';
|
||||
@@ -37,7 +37,7 @@ export class SearchDataSource extends DataSource<Product | undefined> {
|
||||
super();
|
||||
}
|
||||
connect(collectionViewer: CollectionViewer): Observable<(Product | undefined)[]> {
|
||||
collectionViewer.viewChange.pipe(takeUntil(this.destroy$)).subscribe(range => {
|
||||
collectionViewer.viewChange.pipe(takeUntil(this.destroy$)).subscribe((range) => {
|
||||
const startPage = SearchDataSource.getPageForIndex(range.start);
|
||||
const endPage = SearchDataSource.getPageForIndex(range.end - 1);
|
||||
for (let i = startPage; i <= endPage; i++) {
|
||||
@@ -45,7 +45,7 @@ export class SearchDataSource extends DataSource<Product | undefined> {
|
||||
}
|
||||
});
|
||||
|
||||
this.dataStreamDTO.pipe(takeUntil(this.destroy$), debounceTime(1000)).subscribe(i => {
|
||||
this.dataStreamDTO.pipe(takeUntil(this.destroy$), debounceTime(1000)).subscribe((i) => {
|
||||
const currentProcessId = this.store.selectSnapshot(AppState.getCurrentProcessId);
|
||||
this.store.dispatch(new SetProducts([...i], this.search, currentProcessId));
|
||||
});
|
||||
@@ -87,7 +87,7 @@ export class SearchDataSource extends DataSource<Product | undefined> {
|
||||
this.areFiltersNegative
|
||||
);
|
||||
|
||||
productSearch$.pipe(take(1)).subscribe(data => {
|
||||
productSearch$.pipe(take(1)).subscribe((data) => {
|
||||
if (page === 0 && this.skipCache) {
|
||||
this.store.dispatch(new SetProductCachedResults(data));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
ChangeDetectorRef,
|
||||
AfterViewInit,
|
||||
ViewChildren,
|
||||
QueryList
|
||||
QueryList,
|
||||
} from '@angular/core';
|
||||
import { Search } from '../../../../core/models/search.model';
|
||||
import { Process } from '../../../../core/models/process.model';
|
||||
@@ -32,20 +32,21 @@ import { ProductUtilService } from 'apps/sales/src/app/core/services/product-uti
|
||||
import { Side } from '@libs/ui/lib/small-double-choice-switch';
|
||||
import { LoadFilters, SetFilterType, ClearNegativeFilters } from 'apps/sales/src/app/core/store/actions/filter.actions';
|
||||
import { FilterType } from 'apps/sales/src/app/core/models/filter-type.enum';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { ProductCardComponent } from '../../components/product-card/product-card.component';
|
||||
import { ProductSearchResult } from 'apps/sales/src/app/core/models/product-search-result.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-product-results',
|
||||
templateUrl: './product-results.component.html',
|
||||
styleUrls: ['./product-results.component.scss'],
|
||||
animations: [staggerAnimation],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
@Select(ProcessSelectors.getProcesses) processes$: Observable<Process[]>;
|
||||
currentProcess: Process;
|
||||
@Select(SharedSelectors.getSearchedProducts) products$: Observable<{ [key: number]: ItemDTO }>;
|
||||
@Select(SharedSelectors.getSearchedProducts) products$: Observable<ProductSearchResult>;
|
||||
@Select(ProcessSelectors.getProductFilters) filters$: Observable<ProductSerachFilters>;
|
||||
id: number;
|
||||
currentSearch: Search;
|
||||
@@ -77,7 +78,7 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
return this.selectedFilterMode === Side.RIGHT;
|
||||
}
|
||||
const currentFilterType = this.store.selectSnapshot(SharedSelectors.getFilterType);
|
||||
return (currentFilterType) ? currentFilterType === FilterType.Negative : false;
|
||||
return currentFilterType ? currentFilterType === FilterType.Negative : false;
|
||||
}
|
||||
|
||||
get filterContainerHeight() {
|
||||
@@ -101,15 +102,18 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
.pipe(
|
||||
distinctUntilChanged((prev, curr) => prev && curr && JSON.stringify(prev) === JSON.stringify(curr)),
|
||||
takeUntil(this.destroy$),
|
||||
filter(data => !isNullOrUndefined(data) && data.id !== this.id),
|
||||
switchMap(data =>
|
||||
filter((data) => !isNullOrUndefined(data) && data.id !== this.id),
|
||||
switchMap((data) =>
|
||||
this.store.select(SharedSelectors.getFilterType).pipe(
|
||||
filter(fType => !isNullOrUndefined(fType)),
|
||||
filter((fType) => !isNullOrUndefined(fType)),
|
||||
takeUntil(this.destroy$),
|
||||
map(fType => {
|
||||
return {filterType: fType, process: data};
|
||||
}))))
|
||||
.subscribe(({filterType, process}) => {
|
||||
map((fType) => {
|
||||
return { filterType: fType, process: data };
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
.subscribe(({ filterType, process }) => {
|
||||
this.currentProcess = process;
|
||||
this.currentSearch = process.search;
|
||||
this.id = process.id;
|
||||
@@ -123,14 +127,14 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
this.loadCountOfPage += 1;
|
||||
this.loadDataSource(false);
|
||||
if (this.loadCountOfPage === 1) {
|
||||
this.store.dispatch(new AddSearch({...this.currentSearch, firstLoad: false}));
|
||||
this.store.dispatch(new AddSearch({ ...this.currentSearch, firstLoad: false }));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.filters$
|
||||
.pipe(
|
||||
filter(data => !isNullOrUndefined(data)),
|
||||
filter((data) => !isNullOrUndefined(data)),
|
||||
take(1)
|
||||
)
|
||||
.subscribe((filters: ProductSerachFilters) => {
|
||||
@@ -141,9 +145,9 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
this.productUtils.scrollDisabled$
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
filter(data => !isNullOrUndefined(data))
|
||||
filter((data) => !isNullOrUndefined(data))
|
||||
)
|
||||
.subscribe(disable => (this.scrollDisabled = disable));
|
||||
.subscribe((disable) => (this.scrollDisabled = disable));
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
@@ -151,7 +155,7 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
this.scroller.renderedRangeStream
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
filter(data => !isNullOrUndefined(data))
|
||||
filter((data) => !isNullOrUndefined(data))
|
||||
)
|
||||
.subscribe(() => {
|
||||
if (this.doScroll) {
|
||||
@@ -162,14 +166,7 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
}
|
||||
|
||||
initiateDataSource(search: Search, filters: any[], areFiltersNegative: boolean, skipCache: boolean) {
|
||||
this.ds = new SearchDataSource(
|
||||
this.productService,
|
||||
search,
|
||||
this.store,
|
||||
filters,
|
||||
areFiltersNegative,
|
||||
skipCache
|
||||
);
|
||||
this.ds = new SearchDataSource(this.productService, search, this.store, filters, areFiltersNegative, skipCache);
|
||||
}
|
||||
|
||||
loadDataSource(skipCache: boolean) {
|
||||
@@ -177,7 +174,8 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
this.currentSearch,
|
||||
this.currentSearch.fitlers ? this.currentSearch.fitlers : [],
|
||||
this.areFiltersNegative,
|
||||
skipCache);
|
||||
skipCache
|
||||
);
|
||||
|
||||
// Load products up to the previous page
|
||||
const [pageSize] = this.getSelectedProductScrollInformation();
|
||||
@@ -208,7 +206,7 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
if (index) {
|
||||
// Scroll to the selected product - sometimes it can take some time to find it
|
||||
const scrollToInterval = setInterval(() => {
|
||||
const found = this.productCardList.find(productCard => productCard.index === index);
|
||||
const found = this.productCardList.find((productCard) => productCard.index === index);
|
||||
if (found) {
|
||||
found.elementRef.nativeElement.scrollIntoView();
|
||||
clearInterval(scrollToInterval);
|
||||
@@ -235,15 +233,11 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
this.loading = true;
|
||||
this.filters = fil;
|
||||
const type =
|
||||
this.radioButtonGroup.radioButtons && this.radioButtonGroup.radioButtons.find(t => t.selected)
|
||||
? this.radioButtonGroup.radioButtons.find(t => t.selected).key
|
||||
this.radioButtonGroup.radioButtons && this.radioButtonGroup.radioButtons.find((t) => t.selected)
|
||||
? this.radioButtonGroup.radioButtons.find((t) => t.selected).key
|
||||
: undefined;
|
||||
const search = {...currentSearch, type: type};
|
||||
this.initiateDataSource(
|
||||
search,
|
||||
!isNullOrUndefined(fil) ? fil : [],
|
||||
this.areFiltersNegative,
|
||||
true);
|
||||
const search = { ...currentSearch, type: type };
|
||||
this.initiateDataSource(search, !isNullOrUndefined(fil) ? fil : [], this.areFiltersNegative, true);
|
||||
this.loading = false;
|
||||
}
|
||||
setTimeout(() => {
|
||||
@@ -266,7 +260,7 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
skip: 0,
|
||||
firstLoad: false,
|
||||
type: 'author',
|
||||
archiveFilter: this.currentSearch.archiveFilter
|
||||
archiveFilter: this.currentSearch.archiveFilter,
|
||||
};
|
||||
this.store.dispatch(new AddSearch(this.currentSearch));
|
||||
if (!this.searchFired) {
|
||||
@@ -285,8 +279,8 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
this.acrhiveFilter = filtersData.archiveFilters;
|
||||
const filters = this.filters ? this.filters : this.activeFilters();
|
||||
const type =
|
||||
this.radioButtonGroup.radioButtons && this.radioButtonGroup.radioButtons.find(t => t.selected)
|
||||
? this.radioButtonGroup.radioButtons.find(t => t.selected).key
|
||||
this.radioButtonGroup.radioButtons && this.radioButtonGroup.radioButtons.find((t) => t.selected)
|
||||
? this.radioButtonGroup.radioButtons.find((t) => t.selected).key
|
||||
: undefined;
|
||||
|
||||
const exists: Search = {
|
||||
@@ -296,7 +290,7 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
fitlers: filters,
|
||||
firstLoad: false,
|
||||
type: type,
|
||||
archiveFilter: this.acrhiveFilter
|
||||
archiveFilter: this.acrhiveFilter,
|
||||
};
|
||||
this.store.dispatch(new AddSearch(exists));
|
||||
|
||||
@@ -315,12 +309,16 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
private activeFilters(): Filter[] {
|
||||
let filters: Filter[] = [];
|
||||
if (this.currentSearch.fitlers) {
|
||||
filters = this.currentSearch.fitlers.map((f: Filter) => (f.id === 'cattype') ?
|
||||
{
|
||||
...f,
|
||||
items: f.items.map((fi: FilterItem) => (fi.id === '2') ?
|
||||
{...fi, selected: this.acrhiveFilter} : {...fi, selected: false})
|
||||
} : f);
|
||||
filters = this.currentSearch.fitlers.map((f: Filter) =>
|
||||
f.id === 'cattype'
|
||||
? {
|
||||
...f,
|
||||
items: f.items.map((fi: FilterItem) =>
|
||||
fi.id === '2' ? { ...fi, selected: this.acrhiveFilter } : { ...fi, selected: false }
|
||||
),
|
||||
}
|
||||
: f
|
||||
);
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
@@ -328,12 +326,11 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
private selectAuthorFilter() {
|
||||
if (this.radioButtonGroup) {
|
||||
let radioButtons = this.radioButtonGroup.radioButtons;
|
||||
radioButtons = radioButtons.map(radio => (radio.key === 'author') ?
|
||||
{...radio, selected: true} : {...radio, selected: false});
|
||||
radioButtons = radioButtons.map((radio) => (radio.key === 'author' ? { ...radio, selected: true } : { ...radio, selected: false }));
|
||||
|
||||
const updatedRadios: RadioButtonGroup = {radioButtons};
|
||||
const updatedRadios: RadioButtonGroup = { radioButtons };
|
||||
this.radioButtonGroup = updatedRadios;
|
||||
this.store.dispatch(new SetProcessProductFilters({radioButtonGroup: updatedRadios, archiveFilters: this.acrhiveFilter}));
|
||||
this.store.dispatch(new SetProcessProductFilters({ radioButtonGroup: updatedRadios, archiveFilters: this.acrhiveFilter }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,10 +366,10 @@ export class ProductResultsComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
const currentSearch = this.store.selectSnapshot(SharedSelectors.getCurrentSearch);
|
||||
this.loading = true;
|
||||
const type =
|
||||
this.radioButtonGroup.radioButtons && this.radioButtonGroup.radioButtons.find(t => t.selected)
|
||||
? this.radioButtonGroup.radioButtons.find(t => t.selected).key
|
||||
this.radioButtonGroup.radioButtons && this.radioButtonGroup.radioButtons.find((t) => t.selected)
|
||||
? this.radioButtonGroup.radioButtons.find((t) => t.selected).key
|
||||
: undefined;
|
||||
const search = {...currentSearch, type: type};
|
||||
const search = { ...currentSearch, type: type };
|
||||
if (!this.searchFired) {
|
||||
this.searchFired = true;
|
||||
this.initiateDataSource(search, [], false, true);
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
AddSearch,
|
||||
AllowProductLoad,
|
||||
ChangeCurrentRoute,
|
||||
SetArticleSearchErrorStatus
|
||||
SetArticleSearchErrorStatus,
|
||||
} 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';
|
||||
@@ -33,7 +33,7 @@ import { Filter } from '../../../../../../core/models/filter.model';
|
||||
import { FilterItem } from '../../../../../../core/models/filter-item.model';
|
||||
import { SharedSelectors } from 'apps/sales/src/app/core/store/selectors/shared.selectors';
|
||||
import { AppService } from 'apps/sales/src/app/core/services/app.service';
|
||||
import { ListResponseArgsOfItemDTO } from 'swagger';
|
||||
import { ListResponseArgsOfItemDTO } from '@swagger/cat';
|
||||
import { FilterType } from 'apps/sales/src/app/core/models/filter-type.enum';
|
||||
import { SetFilterType } from 'apps/sales/src/app/core/store/actions/filter.actions';
|
||||
|
||||
@@ -41,7 +41,7 @@ import { SetFilterType } from 'apps/sales/src/app/core/store/actions/filter.acti
|
||||
selector: 'app-text-search',
|
||||
templateUrl: './text-search.component.html',
|
||||
styleUrls: ['./text-search.component.scss'],
|
||||
animations: [fadeInAnimation]
|
||||
animations: [fadeInAnimation],
|
||||
})
|
||||
export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
@Select(ProcessSelectors.getRecentProducts) recentArticles$: Observable<RecentArticleSearch[]>;
|
||||
@@ -70,7 +70,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
get filters() {
|
||||
if (this.radioButtonGroup) {
|
||||
const selectedFilter = this.radioButtonGroup.radioButtons.filter(t => t.selected === true);
|
||||
const selectedFilter = this.radioButtonGroup.radioButtons.filter((t) => t.selected === true);
|
||||
if (selectedFilter && selectedFilter.length === 0) {
|
||||
return 'qs';
|
||||
} else {
|
||||
@@ -91,7 +91,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
this.filters$
|
||||
.pipe(
|
||||
filter(data => !isNullOrUndefined(data)),
|
||||
filter((data) => !isNullOrUndefined(data)),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
.subscribe((filters: ProductSerachFilters) => {
|
||||
@@ -99,7 +99,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.acrhiveFilter = filters.archiveFilters;
|
||||
});
|
||||
|
||||
this.searchInput.inputChange.subscribe(data => {
|
||||
this.searchInput.inputChange.subscribe((data) => {
|
||||
if (!data && this.error) {
|
||||
this.updateInputForProcess(data);
|
||||
this.store.dispatch(new SetArticleSearchErrorStatus(false));
|
||||
@@ -108,7 +108,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
this.allFilters$
|
||||
.pipe(
|
||||
filter(data => !isNullOrUndefined(data) && data.length > 0),
|
||||
filter((data) => !isNullOrUndefined(data) && data.length > 0),
|
||||
takeUntil(this.destroy$),
|
||||
distinctUntilChanged((prev, curr) => prev && curr && prev !== curr)
|
||||
)
|
||||
@@ -119,7 +119,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.store
|
||||
.select(AppState.getCurrentProcessId)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(t => {
|
||||
.subscribe((t) => {
|
||||
if (!this.inputForProcess[t]) {
|
||||
this.inputForProcess = { ...this.inputForProcess, [t]: ' ' };
|
||||
this.searchInput.clear();
|
||||
@@ -133,7 +133,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.store
|
||||
.select(ProcessSelectors.getArticleSearchErrorStatus)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(status => {
|
||||
.subscribe((status) => {
|
||||
if (status) {
|
||||
this.error = 'Ergibt keine Suchergebnisse';
|
||||
} else {
|
||||
@@ -173,11 +173,11 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
fitlers: filters.length > 0 ? filters : [],
|
||||
firstLoad: true,
|
||||
type:
|
||||
this.radioButtonGroup && this.radioButtonGroup.radioButtons && this.radioButtonGroup.radioButtons.find(t => t.selected)
|
||||
? this.radioButtonGroup.radioButtons.find(t => t.selected).key
|
||||
this.radioButtonGroup && this.radioButtonGroup.radioButtons && this.radioButtonGroup.radioButtons.find((t) => t.selected)
|
||||
? this.radioButtonGroup.radioButtons.find((t) => t.selected).key
|
||||
: undefined,
|
||||
hits: true,
|
||||
archiveFilter: this.acrhiveFilter
|
||||
archiveFilter: this.acrhiveFilter,
|
||||
};
|
||||
|
||||
this.productService
|
||||
@@ -211,10 +211,10 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
skip: 0,
|
||||
firstLoad: true,
|
||||
type:
|
||||
this.radioButtonGroup && this.radioButtonGroup.radioButtons.find(t => t.selected)
|
||||
? this.radioButtonGroup.radioButtons.find(t => t.selected).key
|
||||
this.radioButtonGroup && this.radioButtonGroup.radioButtons.find((t) => t.selected)
|
||||
? this.radioButtonGroup.radioButtons.find((t) => t.selected).key
|
||||
: undefined,
|
||||
archiveFilter: this.acrhiveFilter
|
||||
archiveFilter: this.acrhiveFilter,
|
||||
};
|
||||
|
||||
this.store.dispatch(new AllowProductLoad());
|
||||
@@ -222,7 +222,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
const newBread: Breadcrumb = {
|
||||
name: (search.query.length > 12 ? search.query.substring(0, 12) + '...' : search.query) + ` (${hits} Ergebnisse)`,
|
||||
path: '/product/results'
|
||||
path: '/product/results',
|
||||
};
|
||||
|
||||
this.store.dispatch(new AddBreadcrumb(newBread, 'product'));
|
||||
@@ -275,7 +275,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
const newProcess = <Process>{
|
||||
id: 1,
|
||||
name: 'Vorgang 1',
|
||||
currentRoute: '/product/search'
|
||||
currentRoute: '/product/search',
|
||||
};
|
||||
|
||||
this.store.dispatch(new AddProcess(newProcess));
|
||||
@@ -283,7 +283,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
new AddBreadcrumb(
|
||||
<Breadcrumb>{
|
||||
name: 'Artikelsuche',
|
||||
path: '/product/search'
|
||||
path: '/product/search',
|
||||
},
|
||||
'product',
|
||||
true
|
||||
@@ -332,7 +332,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
return itm;
|
||||
}
|
||||
return { ...filterItm, selected: false };
|
||||
})
|
||||
}),
|
||||
};
|
||||
|
||||
return fil;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit, Input, OnDestroy, Output, EventEmitter, ViewChild, ElementRef, HostListener } from '@angular/core';
|
||||
import { RecommandationService } from '../../core/services/recommandation.service';
|
||||
import { ItemDTO } from 'swagger';
|
||||
import { ItemDTO } from '@swagger/cat';
|
||||
import { BehaviorSubject, Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { ChangeCurrentRoute, AddProcess } from '../../core/store/actions/process.actions';
|
||||
|
||||
@@ -1,35 +1,9 @@
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
Input,
|
||||
OnDestroy,
|
||||
ViewChild,
|
||||
Output,
|
||||
EventEmitter,
|
||||
ElementRef,
|
||||
ChangeDetectorRef,
|
||||
} from '@angular/core';
|
||||
import { Component, OnInit, Input, OnDestroy, ViewChild, Output, EventEmitter, ElementRef, ChangeDetectorRef } from '@angular/core';
|
||||
import { RemissionListDataSource } from './remission-list.datasource';
|
||||
import {
|
||||
RemissionService,
|
||||
RemissionProcess,
|
||||
RemissionProduct,
|
||||
RemissionFilter,
|
||||
} from '@isa/remission';
|
||||
import { RemissionService, RemissionProcess, RemissionProduct, RemissionFilter } from '@isa/remission';
|
||||
import { RemissionHelperService } from '../../services/remission-helper.service';
|
||||
import { Subject, of, Subscription, Observable } from 'rxjs';
|
||||
import {
|
||||
takeUntil,
|
||||
filter,
|
||||
take,
|
||||
catchError,
|
||||
share,
|
||||
debounceTime,
|
||||
first,
|
||||
map,
|
||||
switchMap,
|
||||
tap,
|
||||
} from 'rxjs/operators';
|
||||
import { takeUntil, filter, take, catchError, share, debounceTime, first, map, switchMap, tap } from 'rxjs/operators';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
|
||||
import { Select, Store } from '@ngxs/store';
|
||||
@@ -54,9 +28,7 @@ export class RemissionListComponent implements OnInit, OnDestroy {
|
||||
@Output() fullListLoaded = new EventEmitter();
|
||||
@Output() scroll = new EventEmitter<void>();
|
||||
@Output() updateShippingDocument = new EventEmitter<void>();
|
||||
@Select(RemissionSelectors.getRemissionProcess) remissionProcess$: Observable<
|
||||
RemissionProcess
|
||||
>;
|
||||
@Select(RemissionSelectors.getRemissionProcess) remissionProcess$: Observable<RemissionProcess>;
|
||||
|
||||
ds: RemissionListDataSource;
|
||||
destroy$ = new Subject();
|
||||
@@ -110,10 +82,7 @@ export class RemissionListComponent implements OnInit, OnDestroy {
|
||||
const takeParam = this.pageSize;
|
||||
const skipParam = Math.max(0, this.totalHits - takeParam);
|
||||
|
||||
if (
|
||||
this.products.length >
|
||||
this.pageSize + (this.totalHits % this.pageSize)
|
||||
) {
|
||||
if (this.products.length > this.pageSize + (this.totalHits % this.pageSize)) {
|
||||
this.products = this.cleanResidualProducts(this.products);
|
||||
}
|
||||
|
||||
@@ -126,16 +95,11 @@ export class RemissionListComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private filterUniqueProducts(products: RemissionProduct[]) {
|
||||
return products.filter(
|
||||
(product, i, allProducts) =>
|
||||
allProducts.findIndex((t) => t.id === product.id) === i
|
||||
);
|
||||
return products.filter((product, i, allProducts) => allProducts.findIndex((t) => t.id === product.id) === i);
|
||||
}
|
||||
|
||||
subscribeToRefetchProducts() {
|
||||
this.refetchProducts$
|
||||
.pipe(debounceTime(10), takeUntil(this.destroy$))
|
||||
.subscribe((_) => this.fetchNewProducts());
|
||||
this.refetchProducts$.pipe(debounceTime(10), takeUntil(this.destroy$)).subscribe((_) => this.fetchNewProducts());
|
||||
}
|
||||
|
||||
onScrollDown() {
|
||||
@@ -218,66 +182,46 @@ export class RemissionListComponent implements OnInit, OnDestroy {
|
||||
map((process) => process.id),
|
||||
tap((_) => this.store.dispatch(new SetRemissionIsLoading(true))),
|
||||
switchMap((remissionProcessId) =>
|
||||
this.remissionService
|
||||
.getRemissionProducts({ remissionProcessId })
|
||||
.pipe(
|
||||
filter((data) => !isNullOrUndefined(data)),
|
||||
debounceTime(250)
|
||||
)
|
||||
this.remissionService.getRemissionProducts({ remissionProcessId }).pipe(
|
||||
filter((data) => !isNullOrUndefined(data)),
|
||||
debounceTime(250)
|
||||
)
|
||||
),
|
||||
takeUntil(this.destroy$),
|
||||
tap((_) => this.store.dispatch(new SetRemissionIsLoading(false)))
|
||||
)
|
||||
.subscribe(
|
||||
(result: {
|
||||
skip?: number;
|
||||
take?: number;
|
||||
hits?: number;
|
||||
items: RemissionProduct[];
|
||||
completed: boolean;
|
||||
}) => {
|
||||
console.log('Subscribe [RemissionProducts]', result);
|
||||
.subscribe((result: { skip?: number; take?: number; hits?: number; items: RemissionProduct[]; completed: boolean }) => {
|
||||
console.error('Subscribe [RemissionProducts]', result);
|
||||
|
||||
this.totalHits = result.hits;
|
||||
this.totalHits = result.hits;
|
||||
|
||||
this.updateFullListLoaded({
|
||||
totalHits: this.totalHits,
|
||||
numberOfProductsFetched: this.products.length,
|
||||
});
|
||||
this.updateFullListLoaded({
|
||||
totalHits: this.totalHits,
|
||||
numberOfProductsFetched: this.products.length,
|
||||
});
|
||||
|
||||
this.isLoading = false;
|
||||
if ((this.page === 0 || result.skip === 0) && !this.isFullLoad) {
|
||||
this.products = [];
|
||||
}
|
||||
this.remissionHelper.setRemissionListHits(result.hits || -1);
|
||||
if (result.items && result.items.length > 0) {
|
||||
if (!this.isItRefetch && !this.isFullLoad) {
|
||||
this.products = this.filterUniqueProducts([
|
||||
...this.products,
|
||||
...result.items,
|
||||
]);
|
||||
} else if (this.isItRefetch && !this.isFullLoad) {
|
||||
this.products.splice(
|
||||
result.skip,
|
||||
result.items.length,
|
||||
...result.items
|
||||
);
|
||||
this.isItRefetch = false;
|
||||
} else if (this.isFullLoad) {
|
||||
this.products = this.filterUniqueProducts([
|
||||
...this.products,
|
||||
...result.items,
|
||||
]);
|
||||
this.isFullLoad = false;
|
||||
this.isFullListLoaded = true;
|
||||
this.cdr.detectChanges();
|
||||
this.fullListLoaded.emit();
|
||||
}
|
||||
}
|
||||
|
||||
this.cdr.detectChanges();
|
||||
this.isLoading = false;
|
||||
if ((this.page === 0 || result.skip === 0) && !this.isFullLoad) {
|
||||
this.products = [];
|
||||
}
|
||||
);
|
||||
this.remissionHelper.setRemissionListHits(result.hits || -1);
|
||||
if (result.items && result.items.length > 0) {
|
||||
if (!this.isItRefetch && !this.isFullLoad) {
|
||||
this.products = this.filterUniqueProducts([...this.products, ...result.items]);
|
||||
} else if (this.isItRefetch && !this.isFullLoad) {
|
||||
this.products.splice(result.skip, result.items.length, ...result.items);
|
||||
this.isItRefetch = false;
|
||||
} else if (this.isFullLoad) {
|
||||
this.products = this.filterUniqueProducts([...this.products, ...result.items]);
|
||||
this.isFullLoad = false;
|
||||
this.isFullListLoaded = true;
|
||||
this.cdr.detectChanges();
|
||||
this.fullListLoaded.emit();
|
||||
}
|
||||
}
|
||||
|
||||
this.cdr.detectChanges();
|
||||
});
|
||||
}
|
||||
|
||||
public loadFullList() {
|
||||
@@ -313,14 +257,9 @@ export class RemissionListComponent implements OnInit, OnDestroy {
|
||||
this.isFullListLoaded = false;
|
||||
}
|
||||
|
||||
private updateFullListLoaded(params: {
|
||||
totalHits: number;
|
||||
numberOfProductsFetched: number;
|
||||
}) {
|
||||
private updateFullListLoaded(params: { totalHits: number; numberOfProductsFetched: number }) {
|
||||
const allProductsFetched = params.numberOfProductsFetched >= this.totalHits;
|
||||
allProductsFetched
|
||||
? (this.isFullListLoaded = true)
|
||||
: (this.isFullListLoaded = false);
|
||||
allProductsFetched ? (this.isFullListLoaded = true) : (this.isFullListLoaded = false);
|
||||
}
|
||||
|
||||
deleteProduct(product: RemissionProduct) {
|
||||
@@ -337,9 +276,7 @@ export class RemissionListComponent implements OnInit, OnDestroy {
|
||||
)
|
||||
.subscribe((result) => {
|
||||
if (result.result) {
|
||||
this.products = this.products.filter(
|
||||
(existingProduct) => existingProduct.id !== product.id
|
||||
);
|
||||
this.products = this.products.filter((existingProduct) => existingProduct.id !== product.id);
|
||||
this.hits = this.products.length;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,33 +10,11 @@ import {
|
||||
ElementRef,
|
||||
AfterViewInit,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
Observable,
|
||||
of,
|
||||
Subject,
|
||||
BehaviorSubject,
|
||||
combineLatest,
|
||||
merge,
|
||||
} from 'rxjs';
|
||||
import {
|
||||
RemissionProduct,
|
||||
RemissionService,
|
||||
RemissionProcess,
|
||||
} from '@isa/remission';
|
||||
import { Observable, of, Subject, BehaviorSubject, combineLatest, merge } from 'rxjs';
|
||||
import { RemissionProduct, RemissionService, RemissionProcess } from '@isa/remission';
|
||||
import { Store, Select } from '@ngxs/store';
|
||||
import { RemissionSelectors } from 'apps/sales/src/app/core/store/selectors/remission.selectors';
|
||||
import {
|
||||
map,
|
||||
switchMap,
|
||||
filter,
|
||||
catchError,
|
||||
takeUntil,
|
||||
take,
|
||||
distinctUntilChanged,
|
||||
debounceTime,
|
||||
tap,
|
||||
skip,
|
||||
} from 'rxjs/operators';
|
||||
import { map, switchMap, filter, catchError, takeUntil, take, distinctUntilChanged, debounceTime, tap, skip } from 'rxjs/operators';
|
||||
import { RemissionListComponent } from '../../../components/remission-list';
|
||||
import { RemissionResourceType } from '../../../models/remission-resource-type.model';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
@@ -50,8 +28,7 @@ import { UpdateShippingDocuent } from 'apps/sales/src/app/core/store/actions/rem
|
||||
styleUrls: ['./product-list.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class RemissionProductListComponent
|
||||
implements OnInit, OnDestroy, AfterViewInit {
|
||||
export class RemissionProductListComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
@ViewChild('toTopToBottomActions')
|
||||
toTopToBottomActions: RemissionToTopToBottomActionsComponent;
|
||||
@ViewChild('remissionList') remissionList: RemissionListComponent;
|
||||
@@ -59,18 +36,12 @@ export class RemissionProductListComponent
|
||||
|
||||
@Input() remissionListContainer: HTMLElement;
|
||||
@Input() shippingDocumentContainer: HTMLElement;
|
||||
@Input() containerScrolled$: Observable<Event> = new Subject<
|
||||
Event
|
||||
>().asObservable();
|
||||
@Input() containerScrolled$: Observable<Event> = new Subject<Event>().asObservable();
|
||||
@Input() shippingDocumentRef: QueryList<ElementRef>;
|
||||
|
||||
@Select(RemissionSelectors.getIsLoading) isLoading$: Observable<boolean>;
|
||||
@Select(RemissionSelectors.getRemissionProcess) remissionProcess$: Observable<
|
||||
RemissionProcess
|
||||
>;
|
||||
@Select(RemissionSelectors.getRemissionSource) source$: Observable<
|
||||
RemissionResourceType
|
||||
>;
|
||||
@Select(RemissionSelectors.getRemissionProcess) remissionProcess$: Observable<RemissionProcess>;
|
||||
@Select(RemissionSelectors.getRemissionSource) source$: Observable<RemissionResourceType>;
|
||||
@Select(RemissionSelectors.getRemissionProcessStatuses)
|
||||
remissionProcessStatuses$: Observable<RemissionProcessStatuses>;
|
||||
@Select(RemissionSelectors.getRemissiontarget)
|
||||
@@ -115,10 +86,7 @@ export class RemissionProductListComponent
|
||||
// Feature Flag: Indicates whether to load entire remission list on navigate to bottom
|
||||
loadAllProductsOnNavigateToBottom = false;
|
||||
|
||||
constructor(
|
||||
private store: Store,
|
||||
private remissionService: RemissionService
|
||||
) {}
|
||||
constructor(private store: Store, private remissionService: RemissionService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.initProducts();
|
||||
@@ -138,10 +106,7 @@ export class RemissionProductListComponent
|
||||
|
||||
initProducts() {
|
||||
this.remissionProductsData$ = this.remissionProcess$.pipe(
|
||||
filter(
|
||||
(process) =>
|
||||
!isNullOrUndefined(process) && !isNullOrUndefined(process.id)
|
||||
),
|
||||
filter((process) => !isNullOrUndefined(process) && !isNullOrUndefined(process.id)),
|
||||
take(1),
|
||||
map((process) => process.id),
|
||||
switchMap((remissionProcessId) =>
|
||||
@@ -149,16 +114,13 @@ export class RemissionProductListComponent
|
||||
filter((data) => !isNullOrUndefined(data)),
|
||||
map((data) => {
|
||||
if (!data.hits) {
|
||||
data.hits =
|
||||
(this.latestRemissionProductsData$.value &&
|
||||
this.latestRemissionProductsData$.value.hits) ||
|
||||
0;
|
||||
data.hits = (this.latestRemissionProductsData$.value && this.latestRemissionProductsData$.value.hits) || 0;
|
||||
}
|
||||
|
||||
return data;
|
||||
}),
|
||||
catchError((err) => {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
return of({
|
||||
items: [],
|
||||
completed: true,
|
||||
@@ -192,9 +154,7 @@ export class RemissionProductListComponent
|
||||
map((process) => process.id),
|
||||
take(1)
|
||||
)
|
||||
.subscribe((remissionProcessId) =>
|
||||
this.store.dispatch(new UpdateShippingDocuent(remissionProcessId))
|
||||
);
|
||||
.subscribe((remissionProcessId) => this.store.dispatch(new UpdateShippingDocuent(remissionProcessId)));
|
||||
}
|
||||
|
||||
navigateToTop() {
|
||||
@@ -235,8 +195,7 @@ export class RemissionProductListComponent
|
||||
const { clientHeight, scrollHeight, scrollTop } = target;
|
||||
|
||||
if (this.refetchProductsOnScroll()) {
|
||||
const shippingContainerHeight = this.shippingDocumentContainer
|
||||
.clientHeight;
|
||||
const shippingContainerHeight = this.shippingDocumentContainer.clientHeight;
|
||||
if (
|
||||
this.shouldRefreshProducts({
|
||||
clientHeight,
|
||||
@@ -274,8 +233,7 @@ export class RemissionProductListComponent
|
||||
const pixelsScrolledUpToTriggerRefresh = 150;
|
||||
|
||||
return (
|
||||
scrollTop + clientHeight - scrollHeight <
|
||||
pixelsScrolledUpToTriggerRefresh - shippingContainerHeight &&
|
||||
scrollTop + clientHeight - scrollHeight < pixelsScrolledUpToTriggerRefresh - shippingContainerHeight &&
|
||||
!!this.viewShippingDocumentFromJumpToBottom
|
||||
);
|
||||
}
|
||||
@@ -286,10 +244,7 @@ export class RemissionProductListComponent
|
||||
this.refetchRemissionProductsOnScrollUp$.next();
|
||||
}
|
||||
|
||||
private setScrollToTopBotomVisibility(
|
||||
topValue: boolean,
|
||||
bottomValue: boolean
|
||||
) {
|
||||
private setScrollToTopBotomVisibility(topValue: boolean, bottomValue: boolean) {
|
||||
this.showJumpToTop$.next(topValue);
|
||||
this.showJumpToBottom$.next(bottomValue);
|
||||
}
|
||||
@@ -300,25 +255,21 @@ export class RemissionProductListComponent
|
||||
}
|
||||
|
||||
private setUpIntersectionObservers() {
|
||||
this.remissionHitsRef.changes
|
||||
.pipe(this.returnFirstElement)
|
||||
.subscribe((element) => {
|
||||
this.subscribeToIntersectionSub({
|
||||
element,
|
||||
sub: this.isNumberOfHitsVisible$,
|
||||
type: 'top',
|
||||
});
|
||||
this.remissionHitsRef.changes.pipe(this.returnFirstElement).subscribe((element) => {
|
||||
this.subscribeToIntersectionSub({
|
||||
element,
|
||||
sub: this.isNumberOfHitsVisible$,
|
||||
type: 'top',
|
||||
});
|
||||
});
|
||||
|
||||
this.shippingDocumentRef.changes
|
||||
.pipe(this.returnFirstElement)
|
||||
.subscribe((element) => {
|
||||
this.subscribeToIntersectionSub({
|
||||
element,
|
||||
sub: this.isShippingDocumentVisible$,
|
||||
type: 'bottom',
|
||||
});
|
||||
this.shippingDocumentRef.changes.pipe(this.returnFirstElement).subscribe((element) => {
|
||||
this.subscribeToIntersectionSub({
|
||||
element,
|
||||
sub: this.isShippingDocumentVisible$,
|
||||
type: 'bottom',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private returnFirstElement(el: Observable<any>): Observable<any> {
|
||||
@@ -328,11 +279,7 @@ export class RemissionProductListComponent
|
||||
);
|
||||
}
|
||||
|
||||
private subscribeToIntersectionSub(params: {
|
||||
element: Element;
|
||||
sub: BehaviorSubject<boolean>;
|
||||
type: 'top' | 'bottom';
|
||||
}) {
|
||||
private subscribeToIntersectionSub(params: { element: Element; sub: BehaviorSubject<boolean>; type: 'top' | 'bottom' }) {
|
||||
const { element, sub, type } = params;
|
||||
|
||||
const unsubscribe = this.intersectionObserverSubs.get(type);
|
||||
@@ -340,10 +287,7 @@ export class RemissionProductListComponent
|
||||
unsubscribe();
|
||||
}
|
||||
|
||||
this.intersectionObserverSubs.set(
|
||||
type,
|
||||
this.initIntersectionObserver(element, type)
|
||||
);
|
||||
this.intersectionObserverSubs.set(type, this.initIntersectionObserver(element, type));
|
||||
|
||||
this.intersectionObserver$
|
||||
.pipe(
|
||||
@@ -362,13 +306,11 @@ export class RemissionProductListComponent
|
||||
}
|
||||
|
||||
private initIntersectionObserver(element: Element, type: 'top' | 'bottom') {
|
||||
const intersectionObserver = new IntersectionObserver(
|
||||
(entries, observer) => {
|
||||
entries.forEach((entry) => {
|
||||
this.intersectionObserver$.next({ entry, observer, type });
|
||||
});
|
||||
}
|
||||
);
|
||||
const intersectionObserver = new IntersectionObserver((entries, observer) => {
|
||||
entries.forEach((entry) => {
|
||||
this.intersectionObserver$.next({ entry, observer, type });
|
||||
});
|
||||
});
|
||||
|
||||
intersectionObserver.observe(element);
|
||||
|
||||
@@ -403,31 +345,22 @@ export class RemissionProductListComponent
|
||||
this.isLoading$
|
||||
)
|
||||
.pipe(
|
||||
map(
|
||||
([
|
||||
isNumberOfHitsVisible,
|
||||
isShippingDocumentVisible,
|
||||
hits,
|
||||
isLoading,
|
||||
]) => {
|
||||
if (!hits || hits === -1 || !!isLoading) {
|
||||
return {
|
||||
showTop: false,
|
||||
showBottom: false,
|
||||
};
|
||||
}
|
||||
|
||||
map(([isNumberOfHitsVisible, isShippingDocumentVisible, hits, isLoading]) => {
|
||||
if (!hits || hits === -1 || !!isLoading) {
|
||||
return {
|
||||
showTop: !isShippingDocumentVisible,
|
||||
showBottom: !isNumberOfHitsVisible,
|
||||
showTop: false,
|
||||
showBottom: false,
|
||||
};
|
||||
}
|
||||
),
|
||||
|
||||
return {
|
||||
showTop: !isShippingDocumentVisible,
|
||||
showBottom: !isNumberOfHitsVisible,
|
||||
};
|
||||
}),
|
||||
takeUntil(this.destroy$),
|
||||
debounceTime(350)
|
||||
)
|
||||
.subscribe(({ showTop, showBottom }) =>
|
||||
this.setScrollToTopBotomVisibility(showTop, showBottom)
|
||||
);
|
||||
.subscribe(({ showTop, showBottom }) => this.setScrollToTopBotomVisibility(showTop, showBottom));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
OnDestroy,
|
||||
ViewChild,
|
||||
ElementRef,
|
||||
ChangeDetectionStrategy,
|
||||
} from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, ViewChild, ElementRef, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { Subject, Observable } from 'rxjs';
|
||||
import {
|
||||
takeUntil,
|
||||
filter,
|
||||
take,
|
||||
switchMap,
|
||||
catchError,
|
||||
first,
|
||||
} from 'rxjs/operators';
|
||||
import { takeUntil, filter, take, switchMap, catchError, first } from 'rxjs/operators';
|
||||
import { RemissionResourceType } from '../../models/remission-resource-type.model';
|
||||
import {
|
||||
RemissionSupplier,
|
||||
@@ -23,6 +9,7 @@ import {
|
||||
RemissionProcess,
|
||||
RemissionFilter,
|
||||
RemissionProduct,
|
||||
RemissionSelectedFilters,
|
||||
} from '@isa/remission';
|
||||
import { Select, Store } from '@ngxs/store';
|
||||
import { RemissionSelectors } from 'apps/sales/src/app/core/store/selectors/remission.selectors';
|
||||
@@ -41,10 +28,7 @@ import {
|
||||
} from 'apps/sales/src/app/core/store/actions/remission.actions';
|
||||
import { RemissionHelperService } from '../../services/remission-helper.service';
|
||||
import { RemissionListComponent } from '../../components/remission-list/remission-list.component';
|
||||
import {
|
||||
AddBreadcrumb,
|
||||
ResetBreadcrumbsTo,
|
||||
} from 'apps/sales/src/app/core/store/actions/breadcrumb.actions';
|
||||
import { AddBreadcrumb, ResetBreadcrumbsTo } from 'apps/sales/src/app/core/store/actions/breadcrumb.actions';
|
||||
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||
import { SetBranchProcessCurrentPath } from 'apps/sales/src/app/core/store/actions/branch-process.actions';
|
||||
import { RemissionStartDialogComponent } from '../../components/remission-start-dialog/remission-start-dialog.component';
|
||||
@@ -67,7 +51,7 @@ export class RemissionListCreateComponent implements OnInit, OnDestroy {
|
||||
@Select(RemissionSelectors.getRemissionProcessStatuses)
|
||||
remissionProcessStatuses$: Observable<RemissionProcessStatuses>;
|
||||
@Select(RemissionSelectors.getRemissionFilters)
|
||||
remissionFilters$: Observable<RemissionFilter>;
|
||||
remissionFilters$: Observable<RemissionSelectedFilters>;
|
||||
@Select(RemissionSelectors.getRemissionProcess)
|
||||
currentRemissionProcess$: Observable<RemissionProcess>;
|
||||
@Select(RemissionSelectors.getRemissionSource)
|
||||
@@ -194,15 +178,11 @@ export class RemissionListCreateComponent implements OnInit, OnDestroy {
|
||||
process$ = this.continueProcess();
|
||||
}
|
||||
|
||||
return process$.pipe(
|
||||
filter((process) => !isNullOrUndefined(process))
|
||||
);
|
||||
return process$.pipe(filter((process) => !isNullOrUndefined(process)));
|
||||
}),
|
||||
take(1)
|
||||
)
|
||||
.subscribe((process) => {
|
||||
console.log('SET REMISSION STATUS', process);
|
||||
|
||||
this.store.dispatch(new SetRemissionProcess(process));
|
||||
this.loadUncompletedRemissions();
|
||||
});
|
||||
@@ -228,21 +208,17 @@ export class RemissionListCreateComponent implements OnInit, OnDestroy {
|
||||
.subscribe(this.uncompletedRemissionsSubscriptionHandler);
|
||||
}
|
||||
|
||||
uncompletedRemissionsSubscriptionHandler = (
|
||||
remissionProcesses: RemissionProcess[]
|
||||
) => {
|
||||
uncompletedRemissionsSubscriptionHandler = (remissionProcesses: RemissionProcess[]) => {
|
||||
this.store.dispatch(new SetAllOpenExistingRemissions(remissionProcesses));
|
||||
};
|
||||
|
||||
continueProcess(): Observable<RemissionProcess> {
|
||||
return this.currentRemissionProcess$
|
||||
.pipe(filter((data) => !isNullOrUndefined(data), take(1)))
|
||||
.pipe(
|
||||
switchMap((process) => {
|
||||
return this.remissionService.continueProcess(process);
|
||||
}),
|
||||
catchError(this.continueProcessErrorHandler)
|
||||
);
|
||||
return this.currentRemissionProcess$.pipe(filter((data) => !isNullOrUndefined(data), take(1))).pipe(
|
||||
switchMap((process) => {
|
||||
return this.remissionService.continueProcess(process);
|
||||
}),
|
||||
catchError(this.continueProcessErrorHandler)
|
||||
);
|
||||
}
|
||||
|
||||
continueProcessErrorHandler = (error: any) => {
|
||||
@@ -257,19 +233,11 @@ export class RemissionListCreateComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
remissionSourcesFilter = (remissionSources: RemissionSourceType[]) => {
|
||||
return (
|
||||
remissionSources &&
|
||||
Array.isArray(remissionSources) &&
|
||||
remissionSources.length === 2
|
||||
);
|
||||
return remissionSources && Array.isArray(remissionSources) && remissionSources.length === 2;
|
||||
};
|
||||
|
||||
remissionSuppliersFilter = (remissionSuppliers: RemissionSupplier[]) => {
|
||||
return (
|
||||
remissionSuppliers &&
|
||||
Array.isArray(remissionSuppliers) &&
|
||||
remissionSuppliers.length === 2
|
||||
);
|
||||
return remissionSuppliers && Array.isArray(remissionSuppliers) && remissionSuppliers.length === 2;
|
||||
};
|
||||
|
||||
remissionSuppliersSubscriptionHandler = (process) => {
|
||||
@@ -290,9 +258,7 @@ export class RemissionListCreateComponent implements OnInit, OnDestroy {
|
||||
this.currentRemissionProcess$
|
||||
.pipe(
|
||||
switchMap((process) =>
|
||||
this.remissionService
|
||||
.startRemission({ remissionProcessId: process.id })
|
||||
.pipe(filter((data) => !isNullOrUndefined(data)))
|
||||
this.remissionService.startRemission({ remissionProcessId: process.id }).pipe(filter((data) => !isNullOrUndefined(data)))
|
||||
),
|
||||
first()
|
||||
)
|
||||
@@ -397,9 +363,7 @@ export class RemissionListCreateComponent implements OnInit, OnDestroy {
|
||||
this.remissionService
|
||||
.searchProduct({ ean: input })
|
||||
.pipe(take(1))
|
||||
.subscribe(this.searchProductResultHandler, () =>
|
||||
this.invalidBarcodeDialog.openDialog()
|
||||
);
|
||||
.subscribe(this.searchProductResultHandler, () => this.invalidBarcodeDialog.openDialog());
|
||||
}
|
||||
|
||||
searchProductResultHandler = (remissionProduct: RemissionProduct) => {
|
||||
@@ -441,31 +405,18 @@ export class RemissionListCreateComponent implements OnInit, OnDestroy {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
Object.keys(process.filter).length &&
|
||||
process.filter.source &&
|
||||
process.filter.target
|
||||
);
|
||||
return Object.keys(process.filter).length && process.filter.source && process.filter.target;
|
||||
}
|
||||
|
||||
private syncContinuedProcessWithStore(process: RemissionProcess) {
|
||||
this.store.dispatch(new SetRemissionProcess(process, true));
|
||||
this.store.dispatch(
|
||||
new SetRemissionSource(process.filter.source as RemissionResourceType)
|
||||
);
|
||||
this.store.dispatch(
|
||||
new SetRemissionTarget(
|
||||
process.filter.target,
|
||||
process.filter.source as RemissionResourceType
|
||||
)
|
||||
);
|
||||
this.store.dispatch(new SetRemissionSource(process.filter.source as RemissionResourceType));
|
||||
this.store.dispatch(new SetRemissionTarget(process.filter.target, process.filter.source as RemissionResourceType));
|
||||
this.store.dispatch(new ActivateRemissionReminder());
|
||||
}
|
||||
|
||||
private initRemissionListHits() {
|
||||
this.remissionListHits$ = this.remissionHelper.remissionListHits$.pipe(
|
||||
filter((hits) => !isNullOrUndefined(hits))
|
||||
);
|
||||
this.remissionListHits$ = this.remissionHelper.remissionListHits$.pipe(filter((hits) => !isNullOrUndefined(hits)));
|
||||
}
|
||||
|
||||
private initFiltersSync() {
|
||||
|
||||
@@ -10,38 +10,15 @@ import {
|
||||
QueryList,
|
||||
} from '@angular/core';
|
||||
import { Subject, Observable, BehaviorSubject } from 'rxjs';
|
||||
import {
|
||||
takeUntil,
|
||||
filter,
|
||||
take,
|
||||
switchMap,
|
||||
catchError,
|
||||
delay,
|
||||
withLatestFrom,
|
||||
map,
|
||||
first,
|
||||
startWith,
|
||||
} from 'rxjs/operators';
|
||||
import {
|
||||
RemissionResourceType,
|
||||
RemissionTargetType,
|
||||
} from '../../models/remission-resource-type.model';
|
||||
import { takeUntil, filter, take, switchMap, catchError, delay, withLatestFrom, map, first, startWith } from 'rxjs/operators';
|
||||
import { RemissionResourceType, RemissionTargetType } from '../../models/remission-resource-type.model';
|
||||
import { ResourceTypeSpecificModel } from '../../models/resource-type-specific-model.model';
|
||||
import { CapacityTypeClientWrapper } from '../../models/capacity-type-client-wrapper.model';
|
||||
import {
|
||||
RemissionSupplier,
|
||||
RemissionService,
|
||||
RemissionSourceType,
|
||||
RemissionProcess,
|
||||
ShippingDocument,
|
||||
} from '@isa/remission';
|
||||
import { RemissionSupplier, RemissionService, RemissionSourceType, RemissionProcess, ShippingDocument } from '@isa/remission';
|
||||
import { Select, Store } from '@ngxs/store';
|
||||
import { RemissionSelectors } from 'apps/sales/src/app/core/store/selectors/remission.selectors';
|
||||
import { RemissionProcessStatuses } from 'apps/sales/src/app/core/models/remission-process-statuses.model';
|
||||
import {
|
||||
RESOURCE_TYPE_SPECIFIC_MODEL_OPTIONS,
|
||||
RESOURCE_TYPE_SWITCH,
|
||||
} from '../../constants/remission.constants';
|
||||
import { RESOURCE_TYPE_SPECIFIC_MODEL_OPTIONS, RESOURCE_TYPE_SWITCH } from '../../constants/remission.constants';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import {
|
||||
SetRemissionProcess,
|
||||
@@ -92,10 +69,8 @@ export class RemissionListStartedComponent implements OnInit, OnDestroy {
|
||||
shippingDocumentRef: QueryList<ElementRef>;
|
||||
|
||||
destroy$ = new Subject();
|
||||
selectedRemissionResourceType: RemissionResourceType =
|
||||
RemissionResourceType.Central;
|
||||
selectedResourceTypeSpecificModel: ResourceTypeSpecificModel =
|
||||
RESOURCE_TYPE_SPECIFIC_MODEL_OPTIONS[this.selectedRemissionResourceType];
|
||||
selectedRemissionResourceType: RemissionResourceType = RemissionResourceType.Central;
|
||||
selectedResourceTypeSpecificModel: ResourceTypeSpecificModel = RESOURCE_TYPE_SPECIFIC_MODEL_OPTIONS[this.selectedRemissionResourceType];
|
||||
capacities: CapacityTypeClientWrapper[] = [];
|
||||
|
||||
resourceTypeSwitch = RESOURCE_TYPE_SWITCH;
|
||||
@@ -131,22 +106,14 @@ export class RemissionListStartedComponent implements OnInit, OnDestroy {
|
||||
|
||||
initViewController() {
|
||||
this.showCreationPage$ = this.shippingDocumentStatus$.pipe(
|
||||
filter(
|
||||
(isShippingDocumentCreated) =>
|
||||
!isNullOrUndefined(isShippingDocumentCreated)
|
||||
),
|
||||
filter((isShippingDocumentCreated) => !isNullOrUndefined(isShippingDocumentCreated)),
|
||||
map((isShippingDocumentCreated) => !isShippingDocumentCreated)
|
||||
);
|
||||
}
|
||||
|
||||
initCompleteButtonStatus() {
|
||||
this.isCompleteButtomEnabled$ = this.shippingDocument$.pipe(
|
||||
map(
|
||||
(shippingDocument) =>
|
||||
!!shippingDocument &&
|
||||
!!shippingDocument.products &&
|
||||
!!shippingDocument.products.length
|
||||
),
|
||||
map((shippingDocument) => !!shippingDocument && !!shippingDocument.products && !!shippingDocument.products.length),
|
||||
startWith(false)
|
||||
);
|
||||
}
|
||||
@@ -164,9 +131,7 @@ export class RemissionListStartedComponent implements OnInit, OnDestroy {
|
||||
this.currentRemissionTarget$
|
||||
.pipe(
|
||||
withLatestFrom(this.remissionSuppliers$),
|
||||
map(([target, suppliers]) =>
|
||||
suppliers.find((supplier) => supplier.name === target)
|
||||
),
|
||||
map(([target, suppliers]) => suppliers.find((supplier) => supplier.name === target)),
|
||||
filter((data) => !isNullOrUndefined(data)),
|
||||
take(1)
|
||||
)
|
||||
@@ -186,15 +151,11 @@ export class RemissionListStartedComponent implements OnInit, OnDestroy {
|
||||
process$ = this.continueProcess();
|
||||
}
|
||||
|
||||
return process$.pipe(
|
||||
filter((process) => !isNullOrUndefined(process))
|
||||
);
|
||||
return process$.pipe(filter((process) => !isNullOrUndefined(process)));
|
||||
}),
|
||||
take(1)
|
||||
)
|
||||
.subscribe((process) => {
|
||||
console.log('SET REMISSION STATUS', process);
|
||||
|
||||
this.store.dispatch(new SetRemissionProcess(process));
|
||||
});
|
||||
}
|
||||
@@ -218,15 +179,13 @@ export class RemissionListStartedComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
});
|
||||
|
||||
this.remissionHelper.filtersUpdated$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(() => {
|
||||
setTimeout(() => {
|
||||
if (this.remissionList) {
|
||||
this.remissionList.setFullListLoadedToFalse();
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
this.remissionHelper.filtersUpdated$.pipe(takeUntil(this.destroy$)).subscribe(() => {
|
||||
setTimeout(() => {
|
||||
if (this.remissionList) {
|
||||
this.remissionList.setFullListLoadedToFalse();
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
||||
initAutomaticRedirect() {
|
||||
@@ -245,14 +204,12 @@ export class RemissionListStartedComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
continueProcess(): Observable<RemissionProcess> {
|
||||
return this.currentRemissionProcess$
|
||||
.pipe(filter((data) => !isNullOrUndefined(data), take(1)))
|
||||
.pipe(
|
||||
switchMap((process) => {
|
||||
return this.remissionService.continueProcess(process);
|
||||
}),
|
||||
catchError(this.continueProcessErrorHandler)
|
||||
);
|
||||
return this.currentRemissionProcess$.pipe(filter((data) => !isNullOrUndefined(data), take(1))).pipe(
|
||||
switchMap((process) => {
|
||||
return this.remissionService.continueProcess(process);
|
||||
}),
|
||||
catchError(this.continueProcessErrorHandler)
|
||||
);
|
||||
}
|
||||
|
||||
continueProcessErrorHandler = (error: any) => {
|
||||
@@ -267,19 +224,11 @@ export class RemissionListStartedComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
remissionSourcesFilter = (remissionSources: RemissionSourceType[]) => {
|
||||
return (
|
||||
remissionSources &&
|
||||
Array.isArray(remissionSources) &&
|
||||
remissionSources.length === 2
|
||||
);
|
||||
return remissionSources && Array.isArray(remissionSources) && remissionSources.length === 2;
|
||||
};
|
||||
|
||||
remissionSuppliersFilter = (remissionSuppliers: RemissionSupplier[]) => {
|
||||
return (
|
||||
remissionSuppliers &&
|
||||
Array.isArray(remissionSuppliers) &&
|
||||
remissionSuppliers.length === 2
|
||||
);
|
||||
return remissionSuppliers && Array.isArray(remissionSuppliers) && remissionSuppliers.length === 2;
|
||||
};
|
||||
|
||||
restoreProcess = () => {
|
||||
@@ -290,11 +239,7 @@ export class RemissionListStartedComponent implements OnInit, OnDestroy {
|
||||
};
|
||||
|
||||
completeShippingDocument() {
|
||||
this.store.dispatch(
|
||||
new SetRemissionFinishedProcessStatus(
|
||||
RemissionFinishingProcessStatus.start
|
||||
)
|
||||
);
|
||||
this.store.dispatch(new SetRemissionFinishedProcessStatus(RemissionFinishingProcessStatus.start));
|
||||
this.navigateToFinishRemission();
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user