Skip to content

Commit 37dee4d

Browse files
authored
Merge pull request #141 from Sohith-code/cbrelease-4.8.20-custom-registration-sohith
hidden some options for state admin
2 parents 17d30da + 2a5f293 commit 37dee4d

File tree

5 files changed

+52
-6
lines changed

5 files changed

+52
-6
lines changed

project/ws/app/src/lib/head/ui-admin-table/directory-list/directory-table.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
Access</button>
8282
<button mat-menu-item (click)="goToRoute('mentormanage', row)">Mentor
8383
Management</button>
84-
<button mat-menu-item (click)="goToRoute('designation_master', row)">Manage
84+
<button mat-menu-item (click)="goToRoute('designation_master', row)"
85+
*ngIf="needCreate">Manage
8586
Designations</button>
8687
<!-- <button mat-menu-item
8788
(click)="goToRoute('grade_setting', row)">Grades/Group</button> -->

project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<div class="flex-display" [ngClass]="{ 'override-text-css': isReportsPath}">
1111

1212
<ws-widget-ui-user-table *ngIf="currentTab==='users'" [tableData]="tabledata" [data]="data"
13-
[otherInput]="createdDepartment" [needAddAdmin]="true" [needCreateUser]="true" (actionsClick)="editUser($event)"
14-
(searchByEnterKey)="onEnterkySearch($event)">
13+
[otherInput]="createdDepartment" [needAddAdmin]="true" [needCreateUser]="isAllowed(allowedCreateRoles)"
14+
(actionsClick)="editUser($event)" (searchByEnterKey)="onEnterkySearch($event)">
1515
</ws-widget-ui-user-table>
1616

1717
<ws-app-roles-access *ngIf="currentTab==='rolesandaccess'" (clickedDepartment)="fClickedDepartment($event)">

project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
4444
}
4545
}
4646
isReportsPath = false
47+
userRoles: any
48+
allowedCreateRoles = ['DASHBOARD_ADMIN', 'SPV_ADMIN', 'SPV_PUBLISHER']
4749
constructor(private usersSvc: UsersService, private router: Router,
4850
private route: ActivatedRoute,
4951
private profile: ProfileV2Service,
@@ -52,6 +54,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
5254
) {
5355
}
5456
ngOnInit() {
57+
this.userRoles = this.route.parent && this.route.parent.snapshot.data.configService.userRoles
5558
this.tabsData = [
5659
{
5760
name: 'Users',
@@ -133,6 +136,10 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
133136
this.tabledata['actions'] = [{ name: 'Edit', label: 'Edit info', optional: true, icon: 'remove_red_eye', type: 'button' }]
134137
}
135138

139+
if (!this.isAllowed(this.allowedCreateRoles)) {
140+
this.tabsData = this.tabsData.filter(item => !(['designation_master'].includes(item.key)))
141+
}
142+
136143
}
137144
ngAfterViewInit() {
138145
// this.elementPosition = this.menuElement.nativeElement.parentElement.offsetTop
@@ -299,4 +306,12 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
299306
return 'cbp-providers'
300307
}
301308
}
309+
310+
isAllowed(allowedRoles: string[]): boolean {
311+
if (this.userRoles && this.userRoles.size > 0) {
312+
const lowerConfigRoles = new Set([...this.userRoles].map(role => role.toLowerCase()))
313+
return allowedRoles.some(role => lowerConfigRoles.has(role.toLowerCase()))
314+
}
315+
return false
316+
}
302317
}

project/ws/app/src/lib/routes/home/routes/directory/directory.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
</div>
5353
<ng-container>
5454
<ws-widget-directory-table [selectedDepartment]='currentDepartment' [tableData]='tabledata' [data]='data'
55-
(eOnRowClick)="onRoleClick($event)" (actionsClick)="actionClick($event)"
56-
(searchByEnterKey)="onEnterkySearch($event)" (pageChangeEvent)="onPageChange($event)">
55+
[needCreate]="isAllowed(allowedCreateRoles)" (eOnRowClick)="onRoleClick($event)"
56+
(actionsClick)="actionClick($event)" (searchByEnterKey)="onEnterkySearch($event)"
57+
(pageChangeEvent)="onPageChange($event)">
5758
</ws-widget-directory-table>
5859
</ng-container>
5960
</mat-card-content>

project/ws/app/src/lib/routes/home/routes/directory/directroy.component.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export class DirectoryViewComponent implements OnInit {
3737
currentTab: any
3838
pagination = { limit: 20, offset: 0 }
3939
totalCount = 0
40+
userRoles: any
41+
allowedCreateRoles = ['DASHBOARD_ADMIN', 'SPV_ADMIN', 'SPV_PUBLISHER']
4042
constructor(
4143
public dialog: MatDialog,
4244
private route: ActivatedRoute,
@@ -54,6 +56,8 @@ export class DirectoryViewComponent implements OnInit {
5456
&& data.profile.data.length > 0
5557
&& data.profile.data[0]
5658
})
59+
this.userRoles = this.route.parent && this.route.parent.snapshot.data.configService.userRoles
60+
5761
}
5862

5963
ngOnInit() {
@@ -107,6 +111,11 @@ export class DirectoryViewComponent implements OnInit {
107111
loader: true,
108112
tableDataCount: this.totalCount
109113
}
114+
115+
const isAllowed = this.isAllowed(this.allowedCreateRoles)
116+
if (!isAllowed) {
117+
delete this.tabledata.link
118+
}
110119
} else {
111120
this.tabledata = {
112121
actions: [{ name: 'Edit', label: 'Edit info', icon: 'remove_red_eye', type: 'button' }],
@@ -155,7 +164,9 @@ export class DirectoryViewComponent implements OnInit {
155164
depatName: role.data.channel,
156165
orgName: role.data.mdo || role.data.organisation,
157166
tab: role.type,
158-
subOrgType: role.data.type
167+
// subOrgType: !this.isAllowed(this.allowedCreateRoles) ? 'ministry' : role.data.type ? role.data.type : 'cbp-providers'
168+
// subOrgType: !this.isAllowed(this.allowedCreateRoles) ? 'ministry' : role.data.type ? role.data.type : 'ministry'
169+
subOrgType: this.getSubOrgType(role.data.type)
159170
}
160171
})
161172
}
@@ -379,4 +390,22 @@ export class DirectoryViewComponent implements OnInit {
379390

380391
return this.datePipe.transform(isoDateString, 'dd/MM/yyyy, hh:mm a')
381392
}
393+
394+
isAllowed(allowedRoles: string[]): boolean {
395+
if (this.userRoles && this.userRoles.size > 0) {
396+
const lowerConfigRoles = new Set([...this.userRoles].map(role => role.toLowerCase()))
397+
return allowedRoles.some(role => lowerConfigRoles.has(role.toLowerCase()))
398+
}
399+
return false
400+
}
401+
402+
getSubOrgType(type: string) {
403+
if (this.currentFilter === 'organisation') {
404+
return 'ministry'
405+
}
406+
else if (type === 'cbp-providers') {
407+
return 'cbp-providers'
408+
}
409+
return ''
410+
}
382411
}

0 commit comments

Comments
 (0)