Hide functionality on a page
Hide a functionality at the development stage
@creatio-devkit/common
includes the FeatureService
service to check the feature status.
Detailed example: Hide a functionality at the development stage on a page.
To hide a functionality at the development stage:
-
If needed, add a component that contains the functionality at the development stage. Instructions: Element setup examples (user documentation).
-
Add the dependencies. Instructions: Display the value of a system variable (similarly to step 2). Instead of the
SysValuesService
service, use theFeatureService
service that checks the feature status. -
Add an attribute. Instructions: Set up the field display condition (step 2).
-
Bind an attribute to the component. Instructions: Set up the field display condition (step 3).
-
Implement the base request handler.
-
Go to the
handlers
schema section. -
Add a custom implementation of the
crt.HandleViewModelInitRequest
base request handler.- Create an instance of the service that checks the feature status from
@creatio-devkit/common
. - Retrieve the status of the feature that has the corresponding code and specify the status in the corresponding attribute.
- Create an instance of the service that checks the feature status from
View an example of a
crt.HandleViewModelInitRequest
request handler that retrieves the status of the feature that has theSomeFeatureCode
code and specify the status in theSomeAttribute
attribute, below.handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "crt.HandleViewModelInitRequest",
/* Custom implementation of a system request handler. */
handler: async (request, next) => {
/* Create an instance of the service that checks the feature status from "@creatio-devkit/common." */
const featureService = new sdk.FeatureService();
/* Retrieve the status of the feature that has the "SomeFeatureCode" code and specify the status in the "IsFeatureDeveloped" attribute. */
request.$context.IsFeatureDeveloped = await featureService.getFeatureState('SomeFeatureCode');
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
}
}
]/**SCHEMA_HANDLERS*/, -
Hide a functionality behind access permissions
@creatio-devkit/common
includes the RightsService
service to check access permissions.
Detailed example: Hide the functionality on a page behind access permissions.
To hide a functionality behind access permissions:
-
If needed, add a component that contains the functionality that requires access permissions. Instructions: Element setup examples (user documentation).
-
Add the dependencies. Instructions: Display the value of a system variable (similarly to step 2). Instead of the
SysValuesService
service, use theRightsService
service that checks access permissions. -
Add an attribute. Instructions: Set up the field display condition (step 2).
-
Bind an attribute to the component. Instructions: Set up the field display condition (step 3).
-
Implement the base request handler.
-
Go to the
handlers
schema section. -
Add a custom implementation of the
crt.HandleViewModelInitRequest
base request handler.- Create an instance of the service that checks access permissions from
@creatio-devkit/common
. - Retrieve data about the user's access permission to the corresponding system operation.
- Specify the data about the user's access permission in the corresponding attribute.
- Create an instance of the service that checks access permissions from
View an example of a
crt.HandleViewModelInitRequest
request handler that retrieves data about the user's access permission to theSomeOperation
system operation and specify it in theSomeAttribute
attribute, below.handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "crt.HandleViewModelInitRequest",
/* Custom implementation of a system request handler. */
handler: async (request, next) => {
/* Create an instance of the service that checks access permissions from "@creatio-devkit/common." */
const rightService = new sdk.RightsService();
/* Retrieve data about the user's access permission to the "SomeOperation" system operation. */
const someVariable = await rightService.getCanExecuteOperation('SomeOperation');
/* Specify data about the user's access permission in the "SomeAttribute" attribute. */
request.$context.SomeAttribute = someVariable;
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
}
}
]/**SCHEMA_HANDLERS*/, -
See also
Element setup examples (user documentation)