Article

How to show action “Set access right” only for some roles

  • Add new operation permission “CanManageAccessRight” and add roles who have access.

     
  • Create replacing client module for "Section base schema":

     

BaseSectionV2 schema code

define("BaseSectionV2", [], function() {
    return {
        attributes: {
            "CanManageAccessRight": {
                dataValueType: this.Terrasoft.DataValueType.BOOLEAN
            }
        },
        messages: {
            "UpdateCanManageAccessRight": {
                "mode": Terrasoft.MessageMode.PTP,
                "direction": Terrasoft.MessageDirectionType.SUBSCRIBE
            }
        },
        methods: {
            subscribeSandboxEvents: function() {
                this.callParent(arguments);
                this.sandbox.subscribe("UpdateCanManageAccessRight", function(result) {
                    this.set("CanManageAccessRight", result);
                }, this, [this.getCardModuleSandboxId()]);
            },
            getSchemaAdministratedByRecords: function() {
                return this.callParent(arguments) && this.get("CanManageAccessRight");
            }
        }
    };
});
  • Create replacing client module for "Base card schema":

     

BasePageV2 schema code

define("BasePageV2", ["RightUtilities"], function(RightUtilities) {
    return {
        attributes: {
            "CanManageAccessRight": {
                dataValueType: this.Terrasoft.DataValueType.BOOLEAN
            }
        },
        messages: {
            "UpdateCanManageAccessRight": {
                "mode": Terrasoft.MessageMode.PTP,
                "direction": Terrasoft.MessageDirectionType.BIDIRECTIONAL
            }
        },
        methods: {
            init: function() {
                this.callParent(arguments);
                this.checkCanManageAccessRight();
            },
            checkCanManageAccessRight: function() {
                RightUtilities.checkCanExecuteOperation({operation: "CanManageAccessRight"}, function(result) {
                    this.set("CanManageAccessRight", result);
                    this.sandbox.publish("UpdateCanManageAccessRight", result, [this.sandbox.id]);
                }, this);
            },
            subscribeSandboxEvents: function() {
                this.callParent(arguments);
                this.sandbox.subscribe("UpdateCanManageAccessRight", function() {
                    return this.get("CanManageAccessRight");
                }, this, this.getDetailIds());
            },
            getSchemaAdministratedByRecords: function() {
                return this.callParent(arguments) && this.get("CanManageAccessRight");
            }
        }
    };
});
  • Create replacing client module for "Base schema - Detail with list":

     

BaseGridDetailV2 schema code

define("BaseGridDetailV2", [], function() {
    return {
        attributes: {
            "CanManageAccessRight": {
                dataValueType: this.Terrasoft.DataValueType.BOOLEAN
            }
        },
        messages: {
            "UpdateCanManageAccessRight": {
                "mode": Terrasoft.MessageMode.PTP,
                "direction": Terrasoft.MessageDirectionType.PUBLISH
            }
        },
        methods: {
            init: function() {
                this.callParent(arguments);
                var canManageAccessRight = this.sandbox.publish("UpdateCanManageAccessRight", null, [this.sandbox.id]);
                this.set("CanManageAccessRight", canManageAccessRight);
            },
            getSchemaAdministratedByRecords: function() {
                return this.callParent(arguments) && this.get("CanManageAccessRight");
            }
        }
    };
});

 

Like 5

Like

Share

0 comments
Show all comments