Fix to upload documents (#1621)

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2023-01-03 20:47:10 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent 9d19d1b061
commit 28d5d7595f
14 changed files with 227 additions and 284 deletions
@@ -1,28 +0,0 @@
<h1 mat-dialog-title>Load Loan Document</h1>
<div>
<form [formGroup]="uploadDocumentForm" fxLayout="column">
<mat-form-field fxFlex>
<mat-label>File Name</mat-label>
<input formControlName="name" required matInput />
<mat-error *ngIf="uploadDocumentForm.controls.name.hasError('required')">
File Name is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>Description</mat-label>
<input formControlName="description" matInput />
</mat-form-field>
<mifosx-file-upload flex="60%" (change)="onFileSelect($event)"></mifosx-file-upload>
<mat-dialog-actions align="end">
<button mat-raised-button mat-dialog-close>Cancel</button>
<button mat-raised-button color="primary" [disabled]="!uploadDocumentForm.valid" *mifosxHasPermission="'CREATE_DOCUMENT'"
[mat-dialog-close]="{data: {name: uploadDocumentForm.value.name, description: uploadDocumentForm.value.description, file: uploadDocumentForm.value.file} }">Confirm</button>
</mat-dialog-actions>
</form>
</div>
@@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LoanAccountLoadDocumentsDialogComponent } from './loan-account-load-documents-dialog.component';
describe('LoanAccountLoadDocumentsDialogComponent', () => {
let component: LoanAccountLoadDocumentsDialogComponent;
let fixture: ComponentFixture<LoanAccountLoadDocumentsDialogComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoanAccountLoadDocumentsDialogComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoanAccountLoadDocumentsDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,51 +0,0 @@
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
@Component({
selector: 'mifosx-loan-account-load-documents-dialog',
templateUrl: './loan-account-load-documents-dialog.component.html',
styleUrls: ['./loan-account-load-documents-dialog.component.scss']
})
export class LoanAccountLoadDocumentsDialogComponent implements OnInit {
/** Upload Document form. */
uploadDocumentForm: FormGroup;
/**
* @param {MatDialogRef} dialogRef Dialog reference element
* @param {FormBuilder} formBuilder Form Builder
* @param {any} data Dialog Data
*/
constructor(public dialogRef: MatDialogRef<LoanAccountLoadDocumentsDialogComponent>,
private formBuilder: FormBuilder,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
ngOnInit() {
this.createUploadDocumentForm();
}
/**
* Creates the upload Document form.
*/
createUploadDocumentForm() {
this.uploadDocumentForm = this.formBuilder.group({
'name': ['', Validators.required],
'description': [''],
'file': ['']
});
}
/**
* Sets file form control value.
* @param {any} $event file change event.
*/
onFileSelect($event: any) {
if ($event.target.files.length > 0) {
const file = $event.target.files[0];
this.uploadDocumentForm.get('file').setValue(file);
}
}
}