@@ -18,6 +18,7 @@ import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component';
|
||||
import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component';
|
||||
import { TellersComponent } from './tellers/tellers.component';
|
||||
import { PaymentTypesComponent } from './payment-types/payment-types.component';
|
||||
import { PasswordPreferencesComponent } from './password-preferences/password-preferences.component';
|
||||
|
||||
/** Custom Resolvers */
|
||||
import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver';
|
||||
@@ -28,6 +29,7 @@ import { SmsCampaignsResolver } from './sms-campaigns/sms-campaigns.resolver';
|
||||
import { AdhocQueriesResolver } from './adhoc-query/adhoc-queries.resolver';
|
||||
import { TellersResolver } from './tellers/tellers.resolver';
|
||||
import { PaymentTypesResolver } from './payment-types/payment-types.resolver';
|
||||
import { PasswordPreferencesTemplateResolver } from './password-preferences/password-preferences-template.resolver';
|
||||
|
||||
/** Organization Routes */
|
||||
const routes: Routes = [
|
||||
@@ -108,6 +110,14 @@ const routes: Routes = [
|
||||
resolve: {
|
||||
paymentTypes: PaymentTypesResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'password-preferences',
|
||||
component: PasswordPreferencesComponent,
|
||||
data: { title: extract('Password Preferences'), breadcrumb: 'Password Preferences' },
|
||||
resolve: {
|
||||
passwordPreferencesTemplate: PasswordPreferencesTemplateResolver
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -130,7 +140,8 @@ const routes: Routes = [
|
||||
SmsCampaignsResolver,
|
||||
AdhocQueriesResolver,
|
||||
TellersResolver,
|
||||
PaymentTypesResolver
|
||||
PaymentTypesResolver,
|
||||
PasswordPreferencesTemplateResolver
|
||||
]
|
||||
})
|
||||
export class OrganizationRoutingModule { }
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<p matLine>Bulk entry screen for mapping fund sources to loans</p>
|
||||
</mat-list-item>
|
||||
|
||||
<mat-list-item>
|
||||
<mat-list-item [routerLink]="['password-preferences']">
|
||||
<mat-icon matListIcon>
|
||||
<fa-icon icon="lock" size="sm"></fa-icon>
|
||||
</mat-icon>
|
||||
|
||||
@@ -16,6 +16,7 @@ import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component';
|
||||
import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component';
|
||||
import { TellersComponent } from './tellers/tellers.component';
|
||||
import { PaymentTypesComponent } from './payment-types/payment-types.component';
|
||||
import { PasswordPreferencesComponent } from './password-preferences/password-preferences.component';
|
||||
|
||||
/**
|
||||
* Organization Module
|
||||
@@ -37,7 +38,8 @@ import { PaymentTypesComponent } from './payment-types/payment-types.component';
|
||||
SmsCampaignsComponent,
|
||||
AdhocQueryComponent,
|
||||
TellersComponent,
|
||||
PaymentTypesComponent
|
||||
PaymentTypesComponent,
|
||||
PasswordPreferencesComponent
|
||||
]
|
||||
})
|
||||
export class OrganizationModule { }
|
||||
|
||||
@@ -82,4 +82,19 @@ export class OrganizationService {
|
||||
return this.http.delete(`/paymenttypes/${paymentTypeId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Password Preferences Template data
|
||||
*/
|
||||
getPasswordPreferencesTemplate(): Observable<any> {
|
||||
return this.http.get('/passwordpreferences/template');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} passwordPreferences Password Preferences data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
updatePasswordPreferences(passwordPreferences: any): Observable<any> {
|
||||
return this.http.put('/passwordpreferences', passwordPreferences);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/** Angular Imports */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Resolve } from '@angular/router';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/** Custom Services */
|
||||
import { OrganizationService } from '../organization.service';
|
||||
|
||||
/**
|
||||
* Password Preferences Template data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class PasswordPreferencesTemplateResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {OrganizationService} organizationService Organization service.
|
||||
*/
|
||||
constructor(private organizationService: OrganizationService) {}
|
||||
|
||||
/**
|
||||
* Returns the password preferences template data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(): Observable<any> {
|
||||
return this.organizationService.getPasswordPreferencesTemplate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="passwordPreferencesForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<mat-radio-group fxLayout="column" formControlName="validationPolicyId" fxLayoutGap="10px">
|
||||
<mat-radio-button *ngFor="let passwordPreference of passwordPreferencesData" [value]="passwordPreference.id">
|
||||
<span class="description-wrap">{{ passwordPreference.description }}</span>
|
||||
</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
|
||||
</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]="passwordPreferencesForm.pristine">Submit</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
.description-wrap {
|
||||
white-space: normal;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PasswordPreferencesComponent } from './password-preferences.component';
|
||||
|
||||
describe('PasswordPreferencesComponent', () => {
|
||||
let component: PasswordPreferencesComponent;
|
||||
let fixture: ComponentFixture<PasswordPreferencesComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ PasswordPreferencesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PasswordPreferencesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,79 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder } from '@angular/forms';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
||||
/** Custom Services */
|
||||
import { OrganizationService } from '../organization.service';
|
||||
|
||||
/**
|
||||
* Password preferences component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-password-preferences',
|
||||
templateUrl: './password-preferences.component.html',
|
||||
styleUrls: ['./password-preferences.component.scss']
|
||||
})
|
||||
export class PasswordPreferencesComponent implements OnInit {
|
||||
|
||||
/** Password preferences form. */
|
||||
passwordPreferencesForm: FormGroup;
|
||||
/** Password preferences data. */
|
||||
passwordPreferencesData: any;
|
||||
|
||||
/**
|
||||
* Retrieves the password preferences data from `resolve`.
|
||||
* @param {FormBuilder} formBuilder Form Builder.
|
||||
* @param {OrganizationService} organizationService Organization Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {Router} router Router for navigation.
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private organizationService: OrganizationService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
this.route.data.subscribe((data: { passwordPreferencesTemplate: any}) => {
|
||||
this.passwordPreferencesData = data.passwordPreferencesTemplate;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and sets the password preferences form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createPasswordPreferencesForm();
|
||||
this.setPasswordPreferencesForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the password preferences form.
|
||||
*/
|
||||
createPasswordPreferencesForm() {
|
||||
this.passwordPreferencesForm = this.formBuilder.group({
|
||||
'validationPolicyId': ['']
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password preferences form.
|
||||
*/
|
||||
setPasswordPreferencesForm() {
|
||||
for (const passwordPreference of this.passwordPreferencesData) {
|
||||
if (passwordPreference.active === true) {
|
||||
this.passwordPreferencesForm.get('validationPolicyId').setValue(passwordPreference.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the password preferences form and updates password preferences,
|
||||
* if successful redirects to organization view.
|
||||
*/
|
||||
submit() {
|
||||
const passwordPreferences = this.passwordPreferencesForm.value;
|
||||
this.organizationService.updatePasswordPreferences(passwordPreferences).subscribe((response: any) => {
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user