cortexrd / Knack-Toolkit-Library

Knack Toolkit Library
MIT License
26 stars 6 forks source link

Question on _cls #267

Open kukuk52 opened 8 months ago

kukuk52 commented 8 months ago

I'd like to be able to hide specific rows in a grid based on the User Roles assigned in Knack. Each record in the grid contains a multiple choice field that has the options for the permissions. There's a hidden view that contains the User Roles of the logged-in user on the page. I tried the following but I'm not having any luck:_cls=[ktlDisplayNone],[ktlCond, hasnt, ktlRefVal, Permissions Level, view_2246],[ktlRefVal, field_37, view_2247]

I'm guessing this is just a user error issue. It may also be the case that this is better done with some conditionals and the ktlRoles keyword, but I couldn't figure that out either. Any help would be appreciated.

Thanks, Dan K

CSWinnall commented 8 months ago

Hi @kukuk52

I think you will need to use cfv for this along with ktlRoles.

Something like

_cfv=[Permissions Level, hasn't, ktlRefVal, , , ,ph], [ktlRefVal, field_37, view_2247]

you can also use ktlRoles i.e.

_cls=[ktlDisplayNone], [ktlRoles, user role 1, !user role 2]

But to use _cls you will need to use ktlTarget as well where as cfv you won't need the target.

Craig

kukuk52 commented 8 months ago

Thanks, Craig.

Using _cfv with ph those rows would still show up, but they would just display as blank, correct? Ideally, I'd like the rows to disappear completely.

cortexrd commented 8 months ago

Hi guys,

I'm not sure there's a way to do this currently.

I was thinking about adding a new option to _cfv: "s" for suppress record.

Example:

_cfv=[HideOnRole,hasnt,Admin,,,,s]

Will suppress the whole record from the grid or list view of the field HideOnRole (multiple choice) doesn't contain Admin.

Any thoughts on better ideas?

Norm

kukuk52 commented 8 months ago

Hi Norm,

Is it currently not possible using _cls and ktlDisplayNone?

I think "s" would be a nice addition. Allowing users to suppress and show records based on different criteria (not just user role) could be very helpful.

cortexrd commented 8 months ago

Dan,

_cls will apply the class to the current view (as a whole) by default. If you add ktlTarget, it will either be a jQuery or a field/view combination.

But in both cases, it won't do what you want because you need to apply the effect on a per-row basis (by record).

What we'd need is a new _cfv option as mentioned above, or a new option: [ktlRecord]. ktlRecord would mean for each record in this same view - grid, search or list.

I'm just trying to evaluate which one would solve the most problems.

Norm

CSWinnall commented 8 months ago

Hi Norm

I like the idea of ktlRecord but your "s" option would be the simpliest way to go as the functionality is there with cfv already.

How would ktlRecord work? Craig

cortexrd commented 8 months ago

Guy,

I've added the "s" option in _cfv to suppress the whole record from the grid and update the visible record count: "Showing 1-13 of 538".

Try it in Beta please and let me know if it works as expected.

Norm

kukuk52 commented 8 months ago

Great! This is working from my end. However, I do see that when records are grouped the group bar is still showing even if all associated records within that group are hidden. Is there anything that can be done about that? It's not a major issue, just something to be aware of.

On Wed, Mar 13, 2024 at 7:56 AM Cortex R&D Inc. @.***> wrote:

Closed #267 https://github.com/cortexrd/Knack-Toolkit-Library/issues/267 as completed.

— Reply to this email directly, view it on GitHub https://github.com/cortexrd/Knack-Toolkit-Library/issues/267#event-12102323117, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQJOGOIYUH6JO7Z6CYXJG3YYA5GRAVCNFSM6AAAAABEQSBUIWVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSGEYDEMZSGMYTCNY . You are receiving this because you were mentioned.Message ID: @.*** com>

-- Daniel J. Kukuk Data & Communications: AFT Michigan, AFL-CIO @.*** (248) 894-9899

kukuk52 commented 8 months ago

I may have spoken too soon. This is hiding a value but not based on the criteria I set. Currently, I'm using this: _cfv=[field_1777, hasnt, ktlRefVal, , , ,s], [ktlRefVal, field_37, view_2267]

In my test, a record that should be viewable is hidden and another that should be hidden is viewable.

On Wed, Mar 13, 2024 at 9:38 AM Daniel Kukuk @.***> wrote:

Great! This is working from my end. However, I do see that when records are grouped the group bar is still showing even if all associated records within that group are hidden. Is there anything that can be done about that? It's not a major issue, just something to be aware of.

On Wed, Mar 13, 2024 at 7:56 AM Cortex R&D Inc. @.***> wrote:

Closed #267 https://github.com/cortexrd/Knack-Toolkit-Library/issues/267 as completed.

— Reply to this email directly, view it on GitHub https://github.com/cortexrd/Knack-Toolkit-Library/issues/267#event-12102323117, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQJOGOIYUH6JO7Z6CYXJG3YYA5GRAVCNFSM6AAAAABEQSBUIWVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSGEYDEMZSGMYTCNY . You are receiving this because you were mentioned.Message ID: @.*** com>

-- Daniel J. Kukuk Data & Communications: AFT Michigan, AFL-CIO @.*** (248) 894-9899

-- Daniel J. Kukuk Data & Communications: AFT Michigan, AFL-CIO @.*** (248) 894-9899

cortexrd commented 7 months ago

Hey Dan,

Sorry for overlooking this issue. Negative logic gets confusing sometimes. Can you confirm you still have this bug please? I've fixed a few things related to this, so I'm not sure.

If you do, I'd like to access the page if possible.

Norm

kukuk52 commented 7 months ago

Hey Norm,

I think I found a workaround that works for us. However, the other issue is still a problem. With grouped records, the bar is still showing even if all associated records within that group are hidden. Is there anything that can be done about that?

Thanks,

On Fri, Apr 12, 2024 at 6:44 PM Cortex R&D Inc. @.***> wrote:

Reopened #267 https://github.com/cortexrd/Knack-Toolkit-Library/issues/267.

— Reply to this email directly, view it on GitHub https://github.com/cortexrd/Knack-Toolkit-Library/issues/267#event-12454829236, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQJOGJ2JPS6VOOCEB7RG2LY5BPULAVCNFSM6AAAAABEQSBUIWVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSGQ2TIOBSHEZDGNQ . You are receiving this because you were mentioned.Message ID: @.*** com>

-- Daniel J. Kukuk Data & Communications: AFT Michigan, AFL-CIO @.*** (248) 894-9899

cortexrd commented 7 months ago

Hi Daniel,

I've found an interesting solution. It solves your issue: empty groups are now removed, but also wrong summaries are fixed which were also affected by removed rows.

Give it a try in Beta please.

Norm

kukuk52 commented 7 months ago

Hey Norm,

Looks good. When there is a single grouping the groups no longer show. However, when there is more than a single grouping where you define a group position (1,2,3 . . . ), the higher levels will still show.

On Sun, Apr 21, 2024 at 8:50 AM Cortex R&D Inc. @.***> wrote:

Hi Daniel,

I've found an interesting solution. It solves your issue: empty groups are now removed, but also wrong summaries are fixed which were also affected by removed rows.

Give it a try in Beta please.

Norm

— Reply to this email directly, view it on GitHub https://github.com/cortexrd/Knack-Toolkit-Library/issues/267#issuecomment-2068032517, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQJOGOSLOWOBNNMRNWLRPLY6OYXVAVCNFSM6AAAAABEQSBUIWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRYGAZTENJRG4 . You are receiving this because you were mentioned.Message ID: @.***>

-- Daniel J. Kukuk Data & Communications: AFT Michigan, AFL-CIO @.*** (248) 894-9899

cortexrd commented 6 months ago

Dan,

Can you give me access to a page where I could see that and debug, please? It would save me some time to do a setup.

Norm

kukuk52 commented 6 months ago

Sure thing. Here's the page we're currently using: https://aftmi.knack.com/aftmi#my-resource-library/