From eba2e51541385ea669dfde8a53a74d658acde9a9 Mon Sep 17 00:00:00 2001
From: Rinat Arsaev <11846445+A77AY@users.noreply.github.com>
Date: Tue, 19 Sep 2023 15:49:17 +0400
Subject: [PATCH] IMP-81: New select autocomple for terminals, party and others
(#256)
---
package-lock.json | 25 +----
package.json | 3 +-
.../add-routing-rule-dialog.component.html | 17 ++--
.../add-routing-rule-dialog.component.ts | 4 -
.../add-routing-rule-dialog.module.ts | 3 +
.../add-routing-rule-dialog.service.ts | 4 +-
.../routing-ruleset.component.html | 2 +-
.../domain-object-field.component.html | 4 +-
.../domain-object-field.component.ts | 32 +++---
.../merchant-field.component.html | 6 +-
.../merchant-field.component.ts | 65 ++++++------
.../merchant-field/merchant-field.module.ts | 5 +-
.../payout-tool-field.component.html | 6 +-
.../payout-tool-field.component.ts | 29 ++----
.../payout-tool-field.module.ts | 6 +-
.../shared/services/fetch-parties.service.ts | 12 ++-
src/components/select-search-field/index.ts | 4 -
.../select-search-field.component.html | 59 -----------
.../select-search-field.component.scss | 9 --
.../select-search-field.component.ts | 99 -------------------
.../select-search-field.module.ts | 31 ------
src/components/select-search-field/tokens.ts | 8 --
.../select-search-field/types/index.ts | 1 -
.../select-search-field/types/option.ts | 5 -
.../utils/filter-options.ts | 14 ---
.../select-search-field/utils/index.ts | 1 -
.../create-control-providers.ts | 4 +
.../provide-validators.ts | 4 +
.../provide-value-accessor.ts | 4 +
.../utils/get-errors-tree.ts | 1 +
.../validated-control-superclass.directive.ts | 3 +
...dated-form-control-superclass.directive.ts | 3 +
32 files changed, 115 insertions(+), 358 deletions(-)
delete mode 100644 src/components/select-search-field/index.ts
delete mode 100644 src/components/select-search-field/select-search-field.component.html
delete mode 100644 src/components/select-search-field/select-search-field.component.scss
delete mode 100644 src/components/select-search-field/select-search-field.component.ts
delete mode 100644 src/components/select-search-field/select-search-field.module.ts
delete mode 100644 src/components/select-search-field/tokens.ts
delete mode 100644 src/components/select-search-field/types/index.ts
delete mode 100644 src/components/select-search-field/types/option.ts
delete mode 100644 src/components/select-search-field/utils/filter-options.ts
delete mode 100644 src/components/select-search-field/utils/index.ts
diff --git a/package-lock.json b/package-lock.json
index ea7476cb..d051a19f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -29,7 +29,7 @@
"@vality/dominant-cache-proto": "2.0.1-99f38c9.0",
"@vality/fistful-proto": "2.0.0",
"@vality/magista-proto": "2.0.2-e46bba2.0",
- "@vality/ng-core": "16.2.1-pr-33-0ae5287.0",
+ "@vality/ng-core": "16.2.1-pr-33-0e1ce8c.0",
"@vality/payout-manager-proto": "2.0.1-b079679.0",
"@vality/repairer-proto": "2.0.1-8f7973d.0",
"@vality/thrift-ts": "2.4.1-8ad5123.0",
@@ -44,7 +44,6 @@
"lodash-es": "4.17.21",
"moment": "2.29.4",
"monaco-editor": "0.21.2",
- "ngx-mat-select-search": "7.0.2",
"papaparse": "5.4.1",
"rxjs": "7.8.1",
"short-uuid": "4.2.2",
@@ -6002,9 +6001,9 @@
"integrity": "sha512-2cPVToAJRdt1CFQ6G/C6ngw6hp94Jp7WFtPtNvtlcCSXRYRnppoi3KpK14tBH9SlLeqrpSy0IrIsCnAkj7tFfg=="
},
"node_modules/@vality/ng-core": {
- "version": "16.2.1-pr-33-0ae5287.0",
- "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-16.2.1-pr-33-0ae5287.0.tgz",
- "integrity": "sha512-utA80+v58QMxzgNcLZ1hFRAO5RGcCyDW6/TJl1FZmDhja/P1FInZVWZIonaZJI/a+yf+YsSPboqM+QeQGZ595g==",
+ "version": "16.2.1-pr-33-0e1ce8c.0",
+ "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-16.2.1-pr-33-0e1ce8c.0.tgz",
+ "integrity": "sha512-nLPX5MtNjyBCeaqIngXjcPcp1tpD9GiLCOoCL0YukJT7wC9MQQg4npQl6SKGRR4rzGOotse71Fmk1EzVJEXP3A==",
"dependencies": {
"@ng-matero/extensions": "^16.0.0",
"@s-libs/js-core": "^16.0.0",
@@ -16754,22 +16753,6 @@
"@angular/core": ">=16.0.0-0"
}
},
- "node_modules/ngx-mat-select-search": {
- "version": "7.0.2",
- "resolved": "https://registry.npmjs.org/ngx-mat-select-search/-/ngx-mat-select-search-7.0.2.tgz",
- "integrity": "sha512-69vy/mWh7pnnR6rw1BWxO8E4HyylUvvBlmhrtWqXIYqfIx3mfvWuNj0tE1v+ERPg8a4vViFpfilRUUvvbrv1cA==",
- "dependencies": {
- "tslib": "^2.4.0"
- },
- "peerDependencies": {
- "@angular/material": "^15.0.0 || ^16.0.0"
- }
- },
- "node_modules/ngx-mat-select-search/node_modules/tslib": {
- "version": "2.5.3",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz",
- "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w=="
- },
"node_modules/nice-napi": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz",
diff --git a/package.json b/package.json
index 7f213fb0..fe3cb2c6 100644
--- a/package.json
+++ b/package.json
@@ -37,7 +37,7 @@
"@vality/dominant-cache-proto": "2.0.1-99f38c9.0",
"@vality/fistful-proto": "2.0.0",
"@vality/magista-proto": "2.0.2-e46bba2.0",
- "@vality/ng-core": "16.2.1-pr-33-0ae5287.0",
+ "@vality/ng-core": "16.2.1-pr-33-0e1ce8c.0",
"@vality/payout-manager-proto": "2.0.1-b079679.0",
"@vality/repairer-proto": "2.0.1-8f7973d.0",
"@vality/thrift-ts": "2.4.1-8ad5123.0",
@@ -52,7 +52,6 @@
"lodash-es": "4.17.21",
"moment": "2.29.4",
"monaco-editor": "0.21.2",
- "ngx-mat-select-search": "7.0.2",
"papaparse": "5.4.1",
"rxjs": "7.8.1",
"short-uuid": "4.2.2",
diff --git a/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.component.html b/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.component.html
index d2c23d23..51d98ca7 100644
--- a/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.component.html
+++ b/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.component.html
@@ -95,17 +95,12 @@
-
- Terminal
-
-
- {{ terminal.data.name }}
-
-
-
+
diff --git a/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.component.ts b/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.component.ts
index 53a281c5..7bbebdcf 100644
--- a/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.component.ts
+++ b/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.component.ts
@@ -5,8 +5,6 @@ import { domain } from '@vality/domain-proto';
import { Predicate } from '@vality/domain-proto/domain';
import { DialogSuperclass } from '@vality/ng-core';
-import { DomainStoreService } from '@cc/app/api/deprecated-damsel';
-
import { AddRoutingRuleDialogService, TerminalType } from './add-routing-rule-dialog.service';
@UntilDestroy()
@@ -25,12 +23,10 @@ export class AddRoutingRuleDialogComponent extends DialogSuperclass<
terminalType = TerminalType;
riskScore = domain.RiskScore;
- terminals$ = this.domainStoreService.getObjects('terminal');
constructor(
injector: Injector,
private addShopRoutingRuleDialogService: AddRoutingRuleDialogService,
- private domainStoreService: DomainStoreService,
private fb: FormBuilder,
) {
super(injector);
diff --git a/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.module.ts b/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.module.ts
index 6d1a2b66..36eba519 100644
--- a/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.module.ts
+++ b/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.module.ts
@@ -15,6 +15,8 @@ import { DialogModule } from '@vality/ng-core';
import { MetadataFormModule } from '@cc/app/shared/components/metadata-form';
+import { DomainObjectFieldComponent } from '../../../../shared';
+
import { AddRoutingRuleDialogComponent } from './add-routing-rule-dialog.component';
import { ExpanderComponent } from './expander';
import { PredicateComponent } from './predicate';
@@ -35,6 +37,7 @@ import { PredicateComponent } from './predicate';
MatAutocompleteModule,
MetadataFormModule,
DialogModule,
+ DomainObjectFieldComponent,
],
declarations: [AddRoutingRuleDialogComponent, PredicateComponent, ExpanderComponent],
exports: [AddRoutingRuleDialogComponent],
diff --git a/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.service.ts b/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.service.ts
index e10e5099..281c62e0 100644
--- a/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.service.ts
+++ b/src/app/sections/routing-rules/routing-ruleset/add-routing-rule-dialog/add-routing-rule-dialog.service.ts
@@ -4,7 +4,7 @@ import { MatDialogRef } from '@angular/material/dialog';
import { Predicate } from '@vality/domain-proto/domain';
import { DialogResponseStatus } from '@vality/ng-core';
import { of } from 'rxjs';
-import { startWith, switchMap, take } from 'rxjs/operators';
+import { startWith, take, switchMap } from 'rxjs/operators';
import { RoutingRulesService } from '../../services/routing-rules';
@@ -22,7 +22,7 @@ export class AddRoutingRuleDialogService {
weight: '',
priority: 1000,
terminalType: [null, Validators.required],
- existentTerminalID: ['', Validators.required],
+ existentTerminalID: [null, Validators.required],
newTerminal: this.fb.group({
name: ['', Validators.required],
description: ['', Validators.required],
diff --git a/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.html b/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.html
index 5f978086..0e8ccf1d 100644
--- a/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.html
+++ b/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.html
@@ -62,7 +62,7 @@
>
-
+
diff --git a/src/app/shared/components/domain-object-field/domain-object-field.component.html b/src/app/shared/components/domain-object-field/domain-object-field.component.html
index 2c1e6259..5d938d5e 100644
--- a/src/app/shared/components/domain-object-field/domain-object-field.component.html
+++ b/src/app/shared/components/domain-object-field/domain-object-field.component.html
@@ -1,6 +1,6 @@
-
+>
diff --git a/src/app/shared/components/domain-object-field/domain-object-field.component.ts b/src/app/shared/components/domain-object-field/domain-object-field.component.ts
index 148c66bb..49ae8e7c 100644
--- a/src/app/shared/components/domain-object-field/domain-object-field.component.ts
+++ b/src/app/shared/components/domain-object-field/domain-object-field.component.ts
@@ -1,8 +1,14 @@
import { CommonModule } from '@angular/common';
import { Component, Input, OnChanges } from '@angular/core';
-import { FormControl, ReactiveFormsModule } from '@angular/forms';
+import { ReactiveFormsModule } from '@angular/forms';
import { DomainObject } from '@vality/domain-proto/internal/domain';
-import { ComponentChanges } from '@vality/ng-core';
+import {
+ ComponentChanges,
+ FormControlSuperclass,
+ createControlProviders,
+ SelectFieldModule,
+ Option,
+} from '@vality/ng-core';
import { defer, switchMap, ReplaySubject } from 'rxjs';
import { shareReplay, map } from 'rxjs/operators';
@@ -12,24 +18,22 @@ import {
OtherDomainObjects,
defaultDomainObjectToOption,
} from '@cc/app/shared/services/domain-metadata-form-extensions/utils/domains-objects-to-options';
-import { SelectSearchFieldModule } from '@cc/components/select-search-field';
-import { ValidatedFormControlSuperclass, provideValueAccessor } from '@cc/utils';
+
+type DomainObjectID = unknown;
@Component({
standalone: true,
selector: 'cc-domain-object-field',
templateUrl: './domain-object-field.component.html',
- providers: [provideValueAccessor(() => DomainObjectFieldComponent)],
- imports: [CommonModule, SelectSearchFieldModule, ReactiveFormsModule],
+ providers: createControlProviders(() => DomainObjectFieldComponent),
+ imports: [CommonModule, ReactiveFormsModule, SelectFieldModule],
})
export class DomainObjectFieldComponent
- extends ValidatedFormControlSuperclass
+ extends FormControlSuperclass
implements OnChanges
{
@Input() name: T;
- control = new FormControl(null);
-
options$ = defer(() => this.name$).pipe(
switchMap((name) => this.domainStoreService.getObjects(name)),
map((objs) => {
@@ -37,9 +41,13 @@ export class DomainObjectFieldComponent
this.name in DOMAIN_OBJECTS_TO_OPTIONS
? DOMAIN_OBJECTS_TO_OPTIONS[this.name as keyof OtherDomainObjects]
: defaultDomainObjectToOption;
- return objs
- .map(domainObjectToOption)
- .map((o) => ({ ...o, description: `#${String(o.value)}` }));
+ return objs.map(domainObjectToOption).map(
+ (o): Option => ({
+ label: o.label,
+ value: o.value,
+ description: String(o.value),
+ }),
+ );
}),
shareReplay({ bufferSize: 1, refCount: true }),
);
diff --git a/src/app/shared/components/merchant-field/merchant-field.component.html b/src/app/shared/components/merchant-field/merchant-field.component.html
index f13b51b9..b31057d0 100644
--- a/src/app/shared/components/merchant-field/merchant-field.component.html
+++ b/src/app/shared/components/merchant-field/merchant-field.component.html
@@ -1,9 +1,9 @@
-
+>
diff --git a/src/app/shared/components/merchant-field/merchant-field.component.ts b/src/app/shared/components/merchant-field/merchant-field.component.ts
index 00219a6e..bc626092 100644
--- a/src/app/shared/components/merchant-field/merchant-field.component.ts
+++ b/src/app/shared/components/merchant-field/merchant-field.component.ts
@@ -1,24 +1,17 @@
import { Component, Input, AfterViewInit } from '@angular/core';
-import { MatSnackBar } from '@angular/material/snack-bar';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { PartyID } from '@vality/domain-proto/domain';
-import { coerceBoolean } from 'coerce-property';
-import { BehaviorSubject, Observable, of, ReplaySubject, Subject, merge } from 'rxjs';
import {
- catchError,
- debounceTime,
- filter,
- map,
- switchMap,
- first,
- takeUntil,
- startWith,
-} from 'rxjs/operators';
+ Option,
+ NotifyLogService,
+ FormControlSuperclass,
+ createControlProviders,
+} from '@vality/ng-core';
+import { coerceBoolean } from 'coerce-property';
+import { BehaviorSubject, Observable, of, ReplaySubject, Subject } from 'rxjs';
+import { catchError, debounceTime, map, switchMap, tap, startWith } from 'rxjs/operators';
import { DeanonimusService } from '@cc/app/api/deanonimus';
-import { Option } from '@cc/components/select-search-field';
-import { createControlProviders, ValidatedFormControlSuperclass } from '@cc/utils';
-import { progressTo } from '@cc/utils/operators';
@UntilDestroy()
@Component({
@@ -27,7 +20,7 @@ import { progressTo } from '@cc/utils/operators';
providers: createControlProviders(() => MerchantFieldComponent),
})
export class MerchantFieldComponent
- extends ValidatedFormControlSuperclass
+ extends FormControlSuperclass
implements AfterViewInit
{
@Input() label: string;
@@ -35,41 +28,45 @@ export class MerchantFieldComponent
options$ = new ReplaySubject