From 458e6560852dd27ed2bc9e3797fe6ec51dbecd6e Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Wed, 3 Mar 2010 22:01:48 -0500 Subject: [PATCH] Shout: Continue implementing action editor for dialplan --- shout/lib/Ajax/Application.php | 11 ++++++++--- shout/lib/Shout.php | 2 +- shout/templates/dialplan/edit.inc | 26 +++++++++++++++++++++----- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index b466f7ed3..f79574303 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -141,7 +141,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base $context = $_SESSION['shout']['context']; $actions = Shout::getMenuActions(); $action = $actions[$action]; - $form = new Horde_Form($vars, $action['description']); + $form = new Horde_Form($vars, $action['description'], 'editActionForm'); foreach($action['args'] as $name => $info) { $defaults = array( 'required' => true, @@ -149,13 +149,13 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base 'description' => null, 'params' => array() ); - //$info = array_merge($info, $defaults); + $info = array_merge($defaults, $info); $form->addVariable($info['name'], $name, $info['type'], $info['required'], $info['readonly'], $info['description'], $info['params']); } $this->_responseType = 'html'; - $form->renderActive(); + $form->renderActive(null, null, 'javascript:saveAction()'); $output = ob_get_clean(); return $output; } catch (Exception $e) { @@ -165,6 +165,11 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base } } + public function saveAction() + { + return null; + } + public function responseType() { return $this->_responseType; diff --git a/shout/lib/Shout.php b/shout/lib/Shout.php index 2b0c02fae..6b183b31d 100644 --- a/shout/lib/Shout.php +++ b/shout/lib/Shout.php @@ -146,7 +146,7 @@ class Shout 'menu' => array( 'description' => _("Jump to menu."), 'args' => array ( - 'menu' => array( + 'menuName' => array( 'name' => _("Menu"), 'type' => 'enum', 'required' => true, diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index 56867543d..58c6d9082 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -30,10 +30,12 @@ var ajax_url = ''; var menu = ''; var menuInfo = $H(); var menuActions = $H(); +var curDigit = null; function editAction(digit) { if ($('selectActionForm') == null) { + curDigit = digit; // Draw the selectActionForm $('editAction').show(); while ((e = $('editAction').childNodes[0]) != null) { @@ -53,6 +55,9 @@ function editAction(digit) }); form.appendChild(select); $('editAction').appendChild(form); + var div = document.createElement('div'); + div.id = 'editActionFormContainer'; + $('editAction').appendChild(div); } else { var action = null; // Draw the options for this action @@ -63,10 +68,7 @@ function editAction(digit) }); var params = $H({'action': action}); var actionForm; - var div = document.createElement('div'); - div.id = 'editActionForm'; - $('editAction').appendChild(div); - new Ajax.Updater('editActionForm', ajax_url + 'getActionForm', + new Ajax.Updater('editActionFormContainer', ajax_url + 'getActionForm', { method: 'post', parameters: params @@ -76,7 +78,21 @@ function editAction(digit) function saveAction(digit) { - $('editAction').hide(); + var params = $('editActionForm').serialize(true); + params.menu = menuInfo.get('meta').name; + params.digit = curDigit; + new Ajax.Request(ajax_url + 'saveAction', + { + method: 'post', + parameters: params, + onSuccess: function(r) { + alert('FIXME'); + while ((e = $('editAction').childNodes[0]) != null) { + $('editAction').removeChild(e); + } + $('editAction').hide(); + } + }); } function changeSoundfile() -- 2.11.0