Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter on M2M on Directus Users ↔ Directus Roles does not work properly #11043

Closed
3 tasks done
Pachat opened this issue Jan 14, 2022 · 3 comments
Closed
3 tasks done

Comments

@Pachat
Copy link

Pachat commented Jan 14, 2022

Preflight Checklist

Describe the Bug

Users may have multiple roles: an M2M field other_roles is therefore added to Directus Users in relation with Directus Roles
M2M

Here is the full list a Member can see when the Directus Users filter is set to All.
Full list
The Manager who is also a Member has 2 roles: the Role Manager Role and an other_roles Member Role.

What I'd like to build is a filter that allows a Member to see any other user that has a Role Member Role or an other_roles Member Role i.e. with the present data:

  • Member who has a Member Role in Role
  • Member 2 who has a Member Role in Role
  • Manager who's role is Manager Role but has a Member Role in other_roles

First step: showing the users that have a Role Member Role
Below, under the filter (in admin) you see the users list (seen by the member)
Members

Second step: we expect the users that have a Role Member Role or an other_roles Member Role,
that is Member, Member 2 and Manager
Below, under the filter (in admin) you see the users list (seen by the member)
Member
But here, we have only the user itself.

I suspect that Directus cannot resolve properly the M2M here, and therefore, goes to the default minimal filter: the user itself.

To Reproduce

You may use this Database: data.2.zip

  1. Connect as member@localhost.com / member@localhost.com : see the full list of users
  2. Connect as admin@localhost.com / admin@localhost.com : set the filter for Member Role as described in the First step
  3. Connect as member@localhost.com / member@localhost.com : see the list of the 2 Users with Member Role
  4. Connect as admin@localhost.com / admin@localhost.com : set the filter for Member Role as described in the Second step
  5. Connect as member@localhost.com / member@localhost.com : you will see only the user itself in the list

Errors Shown

The filter reduces the Users list to the user itself instead of enlarging it to

  • Member
  • Member 2
  • Manager

What version of Directus are you using?

9.4.3

What version of Node.js are you using?

14.17.1

What database are you using?

SQLite version 3.37.0

What browser are you using?

Firefox

What operating system are you using?

Windows_NT 10.0.19043

How are you deploying Directus?

locally

@Oreilles
Copy link
Contributor

On your second image, your filter isn't configured properly: when using a and/or block, its children will be identified by a increased left margin.
Here's how it should look like:
Capture d’écran 2022-01-14 à 11 37 35

@Pachat
Copy link
Author

Pachat commented Jan 14, 2022

@Oreilles Awesome! Directus is really fantastic! Thanks.

BTW: I'm not sure the documentation shows a configuration of "Any of the following" with the block feature.

@benhaynes
Copy link
Sponsor Member

A note and good screenshot in the docs would help! CC @erondpowell

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants