From cd544282c01285f28b74afd72a43ab5bd978994c Mon Sep 17 00:00:00 2001 From: Rinat Arsaev <11846445+A77AY@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:04:28 +0700 Subject: [PATCH] IMP-169: Add payout tool autocomplete for add modification (#331) --- package-lock.json | 8 ++--- package.json | 2 +- ...te-party-claim-metadata-form-extensions.ts | 33 ++++++++++++++++++- ...domain-metadata-view-extensions.service.ts | 10 ++++-- .../domain/utils/get-domain-object-details.ts | 4 +-- 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 066ef76a..74c27b4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "@vality/fistful-proto": "2.0.1-8ecf2b7.0", "@vality/machinegun-proto": "1.0.0", "@vality/magista-proto": "2.0.2-28d11b9.0", - "@vality/ng-core": "^17.2.1-pr-57-fa662ca.0", + "@vality/ng-core": "^17.2.1-pr-57-0134d85.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", @@ -6454,9 +6454,9 @@ "integrity": "sha512-BsDy5ejotfTtUlwuoX3kz+PYJ5NSTW6m5ZRGv+p5HaKXSjR7tserPdv0q133Wp4T+sg0ED0Qr9Peqsrn+9XlDQ==" }, "node_modules/@vality/ng-core": { - "version": "17.2.1-pr-57-fa662ca.0", - "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-17.2.1-pr-57-fa662ca.0.tgz", - "integrity": "sha512-VFqaxeAA2v/zmwfR7lsW9zvtjNz5SlXNNJtQBusT1V38AtoPkGu1J5JaoKQSrWwW2KwXYimaSeLF9tFuUAb4bw==", + "version": "17.2.1-pr-57-0134d85.0", + "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-17.2.1-pr-57-0134d85.0.tgz", + "integrity": "sha512-0wlLzf2+smFYVYqu/iEptyeKrasRsxWRd2hNwqG+cd0eiIwxNWyBMaI0+FuWS141CtodSgF8Ab8CAG2ceD+vkw==", "dependencies": { "@angular/material-date-fns-adapter": "^17.2.0", "@ng-matero/extensions": "^17.1.0", diff --git a/package.json b/package.json index 2f7fd654..7a7af47c 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@vality/fistful-proto": "2.0.1-8ecf2b7.0", "@vality/machinegun-proto": "1.0.0", "@vality/magista-proto": "2.0.2-28d11b9.0", - "@vality/ng-core": "^17.2.1-pr-57-fa662ca.0", + "@vality/ng-core": "^17.2.1-pr-57-0134d85.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/claim/components/modification-form/utils/create-party-claim-metadata-form-extensions.ts b/src/app/sections/claim/components/modification-form/utils/create-party-claim-metadata-form-extensions.ts index 717735d2..cc7357de 100644 --- a/src/app/sections/claim/components/modification-form/utils/create-party-claim-metadata-form-extensions.ts +++ b/src/app/sections/claim/components/modification-form/utils/create-party-claim-metadata-form-extensions.ts @@ -1,4 +1,4 @@ -import { Claim } from '@vality/domain-proto/claim_management'; +import { Claim, PayoutToolModificationUnit } from '@vality/domain-proto/claim_management'; import { Party } from '@vality/domain-proto/domain'; import uniqBy from 'lodash-es/uniqBy'; import { of } from 'rxjs'; @@ -34,6 +34,20 @@ function createClaimOptions( ); } +function createClaimPayoutToolOptions( + modificationUnits: PayoutToolModificationUnit[], +): MetadataFormExtensionOption[] { + return uniqBy( + modificationUnits.map((unit) => ({ + label: 'From claim', + details: unit.modification, + value: unit.payout_tool_id, + color: 'primary', + })), + 'value', + ); +} + function mergeClaimAndPartyOptions( claimOptions: MetadataFormExtensionOption[], partyOptions: MetadataFormExtensionOption[], @@ -125,5 +139,22 @@ export function createPartyClaimMetadataFormExtensions( isIdentifier: true, }), }, + { + determinant: (data) => of(isTypeWithAliases(data, 'PayoutToolID', 'domain')), + extension: () => + of({ + options: createClaimPayoutToolOptions( + claim.changeset + .map( + (unit) => + unit.modification.party_modification?.contract_modification + ?.modification?.payout_tool_modification, + ) + .filter(Boolean), + ), + generate, + isIdentifier: true, + }), + }, ]; } diff --git a/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/domain-metadata-view-extensions.service.ts b/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/domain-metadata-view-extensions.service.ts index 56442c4d..6deee1d3 100644 --- a/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/domain-metadata-view-extensions.service.ts +++ b/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/domain-metadata-view-extensions.service.ts @@ -87,9 +87,15 @@ export class DomainMetadataViewExtensionsService { return undefined; } const [ref, obj] = refObj; + const details = getDomainObjectDetails(obj); return { - value: getDomainObjectDetails(obj).label, - tooltip: getUnionValue(ref), + value: details.label, + tooltip: details.description + ? { + description: details.description, + ref: getUnionValue(ref), + } + : { ref: getUnionValue(ref) }, click: () => { this.sidenavInfoService.toggle( import( diff --git a/src/app/shared/components/thrift-api-crud/domain/utils/get-domain-object-details.ts b/src/app/shared/components/thrift-api-crud/domain/utils/get-domain-object-details.ts index d97ec268..6cb9b82e 100644 --- a/src/app/shared/components/thrift-api-crud/domain/utils/get-domain-object-details.ts +++ b/src/app/shared/components/thrift-api-crud/domain/utils/get-domain-object-details.ts @@ -42,8 +42,8 @@ const GET_DOMAIN_OBJECTS_DETAILS: { /* eslint-disable @typescript-eslint/naming-convention */ currency: (o) => ({ id: o.ref.symbolic_code, - label: o.data.name, - description: `Exponent: ${o.data.exponent}`, + label: o.ref.symbolic_code, + description: o.data.name, }), payment_method: (o) => ({ id: inlineJson(o.ref.id, Infinity),