Merge pull request #2559 from alberto-art3ch/WEB-252/number_input_form_dialog_with_validators

WEB-252: Buy Down fee adjustment template pop up window - Adjustment …
This commit is contained in:
Jose Alberto Hernandez
2025-07-14 08:23:14 -05:00
committed by GitHub
9 changed files with 48 additions and 18 deletions
@@ -120,7 +120,6 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
this.id = this.route.snapshot.queryParams['savingsId'];
this.interbank = this.route.snapshot.queryParams['interbank'] === 'true';
this.balance = this.router.getCurrentNavigation().extras.state.balance;
console.log('is interbank?', this.interbank);
break;
default:
this.accountTypeId = '0';
@@ -71,8 +71,6 @@ export class MakeRepaymentComponent implements OnInit {
*/
ngOnInit() {
this.command = this.dataObject.type.code.split('.')[1];
console.log(this.command);
console.log(this.dataObject.type);
this.maxDate = this.settingsService.businessDate;
this.createRepaymentLoanForm();
this.setRepaymentLoanDetails();
@@ -1,6 +1,6 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { UntypedFormControl, Validators } from '@angular/forms';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import {
@@ -29,9 +29,9 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
import { AlertService } from 'app/core/alert/alert.service';
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
import { NgIf, NgClass } from '@angular/common';
import { NgClass } from '@angular/common';
import { MatCheckbox } from '@angular/material/checkbox';
import { MatButton, MatIconButton } from '@angular/material/button';
import { MatIconButton } from '@angular/material/button';
import { ExternalIdentifierComponent } from '../../../shared/external-identifier/external-identifier.component';
import { MatMenuTrigger, MatMenu, MatMenuItem } from '@angular/material/menu';
import { MatIcon } from '@angular/material/icon';
@@ -472,8 +472,11 @@ export class TransactionsTabComponent implements OnInit {
value: transactionAmount,
type: 'number',
required: true,
max: transactionAmount,
min: 0.001,
max: transactionAmount,
validators: [
Validators.min(0.001),
Validators.max(transactionAmount)],
order: 2
})
@@ -481,7 +484,8 @@ export class TransactionsTabComponent implements OnInit {
const data = {
title: `Adjustment ${transaction.type.value} Transaction`,
layout: { addButtonText: 'Adjustment' },
formfields: formfields
formfields: formfields,
pristine: false
};
const chargebackDialogRef = this.dialog.open(FormDialogComponent, { data });
chargebackDialogRef.afterClosed().subscribe((response: { data: any }) => {
@@ -544,8 +548,11 @@ export class TransactionsTabComponent implements OnInit {
value: transactionAmount,
type: 'number',
required: true,
max: transactionAmount,
min: 0.001,
max: transactionAmount,
validators: [
Validators.min(0.001),
Validators.max(transactionAmount)],
order: 2
})
@@ -553,7 +560,8 @@ export class TransactionsTabComponent implements OnInit {
const data = {
title: `Adjustment ${transaction.type.value} Transaction`,
layout: { addButtonText: 'Adjustment' },
formfields: formfields
formfields: formfields,
pristine: false
};
const chargebackDialogRef = this.dialog.open(FormDialogComponent, { data });
chargebackDialogRef.afterClosed().subscribe((response: { data: any }) => {
@@ -204,7 +204,6 @@ export class ViewTransactionComponent implements OnInit {
* Undo the loans transaction
*/
undoTransaction() {
console.log(this.transactionData);
const accountId = this.route.snapshot.params['loanId'];
if (this.transactionType.contractTermination) {
@@ -54,7 +54,6 @@ export class SavingsActiveClientMembersComponent implements OnInit {
dataSource: any;
ngOnInit(): void {
console.log('Active Client Members in LoansActiveClientMembersComponent:', this.activeClientMembers);
this.dataSource = new MatTableDataSource<any>(this.activeClientMembers);
}
get selectedClientMembers() {
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { UntypedFormControl, UntypedFormGroup, ValidatorFn, Validators } from '@angular/forms';
import { FormfieldBase } from './formfield/model/formfield-base';
@@ -14,10 +14,21 @@ export class FormGroupService {
formfields.forEach((formfield) => {
group[formfield.controlName] = formfield.required
? new UntypedFormControl(formfield.value, Validators.required)
: new UntypedFormControl(formfield.value);
? new UntypedFormControl(formfield.value, this.buildValidators(formfield))
: new UntypedFormControl(formfield.value, this.buildValidators(formfield));
});
return new UntypedFormGroup(group);
}
buildValidators(formfield: FormfieldBase): ValidatorFn[] {
let validators: ValidatorFn[] = [];
if (formfield.required) {
validators.push(Validators.required);
}
if (formfield.validators) {
formfield.validators.forEach((validator: ValidatorFn) => validators.push(validator));
}
return validators;
}
}
@@ -10,6 +10,12 @@
[formControlName]="formfield.controlName"
[required]="formfield.required"
/>
<mat-error *ngIf="form.controls[formfield.controlName].hasError('max')">
<strong>{{ 'labels.commons.Maximum Value must be' | translate }} {{ formfield.max }}</strong>
</mat-error>
<mat-error *ngIf="form.controls[formfield.controlName].hasError('min')">
<strong>{{ 'labels.commons.Minimum Value must be' | translate }} {{ formfield.min }}</strong>
</mat-error>
<mat-select
*ngIf="formfield.controlType === 'select'"
@@ -1,10 +1,16 @@
import { ValidatorFn } from '@angular/forms';
export class FormfieldBase {
controlType: string;
controlName: string;
type: string;
label: string;
value: any;
required: boolean;
order: number;
validators?: ValidatorFn[];
min?: number | null;
max?: number | null;
constructor(
options: {
@@ -14,6 +20,9 @@ export class FormfieldBase {
value?: any;
required?: boolean;
order?: number;
validators?: ValidatorFn[];
min?: number | null;
max?: number | null;
} = {}
) {
this.controlType = options.controlType || '';
@@ -22,5 +31,8 @@ export class FormfieldBase {
this.value = options.value === undefined ? '' : options.value;
this.required = !!options.required;
this.order = options.order === undefined ? 1 : options.order;
this.validators = options.validators === undefined ? [] : options.validators;
this.min = options.min === undefined ? null : options.min;
this.max = options.max === undefined ? null : options.max;
}
}
@@ -39,8 +39,6 @@ export class AuditTrailsDataSource implements DataSource<any> {
pageIndex: number = 0,
limit: number = 10
) {
console.log(pageIndex);
console.log(limit);
this.auditTrailsSubject.next([]);
this.systemService
.getAuditTrails(filterBy, orderBy, sortOrder, pageIndex * limit, limit)