I want to show or hide some form fields based on a condition from a master/detail relation.
I've searched for some enable() or hide() methods in "form.FieldName" bot could not get it.
Have a look around in samples.
In your xyzDialog
this.form.YourField.element.hide();
@Estrusco thanks for the tip. But this only hides the Input and in case of a lookupeditor the real input is already hidden and the select remains.
Sinde we cannot set permissions on fields I wanted to hide the field in case the user has not a specific permission.
I was thinking about changing the visibility of <div class="field MyField">? is this ok?
this.form.YourField.getGridField().toggle(false)
Thanks again @volkanceylan
@rgilsimoes pls could you kindly share your code on how toggled fields based on permission? It is something that I'm also trying to accomplish.
Many thanks.
Sure:
In XYZDialog.ts you add this method:
``` c#
afterLoadEntity() {
super.afterLoadEntity();
if (!SIINv2.Authorization.hasPermission("Admin:TipoUser:Nucleo")) {
this.form.UserId.getGridField().toggle(false);
this.form.IdEntidade.getGridField().toggle(false);
}
}
```
To register the "Admin:TipoUser:Nucleo" permission you have to place this:
[assembly: Serenity.ComponentModel.RegisterPermissionKey("Admin:TipoUser:Nucleo")]
Anywhere in our code.
Thank you for this.
I’ve amended as such..
dialog
afterLoadEntity() {
super.afterLoadEntity();
if (serene.Authorization.hasPermission("ActiveDirectoryDomain\team-deskside-ldn")) {
this.form.Permanent.getGridField().toggle(false);
this.form.DateRemove.getGridField().toggle(false);
}
}
row
[assembly: Serenity.ComponentModel.RegisterPermissionKey("ActiveDirectoryDomain\team-deskside-ldn")]
This works in the sense that both fields do not appear even for users in team-deskside-ldn Active Directory group.
I can only assume serenity can’t see the AD group membership for users in a dialog via typescript because AD groups do work via row.cs as below
using System.ComponentModel;
using System.IO;
[ConnectionKey("desksidedb"), DisplayName("RebootWeekendExclude"), InstanceName("RebootWeekendExclude"), TwoLevelCached]
[ModifyPermission(@"NT AUTHORITY\Authenticated Users, ActiveDirectoryDomain\team-deskside-ldn")]
[DeletePermission(@"ActiveDirectoryDomain \test-group-ldn")]
public sealed class RebootWeekendExcludeRow : Row, IIdRow, INameRow
any suggestions as our company mandates we use AD for permissions.
From: rgilsimoes [mailto:[email protected]]
Sent: 26 September 2016 09:43
To: volkanceylan/Serenity
Cc: Belal, Abu; Comment
Subject: Re: [volkanceylan/Serenity] Hide/show fields based on condition (#1221)
Importance: High
Sure:
In XYZDialog.ts you add this method:
afterLoadEntity() {
super.afterLoadEntity();
if (!SIINv2.Authorization.hasPermission("Admin:TipoUser:Nucleo")) {
this.form.UserId.getGridField().toggle(false);
this.form.IdEntidade.getGridField().toggle(false);
}
}
To register the "Admin:TipoUser:Nucleo" permission you have to place this:
[assembly: Serenity.ComponentModel.RegisterPermissionKey("Admin:TipoUser:Nucleo")]
Anywhere in our code.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/volkanceylan/Serenity/issues/1221#issuecomment-249512454, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ATmzwEpcgzIEybzvbq2ZbFCODOGy3-hIks5qt4WsgaJpZM4KC9uz.
This email, the information therein and any attached materials (collectively the "Email") are intended only for the addressee(s) and may contain confidential, proprietary, copyrighted and/or privileged material. If you have received this Email in error please delete it and notify the sender immediately. This Email remains the property of Brevan Howard, which reserves the right to require its return (together with any copies or extracts thereof) at any time upon request. Any unauthorised review, retransmission, dissemination, forwarding, printing, copying or other use of this Email is prohibited. Brevan Howard may be legally required to review and retain outgoing and incoming email and produce it to regulatory authorities and others with legal rights to the information. Internet communications cannot be guaranteed to be secure or error free as information could be intercepted, changed corrupted, lost, arrive late or contain viruses. Brevan Howard accepts no liability for any errors or omissions in this Email which arise as a result of internet transmission. This Email is not an official confirmation of any transaction. Any comments or statements made herein do not necessarily reflect the views of Brevan Howard.
This Email is not an offer to sell or solicitation of an offer to buy any security or investment. It does not constitute or contain any investment advice and is being made without regard to the recipients investment objectives, financial situation or means. Past Performance is not an indicator of future results and Brevan Howard provides no assurance that future results will be consistent with any information provided herein or attached hereto. Brevan Howard and the sender make no warranties regarding the accuracy or completeness of the information in this Email and it should not be relied upon and is subject to change without notice. Brevan Howard and its representatives, officers and employees accept no responsibility for any losses suffered as a result of reliance on the information in this Email or the reliability, accuracy, or completeness thereof.
In this Email, "Brevan Howard" means Brevan Howard Asset Management LLP ("BHAM"), Brevan Howard Inc., Brevan Howard (Israel) Ltd and their respective affiliates. BHAM is a limited liability partnership authorised and regulated by the Financial Conduct Authority of the United Kingdom and registered in England & Wales (reg. no. OC302636).
Sorry, I'm using Serene permissions :-(
OK, there must be a way to hide GUI elements from server side as opposed to client side, in this way I can do it directly on the .cs file.
From: rgilsimoes [mailto:[email protected]]
Sent: 26 September 2016 10:20
To: volkanceylan/Serenity
Cc: Belal, Abu; Comment
Subject: Re: [volkanceylan/Serenity] Hide/show fields based on condition (#1221)
Importance: High
Sorry, I'm using Serene permissions :-(
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/volkanceylan/Serenity/issues/1221#issuecomment-249520437, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ATmzwAIfZ7kGAvcBmL59fk3ZMr4077bWks5qt45WgaJpZM4KC9uz.
This email, the information therein and any attached materials (collectively the "Email") are intended only for the addressee(s) and may contain confidential, proprietary, copyrighted and/or privileged material. If you have received this Email in error please delete it and notify the sender immediately. This Email remains the property of Brevan Howard, which reserves the right to require its return (together with any copies or extracts thereof) at any time upon request. Any unauthorised review, retransmission, dissemination, forwarding, printing, copying or other use of this Email is prohibited. Brevan Howard may be legally required to review and retain outgoing and incoming email and produce it to regulatory authorities and others with legal rights to the information. Internet communications cannot be guaranteed to be secure or error free as information could be intercepted, changed corrupted, lost, arrive late or contain viruses. Brevan Howard accepts no liability for any errors or omissions in this Email which arise as a result of internet transmission. This Email is not an official confirmation of any transaction. Any comments or statements made herein do not necessarily reflect the views of Brevan Howard.
This Email is not an offer to sell or solicitation of an offer to buy any security or investment. It does not constitute or contain any investment advice and is being made without regard to the recipients investment objectives, financial situation or means. Past Performance is not an indicator of future results and Brevan Howard provides no assurance that future results will be consistent with any information provided herein or attached hereto. Brevan Howard and the sender make no warranties regarding the accuracy or completeness of the information in this Email and it should not be relied upon and is subject to change without notice. Brevan Howard and its representatives, officers and employees accept no responsibility for any losses suffered as a result of reliance on the information in this Email or the reliability, accuracy, or completeness thereof.
In this Email, "Brevan Howard" means Brevan Howard Asset Management LLP ("BHAM"), Brevan Howard Inc., Brevan Howard (Israel) Ltd and their respective affiliates. BHAM is a limited liability partnership authorised and regulated by the Financial Conduct Authority of the United Kingdom and registered in England & Wales (reg. no. OC302636).
Well that is what I wanted in the first place with issue #1220.
For now I can live with just hidding the fields.