From 152955625ce2c34b628a1aea087dab5bf0e80931 Mon Sep 17 00:00:00 2001 From: Andrew Querol Date: Mon, 22 Mar 2021 23:13:33 -0500 Subject: [PATCH 1/6] Initial attempt at allowing the destination button button to dynamically change This sets the UUID as the ID in the options list. The we use the javascript onclick listener to get the id(uuid) of the selected option and open the link to the edit page. --- .../resources/classes/destinations.php | 29 +++++++++---------- app/destinations/resources/destinations.php | 5 ++-- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/app/destinations/resources/classes/destinations.php b/app/destinations/resources/classes/destinations.php index 6f81f54f33..d95d234d2e 100644 --- a/app/destinations/resources/classes/destinations.php +++ b/app/destinations/resources/classes/destinations.php @@ -476,10 +476,11 @@ if (!class_exists('destinations')) { $language2 = new text; //build the destination select list in html - $response .= " \n"; $response .= " \n"; foreach($_SESSION['destinations']['array'][$destination_type] as $key => $value) { - if (permission_exists($destination->singular($key)."_destinations")) { + $singular = $this->singular($key); + if (permission_exists("{$singular}_destinations")) { //determine if selected $selected = ($key == $destination_key) ? "selected='selected'" : ''; @@ -493,7 +494,7 @@ if (!class_exists('destinations')) { $text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/dialplans'); } //add the application to the select list - $response .= " \n"; + $response .= " \n"; } } $response .= " \n"; @@ -502,22 +503,18 @@ if (!class_exists('destinations')) { if ($key == $destination_key) { foreach($value as $k => $row) { $selected = ($row['destination'] == $destination_value) ? "selected='selected'" : ''; - $response .= " \n"; - if ($row['destination'] == $destination_value) { - $response_button = button::create([ - 'type'=>'button', - 'icon'=>'external-link-alt', - 'id'=>'btn_dest_go', - 'title'=>$row['label'], - //'style'=>'margin-left: 15px;', - 'link'=>'/app/'.$key.'/'.$this->singular($key).'_edit.php?id='.$row[$this->singular($key).'_uuid'] - ])."\n"; - } + $response .= " \n"; } } } - $response .= " ".$response_button."\n"; - + $response .= " "; + $response .= button::create([ + 'type'=>'button', + 'icon'=>'external-link-alt', + 'id'=>'btn_dest_go', + 'title'=>$text['label-edit'], + 'onclick'=>"let types = document.getElementById('{destination_id}_type').options; let opts = document.getElementById('{$destination_id}').options; window.location.assign('/app/'+types[types.selectedIndex].className+'/'+types[types.selectedIndex].id+'_edit.php?id='+opts[opts.selectedIndex].id);" + ])."\n"; //debug information //echo $response; diff --git a/app/destinations/resources/destinations.php b/app/destinations/resources/destinations.php index e8095231bf..29595bf316 100644 --- a/app/destinations/resources/destinations.php +++ b/app/destinations/resources/destinations.php @@ -30,7 +30,8 @@ echo "