feat: client actions (undo-transfer) (#1083)

Fixes: #1082
This commit is contained in:
Karan Takalkar
2020-07-13 20:26:37 +05:30
committed by GitHub
parent 8dc254f491
commit 6c081eb724
11 changed files with 158 additions and 2 deletions
@@ -6,3 +6,4 @@
<mifosx-withdraw-client *ngIf="actions['Withdraw']"></mifosx-withdraw-client>
<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>
@@ -21,6 +21,9 @@ export class ClientActionsComponent {
'Withdraw': boolean
'Update Default Savings': boolean
'Transfer Client': boolean
'Undo Transfer': boolean
'Accept Transfer': boolean
'Reject Transfer': boolean
} = {
'Assign Staff': false,
'Close': false,
@@ -28,7 +31,10 @@ export class ClientActionsComponent {
'Survey': false,
'Withdraw': false,
'Update Default Savings': false,
'Transfer Client': false
'Transfer Client': false,
'Undo Transfer': false,
'Accept Transfer': false,
'Reject Transfer': false
};
/**
@@ -0,0 +1,32 @@
<div class="container">
<mat-card>
<form [formGroup]="undoClientTransferForm" (ngSubmit)="submit()">
<mat-card-content fxLayout="column">
<mat-form-field>
<mat-label>Closed On 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]="!undoClientTransferForm.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 { UndoClientTransferComponent } from './undo-client-transfer.component';
describe('UndoClientTransferComponent', () => {
let component: UndoClientTransferComponent;
let fixture: ComponentFixture<UndoClientTransferComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ UndoClientTransferComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UndoClientTransferComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,73 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { ClientsService } from 'app/clients/clients.service';
/**
* Undo Client Transfer Component
*/
@Component({
selector: 'mifosx-undo-client-transfer',
templateUrl: './undo-client-transfer.component.html',
styleUrls: ['./undo-client-transfer.component.scss']
})
export class UndoClientTransferComponent implements OnInit {
/** Undo Approval Savings Account form. */
undoClientTransferForm: 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 undo-approval savings form.
*/
ngOnInit() {
this.createUndoClientTransferForm();
}
/**
* Creates the undo-approval savings account form.
*/
createUndoClientTransferForm() {
this.undoClientTransferForm = this.formBuilder.group({
'transferDate': {value: new Date(this.transferDate), disabled: true},
'note': ['']
});
}
/**
* Submits the form and undo the trandsfer of client
* if successful redirects to the client.
*/
submit() {
const data = {
...this.undoClientTransferForm.value,
};
this.clientsService.executeClientCommand(this.clientId, 'withdrawTransfer', data).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
}
@@ -46,6 +46,9 @@
<button mat-menu-item (click)="doAction('Survey')"> Survey</button>
<button mat-menu-item (click)="doAction('Update Default Savings')"> Update Default Savings </button>
<button mat-menu-item (click)="doAction('Transfer Client')"> Transfer Client </button>
<span *ngIf="clientViewData.status.value === 'Transfer in progress'"><button mat-menu-item (click)="doAction('Undo Transfer')">Undo Transfer</button></span>
<span *ngIf="clientViewData.status.value === 'Transfer in progress'"><button mat-menu-item (click)="doAction('Accept Transfer')">Accept Transfer</button></span>
<span *ngIf="clientViewData.status.value === 'Transfer in progress'"><button mat-menu-item (click)="doAction('Reject Transfer')">Reject transfer</button></span>
<span *ngIf="clientViewData.status.value === 'Pending'"><button mat-menu-item (click)="doAction('Activate')">Activate</button></span>
<span *ngIf="clientViewData.status.value === 'Pending'"><button mat-menu-item (click)="doAction('Withdraw')">Withdraw</button></span>
<span *ngIf="clientViewData.status.value === 'Pending'"><button mat-menu-item (click)="doAction('Reject')">Reject</button></span>
@@ -59,6 +59,9 @@ export class ClientsViewComponent implements OnInit {
case 'Withdraw':
case 'Update Default Savings':
case 'Transfer Client':
case 'Undo Transfer':
case 'Accept Transfer':
case 'Reject Transfer':
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
break;
case 'Unassign Staff':
+3 -1
View File
@@ -36,6 +36,7 @@ import { WithdrawClientComponent } from './clients-view/client-actions/withdraw-
import { TakeSurveyComponent } from './clients-view/client-actions/view-survey/take-survey/take-survey.component';
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';
/**
@@ -77,7 +78,8 @@ import { TransferClientComponent } from './clients-view/client-actions/transfer-
WithdrawClientComponent,
TakeSurveyComponent,
UpdateClientSavingsAccountComponent,
TransferClientComponent
TransferClientComponent,
UndoClientTransferComponent
],
entryComponents: [
UploadDocumentDialogComponent,
+4
View File
@@ -220,6 +220,10 @@ export class ClientsService {
return this.http.get(`/clients/template`, { params: httpParams });
}
getClientTransferProposalDate(clientId: any): Observable<any> {
return this.http.get(`/clients/${clientId}/transferproposaldate`);
}
/**
* @returns {Observable<any>} Offices data
*/
@@ -41,6 +41,10 @@ export class ClientActionsResolver implements Resolve<Object> {
return this.clientsService.getClientCommandTemplate('withdraw');
case 'Transfer Client':
return this.clientsService.getOffices();
case 'Undo Transfer':
case 'Accept Transfer':
case 'Reject Transfer':
return this.clientsService.getClientTransferProposalDate(clientId);
default:
return undefined;
}