From f62a6c6034bdad38fe9e1999b05676c6b3ae6093 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Mon, 8 Mar 2010 23:13:15 -0500 Subject: [PATCH] Shout: Display digit details on the dialpad --- shout/dialplan.php | 5 ++++ shout/lib/Shout.php | 14 ++++----- shout/templates/dialplan/edit.inc | 63 +++++++++++++++++++++++++++++++++++++-- shout/themes/screen.css | 7 +++++ 4 files changed, 80 insertions(+), 9 deletions(-) diff --git a/shout/dialplan.php b/shout/dialplan.php index 3350215b2..de4134dfb 100644 --- a/shout/dialplan.php +++ b/shout/dialplan.php @@ -55,6 +55,11 @@ case 'edit': break; } $menu = $menus[$menu]; + try { + $destinations = $shout->extensions->getExtensions($curaccount); + } catch (Exception $e) { + $notification->push(_("Problem getting destination information.")); + } break; case 'list': default: diff --git a/shout/lib/Shout.php b/shout/lib/Shout.php index 626dc3a88..9ed2fff48 100644 --- a/shout/lib/Shout.php +++ b/shout/lib/Shout.php @@ -155,7 +155,7 @@ class Shout ) ), 'ringexten' => array( - 'description' => _("Ring an extension."), + 'description' => _("Ring extension"), 'args' => array( 'exten' => array( 'name' => _("Extension"), @@ -166,18 +166,18 @@ class Shout ) ), 'leave_message' => array( - 'description' => _("Leave a message."), + 'description' => _("Go to voicemail"), 'args' => array( 'mailbox' => array( 'name' => _("Mailbox"), 'type' => 'enum', 'required' => true, 'params' => array(self::getNames($shout->extensions->getExtensions($account))) - ) + ) ) ), 'conference' => array( - 'description' => _("Enter conference room"), + 'description' => _("Enter conference"), 'args' => array( 'roomno' => array( 'name' => _("Room Number"), @@ -187,11 +187,11 @@ class Shout ) ), 'directory' => array( - 'description' => _("Enter company directory."), + 'description' => _("Company directory"), 'args' => array() ), 'dial' => array( - 'description' => _("Place an outgoing call."), + 'description' => _("Call out"), 'args' => array( 'number' => array( 'name' => _("Phone Number"), @@ -201,7 +201,7 @@ class Shout ) ), 'rewind' => array( - 'description' => _("Restart the current menu."), + 'description' => _("Restart menu"), 'args' => array() ), // TODO: Actions to implement: Queue diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index e6163e248..93f8683ac 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -32,6 +32,7 @@ var ajax_url = ''; var menu = ''; var menuInfo = $H(); var menuActions = $H(); +var destinations = $H(); var curDigit = null; function editAction(digit) @@ -71,7 +72,6 @@ function editAction(digit) } }); var params = $H({'action': action}); - var actionForm; new Ajax.Updater('editAction', ajax_url + 'getActionForm', { method: 'post', @@ -118,6 +118,7 @@ function refreshMenu() var meta = menuInfo.get('meta'); + // Draw the menu metainfo box row = getMetaRow('', meta.name); $('menuInfo').appendChild(row); row = getMetaRow('', meta.description); @@ -130,7 +131,6 @@ function refreshMenu() text = document.createTextNode(''); col.appendChild(text); row.appendChild(col); - col = document.createElement('td'); col.className='menuStatValue'; text = document.createTextNode(meta.soundfile); @@ -148,6 +148,65 @@ function refreshMenu() col.appendChild(img); row.appendChild(col); $('menuInfo').appendChild(row); + + // Fill in the actions + $H(menuInfo.get('actions')).each(function (pair) { + var text; + var digit = pair.key; + var action = pair.value.action; + var button = $('digit_'+digit); + empty(button); + var p = document.createElement('p'); + p.className = 'buttonActionLabel'; + var span = document.createElement('span'); + span.className='digitLabel'; + if (digit == 'star') { + text = document.createTextNode('*'); + } else if (digit == 'octothorpe') { + text = document.createTextNode('#'); + } else { + text = document.createTextNode(digit); + } + span.appendChild(text); + p.appendChild(span); + text = document.createTextNode(menuActions.get(action).description); + p.appendChild(text); + button.appendChild(p); + + p = document.createElement('p'); + p.className = 'buttonDetail'; + + switch(action) { + case 'jump': + var menu = pair.value.args.first()['menuName']; + text = document.createTextNode(destinations.get(exten).name); + break; + case 'ringexten': + case 'leave_message': + // FIXME: Why do I need first() here? + var exten = pair.value.args.first()['exten']; + text = document.createTextNode(destinations.get(exten).name); + break; + case 'conference': + var roomno = pair.value.args.first()['roomno']; + if (roomno != null) { + text = document.createTextNode(roomno); + } else { + text = document.createTextNode(''); + } + break; + case 'dial': + var number = pair.value.args.first()['number']; + text = document.createTextNode(number); + break; + default: + text = document.createTextNode(''); + break; + } + + p.appendChild(text); + button.appendChild(p); + }); } function getMetaRow(name, value) diff --git a/shout/themes/screen.css b/shout/themes/screen.css index 9355d7459..68e770cdc 100644 --- a/shout/themes/screen.css +++ b/shout/themes/screen.css @@ -126,6 +126,7 @@ ul { font-weight: bold; font-size: 1.5em; color: #666; + float: left; } #editActionOverlay { @@ -150,4 +151,10 @@ ul { #editAction { margin: 5px; +} + +.buttonActionLabel +{ + text-align: right; + font-style: italic; } \ No newline at end of file -- 2.11.0