committed by
Abhay Chawla
parent
c2bd5d1444
commit
357b3731cc
@@ -1,46 +1,47 @@
|
|||||||
<div class="tab-container mat-typography">
|
<div class="tab-container mat-typography">
|
||||||
|
|
||||||
<!-- Documents Table -->
|
<!-- Documents Table -->
|
||||||
|
|
||||||
<h3>Documents</h3>
|
<h3>Documents</h3>
|
||||||
|
|
||||||
<button mat-raised-button class="f-right" color="primary">
|
<button mat-raised-button class="f-right" color="primary" (click)="uploadDocument()">
|
||||||
<fa-icon icon="plus"></fa-icon> Add
|
<fa-icon icon="plus"></fa-icon>
|
||||||
|
Add
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<table mat-table #documentsTable [dataSource]="clientDocuments" class="mat-elevation-z1">
|
<table mat-table #documentsTable [dataSource]="clientDocuments" class="mat-elevation-z1">
|
||||||
|
|
||||||
<ng-container matColumnDef="name">
|
<ng-container matColumnDef="name">
|
||||||
<th mat-header-cell *matHeaderCellDef> Name </th>
|
<th mat-header-cell *matHeaderCellDef> Name </th>
|
||||||
<td mat-cell *matCellDef="let document">
|
<td mat-cell *matCellDef="let document">
|
||||||
{{document.name}} </td>
|
{{document.name}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="description">
|
<ng-container matColumnDef="description">
|
||||||
<th mat-header-cell *matHeaderCellDef> Description </th>
|
<th mat-header-cell *matHeaderCellDef> Description </th>
|
||||||
<td mat-cell *matCellDef="let document"> {{document.description}} </td>
|
<td mat-cell *matCellDef="let document"> {{document.description}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="fileName">
|
<ng-container matColumnDef="fileName">
|
||||||
<th mat-header-cell *matHeaderCellDef> File Name </th>
|
<th mat-header-cell *matHeaderCellDef> File Name </th>
|
||||||
<td mat-cell *matCellDef="let document"> {{document.fileName}}
|
<td mat-cell *matCellDef="let document"> {{document.fileName}}
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="actions">
|
<ng-container matColumnDef="actions">
|
||||||
<th mat-header-cell *matHeaderCellDef> Actions </th>
|
<th mat-header-cell *matHeaderCellDef> Actions </th>
|
||||||
<td mat-cell *matCellDef="let document; let i = index">
|
<td mat-cell *matCellDef="let document; let i = index">
|
||||||
<button class="document-action-button" mat-raised-button color="primary" (click)="download(document.parentEntityId,document.id)">
|
<button class="document-action-button" mat-raised-button color="primary" (click)="download(document.parentEntityId,document.id)">
|
||||||
<fa-icon icon="cloud-download-alt"></fa-icon>
|
<fa-icon icon="cloud-download-alt"></fa-icon>
|
||||||
</button>
|
</button>
|
||||||
<button class="document-action-button" mat-raised-button color="warn" (click)="deleteDocument(document.parentEntityId,document.id,index)">
|
<button class="document-action-button" mat-raised-button color="warn" (click)="deleteDocument(document.parentEntityId,document.id,i)">
|
||||||
<fa-icon icon="times"></fa-icon>
|
<fa-icon icon="times"></fa-icon>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="documentsColumns"></tr>
|
<tr mat-header-row *matHeaderRowDef="documentsColumns"></tr>
|
||||||
<tr mat-row *matRowDef="let row; columns: documentsColumns;"></tr>
|
<tr mat-row *matRowDef="let row; columns: documentsColumns;"></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -5,6 +5,9 @@ import { MatDialog } from '@angular/material';
|
|||||||
|
|
||||||
/** Custom Services */
|
/** Custom Services */
|
||||||
import { ClientsService } from '../../clients.service';
|
import { ClientsService } from '../../clients.service';
|
||||||
|
|
||||||
|
/** Custom Components */
|
||||||
|
import { UploadDocumentDialogComponent } from '../upload-document-dialog/upload-document-dialog.component';
|
||||||
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
||||||
|
|
||||||
|
|
||||||
@@ -17,6 +20,7 @@ export class DocumentsTabComponent implements OnInit {
|
|||||||
@ViewChild('documentsTable') documentsTable: MatTable<Element>;
|
@ViewChild('documentsTable') documentsTable: MatTable<Element>;
|
||||||
documentsColumns: string[] = ['name', 'description', 'fileName', 'actions'];
|
documentsColumns: string[] = ['name', 'description', 'fileName', 'actions'];
|
||||||
clientDocuments: any;
|
clientDocuments: any;
|
||||||
|
clientId: string;
|
||||||
|
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
@@ -24,7 +28,10 @@ export class DocumentsTabComponent implements OnInit {
|
|||||||
public dialog: MatDialog) {
|
public dialog: MatDialog) {
|
||||||
this.route.data.subscribe((data: { clientDocuments: any }) => {
|
this.route.data.subscribe((data: { clientDocuments: any }) => {
|
||||||
this.clientDocuments = data.clientDocuments;
|
this.clientDocuments = data.clientDocuments;
|
||||||
|
console.log(this.clientDocuments);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
this.clientId = this.route.parent.snapshot.paramMap.get('clientId');
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -38,10 +45,10 @@ export class DocumentsTabComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteDocument(parentEntityId: string, documentId: string, index: number) {
|
deleteDocument(parentEntityId: string, documentId: string, index: number) {
|
||||||
const deleteFamilyMemberDialogRef = this.dialog.open(DeleteDialogComponent, {
|
const deleteDocumentDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||||
data: { deleteContext: `document id:${documentId}` }
|
data: { deleteContext: `document id:${documentId}` }
|
||||||
});
|
});
|
||||||
deleteFamilyMemberDialogRef.afterClosed().subscribe((response: any) => {
|
deleteDocumentDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
if (response.delete) {
|
if (response.delete) {
|
||||||
this.clientService.deleteClientDocument(parentEntityId, documentId).subscribe(res => {
|
this.clientService.deleteClientDocument(parentEntityId, documentId).subscribe(res => {
|
||||||
this.clientDocuments.splice(index, 1);
|
this.clientDocuments.splice(index, 1);
|
||||||
@@ -51,4 +58,31 @@ export class DocumentsTabComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uploadDocument() {
|
||||||
|
const uploadDocumentDialogRef = this.dialog.open(UploadDocumentDialogComponent, {
|
||||||
|
data: { documentIdentifier: false }
|
||||||
|
});
|
||||||
|
uploadDocumentDialogRef.afterClosed().subscribe((dialogResponse: any) => {
|
||||||
|
console.log(dialogResponse);
|
||||||
|
if (dialogResponse) {
|
||||||
|
const formData: FormData = new FormData;
|
||||||
|
formData.append('name', dialogResponse.fileName);
|
||||||
|
formData.append('file', dialogResponse.file);
|
||||||
|
formData.append('description', dialogResponse.description);
|
||||||
|
this.clientService.uploadClientDocument(this.clientId, formData).subscribe((res: any) => {
|
||||||
|
this.clientDocuments.push({
|
||||||
|
id: res.resourceId,
|
||||||
|
parentEntityType: 'clients',
|
||||||
|
parentEntityId: this.clientId,
|
||||||
|
name: dialogResponse.fileName,
|
||||||
|
description: dialogResponse.description,
|
||||||
|
fileName: dialogResponse.file.name
|
||||||
|
});
|
||||||
|
this.documentsTable.renderRows();
|
||||||
|
console.log('document Uploaded');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
<button class="identity-action-button" mat-raised-button color="primary" (click)="uploadDocument(i,identity.id)">
|
<button class="identity-action-button" mat-raised-button color="primary" (click)="uploadDocument(i,identity.id)">
|
||||||
<fa-icon icon="cloud-upload-alt"></fa-icon>
|
<fa-icon icon="cloud-upload-alt"></fa-icon>
|
||||||
</button>
|
</button>
|
||||||
<button class="identity-action-button" mat-raised-button color="warn" (click)="deleteIdentifier(identity.clientId,identity.id,index)">
|
<button class="identity-action-button" mat-raised-button color="warn" (click)="deleteIdentifier(identity.clientId,identity.id,i)">
|
||||||
<fa-icon icon="times"></fa-icon>
|
<fa-icon icon="times"></fa-icon>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ export class IdentitiesTabComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uploadDocument(index: number, identifierId: string) {
|
uploadDocument(index: number, identifierId: string) {
|
||||||
const uploadDocumentDialogRef = this.dialog.open(UploadDocumentDialogComponent);
|
const uploadDocumentDialogRef = this.dialog.open(UploadDocumentDialogComponent, {
|
||||||
|
data: { documentIdentifier: true }
|
||||||
|
});
|
||||||
uploadDocumentDialogRef.afterClosed().subscribe((dialogResponse: any) => {
|
uploadDocumentDialogRef.afterClosed().subscribe((dialogResponse: any) => {
|
||||||
if (dialogResponse) {
|
if (dialogResponse) {
|
||||||
const formData: FormData = new FormData;
|
const formData: FormData = new FormData;
|
||||||
@@ -65,7 +67,7 @@ export class IdentitiesTabComponent implements OnInit {
|
|||||||
parentEntityType: 'client_identifiers',
|
parentEntityType: 'client_identifiers',
|
||||||
parentEntityId: identifierId,
|
parentEntityId: identifierId,
|
||||||
name: dialogResponse.fileName,
|
name: dialogResponse.fileName,
|
||||||
fileName: dialogResponse.file.fileName
|
fileName: dialogResponse.file.name
|
||||||
});
|
});
|
||||||
this.identifiersTable.renderRows();
|
this.identifiersTable.renderRows();
|
||||||
});
|
});
|
||||||
|
|||||||
+19
-15
@@ -1,22 +1,26 @@
|
|||||||
<h1 mat-dialog-title>Upload Client Documents</h1>
|
<h1 mat-dialog-title>Upload Client Documents</h1>
|
||||||
<div>
|
<div>
|
||||||
<form [formGroup]="uploadDocumentForm" fxLayout="column">
|
<form [formGroup]="uploadDocumentForm" fxLayout="column">
|
||||||
|
|
||||||
<mat-form-field fxFlex>
|
<mat-form-field fxFlex>
|
||||||
<mat-label>File Name</mat-label>
|
<mat-label>File Name</mat-label>
|
||||||
<input formControlName="fileName" required matInput />
|
<input formControlName="fileName" required matInput />
|
||||||
<mat-error *ngIf="uploadDocumentForm.controls.fileName.hasError('required')">
|
<mat-error *ngIf="uploadDocumentForm.controls.fileName.hasError('required')">
|
||||||
File Name is <strong>required</strong>
|
File Name is <strong>required</strong>
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<input type="file" name="file" (change)="onFileSelect($event)" />
|
<mat-form-field fxFlex *ngIf="!documentIdentifier">
|
||||||
|
<mat-label>Description</mat-label>
|
||||||
|
<input formControlName="description" matInput />
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-dialog-actions align="end">
|
<input type="file" name="file" (change)="onFileSelect($event)" />
|
||||||
<button mat-raised-button mat-dialog-close>Cancel</button>
|
|
||||||
<button mat-raised-button color="primary" [disabled]="!uploadDocumentForm.valid"
|
|
||||||
[mat-dialog-close]="uploadDocumentForm.value">Confirm</button>
|
|
||||||
</mat-dialog-actions>
|
|
||||||
|
|
||||||
</form>
|
<mat-dialog-actions align="end">
|
||||||
|
<button mat-raised-button mat-dialog-close>Cancel</button>
|
||||||
|
<button mat-raised-button color="primary" [disabled]="!uploadDocumentForm.valid" [mat-dialog-close]="uploadDocumentForm.value">Confirm</button>
|
||||||
|
</mat-dialog-actions>
|
||||||
|
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
+5
-2
@@ -12,10 +12,12 @@ export class UploadDocumentDialogComponent implements OnInit {
|
|||||||
uploadDocumentForm: FormGroup;
|
uploadDocumentForm: FormGroup;
|
||||||
file: any;
|
file: any;
|
||||||
uploadDocumentData: any = [];
|
uploadDocumentData: any = [];
|
||||||
|
documentIdentifier = false;
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.createUploadDocumentForm();
|
this.createUploadDocumentForm();
|
||||||
@@ -27,6 +29,7 @@ export class UploadDocumentDialogComponent implements OnInit {
|
|||||||
createUploadDocumentForm() {
|
createUploadDocumentForm() {
|
||||||
this.uploadDocumentForm = this.formBuilder.group({
|
this.uploadDocumentForm = this.formBuilder.group({
|
||||||
'fileName': ['', Validators.required],
|
'fileName': ['', Validators.required],
|
||||||
|
'description': [''],
|
||||||
'file': ['']
|
'file': ['']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,10 @@ export class ClientsService {
|
|||||||
return this.http.get(`/clients/${parentEntityId}/documents/${documentId}/attachment`, { responseType: 'blob' });
|
return this.http.get(`/clients/${parentEntityId}/documents/${documentId}/attachment`, { responseType: 'blob' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uploadClientDocument(clientId: string, documentData: any) {
|
||||||
|
return this.http.post(`/clients/${clientId}/documents`, documentData);
|
||||||
|
}
|
||||||
|
|
||||||
deleteClientDocument(parentEntityId: string, documentId: string) {
|
deleteClientDocument(parentEntityId: string, documentId: string) {
|
||||||
return this.http.delete(`/clients/${parentEntityId}/documents/${documentId}`);
|
return this.http.delete(`/clients/${parentEntityId}/documents/${documentId}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user