Client-stepper: pre-fill existing KYC/address proofs in edit, fix identifier saves

Edit-mode now shows the previously selected KYC document type + uploaded file thumbnail
(loads from /clients/{id}/identifiers + /client_identifiers/{id}/documents). Same for
address proof on the India address step. Closes the gap where editing a client showed
an empty file picker even when proof had been uploaded on create.

Identifier-save hardened across all three callsites (create-client, edit-client,
identities-tab.createIdentifierWithDocs) - the KYC chip picker proofId is a CODE
string ('AADHAAR'), but backend ClientIdentifierRequest.documentTypeId is Long, which
Spring rejects with HttpMessageNotReadableException -> 400. resolveDocumentTypeId
helper looks up the code against /kyc/proof-types?type=id and substitutes the numeric
CodeValue id before posting. Skips silently for constitution-specific non-individual
docs that have no CodeValue mapping.

KYC payload normalises panNumber / enterprisePan / gstinNumber / cinNumber via
toUpperCase + whitespace strip so user-typed lowercase or trailing spaces don't trip
the backend regex (validation.msg.CLIENTKYC.panNumber.does.not.match.regexp).

State name match in client-address save now normalises both sides (lowercase, collapse
underscores + spaces) so legacy MADHYA_PRADESH resolves to 'Madhya Pradesh' returned
by api.postalpincode.in. Backed by tenant migration 0297.

Identities-tab resolver flattened - was returning identifiers before the per-row
forkJoin(getClientIdentificationDocuments) completed, so the view rendered empty
documents arrays. Now uses switchMap + forkJoin so the resolver awaits completion.

Also bundles concurrent work-in-progress on letter-mgmt, organization, users,
bank-calendar, shell, nominee/notes/identifier dialogs, and theming.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Aditya
2026-05-20 12:40:58 +05:30
co-authored by Claude Opus 4.7
parent 325228c514
commit 83ea57ccf0
84 changed files with 10281 additions and 1194 deletions
@@ -31,6 +31,13 @@
<strong>{{ 'labels.commons.Minimum Value must be' | translate }} {{ formfield.min }}</strong>
</mat-error>
}
@if (form.controls[formfield.controlName].hasError('minWords')) {
<mat-error>
Must contain at least
<strong> {{ form.controls[formfield.controlName].errors?.['minWords']?.requiredWords || 2 }} words </strong>
(whitespace doesn't count).
</mat-error>
}
@if (formfield.controlType === 'select') {
<mat-select [formControlName]="formfield.controlName" [required]="formfield.required">
@for (option of formfield.options.data; track option) {
+6 -2
View File
@@ -201,7 +201,9 @@ import {
faQrcode,
faRedo,
faSignature,
faPercentage
faPercentage,
faCompressAlt,
faExpandAlt
} from '@fortawesome/free-solid-svg-icons';
/**
@@ -409,7 +411,9 @@ export class IconsModule {
faQrcode,
faRedo,
faSignature,
faPercentage
faPercentage,
faCompressAlt,
faExpandAlt
);
}
}
@@ -24,7 +24,18 @@
placeholder="{{ 'labels.text.Write a note' | translate }} ..."
cdkTextareaAutosize
cdkAutosizeMinRows="2"
matTooltip="At least two words required — e.g. 'Hello User', 'Updated mobile', 'Re-KYC done'."
matTooltipPosition="above"
matTooltipShowDelay="300"
(keydown)="onNoteKeyDown($event)"
(input)="onNoteInput($event)"
></textarea>
@if (noteForm.controls['note'].touched && noteForm.controls['note'].hasError('required')) {
<mat-error>Note cannot be empty.</mat-error>
}
@if (noteForm.controls['note'].touched && noteForm.controls['note'].hasError('minWords')) {
<mat-error>Note must contain at least 2 words (whitespace doesn't count).</mat-error>
}
</mat-form-field>
<button type="submit" mat-raised-button class="flex-1" color="primary" [disabled]="!noteForm.valid">
<fa-icon icon="plus" class="m-r-10" aria-hidden="true"></fa-icon>{{ 'labels.buttons.Add' | translate }}
@@ -15,8 +15,10 @@ import { LoansService } from 'app/loans/loans.service';
import { SavingsService } from 'app/savings/savings.service';
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
import { minWordsValidator } from 'app/shared/validators/min-words.validator';
import { CdkTextareaAutosize } from '@angular/cdk/text-field';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { MatTooltip } from '@angular/material/tooltip';
import { DateFormatPipe } from '../../../pipes/date-format.pipe';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
import { TranslateService } from '@ngx-translate/core';
@@ -29,6 +31,7 @@ import { TranslateService } from '@ngx-translate/core';
...STANDALONE_SHARED_IMPORTS,
CdkTextareaAutosize,
FaIconComponent,
MatTooltip,
DateFormatPipe
]
})
@@ -58,9 +61,14 @@ export class EntityNotesTabComponent implements OnInit {
createNoteForm() {
this.noteForm = this.formBuilder.group({
// Reject whitespace-only or single-word notes — at least two words so the
// audit trail is meaningful (no "ok" / " " entries landing in the DB).
note: [
'',
Validators.required
[
Validators.required,
minWordsValidator(2)
]
]
});
}
@@ -70,6 +78,42 @@ export class EntityNotesTabComponent implements OnInit {
this.formRef.resetForm();
}
/**
* Block whitespace as the very first character so the textarea never starts
* with blanks. Catches Space/Tab pressed against an empty (or only-whitespace)
* value before the OS even inserts the character.
*/
onNoteKeyDown(event: KeyboardEvent): void {
if (event.key !== ' ' && event.key !== 'Tab' && event.key !== 'Enter') return;
const el = event.target as HTMLTextAreaElement;
// Only intervene when the caret is at the start AND the existing value is
// empty / whitespace-only — otherwise users typing legitimate spaces in the
// middle of text are unaffected.
if (el.selectionStart === 0 && el.value.trim() === '') {
event.preventDefault();
}
}
/**
* On every input change (typing or paste), strip leading whitespace and
* collapse internal runs of spaces / tabs to a single space. Newlines are
* preserved so multi-line notes still work.
*/
onNoteInput(event: Event): void {
const el = event.target as HTMLTextAreaElement;
const before = el.value;
const after = before.replace(/^[ \t]+/, '').replace(/[ \t]{2,}/g, ' ');
if (before !== after) {
const cursorDelta = before.length - after.length;
const pos = Math.max(0, (el.selectionStart ?? after.length) - cursorDelta);
el.value = after;
this.noteForm.get('note')!.setValue(after, { emitEvent: false });
// Restore the caret position so the cursor doesn't jump to the end on
// every keystroke (otherwise typing feels broken).
el.setSelectionRange(pos, pos);
}
}
editNote(noteId: string, noteContent: string, index: number) {
const editNoteDialogRef = this.dialog.open(FormDialogComponent, {
data: {
@@ -79,7 +123,9 @@ export class EntityNotesTabComponent implements OnInit {
required: true,
value: noteContent,
controlType: 'input',
label: this.translateService.instant('labels.inputs.Note')
label: this.translateService.instant('labels.inputs.Note'),
// Same rule as the inline Add Note form — at least 2 words.
validators: [minWordsValidator(2)]
}
],
layout: {
@@ -0,0 +1,35 @@
/**
* Copyright since 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { AbstractControl, ValidatorFn, ValidationErrors } from '@angular/forms';
/**
* Reject whitespace-only or single-word input.
*
* Counts contiguous non-whitespace runs as "words". Empty/whitespace-only
* input returns the `minWords` error so an empty string is treated as
* insufficient (callers can still chain `Validators.required` if they want a
* separate "required" error key).
*
* @param min minimum number of words required (default: 2)
*/
export function minWordsValidator(min = 2): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
const raw = control.value;
if (raw == null) return null;
const text = String(raw).trim();
if (!text) {
return { minWords: { requiredWords: min, actual: 0 } };
}
const words = text.split(/\s+/).filter((w) => w.length > 0);
if (words.length < min) {
return { minWords: { requiredWords: min, actual: words.length } };
}
return null;
};
}