Merge pull request #1587 from josehernandezfintecheandomx/fix/client_creation_with_staff

Client and External Id
This commit is contained in:
Adam Saghy
2022-12-05 08:55:30 +01:00
committed by GitHub
18 changed files with 159 additions and 46 deletions
@@ -16,7 +16,7 @@
<mat-form-field fxFlex="48%">
<mat-label>Legal Form</mat-label>
<mat-select formControlName="legalFormId">
<mat-select required formControlName="legalFormId">
<mat-option *ngFor="let legalForm of legalFormOptions" [value]="legalForm.id">
{{ legalForm.value }}
</mat-option>
@@ -1,6 +1,7 @@
/** Angular Imports */
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { ClientsService } from 'app/clients/clients.service';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
@@ -51,10 +52,12 @@ export class ClientGeneralStepComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder
* @param {Dates} dateUtils Date Utils
* @param {SettingsService} settingsService Setting service
* @param {ClientsService} clientService Client service
*/
constructor(private formBuilder: FormBuilder,
private dateUtils: Dates,
private settingsService: SettingsService) {
private settingsService: SettingsService,
private clientService: ClientsService) {
this.setClientForm();
}
@@ -71,7 +74,7 @@ export class ClientGeneralStepComponent implements OnInit {
this.createClientForm = this.formBuilder.group({
'officeId': ['', Validators.required],
'staffId': [''],
'legalFormId': [''],
'legalFormId': ['', Validators.required],
'isStaff': [false],
'active': [false],
'addSavings': [false],
@@ -143,6 +146,11 @@ export class ClientGeneralStepComponent implements OnInit {
this.createClientForm.removeControl('savingsProductId');
}
});
this.createClientForm.get('officeId').valueChanges.subscribe((officeId: number) => {
this.clientService.getClientWithOfficeTemplate(officeId).subscribe((clientTemplate: any) => {
this.staffOptions = clientTemplate.staffOptions;
});
});
}
/**
@@ -29,20 +29,23 @@
<mat-card-title>
<h3>
<i class="fa fa-stop" [ngClass]="clientViewData.status.code|statusLookup" [matTooltip]="clientViewData.status.value"></i>
Client Name : {{clientViewData.displayName}}
<b>Client Name :</b> {{clientViewData.displayName}}
</h3>
</mat-card-title>
<mat-card-subtitle>
<p>
Client #:{{clientViewData.accountNo}} | External
Id: {{clientViewData.externalId}} | Staff:{{clientViewData.staffName || 'Unassigned'}}<br />
Activation Date : {{(clientViewData.activationDate) ? (clientViewData.activationDate | dateFormat) :'Not Activated'}}<br />
Member Of :
<span *ngFor="let group of clientViewData.groups">
<a>{{group.name}}</a>&nbsp;
<b>Office :</b> {{clientViewData.officeName}}<br />
<b>Client :</b> {{clientViewData.accountNo}}<br />
<b>External Id:</b> {{clientViewData.externalId}}<br />
<span *ngIf="clientViewData.staffName"><b>Staff :</b> {{clientViewData.staffName || 'Unassigned'}}<br /></span>
<span *ngIf="clientViewData.activationDate"><b>Activation Date :</b> {{clientViewData.activationDate | dateFormat}}<br /></span>
<span *ngIf="clientViewData.groups.length > 0">
Member Of :
<span *ngFor="let group of clientViewData.groups">
<a>{{group.name}}</a>&nbsp;
</span>
</span>
<span *ngIf="!clientViewData.groups">Unassigned</span>
<br/>
</p>
</mat-card-subtitle>
@@ -112,7 +112,6 @@ export class ClientsViewComponent implements OnInit {
}
}
/**
* Refetches data for the component
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
+3 -1
View File
@@ -34,7 +34,9 @@
<!-- External ID Column -->
<ng-container matColumnDef="externalid">
<th mat-header-cell *matHeaderCellDef mat-sort-header="externalId"> ExternalID </th>
<td mat-cell *matCellDef="let row"> {{row.externalId}} </td>
<td mat-cell *matCellDef="let row">
<mifosx-external-identifier externalId="{{row.externalId}}"></mifosx-external-identifier>
</td>
</ng-container>
<!-- Status Column -->
+4
View File
@@ -41,6 +41,10 @@ export class ClientsService {
return this.http.get('/clients/template');
}
getClientWithOfficeTemplate(officeId: number): Observable<any> {
return this.http.get(`/clients/template?officeId=${officeId}&staffInSelectedOfficeOnly=true`);
}
getClientData(clientId: string) {
return this.http.get(`/clients/${clientId}`);
}
@@ -104,11 +104,13 @@ export class CreateClientComponent {
if (this.legalFormType === 2) {
legalFormTypeVal = 'entity';
}
this.clientTemplate.datatables.forEach((datatable: any) => {
if (datatable.entitySubType.toLowerCase() === legalFormTypeVal) {
this.datatables.push(datatable);
}
});
if (this.clientTemplate.datatables) {
this.clientTemplate.datatables.forEach((datatable: any) => {
if (datatable.entitySubType.toLowerCase() === legalFormTypeVal) {
this.datatables.push(datatable);
}
});
}
}
legalFormChange(eventData: { legalForm: number }) {
@@ -0,0 +1,8 @@
import { ExternalIdentifierPipe } from './external-identifier.pipe';
describe('ExternalIdentifierPipe', () => {
it('create an instance', () => {
const pipe = new ExternalIdentifierPipe();
expect(pipe).toBeTruthy();
});
});
+25
View File
@@ -0,0 +1,25 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'externalIdentifier'
})
export class ExternalIdentifierPipe implements PipeTransform {
transform(externalId: string): string {
const limit = 20;
if (!externalId) {
return '';
} else {
const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi;
if (regexExp.test(externalId)) {
const values = externalId.split('-');
return values[4];
} else {
const inputLen = externalId.length;
return inputLen > limit ? externalId.substring((inputLen - limit), inputLen) : externalId;
}
}
}
}
+4 -3
View File
@@ -8,13 +8,14 @@ import { FindPipe } from './find.pipe';
import { UrlToStringPipe } from './url-to-string.pipe';
import { DateFormatPipe } from './date-format.pipe';
import { DatetimeFormatPipe } from './datetime-format.pipe';
import { ExternalIdentifierPipe } from './external-identifier.pipe';
@NgModule({
imports: [
CommonModule
],
declarations: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe, UrlToStringPipe, DateFormatPipe, DatetimeFormatPipe],
providers: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe, UrlToStringPipe, DateFormatPipe, DatetimeFormatPipe],
exports: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe, UrlToStringPipe, DateFormatPipe, DatetimeFormatPipe]
declarations: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe, UrlToStringPipe, DateFormatPipe, DatetimeFormatPipe, ExternalIdentifierPipe],
providers: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe, UrlToStringPipe, DateFormatPipe, DatetimeFormatPipe, ExternalIdentifierPipe],
exports: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe, UrlToStringPipe, DateFormatPipe, DatetimeFormatPipe, ExternalIdentifierPipe]
})
export class PipesModule { }
@@ -23,7 +23,9 @@
<ng-container matColumnDef="externalId">
<th mat-header-cell *matHeaderCellDef> External Id </th>
<td mat-cell *matCellDef="let entity" class="view-details"> {{entity.entityExternalId | externalIdentifier}} </td>
<td mat-cell *matCellDef="let entity" class="view-details">
<mifosx-external-identifier externalId="{{entity.entityExternalId}}"></mifosx-external-identifier>
</td>
</ng-container>
<ng-container matColumnDef="parentType">
@@ -0,0 +1,4 @@
<div>
<span *ngIf="isLongValue()"><fa-icon icon="eye" size="sm" [title]="externalId"></fa-icon></span>
{{ externalId | externalIdentifier }}
</div>
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ExternalIdentifierComponent } from './external-identifier.component';
describe('ExternalIdentifierComponent', () => {
let component: ExternalIdentifierComponent;
let fixture: ComponentFixture<ExternalIdentifierComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ExternalIdentifierComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ExternalIdentifierComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,23 @@
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'mifosx-external-identifier',
templateUrl: './external-identifier.component.html',
styleUrls: ['./external-identifier.component.scss']
})
export class ExternalIdentifierComponent implements OnInit {
@Input() externalId: string;
constructor() { }
ngOnInit(): void {
}
isLongValue(): boolean {
if (this.externalId == null) {
return false;
}
return (this.externalId.length > 15);
}
}
+7 -2
View File
@@ -27,6 +27,8 @@ import { TenantSelectorComponent } from './tenant-selector/tenant-selector.compo
import { IconsModule } from './icons.module';
import { MaterialModule } from './material.module';
import { TranslateModule } from '@ngx-translate/core';
import { ExternalIdentifierComponent } from './external-identifier/external-identifier.component';
import { PipesModule } from 'app/pipes/pipes.module';
/**
* Shared Module
@@ -40,6 +42,7 @@ import { TranslateModule } from '@ngx-translate/core';
MaterialModule,
ReactiveFormsModule,
TranslateModule.forRoot(),
PipesModule
],
declarations: [
FormfieldComponent,
@@ -59,7 +62,8 @@ import { TranslateModule } from '@ngx-translate/core';
NotificationsTrayComponent,
SearchToolComponent,
ServerSelectorComponent,
TenantSelectorComponent
TenantSelectorComponent,
ExternalIdentifierComponent
],
exports: [
FileUploadComponent,
@@ -76,7 +80,8 @@ import { TranslateModule } from '@ngx-translate/core';
FormsModule,
ReactiveFormsModule,
TranslateModule,
TenantSelectorComponent
TenantSelectorComponent,
ExternalIdentifierComponent
]
})
export class SharedModule { }
@@ -24,28 +24,6 @@
}
}
.alert {
background-color: #E8F4FD;
padding: 6px 16px;
font-size: 0.875rem;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-weight: 400;
line-height: 1.43;
border-radius: 4px;
letter-spacing: 0.01071em;
margin: 10px;
.message {
padding: 8px 0;
font-size: 18px;
}
.alert-check {
color:#359FF4;
margin-right: 2px;
font-size: 1.4rem;
}
}
.error-log {
color: #ffa726;
}
+24
View File
@@ -22,3 +22,27 @@ div {
.nolist {
list-style: none;
}
.alert {
background-color: #E8F4FD;
padding: 6px 16px;
font-size: 0.875rem;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-weight: 400;
line-height: 1.43;
border-radius: 4px;
letter-spacing: 0.01071em;
margin: 10px;
.message {
padding: 8px 0;
font-size: 18px;
}
.alert-check {
color:#359FF4;
margin-right: 2px;
font-size: 1.4rem;
}
}