diff --git a/src/apps/callflows/i18n/en-US.json b/src/apps/callflows/i18n/en-US.json index 4da5a86..5172323 100644 --- a/src/apps/callflows/i18n/en-US.json +++ b/src/apps/callflows/i18n/en-US.json @@ -928,6 +928,21 @@ "check_voicemail": "Check Voicemail", "miscellaneous_cat": "Miscellaneous", "direct_to_voicemail": "Direct to Voicemail", + "eavesdrop": "Eavesdrop", + "eavesdropPopup": { + "title": "Eavesdrop", + "eavesdropTarget": { + "label": "List of eavesdrop targets", + "tooltip": "If you set \"None\" then anybody can be eavesdropped." + }, + "approvedEndpoint": { + "label": "Approved Endpoint", + "tooltip": "One of the approved device, approved user or approved group must be defined to access feature code." + }, + "none": "None", + "default": "Default", + "successUpdate": "You successfully updated settings of the Eavesdrop Feature Code" + }, "intercom": "Intercom", "privacy": "Privacy", "park_and_retrieve": "Park and Retrieve", diff --git a/src/apps/callflows/submodules/featurecodes/featurecodes.css b/src/apps/callflows/submodules/featurecodes/featurecodes.css index 65b2d23..7e21a22 100644 --- a/src/apps/callflows/submodules/featurecodes/featurecodes.css +++ b/src/apps/callflows/submodules/featurecodes/featurecodes.css @@ -45,4 +45,16 @@ #parking_settings_popup label.monster-invalid { margin-top: 0; +} + +#eavesdrop_settings_popup label.monster-invalid { + position: static; + margin: 0; + display: block; + float: none; + color: #FF3D24; +} + +#eavesdrop_settings_popup .form_content select { + min-width: 165px; } \ No newline at end of file diff --git a/src/apps/callflows/submodules/featurecodes/featurecodes.js b/src/apps/callflows/submodules/featurecodes/featurecodes.js index c263c34..3089d6e 100644 --- a/src/apps/callflows/submodules/featurecodes/featurecodes.js +++ b/src/apps/callflows/submodules/featurecodes/featurecodes.js @@ -664,7 +664,25 @@ define(function(require) { build_regex: function(number) { return number; } - } + }, + 'eavesdrop': { + name: self.i18n.active().callflows.featureCodes.eavesdrop, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.miscellaneous_cat, + module: 'eavesdrop', + number_type: 'numbers', + data: {}, + enabled: false, + hasStar: true, + editConfiguration: function() { + self.featureCodesEditEavesdrop(this); + }, + default_number: '*', + number: this.default_number, + build_regex: function(number) { + return '^\\*' + number + '([0-9]+)$'; + } + } /*'call_forward[action=on_busy_enable]': { name: 'Enable Call-Forward on Busy', icon: 'phone', @@ -987,6 +1005,110 @@ define(function(require) { }); }, + featureCodesEditEavesdrop: function(featureCode) { + var self = this; + + self.featureCodeGet(featureCode.id, function(callflowData) { + var featureCodeData = callflowData.featurecode; + self.featureCodesEavesdropGetEndpoints(function(endpoints) { + var getApprovedId = function(data) { + if (data.hasOwnProperty('approved_device_id')) { + return data.approved_device_id; + } + if (data.hasOwnProperty('approved_group_id')) { + return data.approved_group_id; + } + if (data.hasOwnProperty('approved_user_id')) { + return data.approved_user_id; + } + return ''; + }; + var popup, + template = $(self.getTemplate({ + name: 'eavesdrop', + submodule: 'featurecodes', + data: { + fieldData: endpoints, + data: { + 'targetId': featureCodeData.group_id === 'undefined' ? 'empty' : featureCodeData.group_id, + 'approvedId': getApprovedId(featureCodeData) + } + } + })); + + monster.ui.tooltips(template); + + template.find('#save').on('click', function(e) { + e.preventDefault(); + + var $target = $('#endpoint'); + var $approvedEndpointSelected = $('#approved-endpoint option:selected'); + var approvedEndpointField = 'approved_' + $approvedEndpointSelected.data('type') + '_id'; + var approvedEndpointVal = $approvedEndpointSelected.val(); + + var data = {}; + data.group_id = $target.val() === 'empty' ? 'undefined' : $target.val(); + data[approvedEndpointField] = approvedEndpointVal; + + var newCallflowData = $.extend(true, { + flow: callflowData.flow, + patterns: callflowData.patterns, + numbers: callflowData.numbers, + featurecode: { + name: callflowData.featurecode.name, + number: callflowData.featurecode.number + } + }, { + featurecode: data + }); + + self.featureCodeUpdate(callflowData.id, newCallflowData, function() { + monster.ui.toast({ + type: 'success', + message: self.i18n.active().callflows.featureCodes.eavesdropPopup.successUpdate + }); + popup.dialog('close'); + }); + }); + + popup = monster.ui.dialog(template, { + title: self.i18n.active().callflows.featureCodes.eavesdropPopup.title + }); + }); + }); + }, + + featureCodesEavesdropGetEndpoints: function(callback) { + var self = this; + + monster.parallel({ + 'group': function(callback) { + self.groupsGroupList(function(data) { + callback(null, data); + }); + }, + 'user': function(callback) { + self.groupsRequestUserList({ + success: function(data) { + callback(null, data); + } + }); + }, + 'device': function(callback) { + self.groupsRequestDeviceList({ + success: function(data) { + callback(null, data); + } + }); + } + }, function(err, results) { + _.each(results.user, function(user) { + user.name = user.first_name + ' ' + user.last_name; + }); + callback(results); + }); + }, + featureCodesNormalizeData: function(data, formData) { var self = this, dataToUpdate = $.extend(true, {}, data); diff --git a/src/apps/callflows/submodules/featurecodes/views/eavesdrop.html b/src/apps/callflows/submodules/featurecodes/views/eavesdrop.html new file mode 100644 index 0000000..c72536c --- /dev/null +++ b/src/apps/callflows/submodules/featurecodes/views/eavesdrop.html @@ -0,0 +1,74 @@ +
+
+
+ + + + +
+ +
+
+