@acorex/modules 20.7.4 → 20.7.6

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.
Files changed (24) hide show
  1. package/document-management/index.d.ts +3 -2
  2. package/fesm2022/acorex-modules-document-management.mjs +106 -20
  3. package/fesm2022/acorex-modules-document-management.mjs.map +1 -1
  4. package/fesm2022/{acorex-modules-human-capital-management-leave-request.entity-CITYAroH.mjs → acorex-modules-human-capital-management-leave-request.entity-Dn2LLbuq.mjs} +20 -3
  5. package/fesm2022/acorex-modules-human-capital-management-leave-request.entity-Dn2LLbuq.mjs.map +1 -0
  6. package/fesm2022/acorex-modules-human-capital-management.mjs +558 -103
  7. package/fesm2022/acorex-modules-human-capital-management.mjs.map +1 -1
  8. package/fesm2022/{acorex-modules-product-catalog-product.entity-CBieRmkK.mjs → acorex-modules-product-catalog-product.entity-CuTXUcc1.mjs} +20 -17
  9. package/fesm2022/acorex-modules-product-catalog-product.entity-CuTXUcc1.mjs.map +1 -0
  10. package/fesm2022/acorex-modules-product-catalog.mjs +1 -1
  11. package/fesm2022/{acorex-modules-task-management-task-board.page-CIlxqtgJ.mjs → acorex-modules-task-management-task-board.page-BNwqZ5Eu.mjs} +3 -3
  12. package/fesm2022/{acorex-modules-task-management-task-board.page-CIlxqtgJ.mjs.map → acorex-modules-task-management-task-board.page-BNwqZ5Eu.mjs.map} +1 -1
  13. package/fesm2022/acorex-modules-task-management.mjs +9 -3
  14. package/fesm2022/acorex-modules-task-management.mjs.map +1 -1
  15. package/fesm2022/{acorex-modules-workflow-management-index-vstmaa5b.mjs → acorex-modules-workflow-management-index-BIl8No8o.mjs} +16 -10
  16. package/fesm2022/acorex-modules-workflow-management-index-BIl8No8o.mjs.map +1 -0
  17. package/fesm2022/acorex-modules-workflow-management.mjs +36 -4
  18. package/fesm2022/acorex-modules-workflow-management.mjs.map +1 -1
  19. package/human-capital-management/index.d.ts +58 -1
  20. package/package.json +6 -6
  21. package/workflow-management/index.d.ts +2 -0
  22. package/fesm2022/acorex-modules-human-capital-management-leave-request.entity-CITYAroH.mjs.map +0 -1
  23. package/fesm2022/acorex-modules-product-catalog-product.entity-CBieRmkK.mjs.map +0 -1
  24. package/fesm2022/acorex-modules-workflow-management-index-vstmaa5b.mjs.map +0 -1
@@ -10,7 +10,7 @@ import * as _acorex_platform_common from '@acorex/platform/common';
10
10
  import { AXPEntity, AXPFileStorageService, AXPFilterOperatorMiddlewareService, AXPFileType, AXPFileTypeInfoProvider, AXPFileTypeProviderService, AXPMenuProvider, AXPMenuProviderContext, AXPSearchCommandProvider, AXPSearchResult, AXPSettingDefinitionProvider, AXPSettingDefinitionProviderContext } from '@acorex/platform/common';
11
11
  import { AXPEntityModel, AXMEntityCrudServiceImpl, AXPEntityDefinitionLoader, AXPEntityDefinitionPreloader, AXPEntityPreloadEntity } from '@acorex/platform/layout/entity';
12
12
  import * as _acorex_platform_core from '@acorex/platform/core';
13
- import { AXPFileListItem, AXPMetaData, AXPApplicationUserReference, AXPPlatformScope, AXPQueryRequest, AXPActionMenuItem, AXPDeviceService, AXPBackButton, AXPBreadcrumbItem, AXPExecuteCommand } from '@acorex/platform/core';
13
+ import { AXPFileListItem, AXPMetaData, AXPApplicationUserReference, AXPPlatformScope, AXPQueryRequest, AXPHookService, AXPActionMenuItem, AXPDeviceService, AXPBackButton, AXPBreadcrumbItem, AXPExecuteCommand } from '@acorex/platform/core';
14
14
  import * as _acorex_platform_themes_shared from '@acorex/platform/themes/shared';
15
15
  import * as _ngrx_signals from '@ngrx/signals';
16
16
  import * as _acorex_components_menu from '@acorex/components/menu';
@@ -514,6 +514,7 @@ declare class AXMDocumentManagerService implements AXMDocumentManagerServiceInte
514
514
  protected reviewService: AXMReviewService;
515
515
  protected attachmentsService: DocumentAttachmentsService;
516
516
  protected filterMiddlewareService: AXPFilterOperatorMiddlewareService;
517
+ protected hooks: AXPHookService | null;
517
518
  private scopedDriveCache;
518
519
  private buildPathCache;
519
520
  /**
@@ -618,7 +619,7 @@ declare class AXMDocumentManagerService implements AXMDocumentManagerServiceInte
618
619
  */
619
620
  openFile(node: AXMDocumentExplorerNode): Promise<void>;
620
621
  /**
621
- * Downloads a file
622
+ * Downloads a file using the same logic as file-uploader component
622
623
  */
623
624
  downloadFile(node: AXMDocumentExplorerNode): Promise<void>;
624
625
  /**
@@ -1,6 +1,6 @@
1
1
  import { AXPSessionService, AXPAuthGuard, AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex/platform/auth';
2
2
  import { AXPEntityService, AXMEntityCrudServiceImpl, entityMasterCrudActions, entityMasterRecordActions, cloneLayoutArrays, ensureLayoutSection, ensureLayoutPropertyView, ensureListActions, actionExists, AXP_ENTITY_CONFIG_TOKEN, AXP_ENTITY_ACTION_PLUGIN, AXP_ENTITY_DEFINITION_LOADER } from '@acorex/platform/layout/entity';
3
- import { AXPPlatformScope, AXPDataGenerator, AXP_MODULE_MANIFEST_PROVIDER, AXP_FEATURE_DEFINITION_PROVIDER, AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER, AXPDeviceService, resolvePlatformScopeKey, resolvePlatformScopeName } from '@acorex/platform/core';
3
+ import { AXPHookService, AXPPlatformScope, AXPDataGenerator, AXP_MODULE_MANIFEST_PROVIDER, AXP_FEATURE_DEFINITION_PROVIDER, AXP_DISTRIBUTED_EVENT_LISTENER_PROVIDER, AXPDeviceService, resolvePlatformScopeKey, resolvePlatformScopeName } from '@acorex/platform/core';
4
4
  import { AXPSearchCommandProvider, createAllQueryView, createQueryView, AXPEntityCommandScope, AXPEntityQueryType, AXPFileTypeProviderService, AXP_FILE_TYPE_INFO_PROVIDER, AXPFileStorageService, AXPFilterOperatorMiddlewareService, AXPSettingsService, AXPLockService, UploadFromComputerActionProvider, AXP_FILE_ACTION_PROVIDER, AXP_MENU_PROVIDER, AXP_SEARCH_PROVIDER } from '@acorex/platform/common';
5
5
  import * as i0 from '@angular/core';
6
6
  import { Injectable, inject, Injector, NgModule, ChangeDetectionStrategy, Component, signal, viewChild, computed, input, effect, ViewEncapsulation, untracked, HostListener } from '@angular/core';
@@ -4403,6 +4403,7 @@ class AXMDocumentManagerService {
4403
4403
  this.reviewService = inject(AXMReviewService);
4404
4404
  this.attachmentsService = inject(DocumentAttachmentsService);
4405
4405
  this.filterMiddlewareService = inject(AXPFilterOperatorMiddlewareService);
4406
+ this.hooks = inject(AXPHookService, { optional: true });
4406
4407
  //#endregion
4407
4408
  //#region ---- Private Properties ----
4408
4409
  this.scopedDriveCache = new Map();
@@ -4830,32 +4831,117 @@ class AXMDocumentManagerService {
4830
4831
  const file = await this.documentService.getOne(node.id);
4831
4832
  }
4832
4833
  /**
4833
- * Downloads a file
4834
+ * Downloads a file using the same logic as file-uploader component
4834
4835
  */
4835
4836
  async downloadFile(node) {
4836
- // const file = await this.documentService.getOne(node.id);
4837
- if (node.fileId) {
4838
- if (node.fileId.source?.value &&
4839
- typeof node.fileId.source.value === 'string' &&
4840
- node.fileId.source.value?.startsWith('http')) {
4841
- const link = document.createElement('a');
4842
- link.href = node.fileId.source.value;
4843
- link.download = node.name;
4844
- document.body.appendChild(link);
4845
- link.click();
4846
- document.body.removeChild(link);
4847
- return;
4848
- }
4849
- const fileInfo = await this.fileService.getInfo(node.fileId.id ?? '');
4837
+ if (!node.fileId) {
4838
+ console.error('File ID is undefined, cannot download.', node);
4839
+ return;
4840
+ }
4841
+ const file = {
4842
+ ...node.fileId,
4843
+ name: node.fileId.name ?? node.name,
4844
+ };
4845
+ // Run BeforeDownload hook if available
4846
+ // if (this.hooks) {
4847
+ // try {
4848
+ // await this.hooks.runAsync<any>('file-uploader.fileItem.before-download', {
4849
+ // host: undefined,
4850
+ // file,
4851
+ // plugins: [],
4852
+ // excludePlugins: [],
4853
+ // });
4854
+ // } catch {
4855
+ // // Ignore hook errors
4856
+ // }
4857
+ // }
4858
+ if (!file.source) {
4859
+ console.error('File source is undefined, cannot download.', file);
4860
+ return;
4861
+ }
4862
+ const triggerDownload = (blob, fileName) => {
4863
+ const url = URL.createObjectURL(blob);
4850
4864
  const link = document.createElement('a');
4851
- link.href = fileInfo.url ?? '';
4852
- link.download = node.name; // Set the desired file name
4865
+ link.href = url;
4866
+ link.download = fileName;
4853
4867
  document.body.appendChild(link);
4854
4868
  link.click();
4855
4869
  document.body.removeChild(link);
4870
+ URL.revokeObjectURL(url);
4871
+ };
4872
+ switch (file.source.kind) {
4873
+ case 'blob':
4874
+ if (file.source.value instanceof Blob) {
4875
+ triggerDownload(file.source.value, file.name ?? node.name ?? 'download');
4876
+ }
4877
+ else {
4878
+ console.error('Source kind is blob, but value is not a Blob.', file);
4879
+ }
4880
+ break;
4881
+ case 'fileId':
4882
+ if (typeof file.source.value === 'string') {
4883
+ try {
4884
+ const fileInfo = await this.fileService.getInfo(file.source.value);
4885
+ if (fileInfo && fileInfo.url) {
4886
+ const link = document.createElement('a');
4887
+ link.href = fileInfo.url;
4888
+ link.download = file.name ?? node.name ?? fileInfo.name ?? 'download';
4889
+ link.target = '_blank';
4890
+ document.body.appendChild(link);
4891
+ link.click();
4892
+ document.body.removeChild(link);
4893
+ }
4894
+ else if (fileInfo && fileInfo.binary instanceof Blob) {
4895
+ triggerDownload(fileInfo.binary, file.name ?? node.name ?? fileInfo.name ?? 'download');
4896
+ }
4897
+ else {
4898
+ console.error('Could not retrieve file for download from fileId:', fileInfo);
4899
+ }
4900
+ }
4901
+ catch (error) {
4902
+ console.error('Error downloading file by fileId:', file.source.value, error);
4903
+ }
4904
+ }
4905
+ else {
4906
+ console.error('Source kind is fileId, but value is not a string ID.', file);
4907
+ }
4908
+ break;
4909
+ case 'url':
4910
+ if (typeof file.source.value === 'string') {
4911
+ const link = document.createElement('a');
4912
+ link.href = file.source.value;
4913
+ link.download = file.name ?? node.name ?? 'download';
4914
+ link.target = '_blank';
4915
+ document.body.appendChild(link);
4916
+ link.click();
4917
+ document.body.removeChild(link);
4918
+ }
4919
+ else {
4920
+ console.error('Source kind is url, but value is not a string URL.', file);
4921
+ }
4922
+ break;
4923
+ case 'reference':
4924
+ console.error('Download not supported for source kind: reference', file);
4925
+ break;
4926
+ case 'preview':
4927
+ case 'none':
4928
+ default:
4929
+ console.error(`Download not supported for source kind: ${file.source.kind}`, file);
4930
+ break;
4856
4931
  }
4857
- else {
4858
- throw new Error('File ID is required');
4932
+ // Run AfterDownload hook if available
4933
+ if (this.hooks) {
4934
+ try {
4935
+ await this.hooks.runAsync('file-uploader.fileItem.after-download', {
4936
+ host: undefined,
4937
+ file,
4938
+ plugins: [],
4939
+ excludePlugins: [],
4940
+ });
4941
+ }
4942
+ catch {
4943
+ // Ignore hook errors
4944
+ }
4859
4945
  }
4860
4946
  }
4861
4947
  //#endregion