Hide a menu button? #306
Replies: 16 comments 1 reply
-
Hi Dean,
Yes it is.
You can use _cls to add class ktlDisplayNone, combined with ktlRoles and
ktlTarget to target your button. Something like:
_cls=[ktlDisplayNone], [ktlRoles !Bulk Edit], [ktlTarget, $(‘#${viewId}
li:contains(“button text”))’]
Let me know how you get on.
Amanda
…On Fri, 28 Jun 2024 at 06:24, Deanobeano2 ***@***.***> wrote:
Hi
Is it possible to hide/display a menu button based on a User Role?
We have a menu button linking to a Bulk Operations page which we like to
hide from view, or display only for Bulk Edit users.
Dean
—
Reply to this email directly, view it on GitHub
<#306>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATAWKK37TYHM6XKJJRFHVU3ZJTXQ5AVCNFSM6AAAAABKBFJPDOVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZWHA3TEMJSGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi Dean,
Could you send your keyword please?
Amanda
…On Sat, 29 Jun 2024 at 04:09, Deanobeano2 ***@***.***> wrote:
Amanda
Thank you for providing that so promptly.
That seems to hide the whole menu, of 3 buttons, for users irrespective of
the Bulk Edit role.
I'm trying to hide just the 1 menu button containing Bulk Operations.
image.png (view on web)
<https://github.com/cortexrd/Knack-Toolkit-Library/assets/130625963/dfed3ae9-ab52-4c80-aca8-79ff0f51acf8>
Dean
—
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATAWKK7PPAN2WDQU2F2DRDDZJYQNFAVCNFSM6AAAAABKBFJPDOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TSMBZHE4TK>
.
You are receiving this because you commented.Message ID:
<cortexrd/Knack-Toolkit-Library/repo-discussions/306/comments/9909995@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Hi Amanda Never having used the keyword _cls before, I used the solution you provided and tried my view# etc and iterations of this _cls=[ktlDisplayNone], [ktlRoles !Bulk Edit], [ktlTarget, Sadly, everything I tried, not really knowing what I was doing, ended up with the same result of hiding the entire menu rather than the 1 button I would like to hide. Dean |
Beta Was this translation helpful? Give feedback.
-
Hi Dean,
I see the problem, I should have explained the parameters better. The
viewId in {viewId} is a variable that will pull in the id of the view your
keyword is on, so #${viewId} becomes #view_xyz. This is useful if you're
copying keywords to other views as it means you don't have to keep changing
the view ID, the KTL will do that for you.
As long as your KTL is reasonably up to date using ${viewId} should work,
if not use #view_1109 with no {}.
Try:
_cls=[ktlDisplayNone], [ktlRoles !Bulk Edit], [ktlTarget, $(‘#${viewId}
.menu-links__list-item:contains("Bulk Operations")')]
Or:
_cls=[ktlDisplayNone], [ktlRoles !Bulk Edit], [ktlTarget, $(‘#view_1109
.menu-links__list-item:contains("Bulk Operations")')]
This is what I use to hide Knack menu button, should work 🤞🏻
Amanda
…On Sat, 29 Jun 2024 at 10:03, Deanobeano2 ***@***.***> wrote:
Hi Amanda
Never having used the keyword _cls before, I used the solution you
provided and tried my view# etc and iterations of this
_cls=[ktlDisplayNone], [ktlRoles !Bulk Edit], [ktlTarget, $(‘#$
{#view_1109}
li:contains(“Bulk Operations”))’]
Sadly, everything I tried, not really knowing what I was doing, ended up
with the same result of hiding the entire menu rather than the 1 button I
would like to hide.
Dean
—
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATAWKKYKXXZKF3A2JBARBA3ZJZZ7BAVCNFSM6AAAAABKBFJPDOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TSMJRGA4TM>
.
You are receiving this because you commented.Message ID:
<cortexrd/Knack-Toolkit-Library/repo-discussions/306/comments/9911096@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Hi Amanda Both options still result in the entire menu being hidden irrespective of the User Role being Bulk Edit or not. Dean |
Beta Was this translation helpful? Give feedback.
-
Hi Dean,
Looks like there's an issue with the ktlTarget which is leading to the
whole view being hidden. Could you tell me what version of ktl you're using
and send me your latest _cls.
Could you also inspect your menu (press f12, then ctrl shift c or cmd shift
c on mac) and send me a screenshot of the html structure of your menu? Mine
looks like this:
[image: Screen Shot 2024-07-01 at 11.53.50.png]
Maybe worth trying it without the ktlRoles and see if that makes any
difference.
Thanks
Amanda
…On Sat, 29 Jun 2024 at 11:01, Deanobeano2 ***@***.***> wrote:
Hi Amanda
Both options still result in the entire menu being hidden irrespective of
the User Role being Bulk Edit or not.
Dean
—
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATAWKK3PWDN5AFKLOPBW2ELZJ2AYXAVCNFSM6AAAAABKBFJPDOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TSMJRGI3TQ>
.
You are receiving this because you commented.Message ID:
<cortexrd/Knack-Toolkit-Library/repo-discussions/306/comments/9911278@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Hi Amanda We're running the latest V0.27.0. I've currently removed the _cls so that we can see the menu for day to day use and I did try removing the ktlRoles but that also seemed to make no difference. Dean |
Beta Was this translation helpful? Give feedback.
-
Hi Amanda Sorry, you probably wanted this information. Dean |
Beta Was this translation helpful? Give feedback.
-
Hi Dean,
Having further inspected the ktlTarget I found an erant inverted comma (one
of them was different from the others and therefore didn't form a pair).
This meant the ktlTarget wasn't valid and therefore the whole view was
hidden, as if there was no target at all. Try this:
_cls=[ktlDisplayNone], [ktlRoles !Bulk Edit], [ktlTarget, $('#${viewId} .menu-links__list-item:contains("Bulk Operations")')]
Or
_cls=[ktlDisplayNone], [ktlRoles !Bulk Edit], [ktlTarget, $('#view_1109 .menu-links__list-item:contains("Bulk Operations")')]
I'm pretty confident this will now work, if not we may have to have a quick
zoom.
Amanda
…On Mon, 1 Jul 2024 at 21:32, Deanobeano2 ***@***.***> wrote:
Hi Amanda
Sorry, you probably wanted this information.
image.png (view on web)
<https://github.com/cortexrd/Knack-Toolkit-Library/assets/130625963/400c72f1-128e-41bd-83d8-296dc44a493c>
Dean
—
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATAWKK7FZD6Y4BHSPVFAF3LZKG4FRAVCNFSM6AAAAABKBFJPDOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TSMRZGYZTQ>
.
You are receiving this because you commented.Message ID:
<cortexrd/Knack-Toolkit-Library/repo-discussions/306/comments/9929638@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Try this _cls=[ktlHidden], [ktlRoles !Bulk Edit], [ktlTarget, $('#view_1109> div > nav > ul > li:nth-child(3)')] |
Beta Was this translation helpful? Give feedback.
-
Hi guys, @Greenlight88 solution should work. This will hide any button based on its text content:
It's safer than using the child index because it's independent of the button position. If you move it around, it will still work. About ktlHidden vs ktlDisplayNone: both should work and make no difference, in this case. Norm |
Beta Was this translation helpful? Give feedback.
-
Hi All Thank you, @Greenlight88 that solution worked. Norm, thank you for explaining the differences between the 2 solutions. Dean |
Beta Was this translation helpful? Give feedback.
-
Hi Sorry, but in my excitement that we'd achieved the result of hiding the menu button I realized that it isn't taking into account the Bulk Edit role and hides the button for all users. I've tried [ktlRoles !Bulk Edit] and [ktlRoles, !Bulk Edit] and moving the position of this parameter but it makes no difference. Does anyone have any thoughts on why this might be happening? I've double-checked 2 other users accounts and when the button is present for them and they click through to the bulk operations page, which we don't want them to be able to do, they can't perform any bulk operations. Dean |
Beta Was this translation helpful? Give feedback.
-
Or better if you can: create a dummy test page for me to test, with a few records and the button and the keyword. |
Beta Was this translation helpful? Give feedback.
-
Solved by Norm. Make sure to follow "//Your App-specific code goes here..." |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
Is it possible to hide/display a menu button based on a User Role?
We have a menu button linking to a Bulk Operations page which we like to hide from view, or display only for Bulk Edit users.
Dean
Beta Was this translation helpful? Give feedback.
All reactions