@acorex-platform/module-person-core-client 0.0.15 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,11 @@
1
1
  import { AXToastService } from '@acorex/components/toast';
2
2
  import { AXTranslationService } from '@acorex/core/translation';
3
+ import { runtimeCommandPayloadData } from '@acorex-platform/framework-shared/core';
3
4
  import * as i0 from '@angular/core';
4
5
  import { inject, Injectable } from '@angular/core';
5
6
  import { AXPEntityDataSelectorService, AXPEntityFormBuilderService, AXPEntityDefinitionRegistryService } from '@acorex-platform/framework-client/layout/entity';
6
7
  import { resolveContactAssignmentPartyContext, RootConfig, buildContactAssignmentPersonSnapshot } from '@acorex-platform/module-person-core-client/contracts';
8
+ import { resolveEntityActionCommandInput, mergeEntityActionProcessData } from '@acorex-platform/framework-shared/runtime';
7
9
 
8
10
  //#region ---- Imports ----
9
11
  //#endregion
@@ -17,12 +19,9 @@ class AXMContactAssignmentAssignExistingPersonCommand {
17
19
  this.translationService = inject(AXTranslationService);
18
20
  }
19
21
  async execute(input) {
20
- const { entity, data, options, hostContext } = (input?.__context__ ?? input ?? {});
21
- const processData = {
22
- ...(hostContext ?? {}),
23
- ...(data ?? {}),
24
- ...(options?.process?.data ?? {}),
25
- };
22
+ const resolved = resolveEntityActionCommandInput(input);
23
+ const processData = mergeEntityActionProcessData(input);
24
+ const entity = resolved.entity;
26
25
  const locale = this.translationService.getActiveLang?.() ?? 'en-US';
27
26
  const partyContext = resolveContactAssignmentPartyContext(processData, locale);
28
27
  if (!partyContext.partyId) {
@@ -102,10 +101,10 @@ class AXMContactAssignmentAssignExistingPersonCommand {
102
101
  personId,
103
102
  person: personSnapshot,
104
103
  });
105
- if (createResult?.data ?? createResult) {
106
- return {
107
- success: true,
108
- data: createResult?.data ?? createResult,
104
+ const __single_createResult = runtimeCommandPayloadData(createResult);
105
+ if (__single_createResult) {
106
+ return { success: true, kind: 'object',
107
+ data: runtimeCommandPayloadData(createResult),
109
108
  message: {
110
109
  text: await this.translationService.translateAsync('@general:messages.generic.success.description'),
111
110
  },
@@ -136,13 +135,13 @@ class AXMContactAssignmentAssignExistingPersonCommand {
136
135
  .show();
137
136
  return result;
138
137
  }
139
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXMContactAssignmentAssignExistingPersonCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
140
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXMContactAssignmentAssignExistingPersonCommand, providedIn: 'root' }); }
138
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMContactAssignmentAssignExistingPersonCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
139
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMContactAssignmentAssignExistingPersonCommand, providedIn: 'root' }); }
141
140
  }
142
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXMContactAssignmentAssignExistingPersonCommand, decorators: [{
141
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMContactAssignmentAssignExistingPersonCommand, decorators: [{
143
142
  type: Injectable,
144
143
  args: [{ providedIn: 'root' }]
145
144
  }] });
146
145
 
147
146
  export { AXMContactAssignmentAssignExistingPersonCommand };
148
- //# sourceMappingURL=acorex-platform-module-person-core-client-assign-existing-person-to-party.command-DO3Z5pPU.mjs.map
147
+ //# sourceMappingURL=acorex-platform-module-person-core-client-assign-existing-person-to-party.command-CicvKND6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-person-core-client-assign-existing-person-to-party.command-CicvKND6.mjs","sources":["../../../../libs/modules/person-core/client/src/lib/commands/assign-existing-person-to-party.command.ts"],"sourcesContent":["//#region ---- Imports ----\n\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPRuntimeCommandResult, runtimeCommandPayloadData} from '@acorex-platform/framework-shared/core';\nimport { inject, Injectable } from '@angular/core';\nimport {\n AXPEntityDataSelectorService,\n AXPEntityDefinitionRegistryService,\n AXPEntityFormBuilderService,\n} from '@acorex-platform/framework-client/layout/entity';\n\nimport { RootConfig, buildContactAssignmentPersonSnapshot, resolveContactAssignmentPartyContext } from '@acorex-platform/module-person-core-client/contracts';\nimport {\n AXPCommand,\n mergeEntityActionProcessData,\n resolveEntityActionCommandInput,\n type AXPCommandExecuteResultPromise,\n} from '@acorex-platform/framework-shared/runtime';\n\n//#endregion\n\n//#region ---- Command ----\n\n@Injectable({ providedIn: 'root' })\nexport class AXMContactAssignmentAssignExistingPersonCommand implements AXPCommand<any, any> {\n private readonly entityDataSelector = inject(AXPEntityDataSelectorService);\n private readonly entityForm = inject(AXPEntityFormBuilderService);\n private readonly entityService = inject(AXPEntityDefinitionRegistryService);\n private readonly toastService = inject(AXToastService);\n private readonly translationService = inject(AXTranslationService);\n\n async execute(input: any): AXPCommandExecuteResultPromise<any> {\n const resolved = resolveEntityActionCommandInput(input);\n const processData = mergeEntityActionProcessData(input);\n const entity = resolved.entity;\n const locale = this.translationService.getActiveLang?.() ?? 'en-US';\n const partyContext = resolveContactAssignmentPartyContext(processData, locale);\n\n if (!partyContext.partyId) {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync(\n '@person-core:contact-assignments.messages.missing-party-context',\n ),\n },\n };\n }\n\n const [moduleName, entityName] = (entity || '').split('.');\n if (!moduleName || !entityName) {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync('@general:messages.entity.invalid-identifier'),\n },\n };\n }\n\n const personEntity = await this.entityService.resolve(\n RootConfig.module.name,\n RootConfig.entities.person.name,\n );\n if (!personEntity) {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync('@general:messages.entity.invalid-identifier'),\n },\n };\n }\n\n const selectorTitle = await this.translationService.translateAsync(\n '@person-core:contact-assignments.actions.assign-existing-person.selector-title',\n );\n const selectorResult = await this.entityDataSelector.open({\n entity: personEntity,\n title: selectorTitle,\n allowMultiple: false,\n columns: ['fullName', 'phones', 'emails'],\n });\n\n if (!selectorResult?.items?.length) {\n return { success: false };\n }\n\n const selectedPerson = selectorResult.items[0];\n const personId = selectedPerson.id ?? selectedPerson._id;\n const personSnapshot = buildContactAssignmentPersonSnapshot(\n selectedPerson as Record<string, unknown>,\n personId as string,\n );\n\n const formTitle = await this.translationService.translateAsync(\n '@person-core:contact-assignments.actions.assign-existing-person.form-title',\n { params: { partyTitle: partyContext.partyTitle } },\n );\n\n const result = await this.entityForm\n .entity(`${moduleName}.${entityName}`)\n .create({\n partyId: partyContext.partyId,\n personId,\n person: personSnapshot,\n })\n .include('roleId', 'notes')\n .title(formTitle)\n .actions((actions) => {\n actions.cancel('@general:actions.cancel.title');\n actions.submit('@general:actions.create.title');\n })\n .onAction<AXPRuntimeCommandResult<any>>(async (dialogRef) => {\n if (dialogRef.action() === 'cancel') {\n return { success: false };\n }\n\n const contactAssignmentEntity = await this.entityService.resolve(moduleName, entityName);\n const createFn = contactAssignmentEntity?.commands?.create?.execute as\n | ((payload: unknown) => AXPCommandExecuteResultPromise<any>)\n | undefined;\n\n if (!createFn) {\n const msg = await this.translationService.translateAsync(\n '@general:messages.entity.create-command-unavailable',\n );\n this.toastService.show({\n color: 'danger',\n title: await this.translationService.translateAsync('@general:messages.generic.error.title'),\n content: msg,\n });\n throw new Error(msg);\n }\n\n dialogRef.setLoading(true);\n try {\n const context = dialogRef.context();\n const createResult = await createFn({\n ...context,\n partyId: partyContext.partyId,\n personId,\n person: personSnapshot,\n });\n const __single_createResult = runtimeCommandPayloadData(createResult);\n if (__single_createResult) {\n return { success: true, kind: 'object',\n data: runtimeCommandPayloadData(createResult),\n message: {\n text: await this.translationService.translateAsync('@general:messages.generic.success.description'),\n },\n };\n }\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync('@general:messages.entity.create-failed'),\n },\n };\n } catch (error: unknown) {\n const errorMsg =\n error instanceof Error\n ? error.message\n : await this.translationService.translateAsync('@general:messages.entity.create-failed');\n this.toastService.show({\n color: 'danger',\n title: await this.translationService.translateAsync('@general:messages.generic.error.title'),\n content: errorMsg,\n });\n throw error;\n } finally {\n dialogRef.setLoading(false);\n }\n })\n .show();\n\n return result as unknown as AXPRuntimeCommandResult<any>;\n }\n}\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;;AAAA;AAoBA;AAEA;MAGa,+CAA+C,CAAA;AAD5D,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,kBAAkB,GAAG,MAAM,CAAC,4BAA4B,CAAC;AACzD,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,2BAA2B,CAAC;AAChD,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,kCAAkC,CAAC;AAC1D,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC;AACrC,QAAA,IAAA,CAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC;AAmJnE,IAAA;IAjJC,MAAM,OAAO,CAAC,KAAU,EAAA;AACtB,QAAA,MAAM,QAAQ,GAAG,+BAA+B,CAAC,KAAK,CAAC;AACvD,QAAA,MAAM,WAAW,GAAG,4BAA4B,CAAC,KAAK,CAAC;AACvD,QAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,aAAa,IAAI,IAAI,OAAO;QACnE,MAAM,YAAY,GAAG,oCAAoC,CAAC,WAAW,EAAE,MAAM,CAAC;AAE9E,QAAA,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YACzB,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,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