From 01537e464430375f935c7b58453103b532099c33 Mon Sep 17 00:00:00 2001 From: Vladimir Barkasov Date: Thu, 13 Feb 2020 20:19:25 +0700 Subject: [PATCH] Fax Detect submodule --- src/apps/callflows/app.js | 1 + src/apps/callflows/i18n/en-US.json | 16 +++ src/apps/callflows/style/app.css | 1 + .../submodules/faxdetect/faxdetect.css | 3 + .../submodules/faxdetect/faxdetect.js | 124 ++++++++++++++++++ .../faxdetect/views/dialogEdit.html | 24 ++++ .../faxdetect/views/dialogMenuOption.html | 22 ++++ 7 files changed, 191 insertions(+) create mode 100644 src/apps/callflows/submodules/faxdetect/faxdetect.css create mode 100644 src/apps/callflows/submodules/faxdetect/faxdetect.js create mode 100644 src/apps/callflows/submodules/faxdetect/views/dialogEdit.html create mode 100644 src/apps/callflows/submodules/faxdetect/views/dialogMenuOption.html diff --git a/src/apps/callflows/app.js b/src/apps/callflows/app.js index 2ef9a70..d2635ca 100644 --- a/src/apps/callflows/app.js +++ b/src/apps/callflows/app.js @@ -16,6 +16,7 @@ define(function(require) { 'directory', 'eavesdrop', 'faxbox', + 'faxdetect', 'featurecodes', 'groups', 'media', diff --git a/src/apps/callflows/i18n/en-US.json b/src/apps/callflows/i18n/en-US.json index b032e22..bda3e58 100644 --- a/src/apps/callflows/i18n/en-US.json +++ b/src/apps/callflows/i18n/en-US.json @@ -575,6 +575,22 @@ "words": "Please only enter alphanumeric characters, space or - '" } }, + "fax_detect": { + "fax_detect": "Fax Detect", + "tooltip": "Fax Detect allows the detection of fax/voice in a call.", + "caption": "Duration: ${duration} sec.", + "edit_dialog": { + "title": "Fax Detect", + "duration": "Duration", + "duration_tooltip": "The DURATION is the number of seconds the detection lasts, default is 3. if the detection fails, it defaults to voice" + }, + "menu_option_dialog": { + "title": "Menu option", + "menu_option": "Menu option", + "on_voice": "On voice", + "on_fax": "On fax" + } + }, "groups": { "title": "Groups", "edit_group": "Edit Group", diff --git a/src/apps/callflows/style/app.css b/src/apps/callflows/style/app.css index aff678c..f6ebec4 100644 --- a/src/apps/callflows/style/app.css +++ b/src/apps/callflows/style/app.css @@ -16,6 +16,7 @@ @import url('../submodules/branchvariable/branchvariable.css'); @import url('../submodules/checkcid/checkcid.css'); @import url('../submodules/cidlistmatch/cidlistmatch.css'); +@import url('../submodules/faxdetect/faxdetect.css'); @import url('../../../css/vendor/bootstrap-tour.css'); /* style.css */ #ws_callflow > .callflow { diff --git a/src/apps/callflows/submodules/faxdetect/faxdetect.css b/src/apps/callflows/submodules/faxdetect/faxdetect.css new file mode 100644 index 0000000..92a2c2a --- /dev/null +++ b/src/apps/callflows/submodules/faxdetect/faxdetect.css @@ -0,0 +1,3 @@ +.fax-detect-form { + margin: 15px 0 0; +} diff --git a/src/apps/callflows/submodules/faxdetect/faxdetect.js b/src/apps/callflows/submodules/faxdetect/faxdetect.js new file mode 100644 index 0000000..f96b6ba --- /dev/null +++ b/src/apps/callflows/submodules/faxdetect/faxdetect.js @@ -0,0 +1,124 @@ +define(function(require) { + var $ = require('jquery'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'faxdetectDefineActions' + }, + + faxdetectDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions, + i18n = self.i18n.active().callflows.fax_detect; + + $.extend(callflow_nodes, { + 'fax_detect[]': { + name: i18n.fax_detect, + icon: 'fax', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'fax_detect', + tip: i18n.tooltip, + data: { + duration: 3 + }, + rules: [ + { + type: 'quantity', + maxSize: '2' + } + ], + isUsable: 'true', + weight: 48, + caption: function(node, caption_map) { + var duration = node.getMetadata('duration'); + return i18n.caption.replace('${duration}', duration); + }, + edit: function(node, callback) { + self.faxdetectShowEditDialog(node, callback); + }, + key_caption: function(child_node, caption_map) { + if(child_node.key === 'ON_VOICE') { + return i18n.menu_option_dialog.on_voice; + } else if(child_node.key === 'ON_FAX') { + return i18n.menu_option_dialog.on_fax; + } + return child_node.key; + }, + key_edit: function(child_node, callback) { + var $dialog, $popup; + + $popup = $(self.getTemplate({ + name: 'dialogMenuOption', + data: { + selected: child_node.key + }, + submodule: 'faxdetect' + })); + + $popup.find('.js-save').on('click', function() { + var $menuOption = $('#fax-detect_menu-option option:selected', $popup); + child_node.key = $menuOption.val(); + child_node.key_caption = $menuOption.text(); + $dialog.dialog('close'); + }); + + $dialog = monster.ui.dialog($popup, { + title: self.i18n.active().callflows.fax_detect.menu_option_dialog.title, + minHeight: '0', + width: 450, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + } + } + }); + }, + + faxdetectShowEditDialog: function (node, callback) { + var self = this, + $popup, + $dialog, + i18n = self.i18n.active().callflows.fax_detect; + + $dialog = $(self.getTemplate({ + name: 'dialogEdit', + data: { + duration: node.getMetadata('duration') + }, + submodule: 'faxdetect' + })); + + $popup = monster.ui.dialog($dialog, { + title: self.i18n.active().callflows.fax_detect.edit_dialog.title, + minHeight: '0', + width: 450, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + + $dialog.find('.js-save').click(function() { + var duration = parseInt($('#fax-detect_duration').val()); + node.setMetadata('duration', duration); + node.caption = i18n.caption.replace('${duration}', duration); + if (typeof callback === 'function') { + callback(); + } + + $popup.dialog('close'); + }); + + monster.ui.tooltips($dialog); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/faxdetect/views/dialogEdit.html b/src/apps/callflows/submodules/faxdetect/views/dialogEdit.html new file mode 100644 index 0000000..15c57b8 --- /dev/null +++ b/src/apps/callflows/submodules/faxdetect/views/dialogEdit.html @@ -0,0 +1,24 @@ +
+
+
+ +
+
+ +
+ +
+
diff --git a/src/apps/callflows/submodules/faxdetect/views/dialogMenuOption.html b/src/apps/callflows/submodules/faxdetect/views/dialogMenuOption.html new file mode 100644 index 0000000..7f8f46d --- /dev/null +++ b/src/apps/callflows/submodules/faxdetect/views/dialogMenuOption.html @@ -0,0 +1,22 @@ +
+
+
+ +
+
+
+ +
+