From a36485328bdc68a74ab40c60e6d976b1dc787455 Mon Sep 17 00:00:00 2001 From: Ricardo Merino Date: Thu, 6 Jun 2024 10:23:48 -0600 Subject: [PATCH] [5.3] MSPB-365: Replace ignore completed elsewhere control multiselect option (#545) * Replace multi option element * Implement system config default * custom api endpoint and review fixes --- i18n/en-US.json | 3 +- submodules/devices/devices.js | 39 +++++++++++++++++-- submodules/devices/devices.scss | 10 +++++ .../devices/views/devices-sip_device.html | 11 ++++++ 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/i18n/en-US.json b/i18n/en-US.json index b1de70a7..2cc4871d 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -233,7 +233,8 @@ "__version": "3.19", "ignoreCompletedElsewhere": { "label": "Ignore Completed Elsewhere", - "help": "When checked supporting phones will show a call missed if it was part of a ring group answered elsewhere." + "help": "When checked supporting phones will show a call missed if it was part of a ring group answered elsewhere.", + "systemDefault": "System Default" }, "__comment": "UI-377: Adding Restart device feature", "__version": "3.21", diff --git a/submodules/devices/devices.js b/submodules/devices/devices.js index ddbabeb2..caf89726 100644 --- a/submodules/devices/devices.js +++ b/submodules/devices/devices.js @@ -678,6 +678,13 @@ define(function(require) { }); }); + templateDevice.find('.btn-group-wrapper button.monster-button-ignore').on('click', function(e) { + e.preventDefault(); + var $this = $(this); + $this.siblings().removeClass('selected monster-button-primary'); + $this.addClass('selected monster-button-primary'); + }); + var popup = monster.ui.dialog(templateDevice, { title: popupTitle, dialogClass: 'voip-edit-device-popup' @@ -729,6 +736,17 @@ define(function(require) { .value(); }; + template.find('.ignore-completed-elsewhere').each(function() { + var $this = $(this), + hasValue = $this.find('button.selected').length, + value = hasValue ? $this.find('button.selected').data('value') : 'default'; + + // If value is set to something else than account default then we set the enabled boolean + if (value && value !== 'default') { + formData.ignore_completed_elsewhere = value === 'on' + } + }); + if ('mac_address' in formData) { formData.mac_address = monster.util.formatMacAddress(formData.mac_address); } @@ -1064,7 +1082,10 @@ define(function(require) { value: false }] } - } + }, + system_ignore_completed_elsewhere: _.get(data, 'configs.ignore_completed_elsewhere', true) + ? self.i18n.active().on + : self.i18n.active().off }, deviceData); }, @@ -1167,7 +1188,7 @@ define(function(require) { outbound_privacy: "none" }, sip: _.merge({ - ignore_completed_elsewhere: false, + ignore_completed_elsewhere: 'true', }, _.pick(sipSettings.sip, ['password', 'username'])), media: { webrtc: false, @@ -1415,7 +1436,19 @@ define(function(require) { callback(null, users); } }); - } + }, + configs: function(callback) { + self.callApi({ + resource: 'configs.get', + data: { + accountId: self.accountId, + endpoint: 'kazoo_endpoint' + }, + success: function(data, status) { + callback(null, data.data); + } + }); + }, }, function(error, results) { waterfallCb(null, results); }); diff --git a/submodules/devices/devices.scss b/submodules/devices/devices.scss index 14ff2595..9e9bde88 100644 --- a/submodules/devices/devices.scss +++ b/submodules/devices/devices.scss @@ -228,6 +228,16 @@ width: 700px; } +.voip-edit-device-popup .edit-device .btn-group-controls { + font-size: 1rem; + margin-left: 8px; +} + +.voip-edit-device-popup .edit-device .ignore-completed-elsewhere-group .control-label{ + width: 200px; + margin-left: 22px; +} + .voip-edit-device-popup .edit-device .actions { border-top: 1px solid #CCCCCC; height: 30px; diff --git a/submodules/devices/views/devices-sip_device.html b/submodules/devices/views/devices-sip_device.html index 918cff78..c5ff34aa 100644 --- a/submodules/devices/views/devices-sip_device.html +++ b/submodules/devices/views/devices-sip_device.html @@ -268,6 +268,17 @@ +
+ +
+
+ + + +
+
+
+