繁体   English   中英

使用另一个按钮 - HYBRIS 进行操作时,如何禁用后台中的按钮?

[英]How can I disable button in backoffice when make action with another button - HYBRIS?

嗨,专家,当使用另一个按钮进行操作时,如何在后台禁用按钮操作?

例如,当我从店面创建订单然后在后台的订单选项卡中为当前订单创建订单时,我有 2 个操作按钮。 批准和拒绝。

在此处输入图片说明

当批准订单时,我仍然看到拒绝按钮。 批准后如何禁用此按钮?

在此处输入图片说明

在您的操作类(实现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>

现在参考disableb2bcustomeractionenableb2bcustomeraction类是如何实现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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM