Problem/Motivation
There are often very meaty vocabularies and maybe you only need to filter by parents.
Proposed resolution
I've added a "Show only parents" option inside the SettingsForm. If enabled the permissions_by_term_form_user_form_alter function, during all terms obtaining, will filter the list for all terms with parent = 0 (that means that has no parents).
User interface changes
Just another checkbox into the Settings page. 
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | Screenshot from 2022-10-19 10-31-44.png | 70.04 KB | reinchek |
| permissions_by_terms_parents.patch | 4.4 KB | reinchek |
Issue fork permissions_by_term-3316218
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
reinchekComment #3
reinchekComment #4
reinchekJust a brief description of what i did inside the permissions_by_terms_parents.patch
- Added only_parents item inside $form array, SettingsForm.php:a
- Then, before getting all terms (from multiple vocabularies or from one) checks if the only_parents is true (default value FALSE):
Comment #5
reinchekComment #7
marcoliverHi reinchek, thanks for your patch!
I went ahead and created an issue fork. The patch applied fine. I made some slight modifications (using
$this->t()throughout the settings form now; made the description of the checkbox a bit more self-explanatory).Feel free to take a look if you are happy with these changes.
Comment #9
reinchekHi @marcoliver,
I fully agree with the proposed changes (I thought I had applied them myself, but apparently I mixed them up when creating the patch). Indeed, thank you for taking the trouble to look and fix those unclean portions of code!
Comment #11
marcoliverThanks! I merged the changes just now. New release forthcoming.
Comment #12
reinchekGreat! thank you!