codefog / contao-haste

Haste is a collection of tools and classes to ease working with Contao
http://codefog.pl/extension/haste.html
MIT License
43 stars 24 forks source link

ajax toggle permissions with exclude = false #77

Closed m-vo closed 8 years ago

m-vo commented 8 years ago

The ajax toggle operation ('eye on/off') is not shown in the backend for non-admins if the dca-column does not have exclude = true set and the field is explicitly allowed for the user/group.

Toflar commented 8 years ago

Hi, I don't really get the issue here. Can you explain a bit more or maybe even provide a pull request fixing the issue?

m-vo commented 8 years ago

Sure. :-)

I added that to my list/operations part in the dca:

[...]
'toggle' => array 
            (
                'label'               => &$GLOBALS['TL_LANG']['tl_foo]['toggle'],
                'attributes'            => 'onclick="Backend.getScrollOffset();"',
                'haste_ajax_operation'  => [
                    'field'     => 'someField',
                    'options'    => [
                        [
                            'value'     => '',
                            'icon'      => 'invisible.gif'
                        ],
                        [
                            'value'     => '1',
                            'icon'      => 'visible.gif'
                        ]
                    ]
                ]
            ),

The corresponding field looks like this:

[...]
'someField' => array
(
            'label'                  => &$GLOBALS['TL_LANG']['tl_foo']['someField'],
            'default'          => true,
            'inputType'          => 'checkbox',
            'eval'             => array('isBoolean'=>true),
            'sql'                     => "char(1) NOT NULL default ''"
),

Now only administrators can see the 'visible'-icon in the backend and therefore toggle someField. It's accessible for all users when editing an entry though. To get it working I had to add 'exclude' => true to the field definition and allow it in the user group (section: allowed fields).

aschempp commented 8 years ago

I always thought if exclude is not set it's allowed for everyone?

qzminski commented 8 years ago

Fixed in 5a2767d.