cat-documents-ng 0.4.9 → 0.4.11
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.
|
@@ -3418,6 +3418,7 @@ class DocumentUploadComponent {
|
|
|
3418
3418
|
this.handleApplicantLoading();
|
|
3419
3419
|
this.validateForm(); // Validate form after assignment type change
|
|
3420
3420
|
this.emitFormValidationChange();
|
|
3421
|
+
this.emitUpdatedPayloadIfFilesUploaded();
|
|
3421
3422
|
}
|
|
3422
3423
|
/**
|
|
3423
3424
|
* Handles changes in category selection.
|
|
@@ -3429,17 +3430,24 @@ class DocumentUploadComponent {
|
|
|
3429
3430
|
this.loadDocumentTypes();
|
|
3430
3431
|
this.validateForm(); // Validate form after category change
|
|
3431
3432
|
this.validateAndEmit();
|
|
3433
|
+
this.emitUpdatedPayloadIfFilesUploaded();
|
|
3432
3434
|
}
|
|
3433
3435
|
/**
|
|
3434
3436
|
* Handles changes in document type selection.
|
|
3435
3437
|
* Validates form and emits validation change event.
|
|
3436
3438
|
*/
|
|
3437
|
-
onDocumentTypeChange() {
|
|
3439
|
+
onDocumentTypeChange() {
|
|
3440
|
+
this.validateAndEmit();
|
|
3441
|
+
this.emitUpdatedPayloadIfFilesUploaded();
|
|
3442
|
+
}
|
|
3438
3443
|
/**
|
|
3439
3444
|
* Handles changes in applicant selection.
|
|
3440
3445
|
* Validates form and emits validation change event.
|
|
3441
3446
|
*/
|
|
3442
|
-
onApplicantSelectionChange() {
|
|
3447
|
+
onApplicantSelectionChange() {
|
|
3448
|
+
this.validateAndEmit();
|
|
3449
|
+
this.emitUpdatedPayloadIfFilesUploaded();
|
|
3450
|
+
}
|
|
3443
3451
|
/**
|
|
3444
3452
|
* Handles file selection from the file upload component.
|
|
3445
3453
|
* Processes each selected file for templated upload sequentially.
|
|
@@ -3547,6 +3555,8 @@ class DocumentUploadComponent {
|
|
|
3547
3555
|
}
|
|
3548
3556
|
else {
|
|
3549
3557
|
this.validateAndEmit();
|
|
3558
|
+
// Emit updated payload if there are still files remaining
|
|
3559
|
+
this.emitUpdatedPayloadIfFilesUploaded();
|
|
3550
3560
|
}
|
|
3551
3561
|
this.cdr.detectChanges();
|
|
3552
3562
|
}
|
|
@@ -3739,6 +3749,9 @@ class DocumentUploadComponent {
|
|
|
3739
3749
|
this.onFilesUploaded.emit([...this.uploadedFiles]);
|
|
3740
3750
|
}
|
|
3741
3751
|
else {
|
|
3752
|
+
// When form is not hidden, emit the structured payload format
|
|
3753
|
+
const payload = this.createUploadPayload();
|
|
3754
|
+
this.onFilesUploaded.emit(payload);
|
|
3742
3755
|
this.onFormValidationChange.emit();
|
|
3743
3756
|
}
|
|
3744
3757
|
}
|
|
@@ -3790,6 +3803,37 @@ class DocumentUploadComponent {
|
|
|
3790
3803
|
getUploadedFiles() {
|
|
3791
3804
|
return [...this.uploadedFiles];
|
|
3792
3805
|
}
|
|
3806
|
+
/**
|
|
3807
|
+
* Creates the upload payload in the required format for onFilesUploaded event
|
|
3808
|
+
* @returns The structured payload object
|
|
3809
|
+
*/
|
|
3810
|
+
createUploadPayload() {
|
|
3811
|
+
const contextId = this.selectedApplicant || this.contextId;
|
|
3812
|
+
return {
|
|
3813
|
+
source: this.selectedAssignmentType || "Application",
|
|
3814
|
+
categoryId: this.selectedCategory,
|
|
3815
|
+
documentTypeId: this.selectedDocumentType,
|
|
3816
|
+
contextId: contextId,
|
|
3817
|
+
documents: this.uploadedFiles.map(file => ({
|
|
3818
|
+
fileName: file.file.name,
|
|
3819
|
+
fileSize: file.file.size,
|
|
3820
|
+
url: file.url,
|
|
3821
|
+
contentType: file.contentType,
|
|
3822
|
+
uploadedFileId: file.uploadResponse?.id || file.uploadResponse?.fileName || file.file.name
|
|
3823
|
+
}))
|
|
3824
|
+
};
|
|
3825
|
+
}
|
|
3826
|
+
/**
|
|
3827
|
+
* Emits updated payload if files are already uploaded and form is not hidden
|
|
3828
|
+
* This ensures the payload is always current when form selections change
|
|
3829
|
+
*/
|
|
3830
|
+
emitUpdatedPayloadIfFilesUploaded() {
|
|
3831
|
+
// Only emit if form is not hidden and there are uploaded files
|
|
3832
|
+
if (!this.isFormHide && this.uploadedFiles.length > 0) {
|
|
3833
|
+
const payload = this.createUploadPayload();
|
|
3834
|
+
this.onFilesUploaded.emit(payload);
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3793
3837
|
/**
|
|
3794
3838
|
* Resets the upload component to its initial state (useful when form is hidden)
|
|
3795
3839
|
*/
|