Files
cbsnexora/src/app/centers/centers-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

73 lines
2.4 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/.
*/
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { AuthenticationService } from '../../../core/authentication/authentication.service';
import { CentersService } from '../../centers.service';
import { EntityNotesTabComponent } from '../../../shared/tabs/entity-notes-tab/entity-notes-tab.component';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
@Component({
selector: 'mifosx-centers-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 authenticationService = inject(AuthenticationService);
private centersService = inject(CentersService);
entityId: string;
username: string;
entityNotes: any;
constructor() {
this.entityId = this.route.parent.parent.snapshot.params['centerId'];
this.addNote = this.addNote.bind(this);
this.editNote = this.editNote.bind(this);
this.deleteNote = this.deleteNote.bind(this);
}
ngOnInit() {
const savedCredentials = this.authenticationService.getCredentials();
this.username = savedCredentials.username;
this.route.data.subscribe((data: { centerNotes: any }) => {
this.entityNotes = data.centerNotes;
});
}
addNote(noteContent: any) {
this.centersService.createCenterNote(this.entityId, noteContent).subscribe((response: any) => {
this.entityNotes.push({
id: response.resourceId,
createdByUsername: this.username,
createdOn: new Date(),
note: noteContent.note
});
});
}
editNote(noteId: string, noteContent: any, index: number) {
this.centersService.editCenterNote(this.entityId, noteId, noteContent).subscribe(() => {
this.entityNotes[index].note = noteContent.note;
});
}
deleteNote(noteId: string, index: number) {
this.centersService.deleteCenterNote(this.entityId, noteId).subscribe(() => {
this.entityNotes.splice(index, 1);
});
}
}