User AccessType
This commit is contained in:
parent
e3fd97be95
commit
1853718cbd
|
|
@ -33,6 +33,15 @@ namespace HRM.BO
|
|||
public int? ApprovedBy { get; set; }
|
||||
public DateTime? ApprovedDate { get; set; }
|
||||
|
||||
// Filled only by GetPending (the Pending approvals list), for display.
|
||||
public string UserName { get; set; }
|
||||
public string LoginID { get; set; }
|
||||
/// <summary>Who requested this pending row: CreatedBy for a new access, ModifiedBy for a removal.</summary>
|
||||
public int MakerID { get; set; }
|
||||
public string MakerLoginID { get; set; }
|
||||
/// <summary>When it was requested: CreatedDate for a new access, ModifiedDate for a removal.</summary>
|
||||
public DateTime? RequestDate { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -55,6 +64,8 @@ namespace HRM.BO
|
|||
void Approve(int userID, int approverID);
|
||||
/// <summary>Checker: drops every pending change of the user; access stays as it was.</summary>
|
||||
void Reject(int userID);
|
||||
/// <summary>Every row waiting for approval, of every user, with user, payroll type and maker for display.</summary>
|
||||
List<UserAccessType> GetPending();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -86,6 +86,21 @@ namespace HRM.DA
|
|||
return tc.ExecuteReader("SELECT * FROM UserAccessType WHERE UserID=%n", UserID);
|
||||
}
|
||||
|
||||
// Every row waiting for approval, of every user (Pending approvals list).
|
||||
internal static IDataReader GetPending(TransactionContext tc)
|
||||
{
|
||||
return tc.ExecuteReader(@"SELECT ua.*, p.Description PayrollTypeName, u.LoginID UserLoginID, u.UserName UserFullName,
|
||||
mk.LoginID MakerLoginID
|
||||
FROM UserAccessType ua
|
||||
JOIN PayrollType p ON p.PayrollTypeID = ua.PayrollTypeID
|
||||
JOIN Users u ON u.UserID = ua.UserID
|
||||
LEFT JOIN Users mk ON mk.UserID = CASE WHEN ua.Status=%n THEN ua.ModifiedBy ELSE ua.CreatedBy END
|
||||
WHERE ua.Status IN (%n, %n)
|
||||
ORDER BY u.UserName, p.Description",
|
||||
(int)EnumAuthStatus.DeletedNotYetApprove,
|
||||
(int)EnumAuthStatus.NewNotYetApprove, (int)EnumAuthStatus.DeletedNotYetApprove);
|
||||
}
|
||||
|
||||
// Names of the payroll types a pending approval of this user will newly give access to.
|
||||
internal static IDataReader GetPendingNewDescriptions(TransactionContext tc, int userID)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -329,6 +329,43 @@ namespace HRM.DA
|
|||
}
|
||||
}
|
||||
|
||||
public List<UserAccessType> GetPending()
|
||||
{
|
||||
List<UserAccessType> items = new List<UserAccessType>();
|
||||
TransactionContext tc = null;
|
||||
try
|
||||
{
|
||||
tc = TransactionContext.Begin();
|
||||
DataReader dr = new DataReader(UserAccessTypeDA.GetPending(tc));
|
||||
while (dr.Read())
|
||||
{
|
||||
UserAccessType item = this.CreateObject<UserAccessType>(dr);
|
||||
item.Description = dr.GetString("PayrollTypeName");
|
||||
item.LoginID = dr.GetString("UserLoginID");
|
||||
item.UserName = dr.GetString("UserFullName");
|
||||
item.MakerLoginID = dr.GetString("MakerLoginID");
|
||||
bool isRemoval = item.AccessTypeStatus == EnumAuthStatus.DeletedNotYetApprove;
|
||||
item.MakerID = isRemoval ? (item.ModifiedBy ?? 0) : item.CreatedBy;
|
||||
item.RequestDate = isRemoval
|
||||
? item.ModifiedDate
|
||||
: (item.CreatedDate == DateTime.MinValue ? (DateTime?)null : item.CreatedDate);
|
||||
items.Add(item);
|
||||
}
|
||||
dr.Close();
|
||||
tc.End();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#region Handle Exception
|
||||
if (tc != null)
|
||||
tc.HandleError();
|
||||
ExceptionLog.Write(e);
|
||||
throw new ServiceException(e.Message, e);
|
||||
#endregion
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public void Reject(int userID)
|
||||
{
|
||||
TransactionContext tc = null;
|
||||
|
|
|
|||
|
|
@ -237,6 +237,17 @@ export class AuthService {
|
|||
RejectUserAccessType(userID: number) {
|
||||
return this.apiService.httpPost<boolean>('/Authentication/RejectUserAccessType/' + userID, {});
|
||||
}
|
||||
GetPendingUserAccessTypes() {
|
||||
return this.apiService.httpGet<UserAccessType[]>('/Authentication/GetPendingUserAccessTypes');
|
||||
}
|
||||
/** Returns { done: number, failed: { userID, message }[] }. */
|
||||
ApproveUserAccessTypes(userIDs: number[]) {
|
||||
return this.apiService.httpPost<any>('/Authentication/ApproveUserAccessTypes', userIDs);
|
||||
}
|
||||
/** Returns { done: number, failed: { userID, message }[] }. */
|
||||
RejectUserAccessTypes(userIDs: number[]) {
|
||||
return this.apiService.httpPost<any>('/Authentication/RejectUserAccessTypes', userIDs);
|
||||
}
|
||||
changePassword(userData: any) {
|
||||
return this.apiService.httpPost<any>('/Authentication/changePassword', userData);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,567 @@
|
|||
/* This component uses ViewEncapsulation.None, so every rule carries the uat- prefix. */
|
||||
/* User Access Type page. This component uses ViewEncapsulation.None, so every rule carries the uat- prefix.
|
||||
Colours follow the app tokens (src/styles/abstracts/_tokens.scss) and the User / Role page badges. */
|
||||
|
||||
/* Banner shown while the selected user has an access change waiting for approval */
|
||||
.uat-pending {
|
||||
margin-bottom: 12px;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid #F5D9A8;
|
||||
.uat-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
/* ---------- header ---------- */
|
||||
|
||||
.uat-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.uat-header__icon {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 10px;
|
||||
background: #DEDEFF;
|
||||
color: #414278;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 20px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.uat-title {
|
||||
margin: 0 0 2px;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.uat-subtitle {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
/* ---------- view switch ---------- */
|
||||
|
||||
.uat-views {
|
||||
display: inline-flex;
|
||||
gap: 4px;
|
||||
padding: 4px;
|
||||
border: 1px solid #E3E3EC;
|
||||
border-radius: 10px;
|
||||
background: #FFFFFF;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.uat-view {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
height: 34px;
|
||||
padding: 0 14px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: #424242;
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.uat-view:hover {
|
||||
background: #F3F3FF;
|
||||
}
|
||||
|
||||
.uat-view.is-active {
|
||||
background: #52527A;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.uat-view__count {
|
||||
min-width: 20px;
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
background: #EEEEF2;
|
||||
color: #5B5B6B;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.uat-view__count.has-items {
|
||||
background: #FFF2DB;
|
||||
color: #8A5300;
|
||||
}
|
||||
|
||||
.uat-view.is-active .uat-view__count {
|
||||
background: rgba(255, 255, 255, 0.22);
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* ---------- pending approvals table ---------- */
|
||||
|
||||
.uat-table-wrap {
|
||||
border: 1px solid #E3E3EC;
|
||||
border-radius: 10px;
|
||||
overflow: auto;
|
||||
max-height: 560px;
|
||||
}
|
||||
|
||||
.uat-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.uat-pending__note {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
.uat-table th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
background: #F7F7FB;
|
||||
color: #666666;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-align: left;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #E3E3EC;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.uat-action {
|
||||
margin-left: 6px;
|
||||
.uat-table td {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #F0F0F4;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
/* While a change waits for approval the ticks show the requested state and cannot be changed */
|
||||
.uat-locked .k-checkbox {
|
||||
pointer-events: none;
|
||||
opacity: 0.6;
|
||||
.uat-table tbody tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* Status badge, same look as the User and Role pages */
|
||||
.uat-badge {
|
||||
.uat-table tbody tr:hover {
|
||||
background: #F7F7FB;
|
||||
}
|
||||
|
||||
.uat-table tbody tr.is-selected {
|
||||
background: #F3F3FF;
|
||||
}
|
||||
|
||||
.uat-table tbody tr.is-mine {
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
.uat-table__check {
|
||||
width: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.uat-table__open {
|
||||
width: 70px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.uat-block {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.uat-mine {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* ---------- layout ---------- */
|
||||
|
||||
.uat-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 320px minmax(0, 1fr);
|
||||
gap: 14px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.uat-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.uat-card {
|
||||
background: #FFFFFF;
|
||||
border: 1px solid #E3E3EC;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.uat-card__title {
|
||||
margin: 0 0 2px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
/* Pending approvals table, "Requested by" cell: maker, date and "Your change" side by side */
|
||||
.uat-requested {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px 10px;
|
||||
}
|
||||
|
||||
/* Left column: user card, then the pending change card under it */
|
||||
.uat-side {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* In the narrow left column the note sits above full-width buttons */
|
||||
.uat-side .uat-pending__actions {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.uat-side .uat-pending__actions .uat-btns > button {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* "3 of 12 selected" next to the Payroll access title */
|
||||
.uat-count {
|
||||
display: inline-block;
|
||||
margin-left: 8px;
|
||||
padding: 0 10px;
|
||||
border-radius: 999px;
|
||||
background: #DEDEFF;
|
||||
color: #414278;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 22px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.uat-label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #888888;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.uat-muted {
|
||||
color: #888888;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.uat-btns {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* ---------- user card ---------- */
|
||||
|
||||
.uat-user__select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.uat-user__option {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.uat-user__summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.uat-avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
background: #52527A;
|
||||
color: #FFFFFF;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.uat-user__info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.uat-user__name {
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.uat-stats {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-top: 14px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 10px;
|
||||
background: #F7F7FB;
|
||||
}
|
||||
|
||||
.uat-stat {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.uat-stat__value {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: #414278;
|
||||
}
|
||||
|
||||
.uat-stat__label {
|
||||
font-size: 12px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.uat-legend {
|
||||
margin-top: 16px;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid #F0F0F4;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.uat-legend__title {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #888888;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.uat-legend__row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
/* ---------- empty state ---------- */
|
||||
|
||||
.uat-empty {
|
||||
padding: 48px 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.uat-empty__icon {
|
||||
font-size: 32px;
|
||||
color: #C9C9D6;
|
||||
}
|
||||
|
||||
.uat-empty__title {
|
||||
margin: 10px 0 4px;
|
||||
font-weight: 600;
|
||||
color: #424242;
|
||||
}
|
||||
|
||||
/* ---------- pending change ---------- */
|
||||
|
||||
.uat-pending {
|
||||
border-color: #F5D9A8;
|
||||
background: #FFFAF0;
|
||||
}
|
||||
|
||||
.uat-pending__head {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: flex-start;
|
||||
color: #8A5300;
|
||||
}
|
||||
|
||||
.uat-pending__head > .pi {
|
||||
font-size: 20px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.uat-pending__title {
|
||||
margin: 0 0 2px;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.uat-pending__text {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.uat-change {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.uat-change__label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #8A5300;
|
||||
}
|
||||
|
||||
.uat-pending__actions {
|
||||
margin-top: 16px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.uat-pending__note {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #8A5300;
|
||||
}
|
||||
|
||||
/* ---------- chips ---------- */
|
||||
|
||||
.uat-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.uat-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 3px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.uat-chip .pi {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.uat-chip--add { background: #E6F4EC; color: #137A4B; }
|
||||
.uat-chip--remove { background: #FDE8EA; color: #D11A2A; }
|
||||
|
||||
/* ---------- payroll type list ---------- */
|
||||
|
||||
.uat-list__head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.uat-list__tools {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.uat-search {
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
.uat-list {
|
||||
border: 1px solid #E3E3EC;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
max-height: 579px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.uat-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin: 0;
|
||||
padding: 8px 14px;
|
||||
border-bottom: 1px solid #F0F0F4;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s;
|
||||
}
|
||||
|
||||
.uat-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.uat-row:hover {
|
||||
background: #F7F7FB;
|
||||
}
|
||||
|
||||
.uat-row.is-ticked {
|
||||
background: #F3F3FF;
|
||||
}
|
||||
|
||||
.uat-row__name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
color: #1a1a1a;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.uat-list--locked .uat-row {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.uat-list--locked .uat-row:hover {
|
||||
background: inherit;
|
||||
}
|
||||
|
||||
.uat-list--locked .uat-row.is-ticked:hover {
|
||||
background: #F3F3FF;
|
||||
}
|
||||
|
||||
.uat-list__empty {
|
||||
padding: 24px 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ---------- save bar ---------- */
|
||||
|
||||
.uat-savebar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
margin-top: 14px;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid #F0F0F4;
|
||||
}
|
||||
|
||||
.uat-savebar__summary {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* ---------- badges / pills (same look as the User and Role pages) ---------- */
|
||||
|
||||
.uat-badge,
|
||||
.uat-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
|
@ -47,6 +580,19 @@
|
|||
background: currentColor;
|
||||
}
|
||||
|
||||
.uat-badge--success { background: #E6F4EC; color: #137A4B; }
|
||||
.uat-badge--warning { background: #FFF2DB; color: #8A5300; }
|
||||
.uat-badge--success,
|
||||
.uat-pill--success { background: #E6F4EC; color: #137A4B; }
|
||||
.uat-badge--warning,
|
||||
.uat-pill--warning { background: #FFF2DB; color: #8A5300; }
|
||||
.uat-badge--neutral { background: #EEEEF2; color: #5B5B6B; }
|
||||
.uat-badge--info { background: #E8EEFC; color: #2F4FB5; }
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.uat-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.uat-search {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,73 +1,287 @@
|
|||
<app-loading-panel></app-loading-panel>
|
||||
|
||||
<app-loading-panel></app-loading-panel>
|
||||
<div class="card">
|
||||
<div class="grid form-group" style="margin: auto;">
|
||||
<div class="col-12 md:col-1" style="margin: auto;">
|
||||
<label for="idUser">Users</label>
|
||||
</div>
|
||||
<div class="col-12 md:col-5">
|
||||
<div class="uat-page">
|
||||
|
||||
<kendo-dropdownlist [data]="_users"
|
||||
id="idUser"
|
||||
[defaultItem]="{ name: 'select a User', id: null }"
|
||||
[textField]="'userName'"
|
||||
[valueField]="'id'"
|
||||
[valuePrimitive]="true"
|
||||
[(ngModel)]="_selectedUserID"
|
||||
(valueChange)="RefreshGrid($event)"
|
||||
class="form-control form-control-sm input-sm">
|
||||
</kendo-dropdownlist>
|
||||
</div>
|
||||
<div class="col-12 md:col-6">
|
||||
</div>
|
||||
</div>
|
||||
<!-- Page header -->
|
||||
<div class="uat-header">
|
||||
<div class="uat-header__icon"><i class="pi pi-id-card"></i></div>
|
||||
<div>
|
||||
<h2 class="uat-title">User Access Type</h2>
|
||||
<p class="uat-subtitle">Choose which payroll types a user can work in. Every change is approved by another administrator before it takes effect.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card card-w-title">
|
||||
@if (hasPending) {
|
||||
<div class="uat-pending">
|
||||
This user has an access change waiting for approval. The user keeps the current access until it is approved.
|
||||
@if (isMakerOfPending) {
|
||||
<span class="uat-pending__note">You made this change, so another user must approve or reject it.</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<div class="grid">
|
||||
<div class="col-12">
|
||||
<kendo-grid [kendoGridBinding]="_payrollTypes"
|
||||
[class.uat-locked]="hasPending"
|
||||
kendoGridSelectBy="id"
|
||||
[selectable]="selectableSettings"
|
||||
[(selectedKeys)]="_selectedPayrollTypes"
|
||||
|
||||
>
|
||||
<kendo-grid-checkbox-column [width]="40"
|
||||
[headerClass]="{'text-center': true}"
|
||||
[class]="{'text-center': true}"
|
||||
[resizable]="false"
|
||||
[columnMenu]="false"
|
||||
showSelectAll="true"></kendo-grid-checkbox-column>
|
||||
<kendo-grid-column field="description" title="Access Type" [width]="220">
|
||||
</kendo-grid-column>
|
||||
<kendo-grid-column title="Status" [width]="200">
|
||||
<ng-template kendoGridCellTemplate let-dataItem>
|
||||
@if (_selectedUserID) {
|
||||
<span class="uat-badge uat-badge--{{ statusOf(dataItem.id).tone }}">
|
||||
<span class="uat-badge__dot"></span>{{ statusOf(dataItem.id).text }}
|
||||
</span>
|
||||
}
|
||||
</ng-template>
|
||||
</kendo-grid-column>
|
||||
</kendo-grid>
|
||||
</div>
|
||||
<!-- View switch -->
|
||||
<div class="uat-views" role="tablist">
|
||||
<button type="button" role="tab" class="uat-view" [class.is-active]="activeView === 'manage'" (click)="activeView = 'manage'">
|
||||
<i class="pi pi-user-edit"></i> Manage access
|
||||
</button>
|
||||
<button type="button" role="tab" class="uat-view" [class.is-active]="activeView === 'pending'" (click)="activeView = 'pending'; loadPending()">
|
||||
<i class="pi pi-clock"></i> Pending approvals
|
||||
<span class="uat-view__count" [class.has-items]="pendingGroups.length > 0">{{ pendingGroups.length }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (activeView === 'pending') {
|
||||
<div class="uat-card">
|
||||
<div class="uat-list__head">
|
||||
<div>
|
||||
<p class="uat-card__title">Pending approvals</p>
|
||||
<p class="uat-muted">Every user whose payroll access change is waiting for approval. Select several and approve or reject them at once.</p>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button kendoButton [svgIcon]="apiService.KendoSVGIcon['save']" class="k-button k-primary" [disabled]="hasPending" (click)="onSave()">Save</button>
|
||||
@if (hasPending) {
|
||||
<button kendoButton themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['check']" class="uat-action" [disabled]="isMakerOfPending" (click)="onApprove()">Approve</button>
|
||||
<button kendoButton themeColor="error" [svgIcon]="apiService.KendoSVGIcon['cancel']" class="uat-action" [disabled]="isMakerOfPending" (click)="onReject()">Reject</button>
|
||||
<button kendoButton type="button" fillMode="flat" [svgIcon]="apiService.KendoSVGIcon['arrowRotateCw']" (click)="loadPending()">Refresh</button>
|
||||
</div>
|
||||
|
||||
@if (pendingGroups.length === 0) {
|
||||
<div class="uat-empty">
|
||||
<i class="pi pi-check-circle uat-empty__icon"></i>
|
||||
<p class="uat-empty__title">Nothing to approve</p>
|
||||
<p class="uat-muted">No user access change is waiting for approval.</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="uat-table-wrap">
|
||||
<table class="uat-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="uat-table__check">
|
||||
<input type="checkbox" kendoCheckBox [checked]="allPendingSelected"
|
||||
[disabled]="selectablePending.length === 0" (change)="toggleAllPending()" title="Select all" />
|
||||
</th>
|
||||
<th>User</th>
|
||||
<th>Will get access to</th>
|
||||
<th>Will lose access to</th>
|
||||
<th>Requested by</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (g of pendingGroups; track g.userID) {
|
||||
<tr [class.is-selected]="isPendingSelected(g.userID)" [class.is-mine]="g.isMine">
|
||||
<td class="uat-table__check">
|
||||
<input type="checkbox" kendoCheckBox [checked]="isPendingSelected(g.userID)" [disabled]="g.isMine"
|
||||
(change)="togglePendingSelection(g.userID)"
|
||||
[attr.title]="g.isMine ? 'You made this change; another administrator must decide it' : null" />
|
||||
</td>
|
||||
<td>
|
||||
<span class="uat-user__name">{{ g.userName }}</span>
|
||||
<span class="uat-muted uat-block">{{ g.loginID }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="uat-chips">
|
||||
@for (n of g.adds; track n) { <span class="uat-chip uat-chip--add"><i class="pi pi-plus"></i>{{ n }}</span> }
|
||||
@if (g.adds.length === 0) { <span class="uat-muted">-</span> }
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="uat-chips">
|
||||
@for (n of g.removes; track n) { <span class="uat-chip uat-chip--remove"><i class="pi pi-minus"></i>{{ n }}</span> }
|
||||
@if (g.removes.length === 0) { <span class="uat-muted">-</span> }
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="uat-requested">
|
||||
<span>{{ g.makers.join(', ') || '-' }}</span>
|
||||
@if (g.requestDate) {
|
||||
<span class="uat-muted">{{ g.requestDate | date: 'dd MMM yyyy, h:mm a' }}</span>
|
||||
}
|
||||
@if (g.isMine) {
|
||||
<span class="uat-badge uat-badge--neutral"><span class="uat-badge__dot"></span>Your change</span>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
<td class="uat-table__open">
|
||||
<button kendoButton type="button" fillMode="flat" (click)="openPendingUser(g.userID)">Open</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="uat-savebar">
|
||||
<div class="uat-savebar__summary">
|
||||
<span class="uat-muted">{{ selectedPendingIDs.length }} of {{ selectablePending.length }} selected</span>
|
||||
</div>
|
||||
<div class="uat-btns">
|
||||
<button kendoButton type="button" themeColor="error" fillMode="outline" [svgIcon]="apiService.KendoSVGIcon['cancel']"
|
||||
[disabled]="selectedPendingIDs.length === 0" (click)="bulkReject()">Reject selected</button>
|
||||
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['check']"
|
||||
[disabled]="selectedPendingIDs.length === 0" (click)="bulkApprove()">Approve selected</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (activeView === 'manage') {
|
||||
<div class="uat-layout">
|
||||
|
||||
<!-- Left: the user, and below it any change waiting for approval -->
|
||||
<div class="uat-side">
|
||||
<div class="uat-card uat-user">
|
||||
<label class="uat-label" for="idUser">User</label>
|
||||
<kendo-dropdownlist id="idUser"
|
||||
[data]="filteredUsers"
|
||||
[filterable]="true"
|
||||
(filterChange)="onUserFilter($event)"
|
||||
[defaultItem]="{ userName: 'Select a user', id: null }"
|
||||
[textField]="'userName'"
|
||||
[valueField]="'id'"
|
||||
[valuePrimitive]="true"
|
||||
[(ngModel)]="_selectedUserID"
|
||||
(valueChange)="RefreshGrid($event)"
|
||||
class="uat-user__select">
|
||||
<ng-template kendoDropDownListItemTemplate let-dataItem>
|
||||
<span class="uat-user__option">
|
||||
<span>{{ dataItem?.userName }}</span>
|
||||
@if (dataItem?.loginID) {
|
||||
<span class="uat-muted">{{ dataItem.loginID }}</span>
|
||||
}
|
||||
</span>
|
||||
</ng-template>
|
||||
</kendo-dropdownlist>
|
||||
|
||||
@if (selectedUser) {
|
||||
<div class="uat-user__summary">
|
||||
<div class="uat-avatar">{{ (selectedUser.userName || '?').charAt(0) | uppercase }}</div>
|
||||
<div class="uat-user__info">
|
||||
<span class="uat-user__name">{{ selectedUser.userName }}</span>
|
||||
<span class="uat-muted">{{ selectedUser.loginID }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uat-stats">
|
||||
<div class="uat-stat">
|
||||
<span class="uat-stat__value">{{ liveCount }}</span>
|
||||
<span class="uat-stat__label">payroll types in use</span>
|
||||
</div>
|
||||
<div class="uat-stat">
|
||||
@if (hasPending) {
|
||||
<span class="uat-pill uat-pill--warning"><span class="uat-badge__dot"></span>Waiting for approval</span>
|
||||
} @else {
|
||||
<span class="uat-pill uat-pill--success"><span class="uat-badge__dot"></span>Up to date</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="uat-legend">
|
||||
<span class="uat-legend__title">Status</span>
|
||||
<div class="uat-legend__row"><span class="uat-badge uat-badge--success"><span class="uat-badge__dot"></span>Active</span><span class="uat-muted">user can use it</span></div>
|
||||
<div class="uat-legend__row"><span class="uat-badge uat-badge--warning"><span class="uat-badge__dot"></span>New - Not Yet Approved</span><span class="uat-muted">not usable until approved</span></div>
|
||||
<div class="uat-legend__row"><span class="uat-badge uat-badge--warning"><span class="uat-badge__dot"></span>Removal - Not Yet Approved</span><span class="uat-muted">still usable until approved</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- A change waiting for approval -->
|
||||
@if (selectedUser && hasPending) {
|
||||
<div class="uat-card uat-pending">
|
||||
<div class="uat-pending__head">
|
||||
<i class="pi pi-clock"></i>
|
||||
<div>
|
||||
<p class="uat-pending__title">Change waiting for approval</p>
|
||||
<p class="uat-pending__text">Until it is approved, {{ selectedUser.userName }} keeps the current access.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (pendingAddNames.length > 0) {
|
||||
<div class="uat-change">
|
||||
<span class="uat-change__label">Will get access to</span>
|
||||
<div class="uat-chips">
|
||||
@for (n of pendingAddNames; track n) { <span class="uat-chip uat-chip--add"><i class="pi pi-plus"></i>{{ n }}</span> }
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if (pendingRemoveNames.length > 0) {
|
||||
<div class="uat-change">
|
||||
<span class="uat-change__label">Will lose access to</span>
|
||||
<div class="uat-chips">
|
||||
@for (n of pendingRemoveNames; track n) { <span class="uat-chip uat-chip--remove"><i class="pi pi-minus"></i>{{ n }}</span> }
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="uat-pending__actions">
|
||||
@if (isMakerOfPending) {
|
||||
<span class="uat-pending__note"><i class="pi pi-info-circle"></i> You made this change, so another administrator must approve or reject it.</span>
|
||||
}
|
||||
<div class="uat-btns">
|
||||
<button kendoButton type="button" themeColor="error" fillMode="outline" [svgIcon]="apiService.KendoSVGIcon['cancel']"
|
||||
[disabled]="isMakerOfPending" (click)="onReject()">Reject</button>
|
||||
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['check']"
|
||||
[disabled]="isMakerOfPending" (click)="onApprove()">Approve</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Right: the access -->
|
||||
<div class="uat-main">
|
||||
|
||||
@if (!selectedUser) {
|
||||
<div class="uat-card uat-empty">
|
||||
<i class="pi pi-user uat-empty__icon"></i>
|
||||
<p class="uat-empty__title">Select a user</p>
|
||||
<p class="uat-muted">Their payroll access and any change waiting for approval will show here.</p>
|
||||
</div>
|
||||
} @else {
|
||||
|
||||
<!-- Payroll types -->
|
||||
<div class="uat-card">
|
||||
<div class="uat-list__head">
|
||||
<div>
|
||||
<p class="uat-card__title">
|
||||
Payroll access
|
||||
<span class="uat-count">{{ _selectedPayrollTypes.length }} of {{ _payrollTypes?.length || 0 }} selected</span>
|
||||
</p>
|
||||
<p class="uat-muted">{{ hasPending ? 'Locked while the change waits for approval.' : 'Tick the payroll types this user should have.' }}</p>
|
||||
</div>
|
||||
<div class="uat-list__tools">
|
||||
<kendo-textbox class="uat-search" placeholder="Search payroll type" [clearButton]="true"
|
||||
[value]="payrollSearch" (valueChange)="payrollSearch = $event ?? ''"></kendo-textbox>
|
||||
@if (!hasPending) {
|
||||
<button kendoButton type="button" fillMode="flat" (click)="selectAllVisible()">Select all</button>
|
||||
<button kendoButton type="button" fillMode="flat" (click)="clearAllVisible()">Clear</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uat-list" [class.uat-list--locked]="hasPending">
|
||||
@for (p of visiblePayrollTypes; track p.id) {
|
||||
<label class="uat-row" [class.is-ticked]="isTicked(p.id)">
|
||||
<input type="checkbox" kendoCheckBox [checked]="isTicked(p.id)" [disabled]="hasPending" (change)="toggle(p.id)" />
|
||||
<span class="uat-row__name">{{ p.description }}</span>
|
||||
<span class="uat-badge uat-badge--{{ rowBadge(p.id).tone }}">
|
||||
<span class="uat-badge__dot"></span>{{ rowBadge(p.id).text }}
|
||||
</span>
|
||||
</label>
|
||||
} @empty {
|
||||
<div class="uat-list__empty uat-muted">No payroll type matches the search.</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Save bar -->
|
||||
@if (!hasPending) {
|
||||
<div class="uat-savebar">
|
||||
<div class="uat-savebar__summary">
|
||||
@if (hasDraftChanges) {
|
||||
@if (draftAddNames.length > 0) { <span class="uat-chip uat-chip--add"><i class="pi pi-plus"></i>{{ draftAddNames.length }} to add</span> }
|
||||
@if (draftRemoveNames.length > 0) { <span class="uat-chip uat-chip--remove"><i class="pi pi-minus"></i>{{ draftRemoveNames.length }} to remove</span> }
|
||||
} @else {
|
||||
<span class="uat-muted">No changes yet.</span>
|
||||
}
|
||||
</div>
|
||||
<div class="uat-btns">
|
||||
<button kendoButton type="button" fillMode="flat" [disabled]="!hasDraftChanges" (click)="resetSelection()">Reset</button>
|
||||
<button kendoButton type="button" themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['paperPlane']"
|
||||
[disabled]="!hasDraftChanges" (click)="onSave()">Send for approval</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -54,12 +54,15 @@ export class UserAccessTypeComponent implements OnInit {
|
|||
this.useService.GetCurrentUser().subscribe(
|
||||
(resp: any) => {
|
||||
this.currentUserID = resp?.userID;
|
||||
// After the current user is known, so "your own change" can be marked.
|
||||
this.loadPending();
|
||||
},
|
||||
);
|
||||
this.useService.GetUsers(EnumUserType.User)
|
||||
.subscribe(
|
||||
(resp: any) => {
|
||||
this._users = resp;
|
||||
this.filteredUsers = (resp ?? []).slice();
|
||||
},
|
||||
(err: any) => {
|
||||
//ON ERROR
|
||||
|
|
@ -88,6 +91,141 @@ export class UserAccessTypeComponent implements OnInit {
|
|||
this.setSelectableSettings();
|
||||
}
|
||||
|
||||
// ---------- Pending approvals (many users at once) ----------
|
||||
|
||||
/** Which view the page shows. */
|
||||
activeView: 'manage' | 'pending' = 'manage';
|
||||
/** One entry per user with a change waiting for approval. */
|
||||
pendingGroups: {
|
||||
userID: number, userName: string, loginID: string,
|
||||
adds: string[], removes: string[], makers: string[], requestDate: Date, isMine: boolean,
|
||||
}[] = [];
|
||||
selectedPendingIDs: number[] = [];
|
||||
|
||||
loadPending(): void {
|
||||
this.useService.GetPendingUserAccessTypes().subscribe(
|
||||
(rows: any[]) => {
|
||||
const groups = new Map<number, any>();
|
||||
(rows ?? []).forEach(r => {
|
||||
let g = groups.get(r.userID);
|
||||
if (!g) {
|
||||
g = { userID: r.userID, userName: r.userName, loginID: r.loginID,
|
||||
adds: [], removes: [], makers: [], makerIDs: [], requestDate: null, isMine: false };
|
||||
groups.set(r.userID, g);
|
||||
}
|
||||
if (r.accessTypeStatus == EnumAuthStatus.Deleted_Not_Yet_Approve) {
|
||||
g.removes.push(r.description);
|
||||
} else {
|
||||
g.adds.push(r.description);
|
||||
}
|
||||
const maker = r.makerLoginID || (r.makerID ? '#' + r.makerID : '');
|
||||
if (maker && !g.makers.includes(maker)) {
|
||||
g.makers.push(maker);
|
||||
}
|
||||
if (r.makerID && !g.makerIDs.includes(r.makerID)) {
|
||||
g.makerIDs.push(r.makerID);
|
||||
}
|
||||
const d = r.requestDate ? new Date(r.requestDate) : null;
|
||||
if (d && (!g.requestDate || d > g.requestDate)) {
|
||||
g.requestDate = d;
|
||||
}
|
||||
});
|
||||
this.pendingGroups = Array.from(groups.values()).map(g => ({
|
||||
...g, isMine: g.makerIDs.includes(this.currentUserID),
|
||||
}));
|
||||
// Keep only selections that are still pending and selectable.
|
||||
this.selectedPendingIDs = this.selectedPendingIDs.filter(id =>
|
||||
this.pendingGroups.some(g => g.userID == id && !g.isMine));
|
||||
},
|
||||
(err: any) => {
|
||||
this.pendingGroups = [];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** Pending users the logged-in user may decide (not their own changes). */
|
||||
get selectablePending() {
|
||||
return this.pendingGroups.filter(g => !g.isMine);
|
||||
}
|
||||
|
||||
isPendingSelected(userID: number): boolean {
|
||||
return this.selectedPendingIDs.includes(userID);
|
||||
}
|
||||
|
||||
togglePendingSelection(userID: number): void {
|
||||
const g = this.pendingGroups.find(x => x.userID == userID);
|
||||
if (!g || g.isMine) {
|
||||
return;
|
||||
}
|
||||
this.selectedPendingIDs = this.isPendingSelected(userID)
|
||||
? this.selectedPendingIDs.filter(x => x != userID)
|
||||
: [...this.selectedPendingIDs, userID];
|
||||
}
|
||||
|
||||
get allPendingSelected(): boolean {
|
||||
return this.selectablePending.length > 0 && this.selectablePending.every(g => this.isPendingSelected(g.userID));
|
||||
}
|
||||
|
||||
toggleAllPending(): void {
|
||||
this.selectedPendingIDs = this.allPendingSelected ? [] : this.selectablePending.map(g => g.userID);
|
||||
}
|
||||
|
||||
/** Opens one pending user in the Manage access view. */
|
||||
openPendingUser(userID: number): void {
|
||||
this.activeView = 'manage';
|
||||
this._selectedUserID = userID;
|
||||
this.RefreshGrid(userID);
|
||||
}
|
||||
|
||||
bulkApprove(): void {
|
||||
this.bulkDecide(true);
|
||||
}
|
||||
|
||||
bulkReject(): void {
|
||||
this.bulkDecide(false);
|
||||
}
|
||||
|
||||
private bulkDecide(approve: boolean): void {
|
||||
const ids = this.selectedPendingIDs.slice();
|
||||
if (ids.length == 0) {
|
||||
this.notificationService.showWarning('Select at least one user.');
|
||||
return;
|
||||
}
|
||||
const call = approve ? this.useService.ApproveUserAccessTypes(ids) : this.useService.RejectUserAccessTypes(ids);
|
||||
let result: any;
|
||||
this.loadingPanel.ShowLoadingPanel = true;
|
||||
call.subscribe(
|
||||
(resp: any) => {
|
||||
result = resp;
|
||||
},
|
||||
(err: any) => {
|
||||
this.loadingPanel.ShowLoadingPanel = false;
|
||||
this.notificationService.showError(err?.error ?? err);
|
||||
},
|
||||
() => {
|
||||
this.loadingPanel.ShowLoadingPanel = false;
|
||||
const done = result?.done ?? 0;
|
||||
const failed: any[] = result?.failed ?? [];
|
||||
if (done > 0) {
|
||||
this.notificationService.showSuccess(
|
||||
(approve ? 'Approved' : 'Rejected') + ' for ' + done + (done == 1 ? ' user.' : ' users.'));
|
||||
}
|
||||
if (failed.length > 0) {
|
||||
const names = failed.map(f => {
|
||||
const g = this.pendingGroups.find(x => x.userID == f.userID);
|
||||
return (g?.userName ?? ('User ' + f.userID)) + ': ' + f.message;
|
||||
});
|
||||
this.notificationService.showError(names.join(' | '));
|
||||
}
|
||||
this.selectedPendingIDs = [];
|
||||
this.loadPending();
|
||||
if (this._selectedUserID && ids.includes(this._selectedUserID)) {
|
||||
this.RefreshGrid(this._selectedUserID);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
setSelectableSettings(): void {
|
||||
this.selectableSettings = {
|
||||
checkboxOnly: true,
|
||||
|
|
@ -95,6 +233,120 @@ export class UserAccessTypeComponent implements OnInit {
|
|||
};
|
||||
}
|
||||
|
||||
// ---------- view helpers (screen only; saving and approval logic is below) ----------
|
||||
|
||||
/** Users dropdown, narrowed by what is typed in it. */
|
||||
filteredUsers: User[] = [];
|
||||
/** Search box over the payroll type list. */
|
||||
payrollSearch = '';
|
||||
|
||||
onUserFilter(term: string): void {
|
||||
const t = (term ?? '').trim().toLowerCase();
|
||||
this.filteredUsers = (this._users ?? []).filter(u =>
|
||||
!t || (u.userName ?? '').toLowerCase().includes(t) || (u.loginID ?? '').toLowerCase().includes(t));
|
||||
}
|
||||
|
||||
get selectedUser(): User {
|
||||
return (this._users ?? []).find(u => u.id == this._selectedUserID);
|
||||
}
|
||||
|
||||
/** Payroll types shown in the list, after the search box. */
|
||||
get visiblePayrollTypes(): PayrollType[] {
|
||||
const t = this.payrollSearch.trim().toLowerCase();
|
||||
return (this._payrollTypes ?? []).filter(p => !t || (p.description ?? '').toLowerCase().includes(t));
|
||||
}
|
||||
|
||||
isTicked(payrollTypeID: number): boolean {
|
||||
return this._selectedPayrollTypes.includes(payrollTypeID);
|
||||
}
|
||||
|
||||
/** Ticks or unticks one payroll type. Locked while a change waits for approval. */
|
||||
toggle(payrollTypeID: number): void {
|
||||
if (this.hasPending || !this._selectedUserID) {
|
||||
return;
|
||||
}
|
||||
this._selectedPayrollTypes = this.isTicked(payrollTypeID)
|
||||
? this._selectedPayrollTypes.filter(x => x != payrollTypeID)
|
||||
: [...this._selectedPayrollTypes, payrollTypeID];
|
||||
}
|
||||
|
||||
selectAllVisible(): void {
|
||||
if (this.hasPending || !this._selectedUserID) {
|
||||
return;
|
||||
}
|
||||
const ids = this.visiblePayrollTypes.map(p => p.id).filter(id => !this.isTicked(id));
|
||||
this._selectedPayrollTypes = [...this._selectedPayrollTypes, ...ids];
|
||||
}
|
||||
|
||||
clearAllVisible(): void {
|
||||
if (this.hasPending || !this._selectedUserID) {
|
||||
return;
|
||||
}
|
||||
const ids = this.visiblePayrollTypes.map(p => p.id);
|
||||
this._selectedPayrollTypes = this._selectedPayrollTypes.filter(x => !ids.includes(x));
|
||||
}
|
||||
|
||||
/** Undoes unsaved ticks: back to what the user has now. */
|
||||
resetSelection(): void {
|
||||
this._selectedPayrollTypes = (this._userAcessTypes ?? [])
|
||||
.filter(x => x.accessTypeStatus != EnumAuthStatus.Deleted_Not_Yet_Approve)
|
||||
.map(x => x.payrollTypeID);
|
||||
}
|
||||
|
||||
payrollName(payrollTypeID: number): string {
|
||||
return (this._payrollTypes ?? []).find(p => p.id == payrollTypeID)?.description ?? '';
|
||||
}
|
||||
|
||||
/** Payroll types the user can use right now (approved, or a removal not yet approved). */
|
||||
get liveCount(): number {
|
||||
return (this._userAcessTypes ?? []).filter(x => x.accessTypeStatus != EnumAuthStatus.New_Not_Yet_Approve).length;
|
||||
}
|
||||
|
||||
/** Waiting for approval: access to be given. */
|
||||
get pendingAddNames(): string[] {
|
||||
return (this._userAcessTypes ?? []).filter(x => x.accessTypeStatus == EnumAuthStatus.New_Not_Yet_Approve)
|
||||
.map(x => this.payrollName(x.payrollTypeID));
|
||||
}
|
||||
|
||||
/** Waiting for approval: access to be taken away. */
|
||||
get pendingRemoveNames(): string[] {
|
||||
return (this._userAcessTypes ?? []).filter(x => x.accessTypeStatus == EnumAuthStatus.Deleted_Not_Yet_Approve)
|
||||
.map(x => this.payrollName(x.payrollTypeID));
|
||||
}
|
||||
|
||||
/** Unsaved ticks that would give new access. */
|
||||
get draftAddNames(): string[] {
|
||||
return this._selectedPayrollTypes
|
||||
.filter(id => !(this._userAcessTypes ?? []).some(x => x.payrollTypeID == id))
|
||||
.map(id => this.payrollName(id));
|
||||
}
|
||||
|
||||
/** Unsaved unticks that would take access away. */
|
||||
get draftRemoveNames(): string[] {
|
||||
return (this._userAcessTypes ?? [])
|
||||
.filter(x => !this.isPendingStatus(x.accessTypeStatus) && !this.isTicked(x.payrollTypeID))
|
||||
.map(x => this.payrollName(x.payrollTypeID));
|
||||
}
|
||||
|
||||
/** Badge on one payroll type row: unsaved ticks first, then the saved status. */
|
||||
rowBadge(payrollTypeID: number): { text: string, tone: string } {
|
||||
const saved = this.statusOf(payrollTypeID);
|
||||
if (!this.hasPending) {
|
||||
const row = (this._userAcessTypes ?? []).find(x => x.payrollTypeID == payrollTypeID);
|
||||
if (!row && this.isTicked(payrollTypeID)) {
|
||||
return { text: 'To be added', tone: 'info' };
|
||||
}
|
||||
if (row && !this.isTicked(payrollTypeID)) {
|
||||
return { text: 'To be removed', tone: 'info' };
|
||||
}
|
||||
}
|
||||
return saved;
|
||||
}
|
||||
|
||||
get hasDraftChanges(): boolean {
|
||||
return this.draftAddNames.length > 0 || this.draftRemoveNames.length > 0;
|
||||
}
|
||||
|
||||
// ---------- maker-checker ----------
|
||||
|
||||
private isPendingStatus(status: EnumAuthStatus): boolean {
|
||||
|
|
@ -156,6 +408,7 @@ export class UserAccessTypeComponent implements OnInit {
|
|||
this.loadingPanel.ShowLoadingPanel = false;
|
||||
this.notificationService.showSuccess(approve ? 'Approved Successfully.' : 'Rejected Successfully.');
|
||||
this.RefreshGrid(userID);
|
||||
this.loadPending();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -245,6 +498,7 @@ export class UserAccessTypeComponent implements OnInit {
|
|||
this.notificationService.showSuccess('Saved. The change is waiting for approval.');
|
||||
// this.loadGrid();
|
||||
this.RefreshGrid(this._userAcessTypesforSave[0].userID);
|
||||
this.loadPending();
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1684,6 +1684,92 @@ namespace HRM.UI.Controllers
|
|||
return Ok(true);
|
||||
}
|
||||
|
||||
// Pending approvals list: every user access change waiting for approval, one row per payroll type.
|
||||
[HttpGet("GetPendingUserAccessTypes")]
|
||||
public ActionResult GetPendingUserAccessTypes()
|
||||
{
|
||||
try
|
||||
{
|
||||
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||
if (!CanManageUserAccessType(currentUser))
|
||||
{
|
||||
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to see user access type approvals.");
|
||||
}
|
||||
return Ok(this._userAccessTypeService.GetPending());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// Checker, many users at once: approves each user's pending change on its own, with the same
|
||||
// checks as ApproveUserAccessType, so one user that cannot be approved does not stop the rest.
|
||||
[HttpPost("ApproveUserAccessTypes")]
|
||||
public ActionResult ApproveUserAccessTypes(List<int> userIDs)
|
||||
{
|
||||
return DecideUserAccessTypes(userIDs, true);
|
||||
}
|
||||
|
||||
// Checker, many users at once: rejects each user's pending change on its own (see ApproveUserAccessTypes).
|
||||
[HttpPost("RejectUserAccessTypes")]
|
||||
public ActionResult RejectUserAccessTypes(List<int> userIDs)
|
||||
{
|
||||
return DecideUserAccessTypes(userIDs, false);
|
||||
}
|
||||
|
||||
private ActionResult DecideUserAccessTypes(List<int> userIDs, bool approve)
|
||||
{
|
||||
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||
try
|
||||
{
|
||||
if (!CanManageUserAccessType(currentUser))
|
||||
{
|
||||
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to approve or reject user access types.");
|
||||
}
|
||||
if (userIDs == null || userIDs.Count == 0)
|
||||
{
|
||||
return BadRequest("Select at least one user.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
||||
}
|
||||
|
||||
int done = 0;
|
||||
var failed = new List<object>();
|
||||
foreach (int userID in userIDs.Distinct())
|
||||
{
|
||||
try
|
||||
{
|
||||
List<UserAccessType> pending = this._userAccessTypeService.GetByUserID(userID).Where(IsPendingAccess).ToList();
|
||||
if (pending.Count == 0)
|
||||
{
|
||||
failed.Add(new { userID, message = "No access change waiting for approval." });
|
||||
continue;
|
||||
}
|
||||
if (pending.Any(x => AccessMakerID(x) == currentUser.UserID))
|
||||
{
|
||||
failed.Add(new { userID, message = "You made this change yourself; another user must decide it." });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (approve)
|
||||
this._userAccessTypeService.Approve(userID, currentUser.UserID);
|
||||
else
|
||||
this._userAccessTypeService.Reject(userID);
|
||||
done++;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
failed.Add(new { userID, message = e.Message });
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(new { done, failed });
|
||||
}
|
||||
|
||||
// password history
|
||||
//[HttpGet]
|
||||
//[Route("getPasswordHistoryList")]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user