+39
@@ -0,0 +1,39 @@
|
|||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<mat-card>
|
||||||
|
|
||||||
|
<form [formGroup]="closeSharesAccountForm" (ngSubmit)="submit()">
|
||||||
|
|
||||||
|
<mat-card-content>
|
||||||
|
|
||||||
|
<div fxLayout="column">
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Closed On Date</mat-label>
|
||||||
|
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="closedDatePicker" required formControlName="closedDate">
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="closedDatePicker"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #closedDatePicker></mat-datepicker>
|
||||||
|
<mat-error *ngIf="closeSharesAccountForm.controls.closedDate.hasError('required')">
|
||||||
|
Closed On Date is <strong>required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Note</mat-label>
|
||||||
|
<textarea matInput formControlName="note"></textarea>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</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="warn" [disabled]="!closeSharesAccountForm.valid">Confirm</button>
|
||||||
|
</mat-card-actions>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
</div>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
.container {
|
||||||
|
max-width: 37rem;
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CloseSharesAccountComponent } from './close-shares-account.component';
|
||||||
|
|
||||||
|
describe('CloseSharesAccountComponent', () => {
|
||||||
|
let component: CloseSharesAccountComponent;
|
||||||
|
let fixture: ComponentFixture<CloseSharesAccountComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ CloseSharesAccountComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(CloseSharesAccountComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
+76
@@ -0,0 +1,76 @@
|
|||||||
|
/** 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 { SharesService } from 'app/shares/shares.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Shares Account Component
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-close-shares-account',
|
||||||
|
templateUrl: './close-shares-account.component.html',
|
||||||
|
styleUrls: ['./close-shares-account.component.scss']
|
||||||
|
})
|
||||||
|
export class CloseSharesAccountComponent implements OnInit {
|
||||||
|
|
||||||
|
/** Minimum date allowed. */
|
||||||
|
minDate = new Date(2000, 0, 1);
|
||||||
|
/** Maximum date allowed. */
|
||||||
|
maxDate = new Date();
|
||||||
|
/** Close Share Account form. */
|
||||||
|
closeSharesAccountForm: FormGroup;
|
||||||
|
/** Shares Account Id */
|
||||||
|
accountId: any;
|
||||||
|
|
||||||
|
constructor(private formBuilder: FormBuilder,
|
||||||
|
private sharesService: SharesService,
|
||||||
|
private datePipe: DatePipe,
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private router: Router) {
|
||||||
|
this.accountId = this.route.parent.parent.snapshot.params['shareAccountId'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the close shares form.
|
||||||
|
*/
|
||||||
|
ngOnInit() {
|
||||||
|
this.createCloseSharesAccountForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the close shares account form.
|
||||||
|
*/
|
||||||
|
createCloseSharesAccountForm() {
|
||||||
|
this.closeSharesAccountForm = this.formBuilder.group({
|
||||||
|
'closedDate': ['', Validators.required],
|
||||||
|
'note': ['']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submits the form and closes the share account,
|
||||||
|
* if successful redirects to the share account.
|
||||||
|
*/
|
||||||
|
submit() {
|
||||||
|
// TODO: Update once language and date settings are setup
|
||||||
|
const locale = 'en';
|
||||||
|
const dateFormat = 'dd MMMM yyyy';
|
||||||
|
const prevClosedDate: Date = this.closeSharesAccountForm.value.closedDate;
|
||||||
|
this.closeSharesAccountForm.patchValue({
|
||||||
|
closedDate: this.datePipe.transform(prevClosedDate, dateFormat),
|
||||||
|
});
|
||||||
|
const data = {
|
||||||
|
...this.closeSharesAccountForm.value,
|
||||||
|
dateFormat,
|
||||||
|
locale
|
||||||
|
};
|
||||||
|
this.sharesService.executeSharesAccountCommand(this.accountId, 'close', data).subscribe(() => {
|
||||||
|
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
<mifosx-approve-shares-account *ngIf="actions.Approve"></mifosx-approve-shares-account>
|
<mifosx-approve-shares-account *ngIf="actions.Approve"></mifosx-approve-shares-account>
|
||||||
<mifosx-reject-shares-account *ngIf="actions.Reject"></mifosx-reject-shares-account>
|
<mifosx-reject-shares-account *ngIf="actions.Reject"></mifosx-reject-shares-account>
|
||||||
|
<mifosx-close-shares-account *ngIf="actions.Close"></mifosx-close-shares-account>
|
||||||
@@ -16,9 +16,11 @@ export class SharesAccountActionsComponent {
|
|||||||
actions: {
|
actions: {
|
||||||
Approve: boolean
|
Approve: boolean
|
||||||
Reject: boolean
|
Reject: boolean
|
||||||
|
Close: boolean
|
||||||
} = {
|
} = {
|
||||||
Approve: false ,
|
Approve: false,
|
||||||
Reject: false
|
Reject: false,
|
||||||
|
Close: false
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute) {
|
constructor(private route: ActivatedRoute) {
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ export class SharesAccountViewComponent implements OnInit {
|
|||||||
case 'Reject':
|
case 'Reject':
|
||||||
this.router.navigate(['actions/Reject'], { relativeTo: this.route });
|
this.router.navigate(['actions/Reject'], { relativeTo: this.route });
|
||||||
break;
|
break;
|
||||||
|
case 'Close':
|
||||||
|
this.router.navigate(['actions/Close'], { relativeTo: this.route });
|
||||||
|
break;
|
||||||
case 'Delete':
|
case 'Delete':
|
||||||
this.deleteSharesAccount();
|
this.deleteSharesAccount();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { EditSharesAccountComponent } from './edit-shares-account/edit-shares-ac
|
|||||||
import { SharesAccountActionsComponent } from './shares-account-actions/shares-account-actions.component';
|
import { SharesAccountActionsComponent } from './shares-account-actions/shares-account-actions.component';
|
||||||
import { ApproveSharesAccountComponent } from './shares-account-actions/approve-shares-account/approve-shares-account.component';
|
import { ApproveSharesAccountComponent } from './shares-account-actions/approve-shares-account/approve-shares-account.component';
|
||||||
import { RejectSharesAccountComponent } from './shares-account-actions/reject-shares-account/reject-shares-account.component';
|
import { RejectSharesAccountComponent } from './shares-account-actions/reject-shares-account/reject-shares-account.component';
|
||||||
|
import { CloseSharesAccountComponent } from './shares-account-actions/close-shares-account/close-shares-account.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shares Module
|
* Shares Module
|
||||||
@@ -46,7 +47,8 @@ import { RejectSharesAccountComponent } from './shares-account-actions/reject-sh
|
|||||||
EditSharesAccountComponent,
|
EditSharesAccountComponent,
|
||||||
SharesAccountActionsComponent,
|
SharesAccountActionsComponent,
|
||||||
ApproveSharesAccountComponent,
|
ApproveSharesAccountComponent,
|
||||||
RejectSharesAccountComponent
|
RejectSharesAccountComponent,
|
||||||
|
CloseSharesAccountComponent
|
||||||
],
|
],
|
||||||
providers: [DatePipe]
|
providers: [DatePipe]
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user