diff --git a/src/apps/callflows/app.js b/src/apps/callflows/app.js index 7c86692..4ed63d3 100644 --- a/src/apps/callflows/app.js +++ b/src/apps/callflows/app.js @@ -6,6 +6,7 @@ define(function(require) { 'afterbridge', 'audiomacro', 'blacklist', + 'branchbnumber', 'branchvariable', 'callcenter', 'conference', diff --git a/src/apps/callflows/i18n/en-US.json b/src/apps/callflows/i18n/en-US.json index c8562b0..dd5495e 100644 --- a/src/apps/callflows/i18n/en-US.json +++ b/src/apps/callflows/i18n/en-US.json @@ -120,6 +120,25 @@ }, "are_you_sure_you_want_to_delete": "Are you sure you want to delete this item?" }, + "branch_bnumber": { + "branch_bnumber": "Branch Bnumber", + "tooltip": "Try to branch to the capture group of the feature code", + "hunting": "Hunting", + "branching": "Branching", + "menu_option": "Menu option", + "menu_option_title": "Menu Option", + "default_action": "Default action", + "timeout": "Timeout", + "edit_dialog": { + "title": "Branch Bnumber", + "hunt_label": "Hunt", + "hunt_tooltip": "With the hunt flag set to false, the capture group will be used to lookup a child branch", + "hunt_allow_label": "Hunt allow (regexp)", + "hunt_allow_tooltip": "A regexp used to match against the capture group to whitelist allowed numbers to hunt", + "hunt_deny_label": "Hunt deny (regexp)", + "hunt_deny_tooltip": "A regexp used to match against the capture group to blacklist denied numbers to hunt" + } + }, "branch_variable": { "branch_variable": "Branch variable", "tooltip": "The Branch variable callflow enables you to branch based on value of some field inside one of the a call CCVs, user's document, device's document or an account's document.", diff --git a/src/apps/callflows/style/app.css b/src/apps/callflows/style/app.css index ef2e2b5..8d4a0f1 100644 --- a/src/apps/callflows/style/app.css +++ b/src/apps/callflows/style/app.css @@ -12,6 +12,7 @@ @import url('../submodules/callcenter/callcenter.css'); @import url('../submodules/audiomacro/audiomacro.css'); @import url('../submodules/afterbridge/afterbridge.css'); +@import url('../submodules/branchbnumber/branchbnumber.css'); @import url('../submodules/branchvariable/branchvariable.css'); @import url('../../../css/vendor/bootstrap-tour.css'); /* style.css */ diff --git a/src/apps/callflows/submodules/branchbnumber/branchbnumber.css b/src/apps/callflows/submodules/branchbnumber/branchbnumber.css new file mode 100644 index 0000000..0a7172f --- /dev/null +++ b/src/apps/callflows/submodules/branchbnumber/branchbnumber.css @@ -0,0 +1,14 @@ +.dialog_popup .branch-bnumber-form .form_content .checkbox-label-wrapper { + padding-left: 170px; + text-align: left; + width: 200px; + margin-right: 0; + margin-bottom: 13px; + padding-top: 0; +} + +.callflows-port form.branch-bnumber-form label:not(.monster-invalid) { + width: 160px; +} + + diff --git a/src/apps/callflows/submodules/branchbnumber/branchbnumber.js b/src/apps/callflows/submodules/branchbnumber/branchbnumber.js new file mode 100644 index 0000000..f39d30c --- /dev/null +++ b/src/apps/callflows/submodules/branchbnumber/branchbnumber.js @@ -0,0 +1,131 @@ +define(function(require) { + var $ = require('jquery'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'branchbnumberDefineActions' + }, + + branchbnumberDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions, + i18n = self.i18n.active().callflows.branch_bnumber; + + $.extend(callflow_nodes, { + 'branch_bnumber[]': { + name: i18n.branch_bnumber, + icon: 'share-alt', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'branch_bnumber', + tip: i18n.tooltip, + data: { + hunt: true + }, + rules: [ + { + type: 'quantity', + maxSize: '9999' + } + ], + isUsable: 'true', + weight: 48, + key_caption: function(child_node) { + var key = child_node.key; + + return (key !== '_') ? key : i18n.default_action; + }, + key_edit: function(child_node, callback) { + var popup, popup_html; + + popup_html = $(self.getTemplate({ + name: 'dialogMenuOption', + data: { + menuOption: child_node.key + }, + submodule: 'branchbnumber' + })); + + popup_html.find('.js-save').on('click', function() { + var menuOption = $('[name="menu_option"]', popup).val(); + child_node.key = menuOption; + child_node.key_caption = menuOption; + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: i18n.menu_option_title, + minHeight: '0', + beforeClose: function() { + callback && callback(); + } + }); + }, + caption: function(node, caption_map) { + return node.getMetadata('hunt') ? i18n.hunting : i18n.branching; + }, + edit: function(node, callback) { + self.branchbnumberShowEditDialog(node, callback); + } + } + }); + }, + + branchbnumberShowEditDialog: function (node, callback) { + var self = this, + $popup, + $dialog, + i18n = self.i18n.active().callflows.branch_bnumber, + hunt = node.getMetadata('hunt'), + huntAllow = node.getMetadata('hunt_allow'), + huntDeny = node.getMetadata('hunt_deny'); + + $dialog = $(self.getTemplate({ + name: 'dialogEdit', + data: { + hunt: hunt, + huntAllow: huntAllow || '', + huntDeny: huntDeny || '' + }, + submodule: 'branchbnumber' + })); + + $popup = monster.ui.dialog($dialog, { + title: self.i18n.active().callflows.branch_bnumber.edit_dialog.title, + minHeight: '0', + width: 450, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + + monster.ui.tooltips($dialog); + + $dialog.find('.js-save').click(function() { + var $form = $(this) + .closest('.js-branch-bnumber-dialog') + .find('.js-branch-bnumber-form'); + var formData = monster.ui.getFormData($form[0]); + + node.deleteMetadata('hunt_allow'); + node.deleteMetadata('hunt_deny'); + + formData.hunt_allow && node.setMetadata('hunt_allow', formData.hunt_allow); + formData.hunt_deny && node.setMetadata('hunt_deny', formData.hunt_deny); + node.setMetadata('hunt', formData.hunt); + node.caption = formData.hunt ? i18n.hunting : i18n.branching; + if (typeof callback === 'function') { + callback(); + } + + $popup.dialog('close'); + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/branchbnumber/views/dialogEdit.html b/src/apps/callflows/submodules/branchbnumber/views/dialogEdit.html new file mode 100644 index 0000000..04e6806 --- /dev/null +++ b/src/apps/callflows/submodules/branchbnumber/views/dialogEdit.html @@ -0,0 +1,52 @@ +
+
+
+ + + + + +
+
+ +
+ +
+
diff --git a/src/apps/callflows/submodules/branchbnumber/views/dialogMenuOption.html b/src/apps/callflows/submodules/branchbnumber/views/dialogMenuOption.html new file mode 100644 index 0000000..3f66aa7 --- /dev/null +++ b/src/apps/callflows/submodules/branchbnumber/views/dialogMenuOption.html @@ -0,0 +1,17 @@ +
+
+
+ +
+
+
+ +
+