+30
@@ -0,0 +1,30 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="activateCenterForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Activated On Date</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="activationDatePicker" required formControlName="activationDate">
|
||||
<mat-datepicker-toggle matSuffix [for]="activationDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #activationDatePicker></mat-datepicker>
|
||||
<mat-error *ngIf="activateCenterForm.controls.activationDate.hasError('required')">
|
||||
Activated On Date is <strong>required</strong>
|
||||
</mat-error>
|
||||
</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="accent" [disabled]="!activateCenterForm.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 { ActivateCenterComponent } from './activate-center.component';
|
||||
|
||||
describe('ActivateCenterComponent', () => {
|
||||
let component: ActivateCenterComponent;
|
||||
let fixture: ComponentFixture<ActivateCenterComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ActivateCenterComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ActivateCenterComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/** 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 { CentersService } from 'app/centers/centers.service';
|
||||
|
||||
/**
|
||||
* Activate Center Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-activate-center',
|
||||
templateUrl: './activate-center.component.html',
|
||||
styleUrls: ['./activate-center.component.scss']
|
||||
})
|
||||
export class ActivateCenterComponent implements OnInit {
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Activate center form. */
|
||||
activateCenterForm: FormGroup;
|
||||
/** Group Account Id */
|
||||
centerId: any;
|
||||
|
||||
/**
|
||||
* @param {FormBuilder} formBuilder Form Builder
|
||||
* @param {centersService} CentersService Shares Service
|
||||
* @param {DatePipe} datePipe Date Pipe
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Router} router Router
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private centersService: CentersService,
|
||||
private datePipe: DatePipe,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
this.centerId = this.route.parent.snapshot.params['centerId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the activate center form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createActivateCenterForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the activate center form.
|
||||
*/
|
||||
createActivateCenterForm() {
|
||||
this.activateCenterForm = this.formBuilder.group({
|
||||
'activationDate': [new Date(), Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the form and activates the center,
|
||||
* if successful redirects to the center.
|
||||
*/
|
||||
submit() {
|
||||
// TODO: Update once language and date settings are setup
|
||||
const locale = 'en';
|
||||
const dateFormat = 'dd MMMM yyyy';
|
||||
const prevactivationDate: Date = this.activateCenterForm.value.activationDate;
|
||||
this.activateCenterForm.patchValue({
|
||||
activationDate: this.datePipe.transform(prevactivationDate, dateFormat),
|
||||
});
|
||||
const data = {
|
||||
...this.activateCenterForm.value,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.centersService.executeCenterActionCommand(this.centerId, 'activate', data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<mifosx-activate-center *ngIf="actions['Activate']"></mifosx-activate-center>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CenterActionsComponent } from './center-actions.component';
|
||||
|
||||
describe('CenterActionsComponent', () => {
|
||||
let component: CenterActionsComponent;
|
||||
let fixture: ComponentFixture<CenterActionsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CenterActionsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CenterActionsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
/** Angular Imports */
|
||||
import { Component } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
/**
|
||||
* Center actions component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-center-actions',
|
||||
templateUrl: './center-actions.component.html',
|
||||
styleUrls: ['./center-actions.component.scss']
|
||||
})
|
||||
export class CenterActionsComponent {
|
||||
|
||||
/** Flag object to store possible actions and render appropriate UI to the user */
|
||||
actions: {
|
||||
'Activate': boolean
|
||||
} = {
|
||||
'Activate': false,
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
||||
const name = this.route.snapshot.params['name'];
|
||||
this.actions[name] = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,7 +51,7 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-actions class="center-actions" *ngIf="!(centerViewData.status.value==='Closed')">
|
||||
<span *ngIf="!(centerViewData.status.value=='Active')">
|
||||
<button mat-raised-button *mifosxHasPermission="'ACTIVATE_CENTER'" ><i class="fa fa-check-sign"></i> Activate </button>
|
||||
<button mat-raised-button *mifosxHasPermission="'ACTIVATE_CENTER'" (click)="doAction('Activate')"><i class="fa fa-check-sign"></i> Activate </button>
|
||||
</span>
|
||||
<button mat-raised-button *mifosxHasPermission="'UPDATE_CENTER'"><i class="fa fa-edit"></i> Edit </button>
|
||||
<button mat-raised-button *mifosxHasPermission="'CREATE_GROUP'"><i class="fa fa-plus"></i> Add Group </button>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
/**
|
||||
* Create Center View
|
||||
@@ -23,7 +24,9 @@ export class CentersViewComponent implements OnInit {
|
||||
* Retrieves the data for center
|
||||
* @param route route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
public dialog: MatDialog) {
|
||||
this.route.data.subscribe((data: {
|
||||
centerViewData: any,
|
||||
centerDatatables: any
|
||||
@@ -39,4 +42,16 @@ export class CentersViewComponent implements OnInit {
|
||||
} else { this.meetingData = false; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs action button/option action.
|
||||
* @param {string} name action name.
|
||||
*/
|
||||
doAction(name: string) {
|
||||
switch (name) {
|
||||
case 'Activate':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user