It can set the whole brixxbox app or some controls depending upon the use case which is required, in a readonly mode. All Input fields, save- new- and delete toolbar buttons are disabled.
In Brixxbox, we have certain types of users like system users those who build the system, users those who will use the system, and admins, they will manage the systems etc. Each user should have different access to the system. It means all acess rights should only be given to admin users. Lets suppose we have an orders app and recorded orders. System users should only be allowed to fetch and check orders while on the other hand admins shouls also be allowed to edit orders and make changes to them. This is this brixxApi readOnlyMode function comes into play.
This code sets the whole app to read only mode. All the input controls and even the toolbar button get disabled.
readOnlyMode function can be used with or without options. Following are the optional parameters:
- 1.readOnly - (bool, default = true) This indicates if the readOnly mode is enabled (true) or disabled (false). If it is set to true or without options, it disables the whole app. If set to false, the app starts to behave normally. Every control and each toolbar button is enabled.
- 2.options - It is a JSON object which can be passed as an additional options.
- exclude - It is an array of controlIds that should be excluded from the disable functionality of readOnlyMode function.
We can use this "readOnlyMode" function with or without options. Lets see both of them in action.
To disable each and every control and toolbar buttons use this function without any options like
brixxApi.readOnlyMode(); // This will set app in readOnly Mode.
brixxApi.readOnlyMode(true); // This will also set complete app in readOnly Mode.
In order to enable all the controls, set the readOnlyMode function with false value of readOnly parameter. It will enable back all the controls and the app will start behaving normally.
brixxApi.readOnlyMode(false); // sets back to normal Mode.
Now if we dont want to use default functionality of disabling or enabling the whole app, we can usereadOnlyMode options to enable or disable some of the controls. Lets say we want to disable 2 controls from an app then we have to pass the name sof these controls in exclude option array like
exclude: ["myFrstControl", "mySecondControl"]
Lets say we have address app and we want to disable all of it. It can be done in different ways. For a moment, lets stick to "appInitialized" event. Add this function as a custom code of "appInitialized" event and save the app. It will look like this
As we can see each control as well as app toolbar is also disabled.