45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { Component, OnInit, Inject } from '@angular/core';
|
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
|
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
|
|
|
|
@Component({
|
|
selector: 'mifosx-upload-document-dialog',
|
|
templateUrl: './upload-document-dialog.component.html',
|
|
styleUrls: ['./upload-document-dialog.component.scss']
|
|
})
|
|
export class UploadDocumentDialogComponent implements OnInit {
|
|
/** Upload Document form. */
|
|
uploadDocumentForm: FormGroup;
|
|
file: any;
|
|
uploadDocumentData: any = [];
|
|
documentIdentifier = false;
|
|
constructor(public dialogRef: MatDialogRef<UploadDocumentDialogComponent>,
|
|
private formBuilder: FormBuilder,
|
|
@Inject(MAT_DIALOG_DATA) public data: any) {
|
|
this.documentIdentifier = data.documentIdentifier;
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.createUploadDocumentForm();
|
|
}
|
|
|
|
/**
|
|
* Creates the upload Document form.
|
|
*/
|
|
createUploadDocumentForm() {
|
|
this.uploadDocumentForm = this.formBuilder.group({
|
|
'fileName': ['', Validators.required],
|
|
'description': [''],
|
|
'file': ['']
|
|
});
|
|
}
|
|
onFileSelect(event: any) {
|
|
if (event.target.files.length > 0) {
|
|
const file = event.target.files[0];
|
|
this.uploadDocumentForm.get('file').setValue(file);
|
|
}
|
|
}
|
|
}
|
|
|
|
|