mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-13 01:18:42 +01:00
Move initialisation for egw_actions stuff into static method of nextmatch_widget, it get called now from:
- etemplate::show_grid() - addressbook_ui::view() to load JS stuff before header get generated
This commit is contained in:
parent
dfd160f11b
commit
1e8de99ed7
@ -1999,6 +1999,9 @@ class addressbook_ui extends addressbook_bo
|
|||||||
$GLOBALS['egw_info']['flags']['currentid'] = $content['id'];
|
$GLOBALS['egw_info']['flags']['currentid'] = $content['id'];
|
||||||
// Load JS for infolog actions
|
// Load JS for infolog actions
|
||||||
egw_framework::validate_file('.','index','infolog');
|
egw_framework::validate_file('.','index','infolog');
|
||||||
|
// Load egw_action stuff for infolog, required before etemplate::exec() because it loads stuff into HTML header
|
||||||
|
nextmatch_widget::init_egw_actions();
|
||||||
|
|
||||||
$this->tmpl->exec('addressbook.addressbook_ui.view',$content,$sel_options,$readonlys,array('id' => $content['id']));
|
$this->tmpl->exec('addressbook.addressbook_ui.view',$content,$sel_options,$readonlys,array('id' => $content['id']));
|
||||||
|
|
||||||
$GLOBALS['egw']->hooks->process(array(
|
$GLOBALS['egw']->hooks->process(array(
|
||||||
|
@ -953,52 +953,10 @@ class etemplate extends boetemplate
|
|||||||
$html = html::div($html,$div_style);
|
$html = html::div($html,$div_style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialise egw_actions for nextmatch widget, if egwGridView_grid CSS class set
|
||||||
if ($options[3] == 'egwGridView_grid')
|
if ($options[3] == 'egwGridView_grid')
|
||||||
{
|
{
|
||||||
// Load some JS files needed for the egw_action framework
|
$html .= nextmatch_widget::init_egw_actions($content['_actions'], $content['action_links'], $this->name);
|
||||||
egw_framework::includeCSS('/phpgwapi/js/egw_action/test/skins/dhtmlxmenu_egw.css');
|
|
||||||
|
|
||||||
egw_framework::validate_file('dhtmlxtree','dhtmlxMenu/codebase/dhtmlxcommon');
|
|
||||||
egw_framework::validate_file('dhtmlxtree','dhtmlxMenu/codebase/dhtmlxmenu');
|
|
||||||
egw_framework::validate_file('dhtmlxtree','dhtmlxMenu/codebase/ext/dhtmlxmenu_ext');
|
|
||||||
egw_framework::validate_file('egw_action','egw_action');
|
|
||||||
egw_framework::validate_file('egw_action','egw_action_common');
|
|
||||||
egw_framework::validate_file('egw_action','egw_action_popup');
|
|
||||||
egw_framework::validate_file('egw_action','egw_menu');
|
|
||||||
egw_framework::validate_file('egw_action','egw_menu_dhtmlx');
|
|
||||||
egw_framework::validate_file('.', 'nextmatch_action', 'etemplate');
|
|
||||||
|
|
||||||
// JS action objects generated for this widget are prefixed with the
|
|
||||||
// prefix given here
|
|
||||||
$prefix = "egw_";
|
|
||||||
|
|
||||||
$action_links = array();
|
|
||||||
|
|
||||||
$html .= '
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function() {
|
|
||||||
// Initialize the action manager and add some actions to it
|
|
||||||
'.$prefix.'actionManager = new egwActionManager();
|
|
||||||
'.$prefix.'objectManager = new egwActionObjectManager("", '.$prefix.'actionManager);
|
|
||||||
|
|
||||||
'.$prefix.'actionManager.updateActions('.str_replace('},',"},\n",
|
|
||||||
json_encode(nextmatch_widget::egw_actions($content['_actions'], $this->name, '', $action_links))).');
|
|
||||||
'.$prefix.'actionManager.setDefaultExecute("javaScript:nm_action");
|
|
||||||
|
|
||||||
var actionLinks = ['.($content['_actions'] ? '"'.implode('","', isset($content['_action_links']) ?
|
|
||||||
$content['_action_links'] : $action_links).'"' : '').'];
|
|
||||||
|
|
||||||
// Create a new action object for each table row
|
|
||||||
// TODO: only apply function to outer level
|
|
||||||
$("table.egwGridView_grid>tbody>tr").each(function(index, elem)
|
|
||||||
{
|
|
||||||
// Create a new action object
|
|
||||||
var obj = '.$prefix.'objectManager.addObject(elem.id, new nextmatchRowAOI(elem));
|
|
||||||
|
|
||||||
obj.updateActionLinks(actionLinks);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "\n\n<!-- BEGIN grid $grid[name] -->\n$html<!-- END grid $grid[name] -->\n\n";
|
return "\n\n<!-- BEGIN grid $grid[name] -->\n$html<!-- END grid $grid[name] -->\n\n";
|
||||||
|
@ -60,9 +60,10 @@
|
|||||||
* 'actions' => // I array with actions, see nextmatch_widget::egw_actions
|
* 'actions' => // I array with actions, see nextmatch_widget::egw_actions
|
||||||
* 'action_links' => // I array with enabled actions or ones which should be checked if they are enabled
|
* 'action_links' => // I array with enabled actions or ones which should be checked if they are enabled
|
||||||
* optional, default id of all first level actions plus the ones with enabled='javaScript:...'
|
* optional, default id of all first level actions plus the ones with enabled='javaScript:...'
|
||||||
|
* 'action' => // O string selected action
|
||||||
* 'selected' => // O array with selected id's
|
* 'selected' => // O array with selected id's
|
||||||
* 'checkboxes' => // 0 array with checkbox id as key and boolean checked value
|
* 'checkboxes' => // O array with checkbox id as key and boolean checked value
|
||||||
* 'select_all' => // 0 boolean value of select_all checkbox, reference to above value for key 'select_all'
|
* 'select_all' => // O boolean value of select_all checkbox, reference to above value for key 'select_all'
|
||||||
* );
|
* );
|
||||||
*/
|
*/
|
||||||
class nextmatch_widget
|
class nextmatch_widget
|
||||||
@ -804,6 +805,62 @@ class nextmatch_widget
|
|||||||
return $cat_actions;
|
return $cat_actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return HTML to initialise actions, if called without arguments only CSS and JS get loaded
|
||||||
|
*
|
||||||
|
* Gets called from etemplate::show_grid() and addressbook_ui::view (without arguments).
|
||||||
|
*
|
||||||
|
* @param array $actions=null
|
||||||
|
* @param array $action_links=null
|
||||||
|
* @param string $template_name='' name of the template, used as default for app name of images
|
||||||
|
* @param string $prefix='egw_' JS action objects generated for this widget are prefixed with given prefix
|
||||||
|
*/
|
||||||
|
public static function init_egw_actions(array $actions=null, $action_links=null, $template_name='', $prefix='egw_')
|
||||||
|
{
|
||||||
|
// Load some JS files needed for the egw_action framework
|
||||||
|
egw_framework::includeCSS('/phpgwapi/js/egw_action/test/skins/dhtmlxmenu_egw.css');
|
||||||
|
|
||||||
|
egw_framework::validate_file('dhtmlxtree','dhtmlxMenu/codebase/dhtmlxcommon');
|
||||||
|
egw_framework::validate_file('dhtmlxtree','dhtmlxMenu/codebase/dhtmlxmenu');
|
||||||
|
egw_framework::validate_file('dhtmlxtree','dhtmlxMenu/codebase/ext/dhtmlxmenu_ext');
|
||||||
|
egw_framework::validate_file('egw_action','egw_action');
|
||||||
|
egw_framework::validate_file('egw_action','egw_action_common');
|
||||||
|
egw_framework::validate_file('egw_action','egw_action_popup');
|
||||||
|
egw_framework::validate_file('egw_action','egw_menu');
|
||||||
|
egw_framework::validate_file('egw_action','egw_menu_dhtmlx');
|
||||||
|
egw_framework::validate_file('.', 'nextmatch_action', 'etemplate');
|
||||||
|
|
||||||
|
if ($actions)
|
||||||
|
{
|
||||||
|
if (!is_array($action_links)) $action_links = array();
|
||||||
|
|
||||||
|
return '
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
// Initialize the action manager and add some actions to it
|
||||||
|
'.$prefix.'actionManager = new egwActionManager();
|
||||||
|
'.$prefix.'objectManager = new egwActionObjectManager("", '.$prefix.'actionManager);
|
||||||
|
|
||||||
|
'.$prefix.'actionManager.updateActions('.str_replace('},',"},\n",
|
||||||
|
json_encode(self::egw_actions($actions, $template_name, '', $action_links))).');
|
||||||
|
'.$prefix.'actionManager.setDefaultExecute("javaScript:nm_action");
|
||||||
|
|
||||||
|
var actionLinks = ["'.implode('","', $action_links).'"];
|
||||||
|
|
||||||
|
// Create a new action object for each table row
|
||||||
|
// TODO: only apply function to outer level
|
||||||
|
$("table.egwGridView_grid>tbody>tr").each(function(index, elem)
|
||||||
|
{
|
||||||
|
// Create a new action object
|
||||||
|
var obj = '.$prefix.'objectManager.addObject(elem.id, new nextmatchRowAOI(elem));
|
||||||
|
|
||||||
|
obj.updateActionLinks(actionLinks);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calling our callback
|
* Calling our callback
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user