From 26c69442801a36e504a3af8945c4a33fd56338a7 Mon Sep 17 00:00:00 2001 From: Rinat Arsaev <11846445+A77AY@users.noreply.github.com> Date: Mon, 20 Nov 2023 23:27:41 +0700 Subject: [PATCH] IMP-125: Fix optional value of thrift form (#288) --- package-lock.json | 8 +- package.json | 2 +- .../domain-group/domain-group.component.html | 3 +- .../domain-info/domain-info.component.ts | 4 +- .../domain-obj-modification.component.ts | 11 ++- .../domain-obj-review.component.ts | 4 +- .../sections/domain/domain-routing.module.ts | 4 +- .../domain-obj-modification.service.ts | 2 +- .../sections/payments/payments.component.html | 4 +- .../create-payout-dialog.component.html | 2 +- .../repair-by-scenario-dialog.component.html | 9 ++- .../repairing/repairing.component.html | 5 +- .../create-adjustment-dialog.component.html | 7 +- ...e-chargebacks-status-dialog.component.html | 2 +- .../json-viewer/json-viewer.component.html | 24 ++++-- .../complex-form/complex-form.component.ts | 8 +- .../primitive-field.component.html | 80 ++++--------------- .../primitive-field.component.ts | 49 +++++++----- .../struct-form/struct-form.component.html | 2 +- .../union-field/union-field.component.html | 5 +- .../metadata-form/metadata-form.module.ts | 3 +- ...tional-bank-account-details.component.html | 2 +- ...ussian-bank-account-details.component.html | 2 +- .../payout-tool-details.component.html | 6 +- .../thrift-viewer.component.html | 2 +- .../thrift-viewer.component.scss | 4 + 26 files changed, 123 insertions(+), 131 deletions(-) diff --git a/package-lock.json b/package-lock.json index a092a065..7f767146 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,7 @@ "@vality/domain-proto": "2.0.1-45b0719.0", "@vality/fistful-proto": "2.0.1-3b9a0a7.0", "@vality/magista-proto": "2.0.2-4383410.0", - "@vality/ng-core": "16.2.1-pr-49-6a1a300.0", + "@vality/ng-core": "16.2.1-pr-49-05562a6.0", "@vality/payout-manager-proto": "2.0.1-eb4091a.0", "@vality/repairer-proto": "2.0.2-07b73e9.0", "@vality/thrift-ts": "2.4.1-8ad5123.0", @@ -5966,9 +5966,9 @@ "integrity": "sha512-kAiKSTvof+jFuNkQKyAsc2s+Br2NXPWAyKuD0f7mQIk9HrP8uHsKJya5KxdOdng97JYe0MSUlx7seQxWmCgYfA==" }, "node_modules/@vality/ng-core": { - "version": "16.2.1-pr-49-6a1a300.0", - "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-16.2.1-pr-49-6a1a300.0.tgz", - "integrity": "sha512-ZIJtxfBqfqyMbjtt1OUJwEzGJxI2sIBYVldn/LXKB1WqK3rICfmwQL1tannuVD1SD8z41sW5cC/70W/ax/FZxQ==", + "version": "16.2.1-pr-49-05562a6.0", + "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-16.2.1-pr-49-05562a6.0.tgz", + "integrity": "sha512-QUkFbN+e2BgfWnyVpaEVHqJJotcmBLgaoznoJo+smGz8JBje0UdGUxX8lroqRMJ2flZ8gprEO9iqBRZwGqpN5A==", "dependencies": { "@angular/material-date-fns-adapter": "^16.0.0", "@ng-matero/extensions": "^16.0.0", diff --git a/package.json b/package.json index 8c60a83c..158d3dd1 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@vality/domain-proto": "2.0.1-45b0719.0", "@vality/fistful-proto": "2.0.1-3b9a0a7.0", "@vality/magista-proto": "2.0.2-4383410.0", - "@vality/ng-core": "16.2.1-pr-49-6a1a300.0", + "@vality/ng-core": "16.2.1-pr-49-05562a6.0", "@vality/payout-manager-proto": "2.0.1-eb4091a.0", "@vality/repairer-proto": "2.0.2-07b73e9.0", "@vality/thrift-ts": "2.4.1-8ad5123.0", diff --git a/src/app/sections/domain/domain-info/domain-group/domain-group.component.html b/src/app/sections/domain/domain-info/domain-group/domain-group.component.html index 1ba087f8..75254e70 100644 --- a/src/app/sections/domain/domain-info/domain-group/domain-group.component.html +++ b/src/app/sections/domain/domain-info/domain-group/domain-group.component.html @@ -1,10 +1,11 @@
-
+
Search diff --git a/src/app/sections/domain/domain-info/domain-info.component.ts b/src/app/sections/domain/domain-info/domain-info.component.ts index 1cf8dc59..215d858c 100644 --- a/src/app/sections/domain/domain-info/domain-info.component.ts +++ b/src/app/sections/domain/domain-info/domain-info.component.ts @@ -59,7 +59,9 @@ export class DomainInfoComponent { ) {} edit() { - void this.router.navigate(['domain', 'edit', JSON.stringify(this.objWithRef.ref)]); + void this.router.navigate(['domain', 'edit'], { + queryParams: { ref: JSON.stringify(this.objWithRef.ref) }, + }); } delete() { diff --git a/src/app/sections/domain/domain-obj-modification/domain-obj-modification.component.ts b/src/app/sections/domain/domain-obj-modification/domain-obj-modification.component.ts index 0f17c0c6..52d9dfb9 100644 --- a/src/app/sections/domain/domain-obj-modification/domain-obj-modification.component.ts +++ b/src/app/sections/domain/domain-obj-modification/domain-obj-modification.component.ts @@ -61,7 +61,7 @@ export class DomainObjModificationComponent implements OnInit { this.domainObjModService.object$.pipe(first(), untilDestroyed(this)).subscribe((object) => { if ( this.modifiedDomainObjectService.domainObject && - this.route.snapshot.params.ref === this.modifiedDomainObjectService.ref + this.route.snapshot.queryParams.ref === this.modifiedDomainObjectService.ref ) { this.control.setValue(this.modifiedDomainObjectService.domainObject); } else { @@ -71,8 +71,13 @@ export class DomainObjModificationComponent implements OnInit { } reviewChanges() { - this.modifiedDomainObjectService.update(this.control.value, this.route.snapshot.params.ref); - void this.router.navigate(['domain', 'edit', this.route.snapshot.params.ref, 'review']); + this.modifiedDomainObjectService.update( + this.control.value, + this.route.snapshot.queryParams.ref, + ); + void this.router.navigate(['domain', 'review'], { + queryParams: { ref: this.route.snapshot.queryParams.ref }, + }); } backToDomain() { diff --git a/src/app/sections/domain/domain-obj-review/domain-obj-review.component.ts b/src/app/sections/domain/domain-obj-review/domain-obj-review.component.ts index 1db0ce83..fccace06 100644 --- a/src/app/sections/domain/domain-obj-review/domain-obj-review.component.ts +++ b/src/app/sections/domain/domain-obj-review/domain-obj-review.component.ts @@ -76,6 +76,8 @@ export class DomainObjReviewComponent { } back() { - void this.router.navigate(['domain', 'edit', this.route.snapshot.params.ref]); + void this.router.navigate(['domain', 'edit'], { + queryParams: { ref: this.route.snapshot.queryParams.ref }, + }); } } diff --git a/src/app/sections/domain/domain-routing.module.ts b/src/app/sections/domain/domain-routing.module.ts index c270b01a..d990c482 100644 --- a/src/app/sections/domain/domain-routing.module.ts +++ b/src/app/sections/domain/domain-routing.module.ts @@ -26,11 +26,11 @@ import { ROUTING_CONFIG } from './routing-config'; component: DomainObjCreationComponent, }, { - path: 'edit/:ref', + path: 'edit', component: DomainObjModificationComponent, }, { - path: 'edit/:ref/review', + path: 'review', component: DomainObjReviewComponent, }, ], diff --git a/src/app/sections/domain/services/domain-obj-modification.service.ts b/src/app/sections/domain/services/domain-obj-modification.service.ts index a9382da1..933f698e 100644 --- a/src/app/sections/domain/services/domain-obj-modification.service.ts +++ b/src/app/sections/domain/services/domain-obj-modification.service.ts @@ -25,7 +25,7 @@ export class DomainObjModificationService { shareReplay({ refCount: true, bufferSize: 1 }), ); - private ref$ = this.route.params.pipe( + private ref$ = this.route.queryParams.pipe( map(({ ref }) => { try { return JSON.parse(ref as string) as Reference; diff --git a/src/app/sections/payments/payments.component.html b/src/app/sections/payments/payments.component.html index db62ffd3..6be9f190 100644 --- a/src/app/sections/payments/payments.component.html +++ b/src/app/sections/payments/payments.component.html @@ -44,10 +44,10 @@ diff --git a/src/app/sections/payouts/payouts/components/create-payout-dialog/create-payout-dialog.component.html b/src/app/sections/payouts/payouts/components/create-payout-dialog/create-payout-dialog.component.html index 0162b930..1225e9c8 100644 --- a/src/app/sections/payouts/payouts/components/create-payout-dialog/create-payout-dialog.component.html +++ b/src/app/sections/payouts/payouts/components/create-payout-dialog/create-payout-dialog.component.html @@ -1,5 +1,5 @@ -
+
-
+ +
Type @@ -8,7 +8,10 @@ - + Same Different diff --git a/src/app/sections/repairing/repairing.component.html b/src/app/sections/repairing/repairing.component.html index 8e6e4942..9b7cf5c0 100644 --- a/src/app/sections/repairing/repairing.component.html +++ b/src/app/sections/repairing/repairing.component.html @@ -1,6 +1,9 @@ - + Namespace diff --git a/src/app/sections/withdrawals/components/create-adjustment-dialog/create-adjustment-dialog.component.html b/src/app/sections/withdrawals/components/create-adjustment-dialog/create-adjustment-dialog.component.html index 1c96899d..a7715a41 100644 --- a/src/app/sections/withdrawals/components/create-adjustment-dialog/create-adjustment-dialog.component.html +++ b/src/app/sections/withdrawals/components/create-adjustment-dialog/create-adjustment-dialog.component.html @@ -1,6 +1,9 @@ -
- +
+ Use ID from withdrawal Generate ID diff --git a/src/app/shared/components/change-chargebacks-status-dialog/change-chargebacks-status-dialog.component.html b/src/app/shared/components/change-chargebacks-status-dialog/change-chargebacks-status-dialog.component.html index a2f0c2eb..e6b2be51 100644 --- a/src/app/shared/components/change-chargebacks-status-dialog/change-chargebacks-status-dialog.component.html +++ b/src/app/shared/components/change-chargebacks-status-dialog/change-chargebacks-status-dialog.component.html @@ -6,7 +6,7 @@ : dialogData.chargebacks.length + ' chargebacks' }} status" > -
+
Action diff --git a/src/app/shared/components/json-viewer/json-viewer.component.html b/src/app/shared/components/json-viewer/json-viewer.component.html index f2f952ec..077bd35e 100644 --- a/src/app/shared/components/json-viewer/json-viewer.component.html +++ b/src/app/shared/components/json-viewer/json-viewer.component.html @@ -1,14 +1,20 @@ -
+
@@ -30,8 +36,12 @@
const values = this.valueControls.value; switch (this.data.type.name) { case 'list': - this.emitOutgoingValue(values); + this.emitOutgoingValue(values.length ? values : null); break; case 'map': { const keys = this.keyControls.value; - this.emitOutgoingValue(new Map(values.map((v, idx) => [keys[idx], v]))); + this.emitOutgoingValue( + keys.length ? new Map(values.map((v, idx) => [keys[idx], v])) : null, + ); break; } case 'set': - this.emitOutgoingValue(new Set(values)); + this.emitOutgoingValue(values.length ? new Set(values) : null); break; } }); diff --git a/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.html b/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.html index 7d273372..d3147e25 100644 --- a/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.html +++ b/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.html @@ -12,15 +12,15 @@ > False True - -
- - - -
-
- {{ option.value }} -
- -
-
-
-
- + @@ -116,7 +64,9 @@ - +
+ +
diff --git a/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.ts b/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.ts index a01ca22f..407d95b3 100644 --- a/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.ts +++ b/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.ts @@ -1,19 +1,23 @@ import { Component, Input, OnChanges } from '@angular/core'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import { ComponentChanges } from '@vality/ng-core'; +import { + ComponentChanges, + Option, + FormControlSuperclass, + createControlProviders, +} from '@vality/ng-core'; import { ThriftType } from '@vality/thrift-ts'; import { combineLatest, defer, ReplaySubject, switchMap, Observable } from 'rxjs'; -import { map, pluck, shareReplay, startWith } from 'rxjs/operators'; +import { map, shareReplay, startWith } from 'rxjs/operators'; import { getValueTypeTitle } from '@cc/app/shared'; import { MetadataFormExtensionResult, MetadataFormExtension, } from '@cc/app/shared/components/metadata-form'; -import { getFirstDeterminedExtensionsResult } from '@cc/app/shared/components/metadata-form/types/metadata-form-extension'; -import { createControlProviders, ValidatedFormControlSuperclass } from '@cc/utils'; import { MetadataFormData, getAliases } from '../../types/metadata-form-data'; +import { getFirstDeterminedExtensionsResult } from '../../types/metadata-form-extension'; @UntilDestroy() @Component({ @@ -21,10 +25,7 @@ import { MetadataFormData, getAliases } from '../../types/metadata-form-data'; templateUrl: './primitive-field.component.html', providers: createControlProviders(() => PrimitiveFieldComponent), }) -export class PrimitiveFieldComponent - extends ValidatedFormControlSuperclass - implements OnChanges -{ +export class PrimitiveFieldComponent extends FormControlSuperclass implements OnChanges { @Input() data: MetadataFormData; @Input() extensions: MetadataFormExtension[]; @@ -35,22 +36,26 @@ export class PrimitiveFieldComponent switchMap(([data, extensions]) => getFirstDeterminedExtensionsResult(extensions, data)), shareReplay({ refCount: true, bufferSize: 1 }), ); - generate$ = this.extensionResult$.pipe(pluck('generate')); - selected$ = combineLatest([this.extensionResult$, this.control.valueChanges]).pipe( - map(([extensionResult, value]) => extensionResult?.options?.find((o) => o.value === value)), - ); - filteredOptions$ = combineLatest([ - this.control.valueChanges.pipe(startWith('')), + generate$ = this.extensionResult$.pipe(map((r) => r?.generate)); + selected$ = combineLatest([ this.extensionResult$, + this.control.valueChanges.pipe(startWith(this.control.value)), ]).pipe( - map(([value, extensionResult]) => { - const filterValue = String(value ?? '').toLowerCase(); - return extensionResult.options?.filter( - (option) => - String(option.value).toLowerCase().includes(filterValue) || - (option.label && option.label.toLowerCase().includes(filterValue)), - ); - }), + map( + ([extensionResult]) => + extensionResult?.options?.find((o) => o.value === this.control.value), + ), + ); + options$ = this.extensionResult$.pipe( + map((extensionResult): Option[] => + extensionResult?.options?.length + ? extensionResult.options.map((o) => ({ + label: o.label, + value: o.value as never, + description: String(o.value), + })) + : null, + ), shareReplay({ refCount: true, bufferSize: 1 }), ); diff --git a/src/app/shared/components/metadata-form/components/struct-form/struct-form.component.html b/src/app/shared/components/metadata-form/components/struct-form/struct-form.component.html index 260cc046..bebf2c3d 100644 --- a/src/app/shared/components/metadata-form/components/struct-form/struct-form.component.html +++ b/src/app/shared/components/metadata-form/components/struct-form/struct-form.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/app/shared/components/metadata-form/components/union-field/union-field.component.html b/src/app/shared/components/metadata-form/components/union-field/union-field.component.html index 5184aa59..f5324d86 100644 --- a/src/app/shared/components/metadata-form/components/union-field/union-field.component.html +++ b/src/app/shared/components/metadata-form/components/union-field/union-field.component.html @@ -1,4 +1,4 @@ -
+
{{ data.type | fieldLabel: data.field }}