gpt4 book ai didi

hybris - 如何根据用户角色在后台隐藏操作按钮?

转载 作者:行者123 更新时间:2023-12-04 10:57:22 25 4
gpt4 key购买 nike

如何根据用户在后台删除按钮操作?我可以通过在 中添加条件来禁用该按钮。 canPerform 像这样的方法

public boolean canPerform(final ActionContext<String> ctx)
{
final UserModel currentUser = userService.getCurrentUser();
final boolean isUserMemberOfGroup = this.userService.isMemberOfGroup(currentUser,"group_name");
return isUserMemberOfGroup;
}

但我想隐藏按钮而不是禁用它。

最佳答案

我希望你已经有一个自定义的后台扩展,如果没有,请关注 this tutorial创建一个。

现在,在 yourcustombackoffice-backoffice-config.xml 您可以申报 ListView 操作您的项目类型的组件以及您希望允许用户/组执行的操作。然后您需要将该用户的角色/组分配给主体属性。

例如,有两个后台角色“mainRole”和“otherRole”。 “mainRole”角色已分配给 X 用户,“otherRole”角色分配给 Y 用户。现在使用下面的后台配置,X 用户只能看到创建按钮,Y 用户只能看到删除按钮。

<contexttype="Media" component="listviewactions" principal="mainRole" module="hideActionB">

<y:actionsxmlns:y="http://www.hybris.com/cockpit/config/hybris"xmlns:advanced-search="http://www.hybris.com/cockpitng/config/advancedsearch"xmlns:df="http://www.hybris.com/cockpitng/component/dynamicForms"xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea"xmlns:explorer-tree="http://www.hybris.com/cockpitng/config/explorertree"xmlns:list-view="http://www.hybris.com/cockpitng/component/listView"xmlns:simple-search="http://www.hybris.com/cockpitng/config/simplesearch"xmlns:wz="http://www.hybris.com/cockpitng/config/wizard-config"xmlns:ysl="http://www.hybris.com/cockpitng/config/simplelist">

<y:group qualifier="common">

<y:label>actiongroup.common</y:label>

<y:action action-id="com.hybris.cockpitng.action.create" property="pageable.typeCode"/>

</y:group>

</y:actions>

</context>


<contexttype="Media" component="listviewactions" principal="otherRole" module="hideActionB">

<y:actionsxmlns:y="http://www.hybris.com/cockpit/config/hybris"xmlns:advanced-search="http://www.hybris.com/cockpitng/config/advancedsearch"xmlns:df="http://www.hybris.com/cockpitng/component/dynamicForms"xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea"xmlns:explorer-tree="http://www.hybris.com/cockpitng/config/explorertree"xmlns:list-view="http://www.hybris.com/cockpitng/component/listView"xmlns:simple-search="http://www.hybris.com/cockpitng/config/simplesearch"xmlns:wz="http://www.hybris.com/cockpitng/config/wizard-config"xmlns:ysl="http://www.hybris.com/cockpitng/config/simplelist">

<y:group qualifier="common">

<y:label>actiongroup.common</y:label>

<y:action action-id="com.hybris.cockpitng.action.delete" property="currentObject"/>

</y:group>

</y:actions>

</context>

</config>

查找更详细的步骤 here

关于hybris - 如何根据用户角色在后台隐藏操作按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59092842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com