I need to modify a select list mentioned for page item in my application.
Currently it displays the departments available.
Select dept_name as d,dept_id as r from depts;
Now i need to modify filter such that, when user role is admin it should see all departments.
And if it is User, it will see only departments it is a part of inroles. Admin is part of all depts so admin would see all departments.
Userrole table:

Role table:

userrole.role_id=roles.id
userrole.user = :APP_USER
The dept_id column is populated from shuttle item, so in app the role allocation is done department wise So user can select multiple departments.
As a result departments are stored in colon separated format so this also needs to be handled in query.
So the query should be such that, when user is admin , all departments should display and if it is user, it should be departments from the userrole table.
The department id in lov select query is equal to the ones in user role.
Apex 20.2