@acorex-platform/module-location-management-client 0.0.32 → 0.0.37
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.
- package/fesm2022/acorex-platform-module-location-management-client-assign-existing-location-to-party.command-DECKrIBR.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-geographic-region.mjs +782 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-geographic-region.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location-assignment.mjs +400 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location-assignment.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location-role.mjs +156 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location-role.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location-type.mjs +288 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location-type.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location.mjs +1356 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-acorex-platform-module-location-management-client-contracts-entity-catalog-B1rJccHr.mjs +70 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-acorex-platform-module-location-management-client-contracts-entity-catalog-B1rJccHr.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-geographic-region.entity-CUhM4K8a.mjs +735 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-geographic-region.entity-CUhM4K8a.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.entity-Cw46YCj9.mjs +198 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.entity-Cw46YCj9.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.utils-CfwbSQiM.mjs +160 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.utils-CfwbSQiM.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-role.entity-CEtJEhCf.mjs +109 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-role.entity-CEtJEhCf.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-type.entity-BXuQ_A7h.mjs +241 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-type.entity-BXuQ_A7h.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location.entity-CmnVKTG-.mjs +1154 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location.entity-CmnVKTG-.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog.mjs +2 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client-contracts.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-location-management-client-create-location-with-assignment.command-Cl6KfruM.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-location-management-client-local-entities.mjs +33 -0
- package/fesm2022/acorex-platform-module-location-management-client-local-entities.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-location-management-client.mjs +1 -1
- package/fesm2022/acorex-platform-module-location-management-client.mjs.map +1 -1
- package/package.json +29 -1
- package/types/acorex-platform-module-location-management-client-contracts-entities-geographic-region.d.ts +5 -0
- package/types/acorex-platform-module-location-management-client-contracts-entities-location-assignment.d.ts +5 -0
- package/types/acorex-platform-module-location-management-client-contracts-entities-location-role.d.ts +5 -0
- package/types/acorex-platform-module-location-management-client-contracts-entities-location-type.d.ts +5 -0
- package/types/acorex-platform-module-location-management-client-contracts-entities-location.d.ts +5 -0
- package/types/acorex-platform-module-location-management-client-contracts-entity-catalog.d.ts +10 -0
- package/types/acorex-platform-module-location-management-client-local-entities.d.ts +12 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acorex-platform-module-location-management-client-assign-existing-location-to-party.command-DECKrIBR.mjs","sources":["../../../../libs/modules/location-management/client/src/lib/commands/assign-existing-location-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 { get } from 'lodash';\nimport {\n AXPEntityDataSelectorService,\n AXPEntityDefinitionRegistryService,\n AXPEntityFormBuilderService,\n} from '@acorex-platform/framework-client/layout/entity';\n\nimport { RootConfig, LOCATION_ASSIGNMENT_PARTY_TYPE, resolveLocationAssignmentDisplayTitle, buildLocationAssignmentLocationSnapshot, buildLocationAssignmentPersonSnapshot } from '@acorex-platform/module-location-management-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 AXMLocationAssignmentAssignExistingLocationCommand 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 ownerRef = this.resolveOwnerRef(processData);\n if (!ownerRef.id) {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync(\n '@location-management:location-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 locationEntity = await this.entityService.resolve(\n RootConfig.module.name,\n RootConfig.entities.location.name,\n );\n if (!locationEntity) {\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 '@location-management:location-assignments.actions.assign-existing-location.selector-title',\n );\n const selectorResult = await this.entityDataSelector.open({\n entity: locationEntity,\n title: selectorTitle,\n allowMultiple: false,\n columns: ['title', 'code', 'street1', 'cityId', 'countryId'],\n });\n\n if (!selectorResult?.items?.length) {\n return { success: false };\n }\n\n const selectedLocation = selectorResult.items[0];\n const locationId = selectedLocation.id ?? selectedLocation._id;\n const locationSnapshot = buildLocationAssignmentLocationSnapshot(\n selectedLocation as Record<string, unknown>,\n locationId as string,\n );\n\n const formTitle = await this.translationService.translateAsync(\n '@location-management:location-assignments.actions.assign-existing-location.form-title',\n { params: { partyTitle: ownerRef.title } },\n );\n\n const result = await this.entityForm\n .entity(`${moduleName}.${entityName}`)\n .create({\n locationId,\n location: locationSnapshot,\n ownerRef,\n })\n .include('roleId', 'personId', '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 locationAssignmentEntity = await this.entityService.resolve(moduleName, entityName);\n const createFn = locationAssignmentEntity?.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 personId = (context['personId'] ?? get(context, 'person.id')) as string | undefined;\n const personInContext = get(context, 'person') as Record<string, unknown> | undefined;\n const personSnapshot =\n personId && personInContext\n ? buildLocationAssignmentPersonSnapshot({ ...personInContext, id: personId }, personId)\n : undefined;\n\n const payload = {\n ...context,\n locationId,\n ownerRef,\n location: locationSnapshot,\n ...(personId ? { personId, person: personSnapshot } : {}),\n };\n const createResult = await createFn(payload);\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 private resolveOwnerRef(processData: Record<string, unknown>) {\n const nestedOwner = get(processData, 'ownerRef') as { type?: string; id?: string; title?: unknown } | undefined;\n const locale = this.translationService.getActiveLang?.() ?? 'en-US';\n\n return {\n type: (processData['ownerRef.type'] as string) ?? nestedOwner?.type ?? LOCATION_ASSIGNMENT_PARTY_TYPE,\n id: (processData['ownerRef.id'] as string) ?? nestedOwner?.id ?? '',\n title: resolveLocationAssignmentDisplayTitle(\n locale,\n processData['ownerRef.title'],\n nestedOwner?.title,\n get(processData, 'party.title'),\n get(processData, 'title'),\n ),\n };\n }\n}\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AAqBA;AA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;kBAD9D,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
|
|
1
|
+
{"version":3,"file":"acorex-platform-module-location-management-client-assign-existing-location-to-party.command-DECKrIBR.mjs","sources":["../../../../libs/modules/location-management/client/src/lib/commands/assign-existing-location-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 { get } from 'lodash';\nimport {\n AXPEntityDataSelectorService,\n AXPEntityDefinitionRegistryService,\n AXPEntityFormBuilderService,\n} from '@acorex-platform/framework-client/layout/entity';\n\nimport { RootConfig, LOCATION_ASSIGNMENT_PARTY_TYPE, resolveLocationAssignmentDisplayTitle, buildLocationAssignmentLocationSnapshot, buildLocationAssignmentPersonSnapshot } from '@acorex-platform/module-location-management-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 AXMLocationAssignmentAssignExistingLocationCommand 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 ownerRef = this.resolveOwnerRef(processData);\n if (!ownerRef.id) {\n return {\n success: false,\n message: {\n text: await this.translationService.translateAsync(\n '@location-management:location-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 locationEntity = await this.entityService.resolve(\n RootConfig.module.name,\n RootConfig.entities.location.name,\n );\n if (!locationEntity) {\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 '@location-management:location-assignments.actions.assign-existing-location.selector-title',\n );\n const selectorResult = await this.entityDataSelector.open({\n entity: locationEntity,\n title: selectorTitle,\n allowMultiple: false,\n columns: ['title', 'code', 'street1', 'cityId', 'countryId'],\n });\n\n if (!selectorResult?.items?.length) {\n return { success: false };\n }\n\n const selectedLocation = selectorResult.items[0];\n const locationId = selectedLocation.id ?? selectedLocation._id;\n const locationSnapshot = buildLocationAssignmentLocationSnapshot(\n selectedLocation as Record<string, unknown>,\n locationId as string,\n );\n\n const formTitle = await this.translationService.translateAsync(\n '@location-management:location-assignments.actions.assign-existing-location.form-title',\n { params: { partyTitle: ownerRef.title } },\n );\n\n const result = await this.entityForm\n .entity(`${moduleName}.${entityName}`)\n .create({\n locationId,\n location: locationSnapshot,\n ownerRef,\n })\n .include('roleId', 'personId', '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 locationAssignmentEntity = await this.entityService.resolve(moduleName, entityName);\n const createFn = locationAssignmentEntity?.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 personId = (context['personId'] ?? get(context, 'person.id')) as string | undefined;\n const personInContext = get(context, 'person') as Record<string, unknown> | undefined;\n const personSnapshot =\n personId && personInContext\n ? buildLocationAssignmentPersonSnapshot({ ...personInContext, id: personId }, personId)\n : undefined;\n\n const payload = {\n ...context,\n locationId,\n ownerRef,\n location: locationSnapshot,\n ...(personId ? { personId, person: personSnapshot } : {}),\n };\n const createResult = await createFn(payload);\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 private resolveOwnerRef(processData: Record<string, unknown>) {\n const nestedOwner = get(processData, 'ownerRef') as { type?: string; id?: string; title?: unknown } | undefined;\n const locale = this.translationService.getActiveLang?.() ?? 'en-US';\n\n return {\n type: (processData['ownerRef.type'] as string) ?? nestedOwner?.type ?? LOCATION_ASSIGNMENT_PARTY_TYPE,\n id: (processData['ownerRef.id'] as string) ?? nestedOwner?.id ?? '',\n title: resolveLocationAssignmentDisplayTitle(\n locale,\n processData['ownerRef.title'],\n nestedOwner?.title,\n get(processData, 'party.title'),\n get(processData, 'title'),\n ),\n };\n }\n}\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AAqBA;AAEA;MAGa,kDAAkD,CAAA;AAD/D,IAAA,WAAA,GAAA;AAEmB,QAAA,IAA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