From: Ben Klang Date: Fri, 26 Mar 2010 17:55:56 +0000 (-0400) Subject: Shout: Continue working on menu action editor X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=dbd1ac3498f58061a645ad21d0a0e72cb68725fb;p=horde.git Shout: Continue working on menu action editor --- diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index dda90d8da..449dfaf2a 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -123,50 +123,10 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base public function saveMenuInfo() { + // FIXME return true; } - public function getActionForm() - { - try { - $vars = $this->_vars; - if (!($action = $vars->get('action'))) { - throw new Shout_Exception("Invalid action requested."); - } - $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; - $actions = Shout::getMenuActions(); - $action = $actions[$action]; - $form = new Horde_Form($vars, $action['description'], 'editActionForm'); - foreach($action['args'] as $name => $info) { - $defaults = array( - 'required' => true, - 'readonly' => false, - 'description' => null, - 'params' => array() - ); - $info = array_merge($defaults, $info); - $form->addVariable($info['name'], $name, $info['type'], - $info['required'], $info['readonly'], - $info['description'], $info['params']); - } - $form->setButtons(_("Save")); - - $this->_responseType = 'html'; - - // Catch and return the output from $form->renderActive() - ob_start(); - $form->renderActive(null, null, 'javascript:saveAction()'); - $output = ob_get_flush(); - return $output; - - } catch (Exception $e) { - //FIXME: Create a way to notify the user of the failure. - Horde::logMessage($e, 'ERR'); - return false; - } - } - public function saveAction() { try { diff --git a/shout/lib/Shout.php b/shout/lib/Shout.php index 30a40aa48..ab6a3e54b 100644 --- a/shout/lib/Shout.php +++ b/shout/lib/Shout.php @@ -181,7 +181,7 @@ class Shout 'description' => _("Enter conference"), 'args' => array( 'roomno' => array( - 'name' => _("Room Number"), + 'name' => _("Room Number (optional)"), 'type' => 'number', 'required' => false ) diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index dd589fc69..b45e0d036 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -54,8 +54,9 @@
Current Digit
-
-
+ +
+
1
@@ -96,6 +97,7 @@ function empty(p) function editAction(digit) { empty('editAction'); + $('editActionFormDigit').value = digit; if ($('selectAction').firstChild == null) { $('digitGraphic').src = ' true, 'nohorde' => true)); ?>/digit-'+digit+'.png'; @@ -121,7 +123,7 @@ function editAction(digit) option = document.createElement('option'); option.value = item.key; if (menuInfo.get(curmenu).actions[digit] != null) { - if (item.key == menuInfo.get('actions')[digit].action) { + if (item.key == menuInfo.get(curmenu).actions[digit].action) { option.selected = "true"; } } @@ -151,7 +153,7 @@ function editAction(digit) switch(action) { case 'jump': var span = document.createElement('span'); - var text = document.createTextNode(''); + var text = document.createTextNode(menuActions.get(action).description); span.appendChild(text); div.appendChild(span); @@ -169,12 +171,7 @@ function editAction(digit) case 'ringexten': case 'leave_message': var span = document.createElement('span'); - var text; - if (action == 'ringexten') { - text = document.createTextNode(''); - } else { - text = document.createTextNode(''); - } + var text = document.createTextNode(menuActions.get(action).description); span.appendChild(text); div.appendChild(span); @@ -187,10 +184,22 @@ function editAction(digit) option.appendChild(text); select.appendChild(option); }) + + if (menuInfo.get(curmenu).actions[digit] != null) { + select.value = menuInfo.get(curmenu).actions[digit].exten; + } + div.appendChild(select); break; case 'conference': - alert(action); + var span = document.createElement('span'); + var text = document.createTextNode(menuActions.get(action).description); + span.appendChild(text); + div.appendChild(span); + + var input = document.createElement('input'); + input.name = 'roomno'; + break; case 'dial': alert(action); @@ -218,15 +227,21 @@ function editAction(digit) cancel.value = ''; div.appendChild(cancel); + Event.observe($('editActionForm'), 'submit', function(event) {saveAction(event);}); + + $('editAction').appendChild(div); } } -function saveAction(digit) +function saveAction(event) { - var params = $('editActionForm').serialize(true); - params.menu = menuInfo.get('meta').name; - params.action = $('editActionForm').getElements().first().getValue(); + Event.stop(event); + var form = event.target; + Element.extend(form); + + var params = form.serialize(true); + params.menu = curmenu; new Ajax.Request(ajax_url + 'saveAction', { method: 'post', @@ -235,7 +250,7 @@ function saveAction(digit) empty('selectAction'); empty('editAction'); $('editActionOverlay').hide(); - new Ajax.Request(ajax_url + 'getMenuInfo', + new Ajax.Request(ajax_url + 'getMenus', { method: 'post', parameters: $H({ @@ -300,7 +315,7 @@ function refreshMenu() $('menu.soundfile').appendChild(text); // Fill in the actions - $H(menuInfo.get('actions')).each(function (pair) { + $H(menuInfo.get(curmenu).actions).each(function (pair) { var text; var digit = pair.key; var action = pair.value.action;