feat: client actions (reject-transfer) (#1087)

Fixes: #1086
This commit is contained in:
Karan Takalkar
2020-07-14 10:43:15 +05:30
committed by GitHub
parent f861e466bf
commit 5573738d86
9 changed files with 146 additions and 8 deletions
@@ -7,3 +7,4 @@
<mifosx-update-client-savings-account *ngIf="actions['Update Default Savings']"></mifosx-update-client-savings-account>
<mifosx-transfer-client *ngIf="actions['Transfer Client']"></mifosx-transfer-client>
<mifosx-undo-client-transfer *ngIf="actions['Undo Transfer']"></mifosx-undo-client-transfer>
<mifosx-reject-client-transfer *ngIf="actions['Reject Transfer']"></mifosx-reject-client-transfer>
@@ -0,0 +1,32 @@
<div class="container">
<mat-card>
<form [formGroup]="rejectClientTransferForm" (ngSubmit)="submit()">
<mat-card-content fxLayout="column">
<mat-form-field>
<mat-label>Transfer Date</mat-label>
<input matInput [matDatepicker]="transferDatePicker" required formControlName="transferDate">
<mat-datepicker-toggle matSuffix [for]="transferDatePicker"></mat-datepicker-toggle>
<mat-datepicker #transferDatePicker></mat-datepicker>
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>Note</mat-label>
<textarea matInput formControlName="note"></textarea>
</mat-form-field>
</mat-card-content>
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
<button type="button" mat-raised-button [routerLink]="['../../']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!rejectClientTransferForm.valid">Confirm</button>
</mat-card-actions>
</form>
</mat-card>
</div>
@@ -0,0 +1,3 @@
.container {
max-width: 37rem;
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RejectClientTransferComponent } from './reject-client-transfer.component';
describe('RejectClientTransferComponent', () => {
let component: RejectClientTransferComponent;
let fixture: ComponentFixture<RejectClientTransferComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RejectClientTransferComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(RejectClientTransferComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,72 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { ClientsService } from 'app/clients/clients.service';
/**
* Reject Client Transfer Component
*/
@Component({
selector: 'mifosx-reject-client-transfer',
templateUrl: './reject-client-transfer.component.html',
styleUrls: ['./reject-client-transfer.component.scss']
})
export class RejectClientTransferComponent implements OnInit {
/** Reject Approval Savings Account form. */
rejectClientTransferForm: FormGroup;
/** Client Id */
clientId: any;
/** Transfer Date */
transferDate: any;
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {ClientsService} clientsService Clients Service
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
*/
constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService,
private route: ActivatedRoute,
private router: Router) {
this.route.data.subscribe((data: { clientActionData: any }) => {
this.transferDate = data.clientActionData;
});
this.clientId = this.route.parent.snapshot.params['clientId'];
}
/**
* Creates the reject-approval savings form.
*/
ngOnInit() {
this.createRejectClientTransferForm();
}
/**
* Creates the reject-approval savings account form.
*/
createRejectClientTransferForm() {
this.rejectClientTransferForm = this.formBuilder.group({
'transferDate': {value: new Date(this.transferDate), disabled: true},
'note': ['']
});
}
/**
* Submits the form and reject the transfer of client
* if successful redirects to the client.
*/
submit() {
const data = {
...this.rejectClientTransferForm.value,
};
this.clientsService.executeClientCommand(this.clientId, 'rejectTransfer', data).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
}
@@ -7,7 +7,7 @@
<mat-card-content fxLayout="column">
<mat-form-field>
<mat-label>Closed On Date</mat-label>
<mat-label>Transfer Date</mat-label>
<input matInput [matDatepicker]="transferDatePicker" required formControlName="transferDate">
<mat-datepicker-toggle matSuffix [for]="transferDatePicker"></mat-datepicker-toggle>
<mat-datepicker #transferDatePicker></mat-datepicker>
@@ -1,7 +1,6 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { FormGroup, FormBuilder } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
@@ -58,7 +57,7 @@ export class UndoClientTransferComponent implements OnInit {
}
/**
* Submits the form and undo the trandsfer of client
* Submits the form and undo the transfer of client
* if successful redirects to the client.
*/
submit() {
@@ -40,9 +40,13 @@ export class ClientsViewComponent implements OnInit {
}
ngOnInit() {
this.clientsService.getClientProfileImage(this.clientViewData.id).subscribe((base64Image: any) => {
this.clientImage = this._sanitizer.bypassSecurityTrustResourceUrl(base64Image);
});
this.clientsService.getClientProfileImage(this.clientViewData.id).subscribe(
(base64Image: any) => {
this.clientImage = this._sanitizer.bypassSecurityTrustResourceUrl(base64Image);
},
(error: any) => {}
);
}
/**
+3 -1
View File
@@ -37,6 +37,7 @@ import { TakeSurveyComponent } from './clients-view/client-actions/view-survey/t
import { UpdateClientSavingsAccountComponent } from './clients-view/client-actions/update-client-savings-account/update-client-savings-account.component';
import { TransferClientComponent } from './clients-view/client-actions/transfer-client/transfer-client.component';
import { UndoClientTransferComponent } from './clients-view/client-actions/undo-client-transfer/undo-client-transfer.component';
import { RejectClientTransferComponent } from './clients-view/client-actions/reject-client-transfer/reject-client-transfer.component';
/**
@@ -79,7 +80,8 @@ import { UndoClientTransferComponent } from './clients-view/client-actions/undo-
TakeSurveyComponent,
UpdateClientSavingsAccountComponent,
TransferClientComponent,
UndoClientTransferComponent
UndoClientTransferComponent,
RejectClientTransferComponent
],
entryComponents: [
UploadDocumentDialogComponent,