diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index 34969e94b8..1f3ef9c082 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -486,8 +486,10 @@ class nextmatch_widget $name = is_object($extension_data['template']) ? $extension_data['template']->name : $extension_data['template']; list($app) = explode('.',$name); $definition = $GLOBALS['egw_info']['user']['preferences'][$app]['nextmatch-export-definition']; - if(!$value['no_csv_export'] && ($definition || !is_array($value['csv_fields']))) { - if($GLOBALS['egw_info']['user']['apps']['importexport'] && ($definition || $value['csv_fields'])) { + if(!$value['no_csv_export'] && ($definition || !is_array($value['csv_fields']))) + { + if($GLOBALS['egw_info']['user']['apps']['importexport'] && ($definition || $value['csv_fields']) && is_object($nextmatch)) + { $nextmatch->set_cell_attribute('export', 'onclick', "egw_openWindowCentered2('". egw::link('/index.php', array( 'menuaction' => 'importexport.importexport_export_ui.export_dialog', @@ -512,7 +514,6 @@ class nextmatch_widget $value['rows']['_actions'] =& $value['actions']; $value['rows']['_action_links'] =& $value['action_links']; $value['rows']['_row_id'] =& $value['row_id']; - $value['action'] = $value['selected'] = $value['select_all'] = null; // nothing yet return False; // NO extra Label } @@ -591,6 +592,18 @@ class nextmatch_widget if (!is_array($action)) $action = array('caption' => $action); $action['id'] = $prefix.$id; + // set some default onExecute + foreach(array( + 'enableClass' => 'javaScript:nm_enableClass', + 'disableClass' => 'javaScript:nm_not_disableClass', + ) as $attr => $check) + { + if (isset($action[$attr]) && !isset($action['enabled'])) + { + $action['enabled'] = $check; + } + } + // add all first level actions plus ones with enabled = 'javaScript:...' to action_links if ($first_level || substr($action['enabled'],0,11) == 'javaScript:') { diff --git a/etemplate/js/nextmatch_action.js b/etemplate/js/nextmatch_action.js index 2697300215..af951ba436 100644 --- a/etemplate/js/nextmatch_action.js +++ b/etemplate/js/nextmatch_action.js @@ -183,6 +183,19 @@ function nm_not_disableClass(_action, _senders, _target) return !$(_target.iface.getDOMNode()).hasClass(_action.data.disableClass); } +/** + * Callback to check if all of _senders rows have enableClass set + * + * @param _action egwAction object, we use _action.data.enableClass 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_enableClass(_action, _senders, _target) +{ + return $(_target.iface.getDOMNode()).hasClass(_action.data.enableClass); +} + /** * Callback to check if a certain field (_action.data.fieldId) is (not) equal to given value (_action.data.fieldValue) *