+1
-1
@@ -15,7 +15,7 @@
|
|||||||
<input formControlName="description" matInput />
|
<input formControlName="description" matInput />
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<input type="file" name="file" (change)="onFileSelect($event)" />
|
<mifosx-file-upload flex="60%" (change)="onFileSelect($event)"></mifosx-file-upload>
|
||||||
|
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions align="end">
|
||||||
<button mat-raised-button mat-dialog-close>Cancel</button>
|
<button mat-raised-button mat-dialog-close>Cancel</button>
|
||||||
|
|||||||
+20
-6
@@ -8,14 +8,22 @@ import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms'
|
|||||||
styleUrls: ['./upload-document-dialog.component.scss']
|
styleUrls: ['./upload-document-dialog.component.scss']
|
||||||
})
|
})
|
||||||
export class UploadDocumentDialogComponent implements OnInit {
|
export class UploadDocumentDialogComponent implements OnInit {
|
||||||
|
|
||||||
/** Upload Document form. */
|
/** Upload Document form. */
|
||||||
uploadDocumentForm: FormGroup;
|
uploadDocumentForm: FormGroup;
|
||||||
file: any;
|
/** Upload Document Data */
|
||||||
uploadDocumentData: any = [];
|
uploadDocumentData: any = [];
|
||||||
|
/** Triggers description field */
|
||||||
documentIdentifier = false;
|
documentIdentifier = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {MatDialogRef} dialogRef Dialog reference element
|
||||||
|
* @param {FormBuilder} formBuilder Form Builder
|
||||||
|
* @param {any} data Dialog Data
|
||||||
|
*/
|
||||||
constructor(public dialogRef: MatDialogRef<UploadDocumentDialogComponent>,
|
constructor(public dialogRef: MatDialogRef<UploadDocumentDialogComponent>,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any) {
|
@Inject(MAT_DIALOG_DATA) public data: any) {
|
||||||
this.documentIdentifier = data.documentIdentifier;
|
this.documentIdentifier = data.documentIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,12 +41,18 @@ export class UploadDocumentDialogComponent implements OnInit {
|
|||||||
'file': ['']
|
'file': ['']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
onFileSelect(event: any) {
|
|
||||||
if (event.target.files.length > 0) {
|
/**
|
||||||
const file = event.target.files[0];
|
* 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);
|
this.uploadDocumentForm.get('file').setValue(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="2%">
|
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="2%">
|
||||||
<mat-form-field fxFlex="83%">
|
|
||||||
<input matInput [readonly]="true" [value]="fileName" placeholder="No file uploaded">
|
<mat-form-field [fxFlex]="flex || '83%'">
|
||||||
|
<input matInput [readonly]="true" [value]="fileName || ''" placeholder="No file selected">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<span fxFlex="13%" fxFlexAlign="center">
|
|
||||||
|
<span fxFlex="10%" fxFlexAlign="center">
|
||||||
<button mat-button (click)="uploadFile.click()">
|
<button mat-button (click)="uploadFile.click()">
|
||||||
<fa-icon icon="file-upload" size="lg"></fa-icon>
|
<fa-icon icon="folder-open" size="lg"></fa-icon>
|
||||||
|
|
||||||
Upload a file
|
Browse
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<input type="file" #uploadFile (change)="onFileSelected($event)" [style.display]="'none'">
|
|
||||||
|
<input type="file" #uploadFile (change)="onFileSelect($event)" [style.display]="'none'">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/** Angular Imports */
|
/** Angular Imports */
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom file upload component based on angular material.
|
* Custom file upload component based on angular material.
|
||||||
@@ -9,21 +9,20 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
templateUrl: './file-upload.component.html',
|
templateUrl: './file-upload.component.html',
|
||||||
styleUrls: ['./file-upload.component.scss']
|
styleUrls: ['./file-upload.component.scss']
|
||||||
})
|
})
|
||||||
export class FileUploadComponent implements OnInit {
|
export class FileUploadComponent {
|
||||||
|
|
||||||
/** Name of file. */
|
/** Form field flex dimension */
|
||||||
fileName = '';
|
@Input() flex: any;
|
||||||
|
/** Selected file name */
|
||||||
|
fileName: File;
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploads a file.
|
* Sets the file name.
|
||||||
* @param {any} event The file input change event.
|
* @param {any} event File input change event.
|
||||||
*/
|
*/
|
||||||
onFileSelected($event: any) {
|
onFileSelect($event: any) {
|
||||||
this.fileName = $event.target.files[0].name;
|
this.fileName = $event.target.files[0].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ import {
|
|||||||
faPen,
|
faPen,
|
||||||
faFlag,
|
faFlag,
|
||||||
faArrowUp,
|
faArrowUp,
|
||||||
faArrowDown
|
faArrowDown,
|
||||||
|
faFolderOpen
|
||||||
} from '@fortawesome/free-solid-svg-icons';
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
/** Add icons to the library for convenient access in other components. */
|
/** Add icons to the library for convenient access in other components. */
|
||||||
@@ -184,7 +185,8 @@ library.add(
|
|||||||
faPen,
|
faPen,
|
||||||
faFlag,
|
faFlag,
|
||||||
faArrowUp,
|
faArrowUp,
|
||||||
faArrowDown
|
faArrowDown,
|
||||||
|
faFolderOpen
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user