[英]How can I disable button in backoffice when make action with another button - HYBRIS?
在您的操作类(实现CockpitAction
)中,您必须覆盖canPerform
方法以根据您的业务逻辑返回真/假。
例如,您可以参考客户的启用/禁用操作如何工作 OOTB。
在b2bcommercebackoffice-backoffice-config.xml
你可以找到
<context merge-by="module" type="B2BCustomer" component="editorareaactions">
<y:actions xmlns:y="http://www.hybris.com/cockpit/config/hybris">
<y:group qualifier="common">
<y:label>actiongroup.common</y:label>
<y:action action-id="de.hybris.platform.b2bcommerce.backoffice.actions.disableb2bcustomeraction" property="currentObject"/>
<y:action action-id="de.hybris.platform.b2bcommerce.backoffice.actions.enableb2bcustomeraction" property="currentObject"/>
</y:group>
</y:actions>
</context>
现在参考disableb2bcustomeraction或enableb2bcustomeraction类是如何实现canPerform方法的。
例如
public boolean canPerform(ActionContext<B2BCustomerModel> ctx) {
Object data = ctx.getData();
if (data != null && data instanceof B2BCustomerModel) {
B2BCustomerModel b2bCustomerModel = (B2BCustomerModel) data;
UserModel currentUser = this.userService.getCurrentUser();
boolean isActive = b2bCustomerModel.getActive();
boolean isUserMemberOfAdminGroup = this.userService.isMemberOfGroup(currentUser,
this.userService.getAdminUserGroup());
boolean isUserMemberOfB2BAdminGroup = this.userService.isMemberOfGroup(currentUser,
this.userService.getUserGroupForUID("b2badmingroup"));
return (isUserMemberOfAdminGroup || isUserMemberOfB2BAdminGroup) && isActive;
} else {
return false;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.