Hi Community,
Any idea how I can hide the Actions and Tag button in section. I want to hide these buttons based on Curent user role
Like
Hello Fulgen,
To check user rights you can use esq. For example:
getUserRights: function() {
var scope = this;
var currentUser = Terrasoft.SysValue.CURRENT_USER.value;
var sysAdmins = ConfigurationConstants.SysAdminUnit.Id.SysAdministrators;
var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "SysUserInRole" });
esq.addColumn("SysRole");
esq.addColumn("SysUser");
esq.filters.add("SysUser", Terrasoft.createColumnFilterWithParameter(
Terrasoft.ComparisonType.EQUAL, "SysUser", currentUser));
esq.filters.add("SysRole", Terrasoft.createColumnFilterWithParameter(
Terrasoft.ComparisonType.EQUAL, "SysRole", sysAdmins));
esq.getEntityCollection(function(response) {
if (response && response.success) {
var result = response.collection;
var isSysAdmin = (result.collection.length !== 0);
scope.set("isSysAdmin", isSysAdmin);
}
scope.loadMenu();
}, this);
},
"isSysAdmin": {
"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
"dataValueType": Terrasoft.DataValueType.BOOLEAN,
"value": false
},
Actions button is located in BaseSectionV2 schema. You can hide it by overriding the element in the desired schema. For example here I hid it in AccountSectionV2: define("AccountSectionV2", [], function() {
return {
entitySchemaName: "Account",
details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
diff: /**SCHEMA_DIFF*/[
{
"operation": "merge",
"name": "SeparateModeActionsButton",
"values": {
"visible": false
}
}]/**SCHEMA_DIFF*/,
methods: {}
};
});
Tag button is added in QuickFilterV2 schema. To remove it, you should debug the schema that I mentioned to understand how this button is added. Basically, you may simply remove rights on the tag object, so users will be unable to choose tags when click on the tag button.
Regards,
Alex
Alex_Tim,
Hi Alex thanks for your reply, how about hiding Actions button in edit page?
Fulgen Ninofranco,
Here is an example:
define("AccountPageV2", [], function() {
return {
entitySchemaName: "Account",
attributes: {},
modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
methods: {},
dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,
diff: /**SCHEMA_DIFF*/[
{
"operation":"merge",
"name":"actions",
"values": {
"visible": false
}
}]/**SCHEMA_DIFF*/
};
});