From d4aed5cf038ed55bdd51c4339d683021ab347f69 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 24 Apr 2012 19:47:23 +0000 Subject: [PATCH] More work on nm actions that need real submit (POST) --- etemplate/inc/class.etemplate.inc.php | 14 ++++++++----- .../js/et2_extension_nextmatch_actions.js | 21 ++++++++++++++++--- etemplate/js/etemplate2.js | 4 ++-- etemplate/process_exec.php | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/etemplate/inc/class.etemplate.inc.php b/etemplate/inc/class.etemplate.inc.php index d7f8429161..6d20a25b27 100644 --- a/etemplate/inc/class.etemplate.inc.php +++ b/etemplate/inc/class.etemplate.inc.php @@ -35,9 +35,9 @@ if (!isset($GLOBALS['egw_info'])) * * @ToDo supported customized templates stored in DB, currently we only support xet files stored in filesystem */ -class etemplate extends etemplate_old {}; -class etemplate_new extends etemplate_widget_template -//class etemplate extends etemplate_widget_template +//class etemplate extends etemplate_old {}; +//class etemplate_new extends etemplate_widget_template +class etemplate extends etemplate_widget_template { /** * Are we running as sitemgr module or not @@ -50,7 +50,7 @@ class etemplate_new extends etemplate_widget_template * Tell egw framework it's ok to call this */ public $public_functions = array( - 'ajax_post_process' => true + 'process_exec' => true ); /** @@ -225,8 +225,12 @@ class etemplate_new extends etemplate_widget_template /** * Process via POST submitted content */ - static public function ajax_process_post() + static public function process_exec() { + $etemplate_exec_id = $_POST['etemplate_exec_id']; + $content = json_decode($_POST['value'],true); + error_log(__METHOD__."(".array2string($content).")"); + self::$request = etemplate_request::read($_POST['etemplate_exec_id']); if (get_magic_quotes_gpc()) $_POST['value'] = stripslashes($_POST['value']); $content = json_decode($_POST['value'],true); diff --git a/etemplate/js/et2_extension_nextmatch_actions.js b/etemplate/js/et2_extension_nextmatch_actions.js index d182f58667..2f834d48c1 100644 --- a/etemplate/js/et2_extension_nextmatch_actions.js +++ b/etemplate/js/et2_extension_nextmatch_actions.js @@ -145,7 +145,7 @@ function nm_action(_action, _senders, _target, _ids) "checkboxes": checkboxes_elem ? checkboxes_elem.value : null }; value[nextmatch.options.settings.action_var]= _action.id; - if(_target && _target.id) value[_target.id] = true; + //if(_target && _target.id) value[_target.id] = true; return value; } @@ -255,7 +255,20 @@ function nm_open_popup(_action, _ids) var popup = jQuery("#"+_action.id+"_popup").get(0) || jQuery("[id*='" + _action.id + "_popup']").get(0); if (popup) { nm_popup_action = _action; - nm_popup_ids = _ids; + if(_ids.length && typeof _ids[0] == 'object') + { + egw().debug("warn", 'Not proper format for IDs'); + _action.data.nextmatch = _ids[0]._context._widget; + nm_popup_ids = []; + for(var i = 0; i < _ids.length; i++) + { + nm_popup_ids.push(_ids[i].id); + } + } + else + { + nm_popup_ids = _ids; + } popup.style.display = 'block'; /* Not working yet - DOM manipulation causes et2 problems @@ -304,6 +317,8 @@ function nm_submit_popup(button) } // call regular nm_action to transmit action and senders correct nm_action(nm_popup_action,nm_popup_ids, button, ids); + + nm_hide_popup(button, null); } /** @@ -312,7 +327,7 @@ function nm_submit_popup(button) function nm_hide_popup(element, div_id) { var prefix = element.id.substring(0,element.id.indexOf('[')); - var popup = jQuery("#"+_action.id+"_popup").get(0) || jQuery("[id*='" + _action.id + "_popup']").get(0); + var popup = jQuery("#"+prefix+"_popup").get(0) || jQuery("[id*='" + prefix + "_popup']").get(0); // Hide popup if(popup) { diff --git a/etemplate/js/etemplate2.js b/etemplate/js/etemplate2.js index b8fd5e0e35..fc7782c7b4 100644 --- a/etemplate/js/etemplate2.js +++ b/etemplate/js/etemplate2.js @@ -313,7 +313,8 @@ etemplate2.prototype.postSubmit = function() if (canSubmit) { - var form = jQuery("
"); + var form = jQuery(""); var etemplate_id = jQuery(document.createElement("input")) .attr("name",'etemplate_exec_id') @@ -324,7 +325,6 @@ etemplate2.prototype.postSubmit = function() input.name = 'value'; input.value = egw().jsonEncode(values); form.append(input); - form.appendTo(jQuery('body')).submit(); } } diff --git a/etemplate/process_exec.php b/etemplate/process_exec.php index d2545c08af..bd91e78865 100644 --- a/etemplate/process_exec.php +++ b/etemplate/process_exec.php @@ -21,4 +21,4 @@ $GLOBALS['egw_info'] = array( ); include('../header.inc.php'); -ExecMethod('etemplate.etemplate_old.process_exec'); +ExecMethod('etemplate.etemplate.process_exec');