mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 18:03:39 +01:00
Implemented usage of global action manager and object manager for nextmatch widget
This commit is contained in:
parent
d02c638ca9
commit
4cb37be5d3
@ -843,7 +843,7 @@ class nextmatch_widget
|
||||
*
|
||||
* @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 $template_name='' name of the template, used as default for app name of images - e.g. infolog.index.rows
|
||||
* @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_')
|
||||
@ -863,29 +863,38 @@ class nextmatch_widget
|
||||
|
||||
if (!is_array($action_links)) $action_links = array();
|
||||
|
||||
$app = $GLOBALS['egw_info']['flags']['currentapp'];
|
||||
|
||||
$enc_actions = self::egw_actions($actions, $template_name, '', $action_links);
|
||||
|
||||
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);
|
||||
var actionManager = egw_getActionManager("'.$app.'");
|
||||
var objectManager = egw_getObjectManager("'.$app.'");
|
||||
|
||||
'.$prefix.'actionManager.updateActions('.str_replace('},',"},\n",
|
||||
json_encode(self::egw_actions($actions, $template_name, '', $action_links))).');
|
||||
'.$prefix.'actionManager.setDefaultExecute("javaScript:nm_action");
|
||||
'.$prefix.'actionManager.etemplate_var_prefix="'.etemplate::$name_vars.'";
|
||||
'.$prefix.'actionManager.etemplate_form=document.forms.'.etemplate::$name_form.';
|
||||
// Create anonymous object and action container for this etemplate
|
||||
var actionCntr = actionManager.addAction("actionManager", "'.$template_name.'");
|
||||
var objectCntr = objectManager.addObject(new egwActionObjectManager("'.$template_name.'", actionCntr));
|
||||
|
||||
actionCntr.updateActions('.json_encode($enc_actions).');
|
||||
actionCntr.setDefaultExecute("javaScript:nm_action");
|
||||
actionCntr.etemplate_var_prefix="'.etemplate::$name_vars.'";
|
||||
actionCntr.etemplate_form=document.forms.'.etemplate::$name_form.';
|
||||
|
||||
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)
|
||||
var divObj = document.getElementById("'.$template_name.'");
|
||||
$("table.egwGridView_grid>tbody>tr", divObj).each(function(index, elem)
|
||||
{
|
||||
// Create a new action object
|
||||
var obj = '.$prefix.'objectManager.addObject(elem.id, new nextmatchRowAOI(elem));
|
||||
if (elem.id) {
|
||||
var obj = objectCntr.addObject(elem.id, new nextmatchRowAOI(elem));
|
||||
|
||||
obj.updateActionLinks(actionLinks);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
@ -105,7 +105,9 @@ function nm_action(_action, _senders)
|
||||
}
|
||||
//console.log(_action); console.log(_senders);
|
||||
|
||||
var select_all = egw_actionManager.getActionById("select_all");
|
||||
var mgr = _action.getManager();
|
||||
|
||||
var select_all = mgr.getActionById("select_all");
|
||||
var confirm_msg = (_senders.length > 1 || select_all && select_all.checked) &&
|
||||
typeof _action.data.confirm_multiple != 'undefined' ?
|
||||
_action.data.confirm_multiple : _action.data.confirm;
|
||||
@ -157,24 +159,24 @@ function nm_action(_action, _senders)
|
||||
{
|
||||
if (!confirm((confirm_msg ? confirm_msg : _action.caption)+"\n\n"+select_all.hint)) return;
|
||||
}
|
||||
var checkboxes = egw_actionManager.getActionsByAttr("checkbox", true);
|
||||
var checkboxes_elem = document.getElementById(egw_actionManager.etemplate_var_prefix+'[nm][checkboxes]');
|
||||
var checkboxes = mgr.getActionsByAttr("checkbox", true);
|
||||
var checkboxes_elem = document.getElementById(mgr.etemplate_var_prefix+'[nm][checkboxes]');
|
||||
if (checkboxes && checkboxes_elem)
|
||||
for (var i in checkboxes)
|
||||
checkboxes_elem.value += checkboxes[i].id + ":" + (checkboxes[i].checked ? "1" : "0") + ";";
|
||||
|
||||
document.getElementById(egw_actionManager.etemplate_var_prefix+'[nm][nm_action]').value = _action.id;
|
||||
document.getElementById(egw_actionManager.etemplate_var_prefix+'[nm][selected]').value = ids;
|
||||
document.getElementById(mgr.etemplate_var_prefix+'[nm][nm_action]').value = _action.id;
|
||||
document.getElementById(mgr.etemplate_var_prefix+'[nm][selected]').value = ids;
|
||||
if (typeof _action.data.button != 'undefined')
|
||||
{
|
||||
submitit(egw_actionManager.etemplate_form.context, egw_actionManager.etemplate_var_prefix+'[nm][rows]['+_action.data.button+']['+ids+']');
|
||||
submitit(mgr.etemplate_form.context, mgr.etemplate_var_prefix+'[nm][rows]['+_action.data.button+']['+ids+']');
|
||||
}
|
||||
else
|
||||
{
|
||||
egw_actionManager.etemplate_form.submit();
|
||||
mgr.etemplate_form.submit();
|
||||
}
|
||||
// Clear action in case there's another one
|
||||
document.getElementById(egw_actionManager.etemplate_var_prefix+'[nm][nm_action]').value = null;
|
||||
document.getElementById(mgr.etemplate_var_prefix+'[nm][nm_action]').value = null;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -242,7 +244,7 @@ var nm_popup_action, nm_popup_senders;
|
||||
*/
|
||||
function nm_open_popup(_action, _senders)
|
||||
{
|
||||
var popup = document.getElementById(egw_actionManager.etemplate_var_prefix + '[' + _action.id + '_popup]');
|
||||
var popup = document.getElementById(_action.getManager().etemplate_var_prefix + '[' + _action.id + '_popup]');
|
||||
|
||||
if (popup) {
|
||||
nm_popup_action = _action;
|
||||
|
Loading…
Reference in New Issue
Block a user