cat-documents-ng 1.0.6 → 1.0.7
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/README.md +322 -322
- package/Shared/components/confirmation-dialog/confirmation-dialog.component.d.ts +44 -0
- package/Shared/components/table-primary/table-primary.component.d.ts +31 -0
- package/Shared/components/table-primary/table-primary.model.d.ts +19 -0
- package/Shared/constant/ERROR.d.ts +52 -0
- package/Shared/constant/SHARED.d.ts +546 -0
- package/{src/Shared/constant/URLS.ts → Shared/constant/URLS.d.ts} +25 -31
- package/Shared/services/app-config.service.d.ts +51 -0
- package/{src/Shared/services/global-error.handler.ts → Shared/services/global-error.handler.d.ts} +9 -11
- package/Shared/services/session.service.d.ts +46 -0
- package/Shared/shared.module.d.ts +14 -0
- package/fesm2022/cat-documents-ng.mjs +11405 -0
- package/fesm2022/cat-documents-ng.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/document/components/document-actions/document-actions.component.d.ts +78 -0
- package/lib/document/components/document-container/document-container.component.d.ts +162 -0
- package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts +291 -0
- package/lib/document/components/document-history/document-history.component.d.ts +160 -0
- package/lib/document/components/document-list/document-list.component.d.ts +299 -0
- package/lib/document/components/document-list-item/document-list-item.component.d.ts +28 -0
- package/lib/document/components/document-search/document-search.component.d.ts +77 -0
- package/lib/document/components/document-status/document-status.component.d.ts +24 -0
- package/lib/document/components/document-upload/document-upload.component.d.ts +321 -0
- package/lib/document/components/document-viewer/document-viewer.component.d.ts +137 -0
- package/lib/document/components/document-zoom-controls/document-zoom-controls.component.d.ts +33 -0
- package/lib/document/components/documents-menu/documents-menu.component.d.ts +110 -0
- package/{src/lib/document/components/folder-block/folder-block.component.ts → lib/document/components/folder-block/folder-block.component.d.ts} +12 -28
- package/lib/document/components/folder-container/folder-container.component.d.ts +162 -0
- package/lib/document/components/linked-document/linked-document.component.d.ts +39 -0
- package/lib/document/components/request-document/request-document.component.d.ts +69 -0
- package/lib/document/components/sidebar/sidebar.component.d.ts +109 -0
- package/lib/document/components/user-list/user-list.component.d.ts +34 -0
- package/lib/document/constant/DOCUMENT_HISTORY.d.ts +41 -0
- package/lib/document/directives/document.directive.d.ts +20 -0
- package/lib/document/directives/permission.directive.d.ts +38 -0
- package/lib/document/document.module.d.ts +60 -0
- package/{src/lib/document/models/document-alert.model.ts → lib/document/models/document-alert.model.d.ts} +4 -11
- package/lib/document/models/document-category.model.d.ts +24 -0
- package/lib/document/models/document-history.model.d.ts +94 -0
- package/lib/document/models/document-list-response.model.d.ts +33 -0
- package/lib/document/models/document-type.model.d.ts +37 -0
- package/lib/document/models/document.model.d.ts +44 -0
- package/{src/lib/document/models/folder.model.ts → lib/document/models/folder.model.d.ts} +4 -10
- package/lib/document/models/status-data.model.d.ts +27 -0
- package/lib/document/models/uploaded-file-response.model.d.ts +7 -0
- package/lib/document/models/user-list.model.d.ts +8 -0
- package/lib/document/services/csv-parser.service.d.ts +88 -0
- package/lib/document/services/document-actions.service.d.ts +48 -0
- package/lib/document/services/document-content-type.service.d.ts +85 -0
- package/lib/document/services/document-history-style.service.d.ts +34 -0
- package/lib/document/services/document-history.service.d.ts +42 -0
- package/lib/document/services/document-http.service.d.ts +179 -0
- package/lib/document/services/document-list.service.d.ts +74 -0
- package/lib/document/services/document-menu.service.d.ts +122 -0
- package/lib/document/services/document-scroll.service.d.ts +55 -0
- package/lib/document/services/document-table-builder.service.d.ts +38 -0
- package/lib/document/services/document-upload-business.service.d.ts +107 -0
- package/lib/document/services/document-upload-data.service.d.ts +40 -0
- package/lib/document/services/document-upload-form.service.d.ts +41 -0
- package/lib/document/services/document-upload.service.d.ts +99 -0
- package/lib/document/services/document-viewer.service.d.ts +97 -0
- package/lib/document/services/document-zoom.service.d.ts +81 -0
- package/lib/document/services/document.service.d.ts +161 -0
- package/lib/document/services/eml-parser.service.d.ts +116 -0
- package/lib/document/services/excel-parser.service.d.ts +169 -0
- package/lib/document/services/file-format.service.d.ts +34 -0
- package/lib/document/services/status-calculator.service.d.ts +20 -0
- package/lib/document/services/user-list.service.d.ts +29 -0
- package/lib/document/state/document.query.d.ts +243 -0
- package/{src/lib/document/state/document.service.ts → lib/document/state/document.service.d.ts} +15 -46
- package/lib/document/state/document.state.d.ts +61 -0
- package/lib/document/state/document.store.d.ts +56 -0
- package/package.json +11 -5
- package/{src/public-api.ts → public-api.d.ts} +0 -4
- package/ng-package.json +0 -10
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.html +0 -3
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.scss +0 -13
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -70
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.ts +0 -133
- package/src/Shared/components/table-primary/table-primary.component.html +0 -66
- package/src/Shared/components/table-primary/table-primary.component.scss +0 -227
- package/src/Shared/components/table-primary/table-primary.component.spec.ts +0 -23
- package/src/Shared/components/table-primary/table-primary.component.ts +0 -143
- package/src/Shared/components/table-primary/table-primary.model.ts +0 -21
- package/src/Shared/constant/ERROR.ts +0 -55
- package/src/Shared/constant/PERMISSIONS.ts +0 -17
- package/src/Shared/constant/SHARED.ts +0 -936
- package/src/Shared/services/app-config.service.spec.ts +0 -19
- package/src/Shared/services/app-config.service.ts +0 -73
- package/src/Shared/services/session.service.spec.ts +0 -16
- package/src/Shared/services/session.service.ts +0 -76
- package/src/Shared/shared.module.ts +0 -25
- package/src/lib/document/components/csv-viewer/csv-viewer.component.ts +0 -1
- package/src/lib/document/components/document-actions/document-actions.component.html +0 -59
- package/src/lib/document/components/document-actions/document-actions.component.scss +0 -362
- package/src/lib/document/components/document-actions/document-actions.component.spec.ts +0 -297
- package/src/lib/document/components/document-actions/document-actions.component.ts +0 -163
- package/src/lib/document/components/document-container/document-container.component.html +0 -36
- package/src/lib/document/components/document-container/document-container.component.scss +0 -144
- package/src/lib/document/components/document-container/document-container.component.spec.ts +0 -110
- package/src/lib/document/components/document-container/document-container.component.ts +0 -363
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.html +0 -332
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.scss +0 -1877
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.spec.ts +0 -258
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.ts +0 -664
- package/src/lib/document/components/document-history/document-history.component.html +0 -96
- package/src/lib/document/components/document-history/document-history.component.scss +0 -392
- package/src/lib/document/components/document-history/document-history.component.spec.ts +0 -93
- package/src/lib/document/components/document-history/document-history.component.ts +0 -373
- package/src/lib/document/components/document-list/document-list.component.html +0 -46
- package/src/lib/document/components/document-list/document-list.component.scss +0 -513
- package/src/lib/document/components/document-list/document-list.component.spec.ts +0 -486
- package/src/lib/document/components/document-list/document-list.component.ts +0 -682
- package/src/lib/document/components/document-list-item/document-list-item.component.html +0 -36
- package/src/lib/document/components/document-list-item/document-list-item.component.scss +0 -34
- package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +0 -75
- package/src/lib/document/components/document-list-item/document-list-item.component.ts +0 -40
- package/src/lib/document/components/document-search/document-search.component.html +0 -64
- package/src/lib/document/components/document-search/document-search.component.scss +0 -206
- package/src/lib/document/components/document-search/document-search.component.spec.ts +0 -82
- package/src/lib/document/components/document-search/document-search.component.ts +0 -163
- package/src/lib/document/components/document-status/document-status.component.html +0 -31
- package/src/lib/document/components/document-status/document-status.component.scss +0 -192
- package/src/lib/document/components/document-status/document-status.component.spec.ts +0 -23
- package/src/lib/document/components/document-status/document-status.component.ts +0 -87
- package/src/lib/document/components/document-upload/document-upload.component.html +0 -160
- package/src/lib/document/components/document-upload/document-upload.component.scss +0 -235
- package/src/lib/document/components/document-upload/document-upload.component.spec.ts +0 -95
- package/src/lib/document/components/document-upload/document-upload.component.ts +0 -668
- package/src/lib/document/components/document-viewer/document-viewer.component.html +0 -50
- package/src/lib/document/components/document-viewer/document-viewer.component.scss +0 -187
- package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +0 -79
- package/src/lib/document/components/document-viewer/document-viewer.component.ts +0 -261
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.html +0 -48
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.scss +0 -320
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.spec.ts +0 -59
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.ts +0 -150
- package/src/lib/document/components/documents-menu/documents-menu.component.html +0 -44
- package/src/lib/document/components/documents-menu/documents-menu.component.scss +0 -363
- package/src/lib/document/components/documents-menu/documents-menu.component.spec.ts +0 -23
- package/src/lib/document/components/documents-menu/documents-menu.component.ts +0 -316
- package/src/lib/document/components/folder-block/folder-block.component.html +0 -46
- package/src/lib/document/components/folder-block/folder-block.component.scss +0 -9
- package/src/lib/document/components/folder-block/folder-block.component.spec.ts +0 -70
- package/src/lib/document/components/folder-container/folder-container.component.html +0 -56
- package/src/lib/document/components/folder-container/folder-container.component.scss +0 -20
- package/src/lib/document/components/folder-container/folder-container.component.spec.ts +0 -27
- package/src/lib/document/components/folder-container/folder-container.component.ts +0 -328
- package/src/lib/document/components/linked-document/linked-document.component.html +0 -23
- package/src/lib/document/components/linked-document/linked-document.component.scss +0 -10
- package/src/lib/document/components/linked-document/linked-document.component.spec.ts +0 -61
- package/src/lib/document/components/linked-document/linked-document.component.ts +0 -49
- package/src/lib/document/components/request-document/request-document.component.html +0 -86
- package/src/lib/document/components/request-document/request-document.component.scss +0 -16
- package/src/lib/document/components/request-document/request-document.component.ts +0 -278
- package/src/lib/document/components/sidebar/sidebar.component.html +0 -75
- package/src/lib/document/components/sidebar/sidebar.component.scss +0 -157
- package/src/lib/document/components/sidebar/sidebar.component.spec.ts +0 -114
- package/src/lib/document/components/sidebar/sidebar.component.ts +0 -223
- package/src/lib/document/components/user-list/user-list.component.html +0 -33
- package/src/lib/document/components/user-list/user-list.component.scss +0 -118
- package/src/lib/document/components/user-list/user-list.component.spec.ts +0 -23
- package/src/lib/document/components/user-list/user-list.component.ts +0 -181
- package/src/lib/document/constant/DOCUMENT_HISTORY.ts +0 -52
- package/src/lib/document/directives/document.directive.ts +0 -32
- package/src/lib/document/directives/permission.directive.spec.ts +0 -0
- package/src/lib/document/directives/permission.directive.ts +0 -72
- package/src/lib/document/document.module.ts +0 -351
- package/src/lib/document/models/document-category.model.ts +0 -30
- package/src/lib/document/models/document-history.model.ts +0 -109
- package/src/lib/document/models/document-list-response.model.ts +0 -37
- package/src/lib/document/models/document-type.model.ts +0 -44
- package/src/lib/document/models/document.model.ts +0 -53
- package/src/lib/document/models/status-data.model.ts +0 -31
- package/src/lib/document/models/uploaded-file-response.model.ts +0 -7
- package/src/lib/document/models/user-list.model.ts +0 -10
- package/src/lib/document/services/csv-parser.service.spec.ts +0 -97
- package/src/lib/document/services/csv-parser.service.ts +0 -303
- package/src/lib/document/services/document-actions.service.ts +0 -125
- package/src/lib/document/services/document-content-type.service.ts +0 -193
- package/src/lib/document/services/document-history-style.service.ts +0 -138
- package/src/lib/document/services/document-history.service.ts +0 -129
- package/src/lib/document/services/document-http.service.spec.ts +0 -119
- package/src/lib/document/services/document-http.service.ts +0 -497
- package/src/lib/document/services/document-list.service.ts +0 -195
- package/src/lib/document/services/document-menu.service.ts +0 -277
- package/src/lib/document/services/document-scroll.service.ts +0 -138
- package/src/lib/document/services/document-severity.service.ts +0 -98
- package/src/lib/document/services/document-table-builder.service.ts +0 -82
- package/src/lib/document/services/document-upload-business.service.ts +0 -326
- package/src/lib/document/services/document-upload-data.service.ts +0 -82
- package/src/lib/document/services/document-upload-form.service.ts +0 -149
- package/src/lib/document/services/document-upload.service.spec.ts +0 -99
- package/src/lib/document/services/document-upload.service.ts +0 -209
- package/src/lib/document/services/document-viewer.service.ts +0 -279
- package/src/lib/document/services/document-zoom.service.spec.ts +0 -56
- package/src/lib/document/services/document-zoom.service.ts +0 -164
- package/src/lib/document/services/document.service.ts +0 -356
- package/src/lib/document/services/eml-parser.service.ts +0 -444
- package/src/lib/document/services/excel-parser.service.spec.ts +0 -66
- package/src/lib/document/services/excel-parser.service.ts +0 -483
- package/src/lib/document/services/file-format.service.spec.ts +0 -16
- package/src/lib/document/services/file-format.service.ts +0 -63
- package/src/lib/document/services/status-calculator.service.ts +0 -44
- package/src/lib/document/services/user-list.service.ts +0 -77
- package/src/lib/document/state/document.query.ts +0 -378
- package/src/lib/document/state/document.state.ts +0 -100
- package/src/lib/document/state/document.store.ts +0 -200
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
|
@@ -1,668 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectorRef, Component, Input, ViewChild, ViewEncapsulation, OnDestroy, Output, EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core';
|
|
2
|
-
import { FileUpload } from 'primeng/fileupload';
|
|
3
|
-
import { MessageService } from 'primeng/api';
|
|
4
|
-
import { PrimeNGConfig } from 'primeng/api';
|
|
5
|
-
import { SHARED } from '../../../../Shared/constant/SHARED';
|
|
6
|
-
import { FileFormatService } from '../../services/file-format.service';
|
|
7
|
-
import { DocumentService } from '../../state/document.service';
|
|
8
|
-
import { DocumentUploadService } from '../../services/document-upload.service';
|
|
9
|
-
import { DocumentUploadBusinessService, UploadedFile } from '../../services/document-upload-business.service';
|
|
10
|
-
import { DocumentUploadFormService } from '../../services/document-upload-form.service';
|
|
11
|
-
import { DocumentUploadDataService } from '../../services/document-upload-data.service';
|
|
12
|
-
import { UserListModel } from '../../models/user-list.model';
|
|
13
|
-
import { DocumentCategory } from '../../models/document-category.model';
|
|
14
|
-
import { DocumentTypeModel } from '../../models/document-type.model';
|
|
15
|
-
import { Subject, takeUntil } from 'rxjs';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Component responsible for handling document uploads with templated metadata.
|
|
19
|
-
* Provides a comprehensive interface for uploading documents with assignment types,
|
|
20
|
-
* categories, document types, and applicant selection.
|
|
21
|
-
*/
|
|
22
|
-
@Component({
|
|
23
|
-
selector: 'lib-document-upload',
|
|
24
|
-
templateUrl: './document-upload.component.html',
|
|
25
|
-
styleUrls: ['./document-upload.component.scss'],
|
|
26
|
-
standalone: false,
|
|
27
|
-
encapsulation: ViewEncapsulation.None
|
|
28
|
-
})
|
|
29
|
-
export class DocumentUploadComponent implements OnInit, OnChanges, OnDestroy {
|
|
30
|
-
/** The context ID for the document upload operation */
|
|
31
|
-
@Input() contextId: string = SHARED.EMPTY;
|
|
32
|
-
|
|
33
|
-
/** Indicates if the document save button has been clicked */
|
|
34
|
-
@Input() isDocumentSaveBtnClicked: boolean = false;
|
|
35
|
-
|
|
36
|
-
/** Indicates if the document sidebar is closed */
|
|
37
|
-
@Input() isDocumentSidebarClosed: boolean = false;
|
|
38
|
-
|
|
39
|
-
/** Whether there are unsaved changes in the form */
|
|
40
|
-
hasUnsavedChanges: boolean = false;
|
|
41
|
-
/** Whether to hide the form and show only upload functionality */
|
|
42
|
-
@Input() isFormHide: boolean = false;
|
|
43
|
-
|
|
44
|
-
/** Whether to hide the multi-attachment button */
|
|
45
|
-
@Input() isMultiAttachmentHidden: boolean = false;
|
|
46
|
-
|
|
47
|
-
/** Reference to the file upload component */
|
|
48
|
-
@ViewChild('fileUploader') fileUploader!: FileUpload;
|
|
49
|
-
|
|
50
|
-
/** Event emitted when form validation state changes */
|
|
51
|
-
@Output() onFormValidationChange = new EventEmitter<void>();
|
|
52
|
-
|
|
53
|
-
/** Event emitted when upload is successful */
|
|
54
|
-
@Output() onUploadSuccess = new EventEmitter<void>();
|
|
55
|
-
|
|
56
|
-
/** Event emitted when files are uploaded (for form-hidden mode) */
|
|
57
|
-
@Output() onFilesUploaded = new EventEmitter<UploadedFile[]>();
|
|
58
|
-
@Output() hasUnsavedChangesChange = new EventEmitter<boolean>();
|
|
59
|
-
|
|
60
|
-
/** Event emitted when a file is removed (for form-hidden mode) */
|
|
61
|
-
@Output() onFileRemoved = new EventEmitter<{file: File, index: number}>();
|
|
62
|
-
|
|
63
|
-
/** Currently selected assignment type (Applicant or Application) */
|
|
64
|
-
selectedAssignmentType: 'Applicant' | 'Application' | null = null;
|
|
65
|
-
|
|
66
|
-
/** Currently selected applicant ID */
|
|
67
|
-
selectedApplicant: string = SHARED.EMPTY;
|
|
68
|
-
|
|
69
|
-
/** Currently selected document category */
|
|
70
|
-
selectedCategory: string = SHARED.EMPTY;
|
|
71
|
-
|
|
72
|
-
/** Currently selected document type */
|
|
73
|
-
selectedDocumentType: string = SHARED.EMPTY;
|
|
74
|
-
|
|
75
|
-
/** List of available applicants */
|
|
76
|
-
applicantList: UserListModel[] = SHARED.EMPTY_ARRAY;
|
|
77
|
-
|
|
78
|
-
/** Filtered list of applicants based on current selection */
|
|
79
|
-
filteredApplicantList: UserListModel[] = SHARED.EMPTY_ARRAY;
|
|
80
|
-
|
|
81
|
-
/** Available document categories for the selected assignment type */
|
|
82
|
-
categoryOptions: DocumentCategory[] = SHARED.EMPTY_ARRAY;
|
|
83
|
-
|
|
84
|
-
/** Available document types for the selected category */
|
|
85
|
-
documentTypeOptions: DocumentTypeModel[] = SHARED.EMPTY_ARRAY;
|
|
86
|
-
|
|
87
|
-
/** Array of files that have been uploaded */
|
|
88
|
-
uploadedFiles: UploadedFile[] = SHARED.EMPTY_ARRAY;
|
|
89
|
-
|
|
90
|
-
/** Map tracking upload progress for each file */
|
|
91
|
-
fileProgress: Map<File, number> = new Map();
|
|
92
|
-
|
|
93
|
-
/** Loading state for applicants data */
|
|
94
|
-
isLoadingApplicants: boolean = false;
|
|
95
|
-
|
|
96
|
-
/** Loading state for categories data */
|
|
97
|
-
isLoadingCategories: boolean = false;
|
|
98
|
-
|
|
99
|
-
/** Loading state for document types data */
|
|
100
|
-
isLoadingDocumentTypes: boolean = false;
|
|
101
|
-
|
|
102
|
-
/** Loading state for save operation */
|
|
103
|
-
isSaving: boolean = false;
|
|
104
|
-
|
|
105
|
-
/** Current form validation state */
|
|
106
|
-
isFormValid: boolean = false;
|
|
107
|
-
|
|
108
|
-
/** File size property for testing */
|
|
109
|
-
fileSize: string = '';
|
|
110
|
-
|
|
111
|
-
/** Subject for managing component lifecycle and unsubscribing from observables */
|
|
112
|
-
private destroy$ = new Subject<void>();
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Creates an instance of DocumentUploadComponent.
|
|
116
|
-
* @param documentUpload - Service for handling document upload operations
|
|
117
|
-
* @param uploadService - Service for document-related operations
|
|
118
|
-
* @param config - PrimeNG configuration service
|
|
119
|
-
* @param fileFormatService - Service for file format validation
|
|
120
|
-
* @param messageService - Service for displaying messages
|
|
121
|
-
* @param cdr - Change detector reference for manual change detection
|
|
122
|
-
* @param businessService - Service for business logic operations
|
|
123
|
-
* @param formService - Service for form validation and handling
|
|
124
|
-
* @param dataService - Service for data loading operations
|
|
125
|
-
*/
|
|
126
|
-
constructor(
|
|
127
|
-
public documentUpload: DocumentUploadService,
|
|
128
|
-
public uploadService: DocumentService,
|
|
129
|
-
private config: PrimeNGConfig,
|
|
130
|
-
public fileFormatService: FileFormatService,
|
|
131
|
-
public messageService: MessageService,
|
|
132
|
-
public cdr: ChangeDetectorRef,
|
|
133
|
-
private businessService: DocumentUploadBusinessService,
|
|
134
|
-
private formService: DocumentUploadFormService,
|
|
135
|
-
private dataService: DocumentUploadDataService
|
|
136
|
-
) { }
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Lifecycle hook called after inputs are initialized.
|
|
140
|
-
* Ensures no stale uploads are shown when navigating back.
|
|
141
|
-
*/
|
|
142
|
-
ngOnInit(): void {
|
|
143
|
-
this.resetForm();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
ngOnChanges(changes: SimpleChanges): void {
|
|
147
|
-
if (changes['isDocumentSaveBtnClicked'] && changes['isDocumentSaveBtnClicked'].currentValue) {
|
|
148
|
-
this.saveDocumentUpload();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if(changes['isDocumentSidebarClosed'] && changes['isDocumentSidebarClosed'].currentValue) {
|
|
152
|
-
if(this.isDocumentSidebarClosed) {
|
|
153
|
-
this.resetForm();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Handles changes in assignment type selection.
|
|
160
|
-
* Resets form selections, loads categories, and handles applicant loading.
|
|
161
|
-
*/
|
|
162
|
-
onAssignmentTypeChange(): void {
|
|
163
|
-
this.resetSelections();
|
|
164
|
-
this.loadCategories();
|
|
165
|
-
this.handleApplicantLoading();
|
|
166
|
-
this.validateForm(); // Validate form after assignment type change
|
|
167
|
-
this.emitFormValidationChange();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private checkForUnsavedChanges(): boolean {
|
|
171
|
-
// Check if files are uploaded
|
|
172
|
-
const hasFiles = Boolean(this.uploadedFiles && this.uploadedFiles.length > 0);
|
|
173
|
-
|
|
174
|
-
// Check if any form fields have been changed
|
|
175
|
-
const hasFormChanges = Boolean(
|
|
176
|
-
(this.selectedAssignmentType && this.selectedAssignmentType !== SHARED.EMPTY) ||
|
|
177
|
-
(this.selectedApplicant && this.selectedApplicant !== SHARED.EMPTY) ||
|
|
178
|
-
(this.selectedCategory && this.selectedCategory !== SHARED.EMPTY) ||
|
|
179
|
-
(this.selectedDocumentType && this.selectedDocumentType !== SHARED.EMPTY)
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
// Set and return the combined result
|
|
183
|
-
this.hasUnsavedChanges = hasFiles || hasFormChanges;
|
|
184
|
-
return this.hasUnsavedChanges;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Handles changes in category selection.
|
|
189
|
-
* Resets document type and loads available document types if category is selected.
|
|
190
|
-
*/
|
|
191
|
-
onCategoryChange(): void {
|
|
192
|
-
this.resetDocumentType();
|
|
193
|
-
if (this.selectedCategory) this.loadDocumentTypes();
|
|
194
|
-
this.validateForm(); // Validate form after category change
|
|
195
|
-
this.validateAndEmit();
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Handles changes in document type selection.
|
|
200
|
-
* Validates form and emits validation change event.
|
|
201
|
-
*/
|
|
202
|
-
onDocumentTypeChange(): void { this.validateAndEmit(); }
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Handles changes in applicant selection.
|
|
206
|
-
* Validates form and emits validation change event.
|
|
207
|
-
*/
|
|
208
|
-
onApplicantSelectionChange(): void { this.validateAndEmit(); }
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Handles file selection from the file upload component.
|
|
212
|
-
* Processes each selected file for templated upload sequentially.
|
|
213
|
-
* @param event - Event containing the selected files
|
|
214
|
-
*/
|
|
215
|
-
async onSelectedFiles(event: { currentFiles: File[] }): Promise<void> {
|
|
216
|
-
// Filter out files with unsupported extensions
|
|
217
|
-
const validFiles = event.currentFiles.filter(file =>
|
|
218
|
-
this.fileFormatService.isAllowedFileType(file.name)
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
if (validFiles.length !== event.currentFiles.length) {
|
|
222
|
-
const invalidFiles = event.currentFiles.filter(file =>
|
|
223
|
-
!this.fileFormatService.isAllowedFileType(file.name)
|
|
224
|
-
);
|
|
225
|
-
const invalidFileNames = invalidFiles.map(file => file.name).join(', ');
|
|
226
|
-
this.messageService.add({
|
|
227
|
-
severity: 'warn',
|
|
228
|
-
summary: 'Invalid File Type',
|
|
229
|
-
detail: `The following files have unsupported formats and will be skipped: ${invalidFileNames}`
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (validFiles.length > 0) {
|
|
234
|
-
await this.processFilesSequentially(validFiles);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
this.fileUploader.clear();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Processes files sequentially for upload
|
|
242
|
-
* @param files - Array of files to process
|
|
243
|
-
*/
|
|
244
|
-
private async processFilesSequentially(files: File[]): Promise<void> {
|
|
245
|
-
if (!this.formService.validateContextId(this.contextId, 'Context ID is required for upload.')) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
await this.documentUpload.uploadFilesSequentiallyWithProgress(
|
|
249
|
-
files,
|
|
250
|
-
this.contextId,
|
|
251
|
-
(currentFile, currentIndex, totalFiles) => {
|
|
252
|
-
this.fileProgress.set(currentFile, SHARED.UPLOAD_PROGRESS_10);
|
|
253
|
-
this.setupFileUploadListener(currentFile);
|
|
254
|
-
const formattedSize = this.businessService.formatFileSize(currentFile.size, this.config);
|
|
255
|
-
const uploadedFile = this.businessService.createUploadedFile(currentFile, formattedSize);
|
|
256
|
-
uploadedFile.progress = SHARED.UPLOAD_PROGRESS_10;
|
|
257
|
-
this.uploadedFiles.push(uploadedFile);
|
|
258
|
-
|
|
259
|
-
// Only validate form if not in form-hidden mode
|
|
260
|
-
if (!this.isFormHide) {
|
|
261
|
-
this.validateForm();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
this.cdr.detectChanges();
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Loads the list of applicants for the current context.
|
|
271
|
-
* Sets loading state and handles success/error responses.
|
|
272
|
-
*/
|
|
273
|
-
loadApplicants(): void {
|
|
274
|
-
this.isLoadingApplicants = true;
|
|
275
|
-
this.dataService.loadApplicants(
|
|
276
|
-
this.contextId,
|
|
277
|
-
(applicants) => this.handleApplicantsLoaded(applicants),
|
|
278
|
-
(error) => this.handleError('Failed to Load Applicants', error, () => this.isLoadingApplicants = false)
|
|
279
|
-
).pipe(takeUntil(this.destroy$)).subscribe({
|
|
280
|
-
next: (applicants) => this.handleApplicantsLoaded(applicants),
|
|
281
|
-
error: (error) => this.handleError('Failed to Load Applicants', error, () => this.isLoadingApplicants = false)
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Loads document categories based on the selected assignment type.
|
|
287
|
-
* Sets loading state and handles success/error responses.
|
|
288
|
-
*/
|
|
289
|
-
loadCategories(): void {
|
|
290
|
-
this.isLoadingCategories = true;
|
|
291
|
-
this.dataService.loadCategories(
|
|
292
|
-
this.selectedAssignmentType!,
|
|
293
|
-
(categories) => this.handleCategoriesLoaded(categories),
|
|
294
|
-
(error) => this.handleError('Failed to Load Categories', error, () => this.isLoadingCategories = false)
|
|
295
|
-
).pipe(takeUntil(this.destroy$)).subscribe({
|
|
296
|
-
next: (categories) => this.handleCategoriesLoaded(categories),
|
|
297
|
-
error: (error) => this.handleError('Failed to Load Categories', error, () => this.isLoadingCategories = false)
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Loads document types based on the selected category.
|
|
303
|
-
* Sets loading state and handles success/error responses.
|
|
304
|
-
*/
|
|
305
|
-
loadDocumentTypes(): void {
|
|
306
|
-
this.isLoadingDocumentTypes = true;
|
|
307
|
-
this.dataService.loadDocumentTypes(
|
|
308
|
-
this.selectedCategory,
|
|
309
|
-
(documentTypes) => this.handleDocumentTypesLoaded(documentTypes),
|
|
310
|
-
(error) => this.handleError('Failed to Load Document Types', error, () => this.isLoadingDocumentTypes = false)
|
|
311
|
-
).pipe(takeUntil(this.destroy$)).subscribe({
|
|
312
|
-
next: (documentTypes) => this.handleDocumentTypesLoaded(documentTypes),
|
|
313
|
-
error: (error) => this.handleError('Failed to Load Document Types', error, () => this.isLoadingDocumentTypes = false)
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Saves the document upload with all metadata.
|
|
319
|
-
* Validates payload and required fields before proceeding with upload.
|
|
320
|
-
*/
|
|
321
|
-
saveDocumentUpload(): void {
|
|
322
|
-
const payloadValidation = this.businessService.validatePayload(
|
|
323
|
-
this.selectedAssignmentType, this.selectedCategory, this.selectedDocumentType,
|
|
324
|
-
this.selectedApplicant, this.uploadedFiles
|
|
325
|
-
);
|
|
326
|
-
|
|
327
|
-
if (!payloadValidation.isValid) {
|
|
328
|
-
this.formService.showWarningMessage('Incomplete Form', payloadValidation.message);
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (!this.formService.validateRequiredFields(
|
|
333
|
-
this.selectedAssignmentType, this.selectedApplicant, this.selectedCategory,
|
|
334
|
-
this.selectedDocumentType, this.uploadedFiles
|
|
335
|
-
)) return;
|
|
336
|
-
|
|
337
|
-
this.isSaving = true;
|
|
338
|
-
this.saveDocumentMetadata();
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Removes a document from the uploaded files list.
|
|
345
|
-
* Updates progress tracking and validates form.
|
|
346
|
-
* @param file - The file to be removed
|
|
347
|
-
* @param index - The index of the file in the uploaded files array
|
|
348
|
-
*/
|
|
349
|
-
handleDocumentRemove(file: File, index: number): void {
|
|
350
|
-
this.uploadedFiles.splice(index, 1);
|
|
351
|
-
this.fileProgress.delete(file);
|
|
352
|
-
|
|
353
|
-
// Emit file removed event for form-hidden mode
|
|
354
|
-
if (this.isFormHide) {
|
|
355
|
-
this.onFileRemoved.emit({file, index});
|
|
356
|
-
} else {
|
|
357
|
-
this.validateAndEmit();
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
this.cdr.detectChanges();
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Utility method for file upload component integration.
|
|
365
|
-
* @param event - The file upload event
|
|
366
|
-
* @param callback - Callback function to execute
|
|
367
|
-
*/
|
|
368
|
-
choose(event: any, callback: () => void): void { callback(); }
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Triggers the file upload dialog.
|
|
372
|
-
*/
|
|
373
|
-
triggerFileUpload(): void { this.fileUploader.choose(); }
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Determines if the save button should be disabled.
|
|
377
|
-
* @returns True if the save button should be disabled, false otherwise
|
|
378
|
-
*/
|
|
379
|
-
getSaveButtonDisabled(): boolean {
|
|
380
|
-
const isDisabled = this.businessService.isSaveButtonDisabled(
|
|
381
|
-
this.selectedAssignmentType, this.selectedCategory, this.selectedDocumentType,
|
|
382
|
-
this.selectedApplicant, this.uploadedFiles, this.isSaving
|
|
383
|
-
)
|
|
384
|
-
return isDisabled;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Gets the upload progress for a specific file.
|
|
389
|
-
* @param file - The file to get progress for
|
|
390
|
-
* @returns The upload progress percentage (0-100)
|
|
391
|
-
*/
|
|
392
|
-
getProgress(file: File): number { return this.fileProgress.get(file) || 0; }
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Checks if a file is currently uploading.
|
|
396
|
-
* @param file - The file to check
|
|
397
|
-
* @returns True if the file is uploading, false otherwise
|
|
398
|
-
*/
|
|
399
|
-
isFileUploading(file: File): boolean {
|
|
400
|
-
const progress = this.fileProgress.get(file);
|
|
401
|
-
return progress !== undefined && progress > 0 && progress < SHARED.UPLOAD_PROGRESS_100;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Checks if a file has been successfully uploaded.
|
|
406
|
-
* @param file - The file to check
|
|
407
|
-
* @returns True if the file is uploaded, false otherwise
|
|
408
|
-
*/
|
|
409
|
-
isFileUploaded(file: File): boolean { return this.fileProgress.get(file) === SHARED.UPLOAD_PROGRESS_100; }
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Checks if a file upload encountered an error.
|
|
413
|
-
* @param file - The file to check
|
|
414
|
-
* @returns True if the file has an error, false otherwise
|
|
415
|
-
*/
|
|
416
|
-
isFileError(file: File): boolean { return this.fileProgress.get(file) === -1; }
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Resets the form to its initial state.
|
|
420
|
-
* Clears all selections, uploaded files, and progress tracking.
|
|
421
|
-
*/
|
|
422
|
-
resetForm(): void {
|
|
423
|
-
const initialState = this.businessService.getInitialFormState();
|
|
424
|
-
Object.assign(this, initialState);
|
|
425
|
-
this.fileProgress.clear();
|
|
426
|
-
this.filteredApplicantList = [];
|
|
427
|
-
this.categoryOptions = [];
|
|
428
|
-
this.documentTypeOptions = [];
|
|
429
|
-
this.cdr.detectChanges();
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Resets form selections (applicant, category, document type).
|
|
434
|
-
* Clears document type options.
|
|
435
|
-
*/
|
|
436
|
-
resetSelections(): void {
|
|
437
|
-
this.selectedApplicant = this.selectedCategory = this.selectedDocumentType = SHARED.EMPTY;
|
|
438
|
-
this.documentTypeOptions = SHARED.EMPTY_ARRAY;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* Resets document type selection and clears document type options.
|
|
443
|
-
*/
|
|
444
|
-
resetDocumentType(): void {
|
|
445
|
-
this.selectedDocumentType = SHARED.EMPTY;
|
|
446
|
-
this.documentTypeOptions = SHARED.EMPTY_ARRAY;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* Handles applicant loading based on assignment type.
|
|
451
|
-
* Loads applicants if type is 'Applicant', otherwise filters existing list.
|
|
452
|
-
*/
|
|
453
|
-
handleApplicantLoading(): void {
|
|
454
|
-
if (this.selectedAssignmentType === SHARED.APPLICANT) {
|
|
455
|
-
this.loadApplicants();
|
|
456
|
-
} else {
|
|
457
|
-
this.filterApplicants();
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Handles successful loading of applicants data.
|
|
463
|
-
* Updates applicant list, filters applicants, and validates form.
|
|
464
|
-
* @param applicants - Array of loaded applicants
|
|
465
|
-
*/
|
|
466
|
-
handleApplicantsLoaded(applicants: UserListModel[]): void {
|
|
467
|
-
this.applicantList = this.documentUpload.sortListByProperty(applicants, 'name');
|
|
468
|
-
this.filterApplicants();
|
|
469
|
-
this.isLoadingApplicants = false;
|
|
470
|
-
this.validateForm();
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Handles successful loading of categories data.
|
|
475
|
-
* Updates category options and validates form.
|
|
476
|
-
* @param categories - Array of loaded categories
|
|
477
|
-
*/
|
|
478
|
-
handleCategoriesLoaded(categories: DocumentCategory[]): void {
|
|
479
|
-
this.categoryOptions = this.documentUpload.sortListByProperty(categories, 'label');
|
|
480
|
-
this.isLoadingCategories = false;
|
|
481
|
-
this.validateForm();
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Handles successful loading of document types data.
|
|
486
|
-
* Updates document type options and validates form.
|
|
487
|
-
* @param documentTypes - Array of loaded document types
|
|
488
|
-
*/
|
|
489
|
-
handleDocumentTypesLoaded(documentTypes: DocumentTypeModel[]): void {
|
|
490
|
-
this.documentTypeOptions = this.documentUpload.sortListByProperty(documentTypes, 'label', 'name');
|
|
491
|
-
this.isLoadingDocumentTypes = false;
|
|
492
|
-
this.validateForm();
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Handles successful upload completion.
|
|
497
|
-
* Resets form and emits upload success event.
|
|
498
|
-
* @param response - The upload response from the server
|
|
499
|
-
*/
|
|
500
|
-
handleUploadSuccess(response: any): void {
|
|
501
|
-
this.isSaving = false;
|
|
502
|
-
this.resetForm();
|
|
503
|
-
this.onUploadSuccess.emit();
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Handles upload error.
|
|
508
|
-
* Resets saving state.
|
|
509
|
-
* @param error - The error that occurred during upload
|
|
510
|
-
*/
|
|
511
|
-
handleUploadError(error: any): void {
|
|
512
|
-
this.isSaving = false;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Filters applicants based on the selected assignment type.
|
|
517
|
-
* Updates the filtered applicant list.
|
|
518
|
-
*/
|
|
519
|
-
filterApplicants(): void {
|
|
520
|
-
this.filteredApplicantList = this.dataService.handleApplicantsLoaded(
|
|
521
|
-
this.applicantList, this.selectedAssignmentType
|
|
522
|
-
);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Validates the current form state.
|
|
527
|
-
* Checks payload validation and emits form validation change if state changed.
|
|
528
|
-
*/
|
|
529
|
-
validateForm(): void {
|
|
530
|
-
const payloadValidation = this.businessService.validatePayload(
|
|
531
|
-
this.selectedAssignmentType, this.selectedCategory, this.selectedDocumentType,
|
|
532
|
-
this.selectedApplicant, this.uploadedFiles
|
|
533
|
-
);
|
|
534
|
-
|
|
535
|
-
const previousValidationState = this.isFormValid;
|
|
536
|
-
this.isFormValid = payloadValidation.isValid;
|
|
537
|
-
|
|
538
|
-
const hasUnsavedChanges = this.checkForUnsavedChanges();
|
|
539
|
-
this.hasUnsavedChangesChange.emit(hasUnsavedChanges);
|
|
540
|
-
if (previousValidationState !== this.isFormValid) {
|
|
541
|
-
this.onFormValidationChange.emit();
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Saves document metadata to the server.
|
|
547
|
-
* Prepares upload payload and calls business service to save.
|
|
548
|
-
*/
|
|
549
|
-
saveDocumentMetadata(): void {
|
|
550
|
-
const contextId = this.selectedApplicant || this.contextId;
|
|
551
|
-
const payload = this.businessService.prepareUploadPayload(
|
|
552
|
-
this.selectedAssignmentType!, this.selectedCategory, this.selectedDocumentType,
|
|
553
|
-
this.selectedApplicant, this.uploadedFiles, contextId
|
|
554
|
-
);
|
|
555
|
-
|
|
556
|
-
this.businessService.saveDocumentUpload(payload)
|
|
557
|
-
.pipe(takeUntil(this.destroy$))
|
|
558
|
-
.subscribe({
|
|
559
|
-
next: (response) => this.handleUploadSuccess(response),
|
|
560
|
-
error: (error) => this.handleUploadError(error)
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Sets up a listener for file upload completion.
|
|
566
|
-
* Updates progress tracking and emits validation change when upload completes.
|
|
567
|
-
* @param file - The file to monitor for upload completion
|
|
568
|
-
*/
|
|
569
|
-
setupFileUploadListener(file: File): void {
|
|
570
|
-
this.documentUpload.uploadCompleted.pipe(takeUntil(this.destroy$)).subscribe(({file: uploadedFile, response}) => {
|
|
571
|
-
if (uploadedFile === file) {
|
|
572
|
-
this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_100);
|
|
573
|
-
const uploadedFileObj = this.uploadedFiles.find(uf => uf.file === file);
|
|
574
|
-
if (uploadedFileObj) {
|
|
575
|
-
uploadedFileObj.uploadResponse = response;
|
|
576
|
-
uploadedFileObj.progress = SHARED.UPLOAD_PROGRESS_100;
|
|
577
|
-
uploadedFileObj.url = response?.url;
|
|
578
|
-
uploadedFileObj.contentType = response?.contentType;
|
|
579
|
-
}
|
|
580
|
-
this.cdr.detectChanges();
|
|
581
|
-
|
|
582
|
-
// Emit files uploaded event for form-hidden mode
|
|
583
|
-
if (this.isFormHide) {
|
|
584
|
-
this.onFilesUploaded.emit([...this.uploadedFiles]);
|
|
585
|
-
} else {
|
|
586
|
-
this.onFormValidationChange.emit();
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* Handles errors during data loading operations.
|
|
594
|
-
* Resets loading state and can be extended for error logging.
|
|
595
|
-
* @param title - Error title for display
|
|
596
|
-
* @param error - The error object
|
|
597
|
-
* @param resetLoading - Callback to reset loading state
|
|
598
|
-
*/
|
|
599
|
-
handleError(title: string, error: any, resetLoading: () => void): void {
|
|
600
|
-
resetLoading();
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* Validates form and emits validation change event.
|
|
605
|
-
*/
|
|
606
|
-
validateAndEmit(): void {
|
|
607
|
-
this.validateForm();
|
|
608
|
-
this.onFormValidationChange.emit();
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* Emits form validation change event.
|
|
613
|
-
*/
|
|
614
|
-
emitFormValidationChange(): void {
|
|
615
|
-
this.onFormValidationChange.emit();
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
/**
|
|
619
|
-
* Formats file size for testing purposes.
|
|
620
|
-
* @param size - The file size in bytes
|
|
621
|
-
*/
|
|
622
|
-
formatSize(size: number): void {
|
|
623
|
-
this.fileSize = this.businessService.formatFileSize(size, this.config);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
/**
|
|
629
|
-
* Gets the accept string for the file upload component
|
|
630
|
-
* @returns String with file extensions for the accept attribute
|
|
631
|
-
*/
|
|
632
|
-
getFileUploadAcceptString(): string {
|
|
633
|
-
return this.fileFormatService.getAllowedFileExtensions()
|
|
634
|
-
.map(ext => `.${ext}`)
|
|
635
|
-
.join(SHARED.COMMA);
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* Gets the uploaded files data for external use (useful when form is hidden)
|
|
640
|
-
* @returns Array of uploaded files with their metadata
|
|
641
|
-
*/
|
|
642
|
-
getUploadedFiles(): UploadedFile[] {
|
|
643
|
-
return [...this.uploadedFiles];
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
/**
|
|
647
|
-
* Resets the upload component to its initial state (useful when form is hidden)
|
|
648
|
-
*/
|
|
649
|
-
resetUpload(): void {
|
|
650
|
-
this.uploadedFiles = [];
|
|
651
|
-
this.fileProgress.clear();
|
|
652
|
-
this.cdr.detectChanges();
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* Lifecycle hook that is called when component is destroyed.
|
|
657
|
-
* Cleans up subscriptions and destroys services.
|
|
658
|
-
*/
|
|
659
|
-
ngOnDestroy(): void {
|
|
660
|
-
console.log("destroyed")
|
|
661
|
-
this.resetUpload()
|
|
662
|
-
this.destroy$.next();
|
|
663
|
-
this.destroy$.complete();
|
|
664
|
-
this.businessService.destroy();
|
|
665
|
-
this.dataService.destroy();
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
|