Files
cbsnexora/src/app/clients/clients-view/notes-tab/notes-tab.component.ts
T
AdityaandClaude Opus 4.7 d175354f88 feat(mfa): DSC as own factor type + fix selector collisions
- access-control: register DSC enrollment under factorType='DSC' instead of
  the legacy 'TOKEN' alias, hydrate / disable paths match on the same code.
  Pill labels in the picker and Hardware Token panel updated to 'Type · DSC'.
  service.ts MfaFactorType union adds 'DSC'.
- two-factor-authentication: initialise the delivery-method form at field
  declaration instead of inside ngOnInit so Angular's first change-detection
  pass doesn't fire 'Cannot find control' before the form is built.
- Rename duplicate component selectors that were tripping NG0912 at runtime:
  mifosx-notes-tab -> mifosx-{centers,clients,current-account,groups,loans,
  savings}-notes-tab; mifosx-unassign-staff-dialog -> mifosx-{clients,groups}-
  unassign-staff-dialog. Selectors aren't referenced in templates (route /
  dialog open), so the rename has no usage-site impact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 18:07:14 +05:30

102 lines
3.0 KiB
TypeScript

/**
* 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/.
*/
/** Angular Imports */
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
/** Custom Components */
/** Custom Services */
import { ClientsService } from '../../clients.service';
import { AuthenticationService } from 'app/core/authentication/authentication.service';
import { EntityNotesTabComponent } from '../../../shared/tabs/entity-notes-tab/entity-notes-tab.component';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
/**
* Notes Tab Component
*/
@Component({
selector: 'mifosx-clients-notes-tab',
templateUrl: './notes-tab.component.html',
styleUrls: ['./notes-tab.component.scss'],
imports: [
...STANDALONE_SHARED_IMPORTS,
EntityNotesTabComponent
]
})
export class NotesTabComponent implements OnInit {
private route = inject(ActivatedRoute);
private clientsService = inject(ClientsService);
private authenticationService = inject(AuthenticationService);
/** Client ID */
entityId: string;
/** Username */
username: string;
/** Client Notes */
entityNotes: any;
/**
* @param {ActivatedRoute} route Activated Route
* @param {ClientsService} clientsService Clients Service
* @param {AuthenticationService} authenticationService Authentication Service
*/
constructor() {
this.entityId = this.route.parent.snapshot.params['clientId'];
this.addNote = this.addNote.bind(this);
this.editNote = this.editNote.bind(this);
this.deleteNote = this.deleteNote.bind(this);
}
ngOnInit(): void {
const credentials = this.authenticationService.getCredentials();
this.username = credentials.username;
this.route.data.subscribe((data: { clientNotes: any }) => {
this.entityNotes = data.clientNotes;
});
}
/**
* Edits a client note.
* @param {string} noteId Note Id
* @param {any} noteContent Note Content
* @param {number} index Index
*/
editNote(noteId: string, noteContent: any, index: number) {
this.clientsService.editClientNote(this.entityId, noteId, noteContent).subscribe(() => {
this.entityNotes[index].note = noteContent.note;
});
}
/**
* Deletes a client note.
* @param {string} noteId Note Id
* @param {number} index Index
*/
deleteNote(noteId: string, index: number) {
this.clientsService.deleteClientNote(this.entityId, noteId).subscribe(() => {
this.entityNotes.splice(index, 1);
});
}
/**
* Creates a client note.
*/
addNote(noteContent: any) {
this.clientsService.createClientNote(this.entityId, noteContent).subscribe((response: any) => {
this.entityNotes.push({
id: response.resourceId,
createdByUsername: this.username,
createdOn: new Date(),
note: noteContent.note
});
});
}
}