Business and COB Date management

This commit is contained in:
Jose Alberto Hernandez
2022-07-12 14:47:38 +02:00
committed by Arnold Gálovics
parent 6e973dd50a
commit 1b72136411
27 changed files with 1146 additions and 263 deletions
@@ -0,0 +1,38 @@
<div class="container space">
<mat-card>
<form [formGroup]="configurationForm" (ngSubmit)="submit()">
<mat-card-content>
<div fxLayout="column">
<mat-form-field>
<mat-label>Configuration Name</mat-label>
<input matInput required formControlName="name">
</mat-form-field>
<mat-form-field>
<mat-label>Configuration Value</mat-label>
<input matInput required type="number" formControlName="value">
<mat-error *ngIf="configurationForm.controls.value.hasError('required')">
Configuration Value 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]="configurationForm.pristine || !configurationForm.valid">
Submit </button>
</mat-card-actions>
</form>
</mat-card>
</div>
@@ -0,0 +1,7 @@
.container {
max-width: 37rem;
}
.space {
padding-bottom: 40px;
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { EditConfigurationComponent } from './edit-configuration.component';
describe('EditConfigurationComponent', () => {
let component: EditConfigurationComponent;
let fixture: ComponentFixture<EditConfigurationComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditConfigurationComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(EditConfigurationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,69 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { SystemService } from '../../../system.service';
/**
* Edit Configuration Component
*/
@Component({
selector: 'mifosx-edit-configuration',
templateUrl: './edit-configuration.component.html',
styleUrls: ['./edit-configuration.component.scss']
})
export class EditConfigurationComponent implements OnInit {
/** Global Configuration form. */
configurationForm: FormGroup;
/** Configuration. */
configuration: any;
/**
* Retrieves the configuration data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder.
* @param {SystemService} systemService System Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: FormBuilder,
private systemService: SystemService,
private route: ActivatedRoute,
private router: Router) {
this.route.data.subscribe((data: { configuration: any }) => {
this.configuration = data.configuration;
});
}
/**
* Creates and sets the configuration form.
*/
ngOnInit() {
this.createConfigurationForm();
}
/**
* Creates and sets the global configuration form.
*/
createConfigurationForm() {
this.configurationForm = this.formBuilder.group({
'name': [{ value: this.configuration.name, disabled: true }, Validators.required],
'value': [this.configuration.value, Validators.required]
});
}
/**
* Submits the global configuration form and updates global configuration,
* if successful redirects to view all global configurations.
*/
submit() {
this.systemService
.updateConfiguration(this.configuration.id, this.configurationForm.value)
.subscribe((response: any) => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
}
@@ -0,0 +1,31 @@
/** Angular Imports */
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
/** rxjs Imports */
import { Observable } from 'rxjs';
/** Custom Services */
import { SystemService } from '../../system.service';
/**
* Configurations data resolver.
*/
@Injectable()
export class GlobalConfigurationResolver implements Resolve<Object> {
/**
* @param {SystemService} systemService System service.
*/
constructor(private systemService: SystemService) {}
/**
* Returns the Configuration data.
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const configurationId = route.paramMap.get('id');
return this.systemService.getConfiguration(configurationId);
}
}
@@ -0,0 +1,56 @@
<div class="container">
<div fxLayout="row">
<mat-form-field fxFlex>
<mat-label>Filter</mat-label>
<input matInput (keyup)="applyFilter($event.target.value)">
</mat-form-field>
</div>
<div class="mat-elevation-z8">
<table mat-table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
<td mat-cell *matCellDef="let configuration"> {{ configuration.name }}&nbsp;&nbsp;
<fa-icon icon="question-circle" matTooltip="{{ configuration.description === undefined ? 'No Description' : configuration.description }}" matTooltipPosition="right"></fa-icon>
</td>
</ng-container>
<ng-container matColumnDef="enabled">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Status </th>
<td mat-cell *matCellDef="let configuration">
<mat-slide-toggle [(ngModel)]="configuration.enabled" name="{{configuration.name}}" (click)="toggleStatus(configuration)">
<div [className]="configuration.enabled ? 'enabled' : 'disabled'">
<span *ngIf="configuration.enabled">Enabled</span>
<span *ngIf="!configuration.enabled">Disabled</span>
</div>
</mat-slide-toggle>
</td>
</ng-container>
<ng-container matColumnDef="value">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Value </th>
<td mat-cell *matCellDef="let configuration"> {{ configuration.value }}</td>
</ng-container>
<ng-container matColumnDef="edit">
<th mat-header-cell *matHeaderCellDef> Edit </th>
<td mat-cell *matCellDef="let configuration">
<button mat-button color="primary" [routerLink]="[configuration.id, 'edit']">
<fa-icon icon="edit"></fa-icon>
</button>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
</div>
</div>
@@ -0,0 +1,12 @@
table {
width: 100%;
}
// TODO: CONFIGURE THESE CLASSES GLOBALLY
.enabled {
color: #32cd32;
}
.disabled {
color: #f44366;
}
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { GlobalConfigurationsTabComponent } from './global-configurations-tab.component';
describe('GlobalConfigurationsTabComponent', () => {
let component: GlobalConfigurationsTabComponent;
let fixture: ComponentFixture<GlobalConfigurationsTabComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ GlobalConfigurationsTabComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(GlobalConfigurationsTabComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,78 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { SystemService } from '../../system.service';
@Component({
selector: 'mifosx-global-configurations-tab',
templateUrl: './global-configurations-tab.component.html',
styleUrls: ['./global-configurations-tab.component.scss']
})
export class GlobalConfigurationsTabComponent implements OnInit {
/** Configuration data. */
configurationData: any;
/** Columns to be displayed in configurations table. */
displayedColumns: string[] = ['name', 'enabled', 'value', 'edit'];
/** Data source for configurations table. */
dataSource: MatTableDataSource<any>;
/** Paginator for configurations table. */
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
/** Sorter for configurations table. */
@ViewChild(MatSort, { static: true }) sort: MatSort;
/**
* Retrieves the configurations data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
* @param {SystemService} systemService System Service.
* @param {Router} router Router for navigation.
*/
constructor(private route: ActivatedRoute,
private systemService: SystemService) {
this.configurationData = this.systemService.getConfigurations();
}
/**
* Sets the configurations table.
*/
ngOnInit() {
this.setConfigurationData();
}
/**
* Initializes the data source, paginator and sorter for configurations table.
*/
setConfigurationData(): void {
this.systemService.getConfigurations()
.subscribe((configurationData: any) => {
this.configurationData = configurationData.globalConfiguration;
this.dataSource = new MatTableDataSource(this.configurationData);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
});
}
/**
* Filters data in configurations table based on passed value.
* @param {string} filterValue Value to filter data.
*/
applyFilter(filterValue: string) {
this.dataSource.filter = filterValue.trim().toLowerCase();
}
/**
* Enables/Disables respective configuration
*/
toggleStatus(configuration: any) {
this.systemService.updateConfiguration(configuration.id, { enabled: !configuration.enabled })
.subscribe((response: any) => {
configuration.enabled = response.changes.enabled;
});
}
}
@@ -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 { SystemService } from '../../system.service';
/**
* Configurations data resolver.
*/
@Injectable()
export class GlobalConfigurationsResolver implements Resolve<Object> {
/**
* @param {SystemService} systemService System service.
*/
constructor(private systemService: SystemService) {}
/**
* Returns the configurations data.
* @returns {Observable<any>}
*/
resolve(): Observable<any> {
return this.systemService.getConfigurations();
}
}