oroinc / platform

Main OroPlatform package with core functionality.
MIT License
629 stars 351 forks source link

BUG: action_configuration not Working #856

Open mary2501 opened 6 years ago

mary2501 commented 6 years ago

I added in my datagrid configuration the following lines to disable some actions added automatically by ORO when using the User class

datagrids.yml
.... 
       action_configuration:
                enableUser: false
                resetPassword: false
                disableUser: false

but it's not working.

I finally have find a solution adding the following lines in actions.yml to disable some actions written in oro/platform/src/Oro/Bundle/UserBundle/Resources/config/oro/actions.yml

operations:
    reset_password:
        exclude_datagrids:
            - my_datagrid_name
    user_enable:
        exclude_datagrids:
            - my_datagrid_name
    user_disable:
        exclude_datagrids:
            - my_datagrid_name
manowark commented 6 years ago

Hello,

datagrids.yml
.... 
       action_configuration:
                enable_user: false
                reset_password: false
                disable_user: false

works.

mary2501 commented 6 years ago

Thank you @manowark, I tried also this solution but it's not working. Has worked for you?

manowark commented 6 years ago

For which grid you trying this? For users-grid? For this grid used Oro\Bundle\UserBundle\Datagrid\ActionChecker which returns array like above. Maybe you need to change it?

mary2501 commented 6 years ago

I have created a my personal user-grid like this

datagrids:
    my-grid:
        source:
            type: orm
            query:
                select:
                    - u.id
                    - u.email
                    - u.firstName
                    - u.lastName
                    - >
                        (CASE WHEN (:client IS NOT NULL) THEN
                          CASE WHEN u.id IN (:data_in) AND u.id NOT IN (:data_not_in)
                          THEN true ELSE false END
                        ELSE
                          CASE WHEN u.id IN (:data_in) AND u.id NOT IN (:data_not_in)
                          THEN true ELSE false END
                        END) as hasProperty
                from:
                    - { table: Oro\Bundle\UserBundle\Entity\User, alias: u }
            bind_parameters:
                -
                    name: client
                    default: null
        columns:
            hasProperty:
                label:  hasProperty
                editable: true
                frontend_type: boolean
            firstName:
                label:  firstName
            lastName:
                label: lastName
            email:
                label: email
            id:
                renderable: false
        properties:
            id: ~
        sorters:
            columns:
                hasProperty: { data_name: hasProperty }
            default:
                hasProperty: DESC
        options:
            routerEnabled: false
            rowSelection:
                dataField: id
                columnName: hasProperty
                selectors:
                    included: '#append'
                    excluded: '#remove'
manowark commented 6 years ago

Where is it displayed? I mean page, route, for which entity?

mary2501 commented 6 years ago

In a widget.. Has a same behaviour when click add contacts in this url: https://demo.orocrm.com/desktop/account/update/42?grid[accountsgrid]=i%3D1%26p%3D25%26s%255Bname%255D%3D-1%26c%3Did0.name1.contactName1.contactEmail1.contactPhone1.ownerName1.createdAt1.updatedAt1.tags1%26v%3D__all__%26a%3Dgrid

But when click 'add', ORO add the red areas

pasted_image_at_2018-08-01__3_57_pm

manowark commented 6 years ago

Now I understand. For your case action_configuration not enough. This three operations configured as mass_action for datagrid and in 2.6 version (I think it is your version) have next configuration: https://github.com/oroinc/platform/blob/2.6/src/Oro/Bundle/UserBundle/Resources/config/oro/actions.yml#L181-L182. It is already fixed in master branch. So, I think, your first solution is the most correct for 2.6 version of application.

Just add to Acme/Bundle/YourCustomBundle/Resources/config/oro/actions.yml

operations:
    reset_password:
        exclude_datagrids:
            - my_datagrid_name
    user_enable:
        exclude_datagrids:
            - my_datagrid_name
    user_disable:
        exclude_datagrids:
            - my_datagrid_name