From 649a245e89b11f9ba7311716ae2dbdb26bfd63bb Mon Sep 17 00:00:00 2001 From: Sohith Kanala Date: Mon, 2 Dec 2024 14:47:39 +0530 Subject: [PATCH] fix: roles and access issue --- .../head/info-modal/info-modal.component.ts | 2 -- .../ui-admin-user-table.component.ts | 5 +++++ .../roles-access/roles-access.component.ts | 7 +++++-- .../routes/users/users.component.html | 20 ------------------ .../routes/users/users.component.ts | 5 ++++- .../create-user/create-user.component.html | 2 +- .../create-user/create-user.component.ts | 21 +++++++++++++------ .../routes/directory/directroy.component.ts | 3 ++- 8 files changed, 32 insertions(+), 33 deletions(-) diff --git a/project/ws/app/src/lib/head/info-modal/info-modal.component.ts b/project/ws/app/src/lib/head/info-modal/info-modal.component.ts index 3dc0a58f..cf9f966d 100644 --- a/project/ws/app/src/lib/head/info-modal/info-modal.component.ts +++ b/project/ws/app/src/lib/head/info-modal/info-modal.component.ts @@ -10,8 +10,6 @@ export class InfoModalComponent { constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any) { } ngOnInit(): void { - console.log('dialog ref', this.data) - } diff --git a/project/ws/app/src/lib/head/ui-admin-table/user-list/ui-admin-user-table.component.ts b/project/ws/app/src/lib/head/ui-admin-table/user-list/ui-admin-user-table.component.ts index 04bce49b..de820eb5 100644 --- a/project/ws/app/src/lib/head/ui-admin-table/user-list/ui-admin-user-table.component.ts +++ b/project/ws/app/src/lib/head/ui-admin-table/user-list/ui-admin-user-table.component.ts @@ -61,6 +61,7 @@ export class UIAdminUserTableComponent implements OnInit, AfterViewInit, OnChang isReports = false reportsPath: any orgName!: string + subOrgType: string = '' constructor( private router: Router, public dialog: MatDialog, private activatedRoute: ActivatedRoute, @@ -93,6 +94,8 @@ export class UIAdminUserTableComponent implements OnInit, AfterViewInit, OnChang this.orgName = params['orgName'] this.departmentId = params['roleId'] this.reportsPath = params['path'] + this.subOrgType = params['subOrgType'] + if (this.needCreateUser !== false && (this.departmentRole && this.departmentRole !== 'ministry') && this.departmentId) { this.needAddAdmin = true this.needCreateUser = true @@ -258,6 +261,8 @@ export class UIAdminUserTableComponent implements OnInit, AfterViewInit, OnChang createDept: JSON.stringify(this.otherInput), orgName: this.orgName, redirectionPath: window.location.href, + subOrgType: this.subOrgType && this.subOrgType.toLowerCase() === 'ministry' ? 'mdo' : 'state' + }, }) } diff --git a/project/ws/app/src/lib/routes/access/routes/roles-access/roles-access.component.ts b/project/ws/app/src/lib/routes/access/routes/roles-access/roles-access.component.ts index b1d49a4e..e8d9e285 100644 --- a/project/ws/app/src/lib/routes/access/routes/roles-access/roles-access.component.ts +++ b/project/ws/app/src/lib/routes/access/routes/roles-access/roles-access.component.ts @@ -31,11 +31,14 @@ export class RolesAccessComponent implements OnInit, AfterViewInit { this.activatedRoute.queryParams.subscribe(params => { this.deparmentId = params['roleId'] this.deparmentName = params['depatName'] - this.currentDept = params['currentDept'] + // this.currentDept = params['currentDept'] + this.currentDept = params['subOrgType'] }) if (this.currentDept === 'CBP Providers' || this.currentDept === 'cbp-providers') { this.currentDept = 'CBP' } + else if (this.currentDept.toLowerCase() === 'ministry') this.currentDept = 'mdo' + else if (this.currentDept.toLowerCase() === 'state') this.currentDept = 'state' } @@ -139,8 +142,8 @@ export class RolesAccessComponent implements OnInit, AfterViewInit { this.usersService.getAllKongUsers(this.deparmentId).subscribe(data => { if (data.result.response.content.length > 0) { this.userWholeData = data.result.response.content || [] - this.fetchRoles() } + this.fetchRoles() }) } diff --git a/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.html b/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.html index 84a4157b..ac17e190 100644 --- a/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.html +++ b/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.html @@ -9,26 +9,6 @@
- - diff --git a/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.ts b/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.ts index 9459c5b1..6bac941d 100644 --- a/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.ts +++ b/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.ts @@ -33,6 +33,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy { private defaultSideNavBarOpenedSubscription: any @ViewChild('stickyMenu', { static: true }) menuElement!: ElementRef goToImportMaster = false + subOrgType: any @HostListener('window:scroll', ['$event']) handleScroll() { const windowScroll = window.pageYOffset @@ -90,7 +91,8 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy { this.id = params['roleId'] this.currentDept = params['currentDept'] this.deptName = params['depatName'] - this.currentTab = params['tab'] + this.currentTab = params['tab'] || 'users' + this.subOrgType = params['subOrgType'] if (this.currentTab.split('/').length > 1 && this.currentTab.split('/')[1] === 'import-designation') { this.currentTab = 'designation_master' @@ -274,6 +276,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy { createDept: JSON.stringify({ depName: this.deptName }), orgName: this.deptName, redirectionPath: window.location.href, + subOrgType: this.subOrgType && this.subOrgType.toLowerCase() === 'ministry' ? 'mdo' : 'state' }, state: { userData: event.row, updateButton: true }, }) } diff --git a/project/ws/app/src/lib/routes/home/routes/create-user/create-user.component.html b/project/ws/app/src/lib/routes/home/routes/create-user/create-user.component.html index 2662fcae..7ea53a95 100644 --- a/project/ws/app/src/lib/routes/home/routes/create-user/create-user.component.html +++ b/project/ws/app/src/lib/routes/home/routes/create-user/create-user.component.html @@ -66,7 +66,7 @@ Please enter a valid email ID diff --git a/project/ws/app/src/lib/routes/home/routes/create-user/create-user.component.ts b/project/ws/app/src/lib/routes/home/routes/create-user/create-user.component.ts index bbaa13fd..f32e41d7 100644 --- a/project/ws/app/src/lib/routes/home/routes/create-user/create-user.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/create-user/create-user.component.ts @@ -76,7 +76,8 @@ export class CreateUserComponent implements OnInit { this.queryParam = params['id'] this.deptId = params['id'] this.orgName = params['orgName'] - this.currentDept = params['currentDept'] + // this.currentDept = params['currentDept'] + this.currentDept = params['subOrgType'] this.redirectionPath = params['redirectionPath'] if (this.currentDept === 'CBP Providers' || this.currentDept === 'cbp-providers') { this.currentDept = 'CBP' @@ -330,11 +331,11 @@ export class CreateUserComponent implements OnInit { this.disableCreateButton = false if (err.error.params.errmsg) { // this.openSnackbar(`${err.error.params.errmsg}`) - if (err.error.params.errmsg === 'phone already exists') { - this.openSnackbar('Phone number already exists') - } else if (err.error.params.errmsg === 'email already exists') { + if (err.error.params.errmsg.toLowerCase() === 'this phone is already registered with an existing user') { + this.openSnackbar('This Phone is already registered with an existing User') + } else if (err.error.params.errmsg.toLowerCase() === 'email already exists') { this.openSnackbar('Email Id already exists') - } else if (err.error.params.errmsg === 'Invalid format for given phone.') { + } else if (err.error.params.errmsg.toLowerCase() === 'Invalid format for given phone.') { this.openSnackbar('Please enter valid phone number') } else { this.openSnackbar('User creation error') @@ -365,7 +366,15 @@ export class CreateUserComponent implements OnInit { navigateTo() { if (this.createdDepartment) { - this.router.navigate([`/app/roles/${this.deptId}/users`], { queryParams: { currentDept: this.currentDept, roleId: this.deptId, depatName: this.createdDepartment.depName } }) + this.router.navigate([`/app/roles/${this.deptId}/users`], + { + queryParams: + { + currentDept: this.currentDept === 'mdo' || 'state' ? 'organisation' : this.currentDept, + roleId: this.deptId, + depatName: this.createdDepartment.depName + } + }) } else { this.router.navigate([`/app/home/users`]) diff --git a/project/ws/app/src/lib/routes/home/routes/directory/directroy.component.ts b/project/ws/app/src/lib/routes/home/routes/directory/directroy.component.ts index 0d66aa63..1090dcf0 100644 --- a/project/ws/app/src/lib/routes/home/routes/directory/directroy.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/directory/directroy.component.ts @@ -141,7 +141,8 @@ export class DirectoryViewComponent implements OnInit { roleId: role.data.id, depatName: role.data.channel, orgName: role.data.mdo || role.data.organisation, - tab: role.type + tab: role.type, + subOrgType: role.data.type } }) }