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:
co-authored by
Claude Opus 4.7
parent
325228c514
commit
83ea57ccf0
@@ -0,0 +1,149 @@
|
||||
<!--
|
||||
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/.
|
||||
-->
|
||||
|
||||
<div class="udd-root">
|
||||
<div class="udd-head">
|
||||
<div class="udd-head__left">
|
||||
<fa-icon icon="user-circle" class="udd-head__ic"></fa-icon>
|
||||
<div>
|
||||
<h2 class="udd-head__title">User Details</h2>
|
||||
<div class="udd-head__sub">Read-only summary of this user's profile</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="udd-x" (click)="close()" matTooltip="Close">
|
||||
<fa-icon icon="times"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (loading) {
|
||||
<div class="udd-loading">
|
||||
<fa-icon icon="spinner" class="fa-spin"></fa-icon>
|
||||
Loading…
|
||||
</div>
|
||||
} @else if (error) {
|
||||
<div class="udd-error">
|
||||
<fa-icon icon="exclamation-triangle"></fa-icon>
|
||||
{{ error }}
|
||||
</div>
|
||||
} @else if (user) {
|
||||
<div class="udd-body">
|
||||
<!-- Identity card -->
|
||||
<div class="udd-id-card" [class.self]="user.isSelfServiceUser">
|
||||
<span class="udd-avatar">{{ initials }}</span>
|
||||
<div class="udd-id-card__txt">
|
||||
<div class="udd-id-card__name">{{ fullName }}</div>
|
||||
<div class="udd-id-card__meta">
|
||||
<span class="mono">@{{ user.username }}</span>
|
||||
<span class="dot">·</span>
|
||||
<span>{{ user.officeName }}</span>
|
||||
@if (user.isSelfServiceUser) {
|
||||
<span class="udd-pill self">Self-Service</span>
|
||||
} @else {
|
||||
<span class="udd-pill staff">Staff</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Contact -->
|
||||
<div class="udd-section">
|
||||
<div class="udd-section__title">Contact</div>
|
||||
<div class="udd-grid">
|
||||
<div>
|
||||
<div class="udd-key">Email</div>
|
||||
<div class="udd-val mono">{{ user.email || '—' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="udd-key">Mobile</div>
|
||||
<div class="udd-val mono">
|
||||
@if (user.mobileNo) {
|
||||
+91 {{ user.mobileNo }}
|
||||
} @else {
|
||||
—
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Office & Staff -->
|
||||
<div class="udd-section">
|
||||
<div class="udd-section__title">Office & Staff</div>
|
||||
<div class="udd-grid">
|
||||
<div>
|
||||
<div class="udd-key">Office</div>
|
||||
<div class="udd-val">{{ user.officeName || '—' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="udd-key">Linked Staff</div>
|
||||
<div class="udd-val">{{ user.staff?.displayName || user.staffDisplayName || '—' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Roles -->
|
||||
<div class="udd-section">
|
||||
<div class="udd-section__title">Roles ({{ roleNames.length }})</div>
|
||||
@if (roleNames.length) {
|
||||
<div class="udd-roles">
|
||||
@for (r of roleNames; track r) {
|
||||
<span class="udd-role">{{ r }}</span>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="udd-val muted">No roles assigned.</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Security -->
|
||||
<div class="udd-section">
|
||||
<div class="udd-section__title">Security</div>
|
||||
<div class="udd-grid">
|
||||
<div>
|
||||
<div class="udd-key">Password Policy</div>
|
||||
<div class="udd-val">
|
||||
@if (user.passwordNeverExpires) {
|
||||
<fa-icon icon="check-circle" class="udd-ic ok"></fa-icon>
|
||||
Never expires
|
||||
} @else {
|
||||
<fa-icon icon="clock" class="udd-ic warn"></fa-icon>
|
||||
Expires per policy
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="udd-key">Last Password Change</div>
|
||||
<div class="udd-val">
|
||||
@if (lastPasswordUpdate) {
|
||||
{{ lastPasswordUpdate | date: 'd MMM y' }}
|
||||
} @else {
|
||||
—
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="udd-actions">
|
||||
<button class="udd-btn ghost" (click)="close()">Close</button>
|
||||
<button class="udd-btn ghost warn" (click)="close('delete')" *mifosxHasPermission="'DELETE_USER'">
|
||||
<fa-icon icon="trash"></fa-icon>
|
||||
Delete
|
||||
</button>
|
||||
<button class="udd-btn ghost" (click)="close('change-password')">
|
||||
<fa-icon icon="key"></fa-icon>
|
||||
Change Password
|
||||
</button>
|
||||
<button class="udd-btn primary" (click)="close('edit')" *mifosxHasPermission="'UPDATE_USER'">
|
||||
<fa-icon icon="pencil-alt"></fa-icon>
|
||||
Edit User
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,331 @@
|
||||
/**
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
$navy: #0d1b2a;
|
||||
$blue: #1e88e5;
|
||||
$blue-d: #1e40af;
|
||||
$green: #10b981;
|
||||
$red: #ef4444;
|
||||
$amber: #f59e0b;
|
||||
$purple: #7c3aed;
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.udd-root {
|
||||
background: #fff;
|
||||
width: 640px;
|
||||
max-width: 96vw;
|
||||
max-height: 90vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.udd-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 20px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
|
||||
|
||||
&__left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
&__ic {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 10px;
|
||||
background: linear-gradient(135deg, $blue 0%, $purple 100%);
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
box-shadow: 0 2px 6px -2px rgb(29 78 216 / 35%);
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
color: $navy;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
margin-top: 2px;
|
||||
font-size: 11.5px;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
|
||||
.udd-x {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #e2e8f0;
|
||||
background: #fff;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:hover {
|
||||
background: #fef2f2;
|
||||
color: $red;
|
||||
border-color: #fecaca;
|
||||
}
|
||||
}
|
||||
|
||||
.udd-loading,
|
||||
.udd-error {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 32px 24px;
|
||||
color: #64748b;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.udd-error {
|
||||
color: $red;
|
||||
}
|
||||
|
||||
.udd-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 16px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.udd-id-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 14px 16px;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, #eff6ff 0%, #fff 100%);
|
||||
border: 1px solid #bfdbfe;
|
||||
|
||||
&.self {
|
||||
background: linear-gradient(135deg, #ecfdf5 0%, #fff 100%);
|
||||
border-color: #a7f3d0;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
color: $navy;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
&__meta {
|
||||
margin-top: 3px;
|
||||
font-size: 11.5px;
|
||||
color: #64748b;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.udd-avatar {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border-radius: 50%;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, $blue 0%, $purple 100%);
|
||||
color: #fff;
|
||||
font-weight: 800;
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 3px 6px -2px rgb(29 78 216 / 35%);
|
||||
}
|
||||
|
||||
.udd-pill {
|
||||
padding: 2px 9px;
|
||||
border-radius: 999px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
|
||||
&.staff {
|
||||
background: #ede9fe;
|
||||
color: $purple;
|
||||
}
|
||||
|
||||
&.self {
|
||||
background: #ecfdf5;
|
||||
color: $green;
|
||||
}
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
.dot {
|
||||
color: #cbd5e1;
|
||||
}
|
||||
|
||||
.udd-section {
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
padding: 12px 14px;
|
||||
|
||||
&__title {
|
||||
font-size: 10.5px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
font-weight: 700;
|
||||
color: $blue-d;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.udd-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px 14px;
|
||||
}
|
||||
|
||||
.udd-key {
|
||||
font-size: 10.5px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: #64748b;
|
||||
font-weight: 600;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.udd-val {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: $navy;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
word-break: break-word;
|
||||
|
||||
&.muted {
|
||||
color: #94a3b8;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.udd-ic {
|
||||
font-size: 11px;
|
||||
|
||||
&.ok {
|
||||
color: $green;
|
||||
}
|
||||
|
||||
&.warn {
|
||||
color: $amber;
|
||||
}
|
||||
}
|
||||
|
||||
.udd-roles {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.udd-role {
|
||||
display: inline-block;
|
||||
padding: 3px 10px;
|
||||
background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
|
||||
color: #5b21b6;
|
||||
border-radius: 999px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.udd-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 14px 20px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
background: #fafbfc;
|
||||
}
|
||||
|
||||
.udd-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
height: 36px;
|
||||
padding: 0 14px;
|
||||
border-radius: 8px;
|
||||
font-size: 12.5px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
border: 1px solid transparent;
|
||||
|
||||
fa-icon {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
&.ghost {
|
||||
background: #fff;
|
||||
border-color: #d0d5dd;
|
||||
color: #475569;
|
||||
|
||||
&:hover {
|
||||
background: #f8fafc;
|
||||
border-color: #94a3b8;
|
||||
color: $navy;
|
||||
}
|
||||
|
||||
&.warn {
|
||||
color: $red;
|
||||
border-color: #fecaca;
|
||||
|
||||
&:hover {
|
||||
background: #fef2f2;
|
||||
border-color: $red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.primary {
|
||||
background: linear-gradient(135deg, $blue 0%, $blue-d 100%);
|
||||
border-color: $blue-d;
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 6px -2px rgb(30 64 175 / 35%);
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 4px 12px -3px rgb(30 64 175 / 45%);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 600px) {
|
||||
.udd-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.udd-actions {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* 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 { CommonModule, DatePipe } from '@angular/common';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
import { UsersService } from '../users.service';
|
||||
|
||||
export interface UserDetailsDialogData {
|
||||
userId: string | number;
|
||||
}
|
||||
|
||||
export type UserDetailsDialogResult = 'edit' | 'delete' | 'change-password' | undefined;
|
||||
|
||||
/**
|
||||
* Read-only "View User" dialog.
|
||||
*
|
||||
* Loads the full user record by id and renders the standard identity / office
|
||||
* / roles / security fields with a footer that lets the caller fast-track to
|
||||
* Edit / Delete / Change Password without leaving the list view.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-user-details-dialog',
|
||||
templateUrl: './user-details-dialog.component.html',
|
||||
styleUrls: ['./user-details-dialog.component.scss'],
|
||||
imports: [
|
||||
...STANDALONE_SHARED_IMPORTS,
|
||||
CommonModule,
|
||||
DatePipe,
|
||||
FaIconComponent,
|
||||
MatTooltip
|
||||
]
|
||||
})
|
||||
export class UserDetailsDialogComponent implements OnInit {
|
||||
private usersService = inject(UsersService);
|
||||
public dialogRef = inject(MatDialogRef<UserDetailsDialogComponent, UserDetailsDialogResult>);
|
||||
public data = inject<UserDetailsDialogData>(MAT_DIALOG_DATA);
|
||||
|
||||
user: any = null;
|
||||
loading = true;
|
||||
error: string | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.usersService.getUser(String(this.data.userId)).subscribe({
|
||||
next: (u: any) => {
|
||||
this.user = u;
|
||||
this.loading = false;
|
||||
},
|
||||
error: () => {
|
||||
this.loading = false;
|
||||
this.error = 'Could not load this user.';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
get fullName(): string {
|
||||
const fn = (this.user?.firstname || '').trim();
|
||||
const ln = (this.user?.lastname || '').trim();
|
||||
return (
|
||||
[
|
||||
fn,
|
||||
ln
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ') ||
|
||||
this.user?.username ||
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
get initials(): string {
|
||||
if (!this.user) return '?';
|
||||
const a = (this.user.firstname || this.user.username || '').charAt(0);
|
||||
const b = (this.user.lastname || '').charAt(0);
|
||||
return `${a}${b}`.toUpperCase() || '?';
|
||||
}
|
||||
|
||||
get roleNames(): string[] {
|
||||
return (this.user?.selectedRoles || []).map((r: any) => r.name);
|
||||
}
|
||||
|
||||
/** Last-password-update can come as ISO string or backend array. Normalise. */
|
||||
get lastPasswordUpdate(): string | null {
|
||||
const raw = this.user?.lastTimePasswordUpdated;
|
||||
if (!raw) return null;
|
||||
if (Array.isArray(raw) && raw.length >= 3) {
|
||||
const dt = new Date(raw[0], raw[1] - 1, raw[2]);
|
||||
return dt.toISOString();
|
||||
}
|
||||
return String(raw);
|
||||
}
|
||||
|
||||
close(result?: UserDetailsDialogResult): void {
|
||||
this.dialogRef.close(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
<!--
|
||||
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/.
|
||||
-->
|
||||
|
||||
<div class="ufd-root">
|
||||
<div class="ufd-head">
|
||||
<div class="ufd-head__left">
|
||||
<fa-icon [icon]="isEdit ? 'pencil-alt' : 'user-plus'" class="ufd-head__ic"></fa-icon>
|
||||
<div>
|
||||
<h2 class="ufd-head__title">{{ isEdit ? 'Edit User' : 'Create User' }}</h2>
|
||||
<div class="ufd-head__sub">
|
||||
{{ isEdit ? 'Update the details for this user.' : 'Add a new operator or self-service user.' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ufd-x" (click)="cancel()" matTooltip="Close">
|
||||
<fa-icon icon="times"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (loadingTemplate || loadingUser) {
|
||||
<div class="ufd-loading">
|
||||
<fa-icon icon="spinner" class="fa-spin"></fa-icon>
|
||||
Loading…
|
||||
</div>
|
||||
} @else {
|
||||
<form class="ufd-body" [formGroup]="form" (ngSubmit)="submit()">
|
||||
<!-- Identity -->
|
||||
<div class="ufd-section">
|
||||
<div class="ufd-section__title">Identity</div>
|
||||
<div class="ufd-grid">
|
||||
<div class="ufd-field">
|
||||
<label>Login Name *</label>
|
||||
<input type="text" formControlName="username" autocomplete="username" placeholder="e.g. arao" />
|
||||
@if (form.get('username')?.touched && form.get('username')?.errors?.['required']) {
|
||||
<div class="ufd-err">Login name is required.</div>
|
||||
}
|
||||
</div>
|
||||
<div class="ufd-field">
|
||||
<label>Email *</label>
|
||||
<input type="email" formControlName="email" placeholder="user@bank.com" />
|
||||
@if (form.get('email')?.touched && form.get('email')?.errors) {
|
||||
<div class="ufd-err">A valid email is required.</div>
|
||||
}
|
||||
</div>
|
||||
<div class="ufd-field">
|
||||
<label>First Name *</label>
|
||||
<input type="text" formControlName="firstname" placeholder="First name" />
|
||||
@if (form.get('firstname')?.touched && form.get('firstname')?.errors) {
|
||||
<div class="ufd-err">First name must start with a letter.</div>
|
||||
}
|
||||
</div>
|
||||
<div class="ufd-field">
|
||||
<label>Last Name *</label>
|
||||
<input type="text" formControlName="lastname" placeholder="Last name" />
|
||||
@if (form.get('lastname')?.touched && form.get('lastname')?.errors) {
|
||||
<div class="ufd-err">Last name must start with a letter.</div>
|
||||
}
|
||||
</div>
|
||||
<div class="ufd-field">
|
||||
<label>Mobile *</label>
|
||||
<div class="ufd-input-prefix">
|
||||
<span class="ufd-prefix">+91</span>
|
||||
<input type="tel" maxlength="10" formControlName="mobileNo" placeholder="10-digit mobile" />
|
||||
</div>
|
||||
@if (form.get('mobileNo')?.touched && form.get('mobileNo')?.errors) {
|
||||
<div class="ufd-err">Mobile must be 10 digits.</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Office mapping -->
|
||||
<div class="ufd-section">
|
||||
<div class="ufd-section__title">Office & Staff</div>
|
||||
<div class="ufd-grid">
|
||||
<div class="ufd-field">
|
||||
<label>Office *</label>
|
||||
<select formControlName="officeId">
|
||||
<option [ngValue]="''">Select an office</option>
|
||||
@for (o of offices; track o.id) {
|
||||
<option [ngValue]="o.id">{{ o.name }}</option>
|
||||
}
|
||||
</select>
|
||||
@if (form.get('officeId')?.touched && form.get('officeId')?.errors?.['required']) {
|
||||
<div class="ufd-err">Office is required.</div>
|
||||
}
|
||||
</div>
|
||||
<div class="ufd-field">
|
||||
<label>Staff (optional)</label>
|
||||
<select formControlName="staffId">
|
||||
<option [ngValue]="''">— Not linked —</option>
|
||||
@for (s of staff; track s.id) {
|
||||
<option [ngValue]="s.id">{{ s.displayName }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Roles -->
|
||||
<div class="ufd-section">
|
||||
<div class="ufd-section__title">Roles *</div>
|
||||
<div class="ufd-roles">
|
||||
@for (r of roles; track r.id) {
|
||||
<button type="button" class="ufd-role" [class.active]="isRoleSelected(r.id)" (click)="toggleRole(r.id)">
|
||||
<fa-icon [icon]="isRoleSelected(r.id) ? 'check' : 'plus'"></fa-icon>
|
||||
{{ r.name }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
@if (form.get('roles')?.touched && form.get('roles')?.errors?.['required']) {
|
||||
<div class="ufd-err">Pick at least one role.</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Security (create-only) -->
|
||||
@if (!isEdit) {
|
||||
<div class="ufd-section">
|
||||
<div class="ufd-section__title">Security</div>
|
||||
<label class="ufd-check">
|
||||
<input type="checkbox" formControlName="sendPasswordToEmail" />
|
||||
<span>Send the auto-generated password to the user's email</span>
|
||||
</label>
|
||||
<label class="ufd-check">
|
||||
<input type="checkbox" formControlName="passwordNeverExpires" />
|
||||
<span>Password never expires</span>
|
||||
</label>
|
||||
|
||||
@if (!form.get('sendPasswordToEmail')?.value) {
|
||||
<div class="ufd-grid">
|
||||
<div class="ufd-field">
|
||||
<label>Password *</label>
|
||||
<input type="password" formControlName="password" autocomplete="new-password" />
|
||||
@if (form.get('password')?.touched && form.get('password')?.invalid) {
|
||||
<div class="ufd-err">Min 8 chars · 1 upper · 1 lower · 1 digit · 1 special.</div>
|
||||
}
|
||||
</div>
|
||||
<div class="ufd-field">
|
||||
<label>Confirm Password *</label>
|
||||
<input type="password" formControlName="repeatPassword" autocomplete="new-password" />
|
||||
@if (form.get('repeatPassword')?.touched && form.get('repeatPassword')?.invalid) {
|
||||
<div class="ufd-err">Passwords don't match.</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="ufd-section">
|
||||
<div class="ufd-section__title">Security</div>
|
||||
<label class="ufd-check">
|
||||
<input type="checkbox" formControlName="passwordNeverExpires" />
|
||||
<span>Password never expires</span>
|
||||
</label>
|
||||
<div class="ufd-hint">
|
||||
<fa-icon icon="info-circle"></fa-icon>
|
||||
To change the password, open the user from the list and use "Change Password".
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (serverError) {
|
||||
<div class="ufd-server-err">
|
||||
<fa-icon icon="exclamation-triangle"></fa-icon>
|
||||
{{ serverError }}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="ufd-actions">
|
||||
<button type="button" class="ufd-btn ghost" (click)="cancel()" [disabled]="submitting">Cancel</button>
|
||||
<button type="submit" class="ufd-btn primary" [disabled]="form.invalid || submitting">
|
||||
<fa-icon
|
||||
[icon]="submitting ? 'spinner' : isEdit ? 'check' : 'user-plus'"
|
||||
[class.fa-spin]="submitting"
|
||||
></fa-icon>
|
||||
{{ submitting ? 'Saving…' : isEdit ? 'Save Changes' : 'Create User' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,357 @@
|
||||
/**
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
$navy: #0d1b2a;
|
||||
$blue: #1e88e5;
|
||||
$blue-d: #1e40af;
|
||||
$green: #10b981;
|
||||
$red: #ef4444;
|
||||
$amber: #f59e0b;
|
||||
$purple: #7c3aed;
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.ufd-root {
|
||||
background: #fff;
|
||||
width: 720px;
|
||||
max-width: 96vw;
|
||||
max-height: 90vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.ufd-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 20px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
|
||||
|
||||
&__left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
&__ic {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 10px;
|
||||
background: linear-gradient(135deg, $blue 0%, $purple 100%);
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
box-shadow: 0 2px 6px -2px rgb(29 78 216 / 35%);
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
color: $navy;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
margin-top: 2px;
|
||||
font-size: 11.5px;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
|
||||
.ufd-x {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #e2e8f0;
|
||||
background: #fff;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:hover {
|
||||
background: #fef2f2;
|
||||
color: $red;
|
||||
border-color: #fecaca;
|
||||
}
|
||||
}
|
||||
|
||||
.ufd-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 40px 24px;
|
||||
color: #64748b;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.ufd-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 16px 20px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.ufd-section {
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
padding: 12px 14px;
|
||||
|
||||
&__title {
|
||||
font-size: 10.5px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
font-weight: 700;
|
||||
color: $blue-d;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.ufd-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px 14px;
|
||||
}
|
||||
|
||||
.ufd-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
|
||||
label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
input,
|
||||
select {
|
||||
height: 36px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 7px;
|
||||
background: #fff;
|
||||
color: $navy;
|
||||
font-size: 13px;
|
||||
transition: all 0.12s;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: $blue;
|
||||
box-shadow: 0 0 0 3px rgb(30 136 229 / 14%);
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
appearance: none;
|
||||
background-image:
|
||||
linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
|
||||
background-position:
|
||||
calc(100% - 14px) 50%,
|
||||
calc(100% - 9px) 50%;
|
||||
background-size:
|
||||
5px 5px,
|
||||
5px 5px;
|
||||
background-repeat: no-repeat;
|
||||
padding-right: 28px;
|
||||
}
|
||||
}
|
||||
|
||||
.ufd-input-prefix {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 7px;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
height: 36px;
|
||||
|
||||
&:focus-within {
|
||||
border-color: $blue;
|
||||
box-shadow: 0 0 0 3px rgb(30 136 229 / 14%);
|
||||
}
|
||||
|
||||
.ufd-prefix {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
border-right: 1px solid #cbd5e1;
|
||||
}
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
padding: 0 10px;
|
||||
font-size: 13px;
|
||||
outline: none;
|
||||
color: $navy;
|
||||
}
|
||||
}
|
||||
|
||||
.ufd-err {
|
||||
font-size: 10.5px;
|
||||
color: $red;
|
||||
font-weight: 600;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.ufd-roles {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.ufd-role {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #cbd5e1;
|
||||
background: #fff;
|
||||
border-radius: 999px;
|
||||
color: #475569;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.12s;
|
||||
|
||||
fa-icon {
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: #94a3b8;
|
||||
color: $navy;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: linear-gradient(135deg, $blue 0%, $blue-d 100%);
|
||||
border-color: $blue-d;
|
||||
color: #fff;
|
||||
box-shadow: 0 1px 4px -1px rgb(30 64 175 / 35%);
|
||||
}
|
||||
}
|
||||
|
||||
.ufd-check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12.5px;
|
||||
color: $navy;
|
||||
margin: 4px 0;
|
||||
cursor: pointer;
|
||||
|
||||
// stylelint-disable-next-line selector-no-qualifying-type
|
||||
input[type='checkbox'] {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
accent-color: $blue;
|
||||
}
|
||||
}
|
||||
|
||||
.ufd-hint {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
font-size: 11.5px;
|
||||
color: #64748b;
|
||||
|
||||
fa-icon {
|
||||
color: $amber;
|
||||
}
|
||||
}
|
||||
|
||||
.ufd-server-err {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid #fecaca;
|
||||
background: #fef2f2;
|
||||
border-radius: 8px;
|
||||
color: $red;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.ufd-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
margin-top: 4px;
|
||||
padding-top: 14px;
|
||||
}
|
||||
|
||||
.ufd-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
height: 38px;
|
||||
padding: 0 18px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
border: 1px solid transparent;
|
||||
|
||||
fa-icon {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
&.ghost {
|
||||
background: #fff;
|
||||
border-color: #d0d5dd;
|
||||
color: #475569;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #f8fafc;
|
||||
border-color: #94a3b8;
|
||||
color: $navy;
|
||||
}
|
||||
}
|
||||
|
||||
&.primary {
|
||||
background: linear-gradient(135deg, $blue 0%, $blue-d 100%);
|
||||
border-color: $blue-d;
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 6px -2px rgb(30 64 175 / 35%);
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
box-shadow: 0 4px 12px -3px rgb(30 64 175 / 45%);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 600px) {
|
||||
.ufd-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
/**
|
||||
* 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 { CommonModule } from '@angular/common';
|
||||
import {
|
||||
UntypedFormBuilder,
|
||||
UntypedFormControl,
|
||||
UntypedFormGroup,
|
||||
ReactiveFormsModule,
|
||||
Validators
|
||||
} from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
import { UsersService } from '../users.service';
|
||||
import { PasswordsUtility } from 'app/core/utils/passwords-utility';
|
||||
|
||||
export interface UserFormDialogData {
|
||||
mode: 'create' | 'edit';
|
||||
userId?: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* User form dialog — drives BOTH create and edit through a single dialog.
|
||||
*
|
||||
* The dialog loads the users template (offices + roles) on init and, for edit
|
||||
* mode, fetches the full user record so all fields pre-fill correctly. On
|
||||
* submit it calls createUser / editUser and closes with `true` on success.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-user-form-dialog',
|
||||
templateUrl: './user-form-dialog.component.html',
|
||||
styleUrls: ['./user-form-dialog.component.scss'],
|
||||
imports: [
|
||||
...STANDALONE_SHARED_IMPORTS,
|
||||
CommonModule,
|
||||
ReactiveFormsModule,
|
||||
FaIconComponent,
|
||||
MatTooltip
|
||||
]
|
||||
})
|
||||
export class UserFormDialogComponent implements OnInit {
|
||||
private fb = inject(UntypedFormBuilder);
|
||||
private usersService = inject(UsersService);
|
||||
private passwordsUtility = inject(PasswordsUtility);
|
||||
public dialogRef = inject(MatDialogRef<UserFormDialogComponent>);
|
||||
public data = inject<UserFormDialogData>(MAT_DIALOG_DATA);
|
||||
|
||||
form!: UntypedFormGroup;
|
||||
offices: any[] = [];
|
||||
roles: any[] = [];
|
||||
staff: any[] = [];
|
||||
|
||||
loadingTemplate = true;
|
||||
loadingUser = false;
|
||||
submitting = false;
|
||||
/** Server-side error to surface in the dialog when the API rejects submit. */
|
||||
serverError: string | null = null;
|
||||
/** Cached existing user payload (edit mode only). */
|
||||
private existing: any = null;
|
||||
|
||||
get isEdit(): boolean {
|
||||
return this.data.mode === 'edit';
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.buildEmptyForm();
|
||||
|
||||
this.usersService.getUsersTemplate().subscribe({
|
||||
next: (tpl: any) => {
|
||||
this.offices = tpl?.allowedOffices || [];
|
||||
this.roles = tpl?.availableRoles || [];
|
||||
this.loadingTemplate = false;
|
||||
// After template arrives, edit-mode user loading is what triggers the
|
||||
// pre-fill — see loadExistingUser().
|
||||
if (this.isEdit) this.loadExistingUser();
|
||||
},
|
||||
error: () => {
|
||||
this.loadingTemplate = false;
|
||||
this.serverError = 'Could not load office / role list. Please retry.';
|
||||
}
|
||||
});
|
||||
|
||||
this.form.get('officeId')!.valueChanges.subscribe((officeId: any) => {
|
||||
this.staff = [];
|
||||
if (officeId == null || officeId === '') return;
|
||||
this.usersService.getStaff(officeId).subscribe((s: any) => (this.staff = s || []));
|
||||
});
|
||||
|
||||
// Toggle password fields based on "Send password to email" checkbox.
|
||||
// Edit mode hides these entirely (password is changed separately).
|
||||
if (!this.isEdit) {
|
||||
this.form.get('sendPasswordToEmail')!.valueChanges.subscribe((send: boolean) => {
|
||||
if (send) {
|
||||
this.form.removeControl('password');
|
||||
this.form.removeControl('repeatPassword');
|
||||
} else {
|
||||
this.form.addControl('password', new UntypedFormControl('', this.passwordsUtility.getPasswordValidators()));
|
||||
this.form.addControl(
|
||||
'repeatPassword',
|
||||
new UntypedFormControl('', [
|
||||
Validators.required,
|
||||
this.passwordsUtility.confirmPassword('password')
|
||||
])
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private buildEmptyForm(): void {
|
||||
this.form = this.fb.group({
|
||||
username: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
firstname: [
|
||||
'',
|
||||
[
|
||||
Validators.required,
|
||||
Validators.pattern('(^[A-z]).*')
|
||||
]
|
||||
],
|
||||
lastname: [
|
||||
'',
|
||||
[
|
||||
Validators.required,
|
||||
Validators.pattern('(^[A-z]).*')
|
||||
]
|
||||
],
|
||||
email: [
|
||||
'',
|
||||
[
|
||||
Validators.required,
|
||||
Validators.email,
|
||||
Validators.pattern(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/)
|
||||
]
|
||||
],
|
||||
mobileNo: [
|
||||
'',
|
||||
[
|
||||
Validators.required,
|
||||
Validators.pattern(/^\d{10}$/)
|
||||
]
|
||||
],
|
||||
officeId: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
staffId: [''],
|
||||
roles: [
|
||||
[] as number[],
|
||||
Validators.required
|
||||
],
|
||||
passwordNeverExpires: [false],
|
||||
sendPasswordToEmail: [true]
|
||||
});
|
||||
}
|
||||
|
||||
private loadExistingUser(): void {
|
||||
if (!this.data.userId) return;
|
||||
this.loadingUser = true;
|
||||
this.usersService.getUser(String(this.data.userId)).subscribe({
|
||||
next: (u: any) => {
|
||||
this.existing = u;
|
||||
const staffId = u?.staff?.id ?? null;
|
||||
const selectedRoleIds = (u?.selectedRoles || []).map((r: any) => r.id);
|
||||
// Edit mode never asks about password — strip those controls.
|
||||
this.form.removeControl('sendPasswordToEmail');
|
||||
this.form.patchValue({
|
||||
username: u.username,
|
||||
firstname: u.firstname,
|
||||
lastname: u.lastname,
|
||||
email: u.email,
|
||||
mobileNo: u.mobileNo || '',
|
||||
officeId: u.officeId,
|
||||
staffId,
|
||||
roles: selectedRoleIds,
|
||||
passwordNeverExpires: !!u.passwordNeverExpires
|
||||
});
|
||||
this.loadingUser = false;
|
||||
},
|
||||
error: () => {
|
||||
this.loadingUser = false;
|
||||
this.serverError = 'Could not load this user. Please retry.';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Toggle a role chip on/off in the multi-select chip group. */
|
||||
toggleRole(roleId: number): void {
|
||||
const ctrl = this.form.get('roles')!;
|
||||
const current: number[] = ctrl.value || [];
|
||||
const next = current.includes(roleId) ? current.filter((id) => id !== roleId) : [
|
||||
...current,
|
||||
roleId
|
||||
];
|
||||
ctrl.setValue(next);
|
||||
ctrl.markAsTouched();
|
||||
}
|
||||
|
||||
isRoleSelected(roleId: number): boolean {
|
||||
return (this.form.get('roles')?.value || []).includes(roleId);
|
||||
}
|
||||
|
||||
submit(): void {
|
||||
if (this.form.invalid || this.submitting) {
|
||||
this.form.markAllAsTouched();
|
||||
return;
|
||||
}
|
||||
this.submitting = true;
|
||||
this.serverError = null;
|
||||
|
||||
const payload: any = { ...this.form.value };
|
||||
if (payload.staffId == null || payload.staffId === '') delete payload.staffId;
|
||||
|
||||
const req$ = this.isEdit
|
||||
? this.usersService.editUser(String(this.existing?.id ?? this.data.userId), payload)
|
||||
: this.usersService.createUser(payload);
|
||||
|
||||
req$.subscribe({
|
||||
next: (response: any) => {
|
||||
this.submitting = false;
|
||||
this.dialogRef.close({
|
||||
ok: true,
|
||||
userId: response?.resourceId ?? this.existing?.id ?? this.data.userId,
|
||||
username: payload.username
|
||||
});
|
||||
},
|
||||
error: (err: any) => {
|
||||
this.submitting = false;
|
||||
this.serverError =
|
||||
err?.error?.errors?.[0]?.defaultUserMessage ||
|
||||
err?.error?.defaultUserMessage ||
|
||||
err?.error?.developerMessage ||
|
||||
(this.isEdit ? 'Failed to update user.' : 'Failed to create user.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
cancel(): void {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
+175
-131
@@ -6,143 +6,187 @@
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
|
||||
<mat-card class="container">
|
||||
<!-- Header Bar -->
|
||||
<div class="table-header">
|
||||
<div class="table-title-group">
|
||||
<h2 class="table-title">
|
||||
<div class="t-logomark"><span></span><span></span><span></span><span></span></div>
|
||||
{{ 'labels.inputs.Users' | translate }}
|
||||
</h2>
|
||||
<span class="table-count" *ngIf="dataSource?.data?.length">{{ dataSource.data.length }} users</span>
|
||||
<div class="usr-container">
|
||||
<!-- Hero header -->
|
||||
<div class="usr-header">
|
||||
<div class="usr-header__left">
|
||||
<fa-icon icon="users" class="usr-header__icon"></fa-icon>
|
||||
<div>
|
||||
<h2 class="usr-header__title">Users</h2>
|
||||
<div class="usr-header__sub">Manage system users, their roles and office mapping</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="usr-header__right">
|
||||
<button class="usr-btn primary" (click)="createUser()" *mifosxHasPermission="'CREATE_USER'">
|
||||
<fa-icon icon="plus"></fa-icon>
|
||||
Create User
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-actions">
|
||||
<mat-form-field class="table-search" appearance="outline">
|
||||
<i matPrefix class="fas fa-search"></i>
|
||||
<input
|
||||
matInput
|
||||
#filter
|
||||
placeholder="{{ 'labels.inputs.Filter' | translate }}"
|
||||
(keyup)="applyFilter($event.target.value)"
|
||||
/>
|
||||
</mat-form-field>
|
||||
|
||||
<div class="table-buttons">
|
||||
<button mat-flat-button color="primary" [routerLink]="['create']" class="btn-create" #buttonCreateUser>
|
||||
<fa-icon icon="plus"></fa-icon>
|
||||
{{ 'labels.buttons.Create User' | translate }}
|
||||
</button>
|
||||
<!-- KPI strip -->
|
||||
<div class="usr-stats">
|
||||
<div class="usr-stat total">
|
||||
<fa-icon icon="users" class="usr-stat__ic"></fa-icon>
|
||||
<div class="usr-stat__body">
|
||||
<div class="usr-stat__val">{{ totalUsers }}</div>
|
||||
<div class="usr-stat__lbl">Total Users</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="usr-stat staff">
|
||||
<fa-icon icon="user-tie" class="usr-stat__ic"></fa-icon>
|
||||
<div class="usr-stat__body">
|
||||
<div class="usr-stat__val">{{ staffUsersCount }}</div>
|
||||
<div class="usr-stat__lbl">Staff Users</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="usr-stat self">
|
||||
<fa-icon icon="user-circle" class="usr-stat__ic"></fa-icon>
|
||||
<div class="usr-stat__body">
|
||||
<div class="usr-stat__val">{{ selfServiceCount }}</div>
|
||||
<div class="usr-stat__lbl">Self-Service</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="usr-stat office">
|
||||
<fa-icon icon="building" class="usr-stat__ic"></fa-icon>
|
||||
<div class="usr-stat__body">
|
||||
<div class="usr-stat__val">{{ distinctOfficesCount }}</div>
|
||||
<div class="usr-stat__lbl">Offices Covered</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="table-container" #usersTable>
|
||||
<table mat-table [dataSource]="dataSource" matSort class="modern-table">
|
||||
<ng-container matColumnDef="username">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Login Name' | translate }}</th>
|
||||
<td mat-cell *matCellDef="let user" class="cell-link">{{ user.username }}</td>
|
||||
</ng-container>
|
||||
<!-- Toolbar -->
|
||||
<div class="usr-toolbar">
|
||||
<div class="usr-toolbar__search">
|
||||
<fa-icon icon="search" class="usr-toolbar__search-ic"></fa-icon>
|
||||
<input type="text" placeholder="Search by username, name, email, mobile, office, role…" [(ngModel)]="search" />
|
||||
@if (search) {
|
||||
<button class="usr-toolbar__clear" (click)="search = ''" matTooltip="Clear">
|
||||
<fa-icon icon="times"></fa-icon>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
<div class="usr-toolbar__filters">
|
||||
<select [(ngModel)]="officeFilter" class="usr-select">
|
||||
<option [ngValue]="''">All Offices</option>
|
||||
@for (o of officeOptions; track o) {
|
||||
<option [ngValue]="o">{{ o }}</option>
|
||||
}
|
||||
</select>
|
||||
<select [(ngModel)]="roleFilter" class="usr-select">
|
||||
<option [ngValue]="''">All Roles</option>
|
||||
<option [ngValue]="'staff'">Staff</option>
|
||||
<option [ngValue]="'selfservice'">Self-Service</option>
|
||||
</select>
|
||||
@if (search || officeFilter || roleFilter) {
|
||||
<button class="usr-btn ghost small" (click)="clearFilters()"><fa-icon icon="times"></fa-icon> Clear</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ng-container matColumnDef="firstname">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.First Name' | translate }}</th>
|
||||
<td mat-cell *matCellDef="let user">{{ user.firstname }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="lastname">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Last Name' | translate }}</th>
|
||||
<td mat-cell *matCellDef="let user">{{ user.lastname }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="email">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Email' | translate }}</th>
|
||||
<td mat-cell *matCellDef="let user" class="cell-mono">{{ user.email }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="mobileNo">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Mobile</th>
|
||||
<td mat-cell *matCellDef="let user" class="cell-mono">
|
||||
@if (user.mobileNo) {
|
||||
+91 {{ user.mobileNo }}
|
||||
} @else {
|
||||
<span class="cell-empty">—</span>
|
||||
<!-- Users table -->
|
||||
<div class="usr-card">
|
||||
<div class="usr-card__head">
|
||||
<div class="usr-card__title">
|
||||
<fa-icon icon="list" class="usr-card__title-ic"></fa-icon>
|
||||
Users
|
||||
<span class="usr-card__count">{{ filteredRows.length }} of {{ rows.length }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="usr-table-wrap">
|
||||
<table class="usr-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="num">#</th>
|
||||
<th>User</th>
|
||||
<th>Login</th>
|
||||
<th>Email</th>
|
||||
<th>Mobile</th>
|
||||
<th>Office</th>
|
||||
<th>Type</th>
|
||||
<th class="actions">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (row of filteredRows; track trackRow($index, row); let i = $index) {
|
||||
<tr>
|
||||
<td class="num">{{ i + 1 }}</td>
|
||||
<td>
|
||||
<div class="usr-id">
|
||||
<span class="usr-avatar" [class.self]="row.isSelfServiceUser">{{ initials(row) }}</span>
|
||||
<div class="usr-id__txt">
|
||||
<div class="usr-id__name">{{ row.fullName }}</div>
|
||||
@if (row.staffDisplayName && row.staffDisplayName !== row.fullName) {
|
||||
<div class="usr-id__staff">{{ row.staffDisplayName }}</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="mono">{{ row.username }}</td>
|
||||
<td class="mono">{{ row.email || '—' }}</td>
|
||||
<td class="mono">
|
||||
@if (row.mobileNo) {
|
||||
+91 {{ row.mobileNo }}
|
||||
} @else {
|
||||
—
|
||||
}
|
||||
</td>
|
||||
<td>{{ row.officeName || '—' }}</td>
|
||||
<td>
|
||||
@if (row.isSelfServiceUser) {
|
||||
<span class="usr-pill self">Self-Service</span>
|
||||
} @else {
|
||||
<span class="usr-pill staff">Staff</span>
|
||||
}
|
||||
</td>
|
||||
<td class="actions">
|
||||
<button class="usr-act view" (click)="viewUser(row)" matTooltip="View user">
|
||||
<fa-icon icon="eye"></fa-icon>
|
||||
</button>
|
||||
<button
|
||||
class="usr-act edit"
|
||||
(click)="editUser(row)"
|
||||
matTooltip="Edit user"
|
||||
*mifosxHasPermission="'UPDATE_USER'"
|
||||
>
|
||||
<fa-icon icon="pencil-alt"></fa-icon>
|
||||
</button>
|
||||
<button class="usr-act more" [matMenuTriggerFor]="rowMenu" matTooltip="More actions">
|
||||
<fa-icon icon="ellipsis-v"></fa-icon>
|
||||
</button>
|
||||
<mat-menu #rowMenu="matMenu" xPosition="before" class="usr-menu">
|
||||
<button mat-menu-item (click)="viewUser(row)">
|
||||
<fa-icon icon="eye" class="usr-menu__ic"></fa-icon>
|
||||
View Details
|
||||
</button>
|
||||
<button mat-menu-item (click)="editUser(row)" *mifosxHasPermission="'UPDATE_USER'">
|
||||
<fa-icon icon="pencil-alt" class="usr-menu__ic"></fa-icon>
|
||||
Edit User
|
||||
</button>
|
||||
<button mat-menu-item (click)="changePassword(row)">
|
||||
<fa-icon icon="key" class="usr-menu__ic"></fa-icon>
|
||||
Change Password
|
||||
</button>
|
||||
<button mat-menu-item (click)="copyUsername(row)">
|
||||
<fa-icon icon="copy" class="usr-menu__ic"></fa-icon>
|
||||
Copy Login Name
|
||||
</button>
|
||||
<button mat-menu-item (click)="deleteUser(row)" *mifosxHasPermission="'DELETE_USER'">
|
||||
<fa-icon icon="trash" class="usr-menu__ic warn"></fa-icon>
|
||||
Delete User
|
||||
</button>
|
||||
</mat-menu>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="officeName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Office' | translate }}</th>
|
||||
<td mat-cell *matCellDef="let user">{{ user.officeName }}</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns" [routerLink]="[row.id]" class="table-row"></tr>
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||
@if (filteredRows.length === 0) {
|
||||
<tr>
|
||||
<td colspan="8" class="usr-empty">No users match the current filters.</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card>
|
||||
|
||||
<!-- Config Wizard Templates (keep as-is) -->
|
||||
<ng-template #templateButtonCreateUser let-popover="popover">
|
||||
<h2>{{ 'labels.buttons.Create User' | translate }}</h2>
|
||||
<p class="mw300">{{ 'labels.text.This option allows you to create new users in your organization' | translate }}.</p>
|
||||
<div class="layout-row align-end gap-2px responsive-column">
|
||||
<button mat-raised-button color="warn" (click)="popover.close(); configurationWizardService.closeConfigWizard()">
|
||||
{{ 'labels.buttons.Close' | translate }}
|
||||
</button>
|
||||
<button mat-raised-button color="primary" (click)="popover.close(); previousStep()">
|
||||
{{ 'labels.buttons.Back' | translate }}
|
||||
</button>
|
||||
<button
|
||||
mat-raised-button
|
||||
color="primary"
|
||||
(click)="popover.close(); showPopover(templateFilter, filter, 'bottom', true)"
|
||||
>
|
||||
{{ 'labels.buttons.Next' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #templateFilter let-popover="popover">
|
||||
<h4>{{ 'labels.heading.Search bar to filter users' | translate }}.</h4>
|
||||
<div class="layout-row align-end gap-2px responsive-column">
|
||||
<button mat-raised-button color="warn" (click)="popover.close(); configurationWizardService.closeConfigWizard()">
|
||||
{{ 'labels.buttons.Close' | translate }}
|
||||
</button>
|
||||
<button
|
||||
mat-raised-button
|
||||
color="primary"
|
||||
(click)="popover.close(); showPopover(templateButtonCreateUser, buttonCreateUser, 'bottom', true)"
|
||||
>
|
||||
{{ 'labels.buttons.Back' | translate }}
|
||||
</button>
|
||||
<button
|
||||
mat-raised-button
|
||||
color="primary"
|
||||
(click)="popover.close(); showPopover(templateUsersTable, usersTable, 'top', true)"
|
||||
>
|
||||
{{ 'labels.buttons.Next' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #templateUsersTable let-popover="popover">
|
||||
<h4>{{ 'labels.heading.List of Users with their details' | translate }}.</h4>
|
||||
<div class="layout-row align-end gap-2px responsive-column">
|
||||
<button mat-raised-button color="warn" (click)="popover.close(); configurationWizardService.closeConfigWizard()">
|
||||
{{ 'labels.buttons.Close' | translate }}
|
||||
</button>
|
||||
<button
|
||||
mat-raised-button
|
||||
color="primary"
|
||||
(click)="popover.close(); showPopover(templateFilter, filter, 'bottom', true)"
|
||||
>
|
||||
{{ 'labels.buttons.Back' | translate }}
|
||||
</button>
|
||||
<button mat-raised-button color="primary" (click)="popover.close(); nextStep()">
|
||||
{{ 'labels.buttons.Next' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</div>
|
||||
|
||||
@@ -6,22 +6,537 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
@use '../shared/styles/list-layout' as *;
|
||||
@use 'sass:color';
|
||||
|
||||
.status-active {
|
||||
background: #ecfdf5 !important;
|
||||
color: #059669 !important;
|
||||
$navy: #0d1b2a;
|
||||
$blue: #1e88e5;
|
||||
$blue-d: #1e40af;
|
||||
$green: #10b981;
|
||||
$amber: #f59e0b;
|
||||
$red: #ef4444;
|
||||
$purple: #7c3aed;
|
||||
|
||||
&::before {
|
||||
background: #059669;
|
||||
.usr-container {
|
||||
padding: 20px 24px;
|
||||
max-width: 1440px;
|
||||
margin: 0 auto;
|
||||
background: #f0f2f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
// ─── Header ───
|
||||
.usr-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
&__left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, $blue 0%, $purple 100%);
|
||||
color: #fff;
|
||||
font-size: 18px;
|
||||
box-shadow: 0 2px 8px rgb(29 78 216 / 25%);
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 800;
|
||||
color: $navy;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
margin-top: 2px;
|
||||
font-size: 12.5px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
&__right {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.status-inactive {
|
||||
background: #fef2f2 !important;
|
||||
color: #dc2626 !important;
|
||||
.usr-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 16px;
|
||||
border-radius: 9px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
white-space: nowrap;
|
||||
border: 1px solid transparent;
|
||||
|
||||
&::before {
|
||||
background: #dc2626;
|
||||
fa-icon {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
&.ghost {
|
||||
background: #fff;
|
||||
border-color: #d0d5dd;
|
||||
color: #475569;
|
||||
|
||||
&:hover {
|
||||
background: #f8fafc;
|
||||
border-color: #94a3b8;
|
||||
color: $navy;
|
||||
}
|
||||
}
|
||||
|
||||
&.primary {
|
||||
background: linear-gradient(135deg, $blue 0%, $blue-d 100%);
|
||||
border-color: $blue-d;
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 6px -2px rgb(30 64 175 / 35%);
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 4px 12px -3px rgb(30 64 175 / 45%);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
}
|
||||
|
||||
&.small {
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── KPI strip ───
|
||||
.usr-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.usr-stat {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
padding: 12px 16px;
|
||||
box-shadow: 0 1px 3px rgb(15 23 42 / 4%);
|
||||
|
||||
&__ic {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 10px;
|
||||
font-size: 15px;
|
||||
color: #fff;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__val {
|
||||
font-size: 22px;
|
||||
font-weight: 800;
|
||||
color: $navy;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
&__lbl {
|
||||
margin-top: 4px;
|
||||
font-size: 11.5px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: #64748b;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&.total .usr-stat__ic {
|
||||
background: linear-gradient(135deg, $blue 0%, $blue-d 100%);
|
||||
}
|
||||
|
||||
&.staff .usr-stat__ic {
|
||||
background: linear-gradient(135deg, $purple 0%, #4338ca 100%);
|
||||
}
|
||||
|
||||
&.self .usr-stat__ic {
|
||||
background: linear-gradient(135deg, $green 0%, #047857 100%);
|
||||
}
|
||||
|
||||
&.office .usr-stat__ic {
|
||||
background: linear-gradient(135deg, $amber 0%, #c2410c 100%);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Toolbar ───
|
||||
.usr-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 12px;
|
||||
|
||||
&__search {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-width: 260px;
|
||||
max-width: 520px;
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 9px 36px;
|
||||
border: 1px solid #d0d5dd;
|
||||
border-radius: 9px;
|
||||
font-size: 13px;
|
||||
background: #fff;
|
||||
color: $navy;
|
||||
transition: all 0.15s;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: $blue;
|
||||
box-shadow: 0 0 0 3px rgb(30 136 229 / 12%);
|
||||
}
|
||||
}
|
||||
|
||||
&-ic {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: #94a3b8;
|
||||
font-size: 12px;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__clear {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid #e2e8f0;
|
||||
background: #fff;
|
||||
color: #94a3b8;
|
||||
font-size: 10px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #fef2f2;
|
||||
color: $red;
|
||||
border-color: #fecaca;
|
||||
}
|
||||
}
|
||||
|
||||
&__filters {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.usr-select {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #d0d5dd;
|
||||
border-radius: 9px;
|
||||
background: #fff;
|
||||
color: $navy;
|
||||
font-size: 12.5px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: $blue;
|
||||
box-shadow: 0 0 0 3px rgb(30 136 229 / 12%);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Card wrapper ───
|
||||
.usr-card {
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 1px 3px rgb(15 23 42 / 6%);
|
||||
overflow: hidden;
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 18px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
|
||||
}
|
||||
|
||||
&__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: $navy;
|
||||
|
||||
&-ic {
|
||||
color: $blue;
|
||||
}
|
||||
}
|
||||
|
||||
&__count {
|
||||
margin-left: 8px;
|
||||
padding: 2px 10px;
|
||||
background: #eff6ff;
|
||||
color: $blue-d;
|
||||
border-radius: 999px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Table ───
|
||||
.usr-table-wrap {
|
||||
overflow: auto;
|
||||
max-height: 620px;
|
||||
}
|
||||
|
||||
.usr-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
|
||||
thead th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
text-align: left;
|
||||
padding: 11px 14px;
|
||||
font-size: 10.5px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
|
||||
&.num {
|
||||
width: 48px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&.actions {
|
||||
width: 150px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
tbody td {
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
vertical-align: middle;
|
||||
color: $navy;
|
||||
|
||||
&.num {
|
||||
text-align: center;
|
||||
color: #94a3b8;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&.mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
font-size: 12px;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
&.actions {
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
tbody tr {
|
||||
transition: background 0.12s;
|
||||
|
||||
&:hover {
|
||||
background: #f8fafc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.usr-id {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
|
||||
&__txt {
|
||||
line-height: 1.15;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-weight: 600;
|
||||
color: $navy;
|
||||
}
|
||||
|
||||
&__staff {
|
||||
font-size: 10.5px;
|
||||
color: #64748b;
|
||||
margin-top: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
.usr-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, $blue 0%, $purple 100%);
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 2px 4px -1px rgb(29 78 216 / 30%);
|
||||
|
||||
&.self {
|
||||
background: linear-gradient(135deg, $green 0%, #047857 100%);
|
||||
box-shadow: 0 2px 4px -1px rgb(16 185 129 / 30%);
|
||||
}
|
||||
}
|
||||
|
||||
.usr-pill {
|
||||
display: inline-block;
|
||||
padding: 2px 9px;
|
||||
border-radius: 999px;
|
||||
font-size: 10.5px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
|
||||
&.staff {
|
||||
background: #ede9fe;
|
||||
color: $purple;
|
||||
}
|
||||
|
||||
&.self {
|
||||
background: #ecfdf5;
|
||||
color: $green;
|
||||
}
|
||||
}
|
||||
|
||||
.usr-act {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin: 0 2px;
|
||||
border: 1px solid #e2e8f0;
|
||||
background: #fff;
|
||||
border-radius: 7px;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
transition: all 0.12s;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
&.view:hover:not(:disabled) {
|
||||
background: #f0f9ff;
|
||||
border-color: #bae6fd;
|
||||
color: $blue;
|
||||
}
|
||||
|
||||
&.edit:hover:not(:disabled) {
|
||||
background: #eff6ff;
|
||||
border-color: #bfdbfe;
|
||||
color: $blue-d;
|
||||
}
|
||||
|
||||
&.more:hover:not(:disabled) {
|
||||
background: #f5f3ff;
|
||||
border-color: #ddd6fe;
|
||||
color: $purple;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.usr-menu__ic {
|
||||
width: 18px;
|
||||
margin-right: 10px;
|
||||
color: #64748b;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
|
||||
&.warn {
|
||||
color: $red;
|
||||
}
|
||||
}
|
||||
|
||||
.usr-empty {
|
||||
text-align: center;
|
||||
padding: 32px 16px;
|
||||
color: #94a3b8;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
// ─── Responsive ───
|
||||
@media (width <= 900px) {
|
||||
.usr-stats {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.usr-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.usr-toolbar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
&__search {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 600px) {
|
||||
.usr-stats {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.usr-table thead th {
|
||||
font-size: 9.5px;
|
||||
padding: 8px 10px;
|
||||
}
|
||||
|
||||
.usr-table tbody td {
|
||||
padding: 8px 10px;
|
||||
}
|
||||
}
|
||||
|
||||
+243
-133
@@ -6,36 +6,47 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit, inject } from '@angular/core';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort, MatSortHeader } from '@angular/material/sort';
|
||||
import {
|
||||
MatTableDataSource,
|
||||
MatTable,
|
||||
MatColumnDef,
|
||||
MatHeaderCellDef,
|
||||
MatHeaderCell,
|
||||
MatCellDef,
|
||||
MatCell,
|
||||
MatHeaderRowDef,
|
||||
MatHeaderRow,
|
||||
MatRowDef,
|
||||
MatRow
|
||||
} from '@angular/material/table';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { of } from 'rxjs';
|
||||
|
||||
/** Custom Services */
|
||||
import { PopoverService } from '../configuration-wizard/popover/popover.service';
|
||||
import { ConfigurationWizardService } from '../configuration-wizard/configuration-wizard.service';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
|
||||
import { UsersService } from './users.service';
|
||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||
import { SuccessDialogComponent } from 'app/shared/success-dialog/success-dialog.component';
|
||||
import { ErrorDialogComponent } from 'app/shared/error-dialog/error-dialog.component';
|
||||
import { ChangePasswordDialogComponent } from 'app/shared/change-password-dialog/change-password-dialog.component';
|
||||
import { UserFormDialogComponent, UserFormDialogData } from './user-form-dialog/user-form-dialog.component';
|
||||
import {
|
||||
UserDetailsDialogComponent,
|
||||
UserDetailsDialogData,
|
||||
UserDetailsDialogResult
|
||||
} from './user-details-dialog/user-details-dialog.component';
|
||||
|
||||
interface UserRow {
|
||||
id: string;
|
||||
username: string;
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
fullName: string;
|
||||
email: string;
|
||||
mobileNo: string;
|
||||
officeName: string;
|
||||
staffDisplayName: string;
|
||||
roles: string[];
|
||||
isSelfServiceUser: boolean;
|
||||
raw: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Users component.
|
||||
* Users — Nexora redesign.
|
||||
*
|
||||
* Hero header + KPI strip + searchable Nexora table with per-row
|
||||
* View / Edit / Delete actions (with kebab menu for less-common ops).
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-users',
|
||||
@@ -43,143 +54,242 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
styleUrls: ['./users.component.scss'],
|
||||
imports: [
|
||||
...STANDALONE_SHARED_IMPORTS,
|
||||
FormsModule,
|
||||
FaIconComponent,
|
||||
MatTable,
|
||||
MatSort,
|
||||
MatColumnDef,
|
||||
MatHeaderCellDef,
|
||||
MatHeaderCell,
|
||||
MatSortHeader,
|
||||
MatCellDef,
|
||||
MatCell,
|
||||
MatHeaderRowDef,
|
||||
MatHeaderRow,
|
||||
MatRowDef,
|
||||
MatRow,
|
||||
MatPaginator
|
||||
MatTooltip,
|
||||
MatMenuModule
|
||||
]
|
||||
})
|
||||
export class UsersComponent implements OnInit, AfterViewInit {
|
||||
export class UsersComponent {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private configurationWizardService = inject(ConfigurationWizardService);
|
||||
private popoverService = inject(PopoverService);
|
||||
private dialog = inject(MatDialog);
|
||||
private usersService = inject(UsersService);
|
||||
|
||||
/** Users data. */
|
||||
usersData: any;
|
||||
/** Columns to be displayed in users table. */
|
||||
displayedColumns: string[] = [
|
||||
'username',
|
||||
'firstname',
|
||||
'lastname',
|
||||
'email',
|
||||
'mobileNo',
|
||||
'officeName'
|
||||
];
|
||||
/** Data source for users table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
/** All users normalised to UserRow for the table. */
|
||||
rows: UserRow[] = [];
|
||||
|
||||
/** Paginator for users table. */
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
/** Sorter for users table. */
|
||||
@ViewChild(MatSort, { static: true }) sort: MatSort;
|
||||
/** Search text. */
|
||||
search = '';
|
||||
|
||||
/* Reference of create user button */
|
||||
@ViewChild('buttonCreateUser') buttonCreateUser: ElementRef<any>;
|
||||
/* Template for popover create user button */
|
||||
@ViewChild('templateButtonCreateUser') templateButtonCreateUser: TemplateRef<any>;
|
||||
/* Reference of users table */
|
||||
@ViewChild('usersTable') usersTable: ElementRef<any>;
|
||||
/* Template for popover on users table */
|
||||
@ViewChild('templateUsersTable') templateUsersTable: TemplateRef<any>;
|
||||
/** Office filter — empty = all. */
|
||||
officeFilter = '';
|
||||
|
||||
/** 'all' | 'staff' | 'selfservice' role filter. */
|
||||
roleFilter: '' | 'staff' | 'selfservice' = '';
|
||||
|
||||
/**
|
||||
* Retrieves the users data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
|
||||
* @param {PopoverService} popoverService PopoverService.
|
||||
*/
|
||||
constructor() {
|
||||
this.route.data.subscribe((data: { users: any }) => {
|
||||
this.usersData = data.users;
|
||||
this.buildRows(data.users || []);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters data in users table based on passed value.
|
||||
* @param {string} filterValue Value to filter data.
|
||||
*/
|
||||
applyFilter(filterValue: string) {
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
private buildRows(users: any[]): void {
|
||||
this.rows = users.map((u: any) => {
|
||||
const fn = (u.firstname || '').trim();
|
||||
const ln = (u.lastname || '').trim();
|
||||
const fullName =
|
||||
[
|
||||
fn,
|
||||
ln
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ') || u.username;
|
||||
const roles: string[] = (u.selectedRoles || u.availableRoles || []).map((r: any) => r?.name).filter(Boolean);
|
||||
return {
|
||||
id: String(u.id),
|
||||
username: u.username || '',
|
||||
firstname: fn,
|
||||
lastname: ln,
|
||||
fullName,
|
||||
email: u.email || '',
|
||||
mobileNo: u.mobileNo || '',
|
||||
officeName: u.officeName || '',
|
||||
staffDisplayName: u.staffDisplayName || '',
|
||||
roles,
|
||||
isSelfServiceUser: !!u.isSelfServiceUser,
|
||||
raw: u
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the users table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.setUsers();
|
||||
// ───── KPIs ─────
|
||||
get totalUsers(): number {
|
||||
return this.rows.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for users table.
|
||||
*/
|
||||
setUsers() {
|
||||
this.dataSource = new MatTableDataSource(this.usersData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
get selfServiceCount(): number {
|
||||
return this.rows.filter((r) => r.isSelfServiceUser).length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Popover function
|
||||
* @param template TemplateRef<any>.
|
||||
* @param target HTMLElement | ElementRef<any>.
|
||||
* @param position String.
|
||||
* @param backdrop Boolean.
|
||||
*/
|
||||
showPopover(
|
||||
template: TemplateRef<any>,
|
||||
target: HTMLElement | ElementRef<any>,
|
||||
position: string,
|
||||
backdrop: boolean
|
||||
): void {
|
||||
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
|
||||
get staffUsersCount(): number {
|
||||
return this.rows.filter((r) => !r.isSelfServiceUser).length;
|
||||
}
|
||||
|
||||
/** Distinct offices represented in the user list. */
|
||||
get distinctOfficesCount(): number {
|
||||
return new Set(this.rows.map((r) => r.officeName).filter(Boolean)).size;
|
||||
}
|
||||
|
||||
/** Office names for the office filter dropdown. */
|
||||
get officeOptions(): string[] {
|
||||
return Array.from(new Set(this.rows.map((r) => r.officeName).filter(Boolean))).sort();
|
||||
}
|
||||
|
||||
// ───── Filtering ─────
|
||||
get filteredRows(): UserRow[] {
|
||||
const q = this.search.trim().toLowerCase();
|
||||
return this.rows.filter((r) => {
|
||||
if (this.officeFilter && r.officeName !== this.officeFilter) return false;
|
||||
if (this.roleFilter === 'staff' && r.isSelfServiceUser) return false;
|
||||
if (this.roleFilter === 'selfservice' && !r.isSelfServiceUser) return false;
|
||||
if (!q) return true;
|
||||
const hay =
|
||||
`${r.username} ${r.fullName} ${r.email} ${r.mobileNo} ${r.officeName} ${r.roles.join(' ')}`.toLowerCase();
|
||||
return hay.includes(q);
|
||||
});
|
||||
}
|
||||
|
||||
clearFilters(): void {
|
||||
this.search = '';
|
||||
this.officeFilter = '';
|
||||
this.roleFilter = '';
|
||||
}
|
||||
|
||||
// ───── Row actions (all popup-driven now) ─────
|
||||
/**
|
||||
* To show popover.
|
||||
* Open the read-only details popup. The footer of the details dialog can
|
||||
* chain into edit / delete / change-password without leaving the list.
|
||||
*/
|
||||
ngAfterViewInit() {
|
||||
if (this.configurationWizardService.showUsers) {
|
||||
setTimeout(() => {
|
||||
this.showPopover(this.templateButtonCreateUser, this.buttonCreateUser.nativeElement, 'bottom', true);
|
||||
viewUser(row: { id: string; username: string }): void {
|
||||
const ref = this.dialog.open<UserDetailsDialogComponent, UserDetailsDialogData, UserDetailsDialogResult>(
|
||||
UserDetailsDialogComponent,
|
||||
{
|
||||
data: { userId: row.id },
|
||||
panelClass: 'udd-panel',
|
||||
autoFocus: false
|
||||
}
|
||||
);
|
||||
ref.afterClosed().subscribe((action) => {
|
||||
if (action === 'edit') this.editUser(row);
|
||||
else if (action === 'delete') this.deleteUser(row as UserRow);
|
||||
else if (action === 'change-password') this.changePassword(row);
|
||||
});
|
||||
}
|
||||
|
||||
/** Open the user form popup in edit mode. */
|
||||
editUser(row: { id: string }): void {
|
||||
const ref = this.dialog.open<UserFormDialogComponent, UserFormDialogData, any>(UserFormDialogComponent, {
|
||||
data: { mode: 'edit', userId: row.id },
|
||||
panelClass: 'ufd-panel',
|
||||
autoFocus: false
|
||||
});
|
||||
ref.afterClosed().subscribe((result) => {
|
||||
if (result?.ok) {
|
||||
this.showSuccess('User Updated', `Changes to "${result.username}" have been saved.`);
|
||||
this.refreshUsers();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Open the user form popup in create mode. */
|
||||
createUser(): void {
|
||||
const ref = this.dialog.open<UserFormDialogComponent, UserFormDialogData, any>(UserFormDialogComponent, {
|
||||
data: { mode: 'create' },
|
||||
panelClass: 'ufd-panel',
|
||||
autoFocus: false
|
||||
});
|
||||
ref.afterClosed().subscribe((result) => {
|
||||
if (result?.ok) {
|
||||
this.showSuccess('User Created', `"${result.username}" has been added.`);
|
||||
this.refreshUsers();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Change-password popup — same dialog the legacy view-user uses. */
|
||||
changePassword(row: { id: string; username?: string }): void {
|
||||
const ref = this.dialog.open(ChangePasswordDialogComponent, { width: '440px' });
|
||||
ref.afterClosed().subscribe((response: any) => {
|
||||
if (!response?.password || !response?.repeatPassword) return;
|
||||
// Backend expects `firstname` in the payload (Fineract quirk) — pull from
|
||||
// the row's cached payload when we have it, otherwise fetch fresh.
|
||||
const cached = this.rows.find((r) => r.id === row.id);
|
||||
const firstname = cached?.firstname || cached?.fullName || row.username || '';
|
||||
const body = {
|
||||
password: response.password,
|
||||
repeatPassword: response.repeatPassword,
|
||||
firstname
|
||||
};
|
||||
this.usersService.changePassword(row.id, body).subscribe({
|
||||
next: () => this.showSuccess('Password Updated', `New password set for "${row.username || row.id}".`),
|
||||
error: (err: any) => {
|
||||
const apiMsg = err?.error?.errors?.[0]?.defaultUserMessage || 'Please try again.';
|
||||
this.showError(`Failed to update password. ${apiMsg}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this.configurationWizardService.showUsersList) {
|
||||
setTimeout(() => {
|
||||
this.showPopover(this.templateUsersTable, this.usersTable.nativeElement, 'top', true);
|
||||
/** Delete user with confirm + polished outcome dialog. */
|
||||
deleteUser(row: UserRow): void {
|
||||
const ref = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `user "${row.username}"` }
|
||||
});
|
||||
ref.afterClosed().subscribe((response: any) => {
|
||||
if (!response?.delete) return;
|
||||
this.usersService.deleteUser(row.id).subscribe({
|
||||
next: () => {
|
||||
this.showSuccess('User Removed', `"${row.username}" has been deleted.`);
|
||||
this.refreshUsers();
|
||||
},
|
||||
error: (err: any) => {
|
||||
const apiMsg =
|
||||
err?.error?.errors?.[0]?.defaultUserMessage || err?.error?.developerMessage || 'Please try again.';
|
||||
this.showError(`Failed to remove "${row.username}". ${apiMsg}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Next Step (Create User Page) Configuration Wizard.
|
||||
*/
|
||||
nextStep() {
|
||||
this.configurationWizardService.showUsers = false;
|
||||
this.configurationWizardService.showUsersList = false;
|
||||
this.configurationWizardService.showUsersForm = true;
|
||||
this.router.navigate(['/appusers/create']);
|
||||
/** Copy the user's login name. */
|
||||
copyUsername(row: UserRow): void {
|
||||
navigator.clipboard
|
||||
?.writeText(row.username)
|
||||
.then(() => this.showSnackSuccess(`Copied "${row.username}" to clipboard.`))
|
||||
.catch(() => this.showError('Clipboard access was blocked by the browser.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Previous Step (Roles and Permission Page) Configuration Wizard.
|
||||
*/
|
||||
previousStep() {
|
||||
this.configurationWizardService.showUsers = false;
|
||||
this.configurationWizardService.showUsersList = false;
|
||||
this.configurationWizardService.showRolesandPermissionList = true;
|
||||
this.router.navigate(['/system/roles-and-permissions']);
|
||||
private refreshUsers(): void {
|
||||
this.usersService.getUsers().subscribe((users: any[]) => this.buildRows(users || []));
|
||||
}
|
||||
|
||||
// ───── Dialog helpers ─────
|
||||
private showSuccess(title: string, message: string): void {
|
||||
this.dialog.open(SuccessDialogComponent, {
|
||||
data: { title, message, buttonLabel: 'OK' },
|
||||
panelClass: 'sd-panel'
|
||||
});
|
||||
}
|
||||
|
||||
/** Used for lightweight confirmations like "copied to clipboard". */
|
||||
private showSnackSuccess(message: string): void {
|
||||
this.dialog.open(SuccessDialogComponent, {
|
||||
data: { title: 'Copied', message, buttonLabel: 'OK' },
|
||||
panelClass: 'sd-panel'
|
||||
});
|
||||
}
|
||||
|
||||
private showError(message: string): void {
|
||||
this.dialog.open(ErrorDialogComponent, { data: message });
|
||||
}
|
||||
|
||||
// ───── Misc ─────
|
||||
trackRow = (_i: number, r: UserRow) => r.id;
|
||||
|
||||
initials(row: UserRow): string {
|
||||
const a = (row.firstname || row.username).charAt(0);
|
||||
const b = (row.lastname || '').charAt(0);
|
||||
return `${a}${b}`.toUpperCase() || '?';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import { UsersComponent } from './users.component';
|
||||
import { CreateUserComponent } from './create-user/create-user.component';
|
||||
import { ViewUserComponent } from './view-user/view-user.component';
|
||||
import { EditUserComponent } from './edit-user/edit-user.component';
|
||||
import { UserFormDialogComponent } from './user-form-dialog/user-form-dialog.component';
|
||||
import { UserDetailsDialogComponent } from './user-details-dialog/user-details-dialog.component';
|
||||
|
||||
/** DSC Components */
|
||||
import { DscListComponent } from './dsc/dsc-list/dsc-list.component';
|
||||
@@ -43,6 +45,8 @@ import { UsersComponent as UserZitadelComponent } from '../zitadel/users/users.c
|
||||
CreateUserComponent,
|
||||
ViewUserComponent,
|
||||
EditUserComponent,
|
||||
UserFormDialogComponent,
|
||||
UserDetailsDialogComponent,
|
||||
DscListComponent,
|
||||
EnrollDscDialogComponent,
|
||||
RevokeDscDialogComponent,
|
||||
|
||||
Reference in New Issue
Block a user