diff --git a/src/apps/callflows/app.js b/src/apps/callflows/app.js index 85368d5..7c86692 100644 --- a/src/apps/callflows/app.js +++ b/src/apps/callflows/app.js @@ -6,6 +6,7 @@ define(function(require) { 'afterbridge', 'audiomacro', 'blacklist', + 'branchvariable', 'callcenter', 'conference', 'device', diff --git a/src/apps/callflows/i18n/en-US.json b/src/apps/callflows/i18n/en-US.json index 3591e04..c8562b0 100644 --- a/src/apps/callflows/i18n/en-US.json +++ b/src/apps/callflows/i18n/en-US.json @@ -120,6 +120,27 @@ }, "are_you_sure_you_want_to_delete": "Are you sure you want to delete this item?" }, + "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.", + "edit_dialog": { + "title": "Branch variable", + "scope_label": "Scope", + "scope_tooltip": "Specifies where the variable is defined", + "variable_label": "Variable", + "variable_tooltip": "Specifies the name of variable/property that should be looked up" + }, + "value_dialog": { + "title": "Variable value", + "value_label": "Value", + "value_tooltip": "specifies the value of variable/property that should be looked up" + }, + "account": "Account", + "custom_channel_vars": "Custom channel vars", + "device": "Device", + "merged": "Merged", + "user": "User" + }, "conference": { "conference": "Conference", "conference_tip": "Connect a caller to a Meet-Me conference bridge", diff --git a/src/apps/callflows/style/app.css b/src/apps/callflows/style/app.css index 4ba8912..ef2e2b5 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/branchvariable/branchvariable.css'); @import url('../../../css/vendor/bootstrap-tour.css'); /* style.css */ #ws_callflow > .callflow { diff --git a/src/apps/callflows/submodules/branchvariable/branchvariable.css b/src/apps/callflows/submodules/branchvariable/branchvariable.css new file mode 100644 index 0000000..4021aed --- /dev/null +++ b/src/apps/callflows/submodules/branchvariable/branchvariable.css @@ -0,0 +1,12 @@ +.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/branchvariable/branchvariable.js b/src/apps/callflows/submodules/branchvariable/branchvariable.js new file mode 100644 index 0000000..c37b83c --- /dev/null +++ b/src/apps/callflows/submodules/branchvariable/branchvariable.js @@ -0,0 +1,164 @@ +define(function(require) { + var $ = require('jquery'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'branchbvariableDefineActions' + }, + + branchbvariableDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions, + i18n = self.i18n.active().callflows.branch_variable; + + self.branchvariableRegisterHandlebarsHelpers(); + + $.extend(callflow_nodes, { + 'branch_variable[]': { + name: i18n.branch_variable, + icon: 'share-alt', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'branch_variable', + tip: i18n.tooltip, + data: { + 'scope': 'custom_channel_vars', + 'variable': '' + }, + rules: [ + { + type: 'quantity', + maxSize: '9999' + } + ], + isUsable: 'true', + weight: 48, + key_caption: function(child_node) { + return child_node.key || ''; + }, + key_edit: function(child_node, callback) { + var $popup, $popupHtml; + + $popupHtml = $(self.getTemplate({ + name: 'dialog_value', + data: { + value: child_node.key + }, + submodule: 'branchvariable' + })); + + $popupHtml.find('.js-save').on('click', function() { + var value = $('input[name="value"]', $popup).val(); + child_node.key = value; + child_node.key_caption = value; + $popup.dialog('close'); + }); + + monster.ui.tooltips($popupHtml); + + $popup = monster.ui.dialog($popupHtml, { + title: i18n.value_dialog.title, + minHeight: '0', + beforeClose: function() { + callback && callback(); + } + }); + }, + caption: function(node, caption_map) { + var scope = node.getMetadata('scope'); + return scope ? i18n[scope] : ''; + }, + edit: function(node, callback) { + self.branchvariableShowEditDialog(node, callback); + } + } + }); + }, + + branchvariableRegisterHandlebarsHelpers: function () { + Handlebars.registerHelper('inc', function(value, options) { + return parseInt(value) + 1; + }); + }, + + branchvariableShowEditDialog: function (node, callback) { + var self = this, + $popup, + $dialog, + i18n = self.i18n.active().callflows.branch_variable, + scope = node.getMetadata('scope'), + variable = node.getMetadata('variable'); + + var scopeList = [ + { + name: i18n.custom_channel_vars, + value: 'custom_channel_vars' + }, { + name: i18n.account, + value: 'account' + }, { + name: i18n.device, + value: 'device' + }, { + name: i18n.user, + value: 'user' + }, { + name: i18n.merged, + value: 'merged' + } + ]; + + $dialog = $(self.getTemplate({ + name: 'dialog_edit', + data: { + scope: scope || 'custom_channel_vars', + scopeList: scopeList.sort(function (a, b) { + if (a.name > b.name) { + return 1; + } + if (a.name < b.name) { + return -1; + } + return 0; + }), + variable: variable || '' + }, + submodule: 'branchvariable' + })); + + $popup = monster.ui.dialog($dialog, { + title: self.i18n.active().callflows.branch_variable.edit_dialog.title, + minHeight: '0', + width: 450, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + + monster.ui.tooltips($dialog); + + $dialog.find('.js-save').click(function(e) { + e.preventDefault(); + var $form = $(this) + .closest('.js-branch-variable-dialog') + .find('.js-branch-variable-form'); + var formData = monster.ui.getFormData($form[0]); + + formData.scope && node.setMetadata('scope', formData.scope); + formData.variable && node.setMetadata('variable', formData.variable); + node.caption = formData.scope && i18n.hasOwnProperty(formData.scope) ? i18n[formData.scope] : ''; + if (typeof callback === 'function') { + callback(); + } + + $popup.dialog('close'); + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/branchvariable/views/dialog_edit.html b/src/apps/callflows/submodules/branchvariable/views/dialog_edit.html new file mode 100644 index 0000000..c475685 --- /dev/null +++ b/src/apps/callflows/submodules/branchvariable/views/dialog_edit.html @@ -0,0 +1,43 @@ +
+
+
+ + + +
+
+ +
+ +
+
diff --git a/src/apps/callflows/submodules/branchvariable/views/dialog_value.html b/src/apps/callflows/submodules/branchvariable/views/dialog_value.html new file mode 100644 index 0000000..269194a --- /dev/null +++ b/src/apps/callflows/submodules/branchvariable/views/dialog_value.html @@ -0,0 +1,21 @@ +
+
+
+ +
+
+
+ +
+