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-form-field fxFlex="48%">
<mat-label>Legal Form</mat-label> <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"> <mat-option *ngFor="let legalForm of legalFormOptions" [value]="legalForm.id">
{{ legalForm.value }} {{ legalForm.value }}
</mat-option> </mat-option>
@@ -1,6 +1,7 @@
/** Angular Imports */ /** Angular Imports */
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { ClientsService } from 'app/clients/clients.service';
import { Dates } from 'app/core/utils/dates'; import { Dates } from 'app/core/utils/dates';
/** Custom Services */ /** Custom Services */
@@ -51,10 +52,12 @@ export class ClientGeneralStepComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder * @param {FormBuilder} formBuilder Form Builder
* @param {Dates} dateUtils Date Utils * @param {Dates} dateUtils Date Utils
* @param {SettingsService} settingsService Setting service * @param {SettingsService} settingsService Setting service
* @param {ClientsService} clientService Client service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private dateUtils: Dates, private dateUtils: Dates,
private settingsService: SettingsService) { private settingsService: SettingsService,
private clientService: ClientsService) {
this.setClientForm(); this.setClientForm();
} }
@@ -71,7 +74,7 @@ export class ClientGeneralStepComponent implements OnInit {
this.createClientForm = this.formBuilder.group({ this.createClientForm = this.formBuilder.group({
'officeId': ['', Validators.required], 'officeId': ['', Validators.required],
'staffId': [''], 'staffId': [''],
'legalFormId': [''], 'legalFormId': ['', Validators.required],
'isStaff': [false], 'isStaff': [false],
'active': [false], 'active': [false],
'addSavings': [false], 'addSavings': [false],
@@ -143,6 +146,11 @@ export class ClientGeneralStepComponent implements OnInit {
this.createClientForm.removeControl('savingsProductId'); 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> <mat-card-title>
<h3> <h3>
<i class="fa fa-stop" [ngClass]="clientViewData.status.code|statusLookup" [matTooltip]="clientViewData.status.value"></i> <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> </h3>
</mat-card-title> </mat-card-title>
<mat-card-subtitle> <mat-card-subtitle>
<p> <p>
Client #:{{clientViewData.accountNo}} | External <b>Office :</b> {{clientViewData.officeName}}<br />
Id: {{clientViewData.externalId}} | Staff:{{clientViewData.staffName || 'Unassigned'}}<br /> <b>Client :</b> {{clientViewData.accountNo}}<br />
Activation Date : {{(clientViewData.activationDate) ? (clientViewData.activationDate | dateFormat) :'Not Activated'}}<br /> <b>External Id:</b> {{clientViewData.externalId}}<br />
Member Of : <span *ngIf="clientViewData.staffName"><b>Staff :</b> {{clientViewData.staffName || 'Unassigned'}}<br /></span>
<span *ngFor="let group of clientViewData.groups"> <span *ngIf="clientViewData.activationDate"><b>Activation Date :</b> {{clientViewData.activationDate | dateFormat}}<br /></span>
<a>{{group.name}}</a>&nbsp; <span *ngIf="clientViewData.groups.length > 0">
Member Of :
<span *ngFor="let group of clientViewData.groups">
<a>{{group.name}}</a>&nbsp;
</span>
</span> </span>
<span *ngIf="!clientViewData.groups">Unassigned</span>
<br/> <br/>
</p> </p>
</mat-card-subtitle> </mat-card-subtitle>
@@ -112,7 +112,6 @@ export class ClientsViewComponent implements OnInit {
} }
} }
/** /**
* Refetches data for the component * Refetches data for the component
* TODO: Replace by a custom reload component instead of hard-coded back-routing. * TODO: Replace by a custom reload component instead of hard-coded back-routing.
+3 -1
View File
@@ -34,7 +34,9 @@
<!-- External ID Column --> <!-- External ID Column -->
<ng-container matColumnDef="externalid"> <ng-container matColumnDef="externalid">
<th mat-header-cell *matHeaderCellDef mat-sort-header="externalId"> ExternalID </th> <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> </ng-container>
<!-- Status Column --> <!-- Status Column -->
+4
View File
@@ -41,6 +41,10 @@ export class ClientsService {
return this.http.get('/clients/template'); return this.http.get('/clients/template');
} }
getClientWithOfficeTemplate(officeId: number): Observable<any> {
return this.http.get(`/clients/template?officeId=${officeId}&staffInSelectedOfficeOnly=true`);
}
getClientData(clientId: string) { getClientData(clientId: string) {
return this.http.get(`/clients/${clientId}`); return this.http.get(`/clients/${clientId}`);
} }
@@ -104,11 +104,13 @@ export class CreateClientComponent {
if (this.legalFormType === 2) { if (this.legalFormType === 2) {
legalFormTypeVal = 'entity'; legalFormTypeVal = 'entity';
} }
this.clientTemplate.datatables.forEach((datatable: any) => { if (this.clientTemplate.datatables) {
if (datatable.entitySubType.toLowerCase() === legalFormTypeVal) { this.clientTemplate.datatables.forEach((datatable: any) => {
this.datatables.push(datatable); if (datatable.entitySubType.toLowerCase() === legalFormTypeVal) {
} this.datatables.push(datatable);
}); }
});
}
} }
legalFormChange(eventData: { legalForm: number }) { 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 { UrlToStringPipe } from './url-to-string.pipe';
import { DateFormatPipe } from './date-format.pipe'; import { DateFormatPipe } from './date-format.pipe';
import { DatetimeFormatPipe } from './datetime-format.pipe'; import { DatetimeFormatPipe } from './datetime-format.pipe';
import { ExternalIdentifierPipe } from './external-identifier.pipe';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule CommonModule
], ],
declarations: [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], providers: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe, UrlToStringPipe, DateFormatPipe, DatetimeFormatPipe, ExternalIdentifierPipe],
exports: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe, UrlToStringPipe, DateFormatPipe, DatetimeFormatPipe] exports: [StatusLookupPipe, AccountsFilterPipe, ChargesFilterPipe, ChargesPenaltyFilterPipe, FindPipe, UrlToStringPipe, DateFormatPipe, DatetimeFormatPipe, ExternalIdentifierPipe]
}) })
export class PipesModule { } export class PipesModule { }
@@ -23,7 +23,9 @@
<ng-container matColumnDef="externalId"> <ng-container matColumnDef="externalId">
<th mat-header-cell *matHeaderCellDef> External Id </th> <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>
<ng-container matColumnDef="parentType"> <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 { IconsModule } from './icons.module';
import { MaterialModule } from './material.module'; import { MaterialModule } from './material.module';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { ExternalIdentifierComponent } from './external-identifier/external-identifier.component';
import { PipesModule } from 'app/pipes/pipes.module';
/** /**
* Shared Module * Shared Module
@@ -40,6 +42,7 @@ import { TranslateModule } from '@ngx-translate/core';
MaterialModule, MaterialModule,
ReactiveFormsModule, ReactiveFormsModule,
TranslateModule.forRoot(), TranslateModule.forRoot(),
PipesModule
], ],
declarations: [ declarations: [
FormfieldComponent, FormfieldComponent,
@@ -59,7 +62,8 @@ import { TranslateModule } from '@ngx-translate/core';
NotificationsTrayComponent, NotificationsTrayComponent,
SearchToolComponent, SearchToolComponent,
ServerSelectorComponent, ServerSelectorComponent,
TenantSelectorComponent TenantSelectorComponent,
ExternalIdentifierComponent
], ],
exports: [ exports: [
FileUploadComponent, FileUploadComponent,
@@ -76,7 +80,8 @@ import { TranslateModule } from '@ngx-translate/core';
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
TranslateModule, TranslateModule,
TenantSelectorComponent TenantSelectorComponent,
ExternalIdentifierComponent
] ]
}) })
export class SharedModule { } 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 { .error-log {
color: #ffa726; color: #ffa726;
} }
+24
View File
@@ -22,3 +22,27 @@ div {
.nolist { .nolist {
list-style: none; 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;
}
}