enable/disable edit and delete action, based on ACL rights, set as css classes to each row

This commit is contained in:
Ralf Becker 2011-04-17 20:45:21 +00:00
parent f2b739e332
commit bb0e8617b2
3 changed files with 23 additions and 1 deletions

View File

@ -520,12 +520,15 @@ class nextmatch_widget
* - string 'iconUrl' full url of icon, better use 'icon' * - string 'iconUrl' full url of icon, better use 'icon'
* - boolean|string 'allowOnMultiple' should action be shown if multiple lines are marked, or string 'only', default true! * - boolean|string 'allowOnMultiple' should action be shown if multiple lines are marked, or string 'only', default true!
* - boolean|string 'enabled' is action available, or string with javascript function to call, default true! * - boolean|string 'enabled' is action available, or string with javascript function to call, default true!
* - string 'disableClass' class name to use with enabled='javaScript:nm_not_disableClass'
* (add that css class in get_rows(), if row lacks rights for an action)
* - boolena 'hideOnDisabled' hide disabled actions, default false * - boolena 'hideOnDisabled' hide disabled actions, default false
* - string 'type' type of action, default 'popup' for contenxt menus, 'drag' or 'drop' * - string 'type' type of action, default 'popup' for contenxt menus, 'drag' or 'drop'
* - boolean 'default' is that action the default action, default false * - boolean 'default' is that action the default action, default false
* - array 'children' array with actions of submenu * - array 'children' array with actions of submenu
* - int 'group' to group items, default all actions are in one group * - int 'group' to group items, default all actions are in one group
* - string 'onExecute' javascript to run, default 'javascript:nm_action' which runs action specified in nm_action attribute: * - string 'onExecute' javascript to run, default 'javaScript:nm_action',
* which runs action specified in nm_action attribute:
* - string 'nm_action' * - string 'nm_action'
* + 'alert' debug action, shows alert with action caption, id and id's of selected rows * + 'alert' debug action, shows alert with action caption, id and id's of selected rows
* + 'submit' default action, sets nm[action], nm[selected] and nm[select_all] * + 'submit' default action, sets nm[action], nm[selected] and nm[select_all]

View File

@ -171,3 +171,16 @@ function nm_select_all(_action, _senders)
{ {
document.getElementById('exec[nm][select_all]').value = _action.checked ? _action.hint : false; document.getElementById('exec[nm][select_all]').value = _action.checked ? _action.hint : false;
} }
/**
* Callback to check if none of _senders rows has disableClass set
*
* @param _action egwAction object, we use _action.data.disableClass to check
* @param _senders array of egwActionObject objects
* @param _target egwActionObject object, get's called for every object in _senders
* @returns boolean true if none has disableClass, false otherwise
*/
function nm_not_disableClass(_action, _senders, _target)
{
return !$(_target.iface.getDOMNode()).hasClass(_action.data.disableClass);
}

View File

@ -693,10 +693,12 @@ class timesheet_ui extends timesheet_bo
if (!$this->check_acl(EGW_ACL_EDIT,$row)) if (!$this->check_acl(EGW_ACL_EDIT,$row))
{ {
$readonlys["edit[$row[ts_id]]"] = true; $readonlys["edit[$row[ts_id]]"] = true;
$row['class'] .= ' rowNoEdit';
} }
if (!$this->check_acl(EGW_ACL_DELETE,$row)) if (!$this->check_acl(EGW_ACL_DELETE,$row))
{ {
$readonlys["delete[$row[ts_id]]"] = true; $readonlys["delete[$row[ts_id]]"] = true;
$row['class'] .= ' rowNoDelete';
} }
if ($query['col_filter']['ts_project'] || !$query['filter2']) if ($query['col_filter']['ts_project'] || !$query['filter2'])
{ {
@ -880,6 +882,8 @@ class timesheet_ui extends timesheet_bo
'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id', 'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id',
'popup' => egw_link::get_registry('timesheet', 'add_popup'), 'popup' => egw_link::get_registry('timesheet', 'add_popup'),
'group' => $group, 'group' => $group,
'enabled' => 'javaScript:nm_not_disableClass',
'disableClass' => 'rowNoEdit',
), ),
'add' => array( 'add' => array(
'caption' => 'Add', 'caption' => 'Add',
@ -920,6 +924,8 @@ class timesheet_ui extends timesheet_bo
'confirm' => 'Delete this entry', 'confirm' => 'Delete this entry',
'confirm_multiple' => 'Delete these entries', 'confirm_multiple' => 'Delete these entries',
'group' => ++$group, 'group' => ++$group,
'enabled' => 'javaScript:nm_not_disableClass',
'disableClass' => 'rowNoDelete',
), ),
); );