@@ -146,22 +146,22 @@ export class CreateGroupComponent implements OnInit, AfterViewInit {
|
|||||||
* if successful redirects to groups.
|
* if successful redirects to groups.
|
||||||
*/
|
*/
|
||||||
submit() {
|
submit() {
|
||||||
const submittedOnDate: Date = this.groupForm.value.submittedOnDate;
|
const submittedOnDate: Date = this.groupForm.value.submittedOnDate;
|
||||||
const activationDate: Date = this.groupForm.value.activationDate;
|
const activationDate: Date = this.groupForm.value.activationDate;
|
||||||
// TODO: Update once language and date settings are setup
|
// TODO: Update once language and date settings are setup
|
||||||
const dateFormat = 'dd MMMM yyyy';
|
const dateFormat = 'dd MMMM yyyy';
|
||||||
this.groupForm.patchValue({
|
this.groupForm.patchValue({
|
||||||
submittedOnDate: this.datePipe.transform(submittedOnDate, dateFormat),
|
submittedOnDate: this.datePipe.transform(submittedOnDate, dateFormat),
|
||||||
activationDate: this.datePipe.transform(activationDate, dateFormat)
|
activationDate: this.datePipe.transform(activationDate, dateFormat)
|
||||||
});
|
});
|
||||||
const group = this.groupForm.value;
|
const group = this.groupForm.value;
|
||||||
group.locale = 'en';
|
group.locale = 'en';
|
||||||
group.dateFormat = dateFormat;
|
group.dateFormat = dateFormat;
|
||||||
group.clientMembers = [];
|
group.clientMembers = [];
|
||||||
this.clientMembers.forEach((client: any) => group.clientMembers.push(client.id));
|
this.clientMembers.forEach((client: any) => group.clientMembers.push(client.id));
|
||||||
this.groupService.createGroup(group).subscribe((response: any) => {
|
this.groupService.createGroup(group).subscribe((response: any) => {
|
||||||
this.router.navigate(['../groups']);
|
this.router.navigate(['../groups']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<mat-card>
|
||||||
|
|
||||||
|
<form [formGroup]="editGroupForm">
|
||||||
|
|
||||||
|
<mat-card-content>
|
||||||
|
|
||||||
|
<div fxLayout="column">
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Name</mat-label>
|
||||||
|
<input matInput required formControlName="name">
|
||||||
|
<mat-error *ngIf="editGroupForm.controls.name.hasError('required')">
|
||||||
|
Group Name is <strong>required</strong>
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="editGroupForm.controls.name.hasError('pattern')">
|
||||||
|
Group Name <strong>cannot</strong> begin with a special character or number
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Staff</mat-label>
|
||||||
|
<mat-select formControlName="staffId">
|
||||||
|
<mat-option *ngFor="let staff of staffData" [value]="staff.id">
|
||||||
|
{{ staff.displayName }}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field *ngIf="this.editGroupForm.contains('activationDate')">
|
||||||
|
<mat-label>Activation 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="editGroupForm.controls.activationDate.hasError('required')">
|
||||||
|
Activation Date is <strong>required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>External id</mat-label>
|
||||||
|
<input matInput formControlName="externalId">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Submitted on</mat-label>
|
||||||
|
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="submittedOnDatePicker" required formControlName="submittedOnDate">
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="submittedOnDatePicker"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #submittedOnDatePicker></mat-datepicker>
|
||||||
|
<mat-error *ngIf="editGroupForm.controls.submittedOnDate.hasError('required')">
|
||||||
|
Submission Date is <strong>required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</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="primary" [disabled]="!editGroupForm.valid" (click)="submit()">Submit</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 { EditGroupComponent } from './edit-group.component';
|
||||||
|
|
||||||
|
describe('EditGroupComponent', () => {
|
||||||
|
let component: EditGroupComponent;
|
||||||
|
let fixture: ComponentFixture<EditGroupComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ EditGroupComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(EditGroupComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
/** Angular Imports */
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';
|
||||||
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
|
import { DatePipe } from '@angular/common';
|
||||||
|
|
||||||
|
/** Custom Services */
|
||||||
|
import { GroupsService } from '../groups.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit Group component.
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-edit-group',
|
||||||
|
templateUrl: './edit-group.component.html',
|
||||||
|
styleUrls: ['./edit-group.component.scss']
|
||||||
|
})
|
||||||
|
export class EditGroupComponent implements OnInit {
|
||||||
|
|
||||||
|
/** Minimum date allowed. */
|
||||||
|
minDate = new Date(2000, 0, 1);
|
||||||
|
/** Maximum date allowed. */
|
||||||
|
maxDate = new Date();
|
||||||
|
/** Group form. */
|
||||||
|
editGroupForm: FormGroup;
|
||||||
|
/** Staff data. */
|
||||||
|
staffData: any;
|
||||||
|
/** Group Data */
|
||||||
|
groupData: any;
|
||||||
|
/** Submitted On Date */
|
||||||
|
submittedOnDate: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the offices data from `resolve`.
|
||||||
|
* @param {FormBuilder} formBuilder Form Builder.
|
||||||
|
* @param {ActivatedRoute} route Activated Route.
|
||||||
|
* @param {Router} router Router for navigation.
|
||||||
|
* @param {GroupsService} groupService GroupsService.
|
||||||
|
* @param {DatePipe} datePipe Date Pipe to format date.
|
||||||
|
*/
|
||||||
|
constructor(private formBuilder: FormBuilder,
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private router: Router,
|
||||||
|
private groupService: GroupsService,
|
||||||
|
private datePipe: DatePipe) {
|
||||||
|
this.route.data.subscribe( (data: { groupAndTemplateData: any, groupViewData: any } ) => {
|
||||||
|
this.staffData = data.groupAndTemplateData.staffOptions;
|
||||||
|
this.groupData = data.groupAndTemplateData;
|
||||||
|
this.submittedOnDate = data.groupViewData.timeline.submittedOnDate && new Date(data.groupViewData.timeline.submittedOnDate);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and sets the group form.
|
||||||
|
*/
|
||||||
|
ngOnInit() {
|
||||||
|
this.createEditGroupForm();
|
||||||
|
this.editGroupForm.patchValue({
|
||||||
|
'name': this.groupData.name,
|
||||||
|
'submittedOnDate': this.submittedOnDate,
|
||||||
|
'staffId': this.groupData.staffId,
|
||||||
|
'externalId': this.groupData.externalId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the group form.
|
||||||
|
*/
|
||||||
|
createEditGroupForm() {
|
||||||
|
this.editGroupForm = this.formBuilder.group({
|
||||||
|
'name': ['', [Validators.required, Validators.pattern('(^[A-z]).*')]],
|
||||||
|
'submittedOnDate': ['', Validators.required],
|
||||||
|
'staffId': [''],
|
||||||
|
'externalId': ['']
|
||||||
|
});
|
||||||
|
this.buildDependencies();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds form control Activation Date if group is active.
|
||||||
|
*/
|
||||||
|
buildDependencies() {
|
||||||
|
if (this.groupData.active) {
|
||||||
|
this.editGroupForm.addControl('activationDate', new FormControl('', Validators.required));
|
||||||
|
this.editGroupForm.get('activationDate').patchValue(this.groupData.activationDate && new Date(this.groupData.activationDate));
|
||||||
|
} else {
|
||||||
|
this.editGroupForm.removeControl('activationDate');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submits the group form and creates group,
|
||||||
|
* if successful redirects to groups.
|
||||||
|
*/
|
||||||
|
submit() {
|
||||||
|
const submittedOnDate: Date = this.editGroupForm.value.submittedOnDate;
|
||||||
|
const activationDate: Date = this.editGroupForm.value.activationDate;
|
||||||
|
// TODO: Update once language and date settings are setup
|
||||||
|
const dateFormat = 'dd MMMM yyyy';
|
||||||
|
this.editGroupForm.patchValue({
|
||||||
|
submittedOnDate: this.datePipe.transform(submittedOnDate, dateFormat),
|
||||||
|
activationDate: activationDate && this.datePipe.transform(activationDate, dateFormat)
|
||||||
|
});
|
||||||
|
const group = this.editGroupForm.value;
|
||||||
|
group.locale = 'en';
|
||||||
|
group.dateFormat = dateFormat;
|
||||||
|
this.groupService.updateGroup(group, this.groupData.id).subscribe((response: any) => {
|
||||||
|
this.router.navigate(['../'], { relativeTo: this.route });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ import { CreateGroupComponent } from './create-group/create-group.component';
|
|||||||
import { DatatableTabsComponent } from './groups-view/datatable-tabs/datatable-tabs.component';
|
import { DatatableTabsComponent } from './groups-view/datatable-tabs/datatable-tabs.component';
|
||||||
import { AddRoleComponent } from './groups-view/add-role/add-role.component';
|
import { AddRoleComponent } from './groups-view/add-role/add-role.component';
|
||||||
import { GroupActionsComponent } from './groups-view/group-actions/group-actions.component';
|
import { GroupActionsComponent } from './groups-view/group-actions/group-actions.component';
|
||||||
|
import { EditGroupComponent } from './edit-group/edit-group.component';
|
||||||
|
|
||||||
/** Custom Resolvers */
|
/** Custom Resolvers */
|
||||||
import { GroupViewResolver } from './common-resolvers/group-view.resolver';
|
import { GroupViewResolver } from './common-resolvers/group-view.resolver';
|
||||||
@@ -44,7 +45,7 @@ const routes: Routes = [
|
|||||||
{
|
{
|
||||||
path: 'create',
|
path: 'create',
|
||||||
component: CreateGroupComponent,
|
component: CreateGroupComponent,
|
||||||
data: { title: extract('Create Group'), breadcrumb: 'Create' },
|
data: { title: extract('Create Group'), breadcrumb: 'Create', routeParamBreadcrumb: false },
|
||||||
resolve: {
|
resolve: {
|
||||||
offices: OfficesResolver
|
offices: OfficesResolver
|
||||||
}
|
}
|
||||||
@@ -98,6 +99,15 @@ const routes: Routes = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'edit',
|
||||||
|
component: EditGroupComponent,
|
||||||
|
data: { title: extract('Edit Group'), breadcrumb: 'Edit', routeParamBreadcrumb: false },
|
||||||
|
resolve: {
|
||||||
|
groupAndTemplateData: GroupDataAndTemplateResolver,
|
||||||
|
groupViewData: GroupViewResolver
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'committee',
|
path: 'committee',
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
<button mat-raised-button *mifosxHasPermission="'UPDATE_GROUP'" (click)="doAction('Activate')">
|
<button mat-raised-button *mifosxHasPermission="'UPDATE_GROUP'" (click)="doAction('Activate')">
|
||||||
<i class="fa fa-check-sign"></i>Activate</button>
|
<i class="fa fa-check-sign"></i>Activate</button>
|
||||||
</span>
|
</span>
|
||||||
<button mat-raised-button *mifosxHasPermission="'UPDATE_GROUP'">
|
<button mat-raised-button *mifosxHasPermission="'UPDATE_GROUP'" (click)="doAction('Edit')">
|
||||||
<i class="fa fa-edit"></i>Edit</button>
|
<i class="fa fa-edit"></i>Edit</button>
|
||||||
<button mat-raised-button *mifosxHasPermission="'CREATE_CLIENT'">
|
<button mat-raised-button *mifosxHasPermission="'CREATE_CLIENT'">
|
||||||
<i class="fa fa-plus"></i>Add Clients</button>
|
<i class="fa fa-plus"></i>Add Clients</button>
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
<span *ngIf="!groupViewData.staffId">
|
<span *ngIf="!groupViewData.staffId">
|
||||||
<button mat-menu-item *mifosxHasPermission="'ASSIGNSTAFF_GROUP'" (click)="doAction('Assign Staff')">Assign Staff</button></span>
|
<button mat-menu-item *mifosxHasPermission="'ASSIGNSTAFF_GROUP'" (click)="doAction('Assign Staff')">Assign Staff</button></span>
|
||||||
<span *ngIf="groupViewData.staffId">
|
<span *ngIf="groupViewData.staffId">
|
||||||
<button mat-menu-item *mifosxHasPermission="'UNASSIGNSTAFF_GROUP'"(click)="doAction('Unassign Staff')">Unassign Staff</button></span>
|
<button mat-menu-item *mifosxHasPermission="'UNASSIGNSTAFF_GROUP'" (click)="doAction('Unassign Staff')">Unassign Staff</button></span>
|
||||||
<span *ngIf="!(groupViewData.centerId || groupViewData.collectionMeetingCalendar) && groupViewData.status.value==='Active'">
|
<span *ngIf="!(groupViewData.centerId || groupViewData.collectionMeetingCalendar) && groupViewData.status.value==='Active'">
|
||||||
<button mat-menu-item *mifosxHasPermission="'CREATE_MEETING'">Attatch Meeting</button></span>
|
<button mat-menu-item *mifosxHasPermission="'CREATE_MEETING'">Attatch Meeting</button></span>
|
||||||
<button mat-menu-item *mifosxHasPermission="'CLOSE_GROUP'" (click)="doAction('Close')">Close</button>
|
<button mat-menu-item *mifosxHasPermission="'CLOSE_GROUP'" (click)="doAction('Close')">Close</button>
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ export class GroupsViewComponent {
|
|||||||
case 'Activate':
|
case 'Activate':
|
||||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||||
break;
|
break;
|
||||||
|
case 'Edit':
|
||||||
|
this.router.navigate(['edit'], { relativeTo: this.route });
|
||||||
|
break;
|
||||||
case 'Unassign Staff':
|
case 'Unassign Staff':
|
||||||
this.unassignStaff();
|
this.unassignStaff();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { GroupAssignStaffComponent } from './groups-view/group-actions/group-ass
|
|||||||
import { UnassignStaffDialogComponent } from './groups-view/custom-dialogs/unassign-staff-dialog/unassign-staff-dialog.component';
|
import { UnassignStaffDialogComponent } from './groups-view/custom-dialogs/unassign-staff-dialog/unassign-staff-dialog.component';
|
||||||
import { CloseGroupComponent } from './groups-view/group-actions/close-group/close-group.component';
|
import { CloseGroupComponent } from './groups-view/group-actions/close-group/close-group.component';
|
||||||
import { ActivateGroupComponent } from './groups-view/group-actions/activate-group/activate-group.component';
|
import { ActivateGroupComponent } from './groups-view/group-actions/activate-group/activate-group.component';
|
||||||
|
import { EditGroupComponent } from './edit-group/edit-group.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Groups Module
|
* Groups Module
|
||||||
@@ -54,7 +55,8 @@ import { ActivateGroupComponent } from './groups-view/group-actions/activate-gro
|
|||||||
GroupAssignStaffComponent,
|
GroupAssignStaffComponent,
|
||||||
UnassignStaffDialogComponent,
|
UnassignStaffDialogComponent,
|
||||||
CloseGroupComponent,
|
CloseGroupComponent,
|
||||||
ActivateGroupComponent
|
ActivateGroupComponent,
|
||||||
|
EditGroupComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
UnassignRoleDialogComponent,
|
UnassignRoleDialogComponent,
|
||||||
|
|||||||
@@ -224,4 +224,13 @@ export class GroupsService {
|
|||||||
return this.http.post('/groups', group);
|
return this.http.post('/groups', group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {any} group Group to be created.
|
||||||
|
* @param {any} groupId Group Id
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
updateGroup(group: any, groupId: any): Observable<any> {
|
||||||
|
return this.http.put(`/groups/${groupId}`, group);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user