diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index e846d4e252..27f6cdf792 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -520,12 +520,15 @@ class nextmatch_widget * - 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 '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 * - string 'type' type of action, default 'popup' for contenxt menus, 'drag' or 'drop' * - boolean 'default' is that action the default action, default false * - array 'children' array with actions of submenu * - 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' * + '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] diff --git a/etemplate/js/nextmatch_action.js b/etemplate/js/nextmatch_action.js index 647d70820c..0faf2dedb1 100644 --- a/etemplate/js/nextmatch_action.js +++ b/etemplate/js/nextmatch_action.js @@ -171,3 +171,16 @@ function nm_select_all(_action, _senders) { 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); +} diff --git a/timesheet/inc/class.timesheet_ui.inc.php b/timesheet/inc/class.timesheet_ui.inc.php index e930a1c0c0..7461100ca8 100644 --- a/timesheet/inc/class.timesheet_ui.inc.php +++ b/timesheet/inc/class.timesheet_ui.inc.php @@ -693,10 +693,12 @@ class timesheet_ui extends timesheet_bo if (!$this->check_acl(EGW_ACL_EDIT,$row)) { $readonlys["edit[$row[ts_id]]"] = true; + $row['class'] .= ' rowNoEdit'; } if (!$this->check_acl(EGW_ACL_DELETE,$row)) { $readonlys["delete[$row[ts_id]]"] = true; + $row['class'] .= ' rowNoDelete'; } 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', 'popup' => egw_link::get_registry('timesheet', 'add_popup'), 'group' => $group, + 'enabled' => 'javaScript:nm_not_disableClass', + 'disableClass' => 'rowNoEdit', ), 'add' => array( 'caption' => 'Add', @@ -920,6 +924,8 @@ class timesheet_ui extends timesheet_bo 'confirm' => 'Delete this entry', 'confirm_multiple' => 'Delete these entries', 'group' => ++$group, + 'enabled' => 'javaScript:nm_not_disableClass', + 'disableClass' => 'rowNoDelete', ), );