Hide fields if not group admin in -dv.js

This sub-forum is for discussing all topics related to AppGini Helper JavaScript Library, provided by bizzworxx as a third-party AppGini plugin.
dharbitindy
Veteran Member
Posts: 101
Joined: 2019-05-26 18:38

Re: Hide fields if not group admin in -dv.js

Post by dharbitindy » 2022-01-17 19:35

dharbitindy wrote:
2022-01-17 17:15
jsetzer wrote:
2022-01-17 16:59

Code: Select all

if (memberID != 'admin' && memberID != 'batman') {
    // ...
}
Awesome Jan!

Thanks again,
David
Hi Jan,

I hate to keep bugging you on this but the only memberID that this works for in my case is 'admin'. I can get the others to work only if I use their individual member ID's. The Group isn't working even though those individuals are in the groups specified? This below is what I have which does work for the individual members, but would rather do this by group if possible.

var dv = AppGiniHelper.dv;

AppGiniHelper.getMemberID(function(memberID) {

if (memberID != 'admin' && memberID != 'jharbit' && memberID != 'mlemerick' && memberID != 'mleagre') {
dv.getFields(["price_lb", "markup_percent", "price_total"]).hide();
}});

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1891
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide fields if not group admin in -dv.js

Post by jsetzer » 2022-01-17 20:34

As I have said above, AppGini, by default, does only provide functions for getting username, not group name.

If you want to check other than username, this will not work with built-in functions.

If you want to check group name, you will have to pass this data from server to client somehow. See my full explanation and working solution above.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.14 Revision 1665 + all AppGini Helper tools

dharbitindy
Veteran Member
Posts: 101
Joined: 2019-05-26 18:38

Re: Hide fields if not group admin in -dv.js

Post by dharbitindy » 2022-01-17 20:44

My apologies for missing that Jan,

Thanks,
David

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1891
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide fields if not group admin in -dv.js

Post by jsetzer » 2022-01-17 21:43

No prob.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.14 Revision 1665 + all AppGini Helper tools

azhar
Posts: 21
Joined: 2023-11-19 17:19

Re: Hide fields if not group admin in -dv.js

Post by azhar » 2023-12-10 16:50

jsetzer wrote:
2022-01-17 07:37
Good morning David!

(2) hiding columns of TV using AppGini Helper Javascript Library

Single column

Code: Select all

// file: hooks/TABLENAME-tv.js
jQuery(document).ready(function () {
    AppGiniHelper.TV.hide("columnname")
});
Multiple columns

Code: Select all

// file: hooks/TABLENAME-tv.js
jQuery(document).ready(function () {
    AppGiniHelper.TV.hide(["columnname_1", "columnname_2", "columnname_x"])
});
Hi Jan,

Can we hide the columns based on member group? same as dv fields..

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1891
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide fields if not group admin in -dv.js

Post by jsetzer » 2023-12-10 17:41

Sure.

Your only challenge is: get to know the user's group.

AG does not provide that information on client side. Only for username, not for group.

You will have to implement that by yourself (pass the groupName or groupID from PHP to Javascript OR retrieve it from your own API script for example via AJAX).
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.14 Revision 1665 + all AppGini Helper tools

azhar
Posts: 21
Joined: 2023-11-19 17:19

Re: Hide fields if not group admin in -dv.js

Post by azhar » 2023-12-10 18:59

jsetzer wrote:
2023-12-10 17:41
Sure.

Your only challenge is: get to know the user's group.

AG does not provide that information on client side. Only for username, not for group.

You will have to implement that by yourself (pass the groupName or groupID from PHP to Javascript OR retrieve it from your own API script for example via AJAX).
Jan, I tried the steps from the blog post by Ahmed, and it worked, but there were too many edits, unlike AGH, where a single line of code is enough. So, I was wondering if it would be possible to achieve this like the DV edits. I only want specific TV columns to be hidden for everyone except admins..

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1891
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Hide fields if not group admin in -dv.js

Post by jsetzer » 2023-12-10 19:18

The JAVASCRIPT library can only provide client side functionality (browser). It can not provide server side functionality for technical reasons. It is just not possible.

For additional server side functionality you need an additional PHP Script, for example.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.14 Revision 1665 + all AppGini Helper tools

azhar
Posts: 21
Joined: 2023-11-19 17:19

Re: Hide fields if not group admin in -dv.js

Post by azhar » 2023-12-10 19:20

jsetzer wrote:
2023-12-10 19:18
The JAVASCRIPT library can only provide client side functionality (browser). It can not provide server side functionality for technical reasons. It is just not possible.

For additional server side functionality you need an additional PHP Script, for example.
Thank you for the clarification Jan.. :D

Post Reply