From 707371cb921fe8e528445d85ea8a205b24ca63c0 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 14 Jun 2021 15:19:45 +0200 Subject: [PATCH] Fix update button labels Convert modal responses to Toast Correct reload parameters to stay on page and redraw table Correct output text --- Sccp_manager.class.php | 2 +- assets/js/sccp_manager.js | 13 +++++++------ sccpManTraits/ajaxHelper.php | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index c6f6767..fac1950 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1182,7 +1182,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $buton_list = $this->dbinterface->HWextension_db_SccpTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial')); } if (empty($buton_list)) { - return array('Response' => ' Found 0 device ', 'data' => ''); + return array('Response' => ' 0 buttons found ', 'data' => ''); } $copy_fld = array('ref', 'reftype', 'instance', 'buttontype'); $user_list = $user_list = $this->dbinterface->get_db_SccpTableByID("SccpExtension", array(), 'name'); diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 9f373e9..da86215 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -586,7 +586,7 @@ $(document).ready(function () { conf_msg = 'Reset Token on All device ?'; } if ($(this).data('id') === 'update_button_label') { - conf_msg = 'Update Butons Labels on All device ?'; + conf_msg = 'Update Button Labels on ALL devices ?'; } $('#table-sccp').bootstrapTable('getSelections').forEach(function (entry) { datas = datas + 'name[' + i + ']=' + entry['name'] + '&'; @@ -615,14 +615,15 @@ $(document).ready(function () { success: function (data) { // console.log(data); if (data.status === true) { - if (data.message) { - var old_style = bs_alert(data.message, data.status,data.reload); - } if (data.table_reload === true) { $('table').bootstrapTable('refresh'); } - if (data.reload === true && old_style === true) { - location.reload(); + if (data.message) { + fpbxToast(data.message,_('Operation Result'), 'success'); + if (data.reload === true) { + //Need setTimout or reload will kill Toast + setTimeout(function(){location.reload();},500); + } } } else { if (Array.isArray(data.message)) { diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 2c4b987..7d21724 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -185,8 +185,8 @@ trait ajaxHelper { } } $res = $this->updateSccpButtons($hw_list); - $msg .= $res['Response'] . ' raw: ' . $res['data'] . ' '; - return array('status' => true, 'message' => 'Update Butons Labels Complite ' . $msg, 'reload' => true); + $msg .= $res['Response'] . (empty($res['data']) ? '' : ' raw data: ' . $res['data'] . ' '); + return array('status' => true, 'message' => 'Update Buttons Labels Complete: ' . $msg, 'reload' => false, 'table_reload' => true); case 'model_add': $save_settings = array(); $key_name = array('model', 'vendor', 'dns', 'buttons', 'loadimage', 'loadinformationid', 'nametemplate');