Skip to content

Commit

Permalink
Merge pull request #125 from NandiniAV/dev-mdo-fixes
Browse files Browse the repository at this point in the history
Added rolesaccess search on enter key
  • Loading branch information
gohilamariappan authored May 19, 2022
2 parents 9f12f91 + 59e2c0c commit 02a580f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<mat-card class="flex-custom ws-mat-accent-border">
<mat-card-content>
<ng-container>
<ws-widget-org-user-table [tableData]="tabledata" [data]="data" (actionsClick)="menuActions($event)">
<ws-widget-org-user-table [tableData]="tabledata" [data]="data" (actionsClick)="menuActions($event)"
(searchByEnterKey)="onEnterkySearch($event)">
</ws-widget-org-user-table>
</ng-container>
</mat-card-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,38 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
// break
}
}

onEnterkySearch(enterValue: any) {
const rootOrgId = _.get(this.route.snapshot.parent, 'data.configService.unMappedUser.rootOrg.rootOrgId')
this.usersSvc.searchUserByenter(enterValue, rootOrgId).subscribe(data => {
this.usersData = data.result.response

let users: any[] = []
if (this.usersData && this.usersData.content && this.usersData.content.length > 0) {
users = _.map(_.compact(_.map(this.usersData.content, i => {
let consider = false
if (!i.isDeleted && i.organisations && i.organisations.length > 0) {
_.each(i.organisations, o => {
if (!o.isDeleted && (o.roles || []).indexOf(this.roleName) >= 0) {
consider = true
}
})
}
return consider ? i : null
})),
// tslint:disable-next-line
user => {
return {
fullName: `${user.firstName} ${user.lastName}`,
email: _.get(user, 'profileDetails.personalDetails.primaryEmail') || user.email,
position: user.department_name,
role: this.getRoleList(user),
wid: user.userId,
}
})
}
this.data = users
}
)
}
}
13 changes: 13 additions & 0 deletions project/ws/app/src/lib/routes/access/services/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const API_END_POINTS = {
USER_BDD: '/apis/protected/v8/portal/mdo/deptAction/userrole',
ACTIVE_USER: 'apis/proxies/v8/user/v1/unblock',
DE_ACTIVE_USER: 'apis/proxies/v8/user/v1/block',
SEARCH_USER_TABLE: '/apis/proxies/v8/user/v1/search',
}

@Injectable({
Expand All @@ -29,4 +30,16 @@ export class UsersService {
deleteUser(user: object): Observable<any> {
return this.http.patch<any>(`${API_END_POINTS.USER_BDD}/`, user)
}
searchUserByenter(value: string, rootOrgId: string) {
const reqBody = {
request: {
query: value,
filters: {
rootOrgId,
},
},
}

return this.http.post<any>(`${API_END_POINTS.SEARCH_USER_TABLE}`, reqBody)
}
}

0 comments on commit 02a580f

Please sign in to comment.