diff --git a/src/apps/callflows/app.js b/src/apps/callflows/app.js index c4d36ad..2ef9a70 100644 --- a/src/apps/callflows/app.js +++ b/src/apps/callflows/app.js @@ -10,6 +10,7 @@ define(function(require) { 'branchvariable', 'callcenter', 'checkcid', + 'cidlistmatch', 'conference', 'device', 'directory', diff --git a/src/apps/callflows/i18n/en-US.json b/src/apps/callflows/i18n/en-US.json index 9394daf..4458d3d 100644 --- a/src/apps/callflows/i18n/en-US.json +++ b/src/apps/callflows/i18n/en-US.json @@ -164,6 +164,20 @@ "merged": "Merged", "user": "User" }, + "cid_list_match": { + "cid_list_match": "CID List Match", + "tooltip": "Handles inspection of incoming caller id and branching to a child callflow node accordingly", + "edit_dialog": { + "title": "CID List Match", + "id": "CallerID List ID" + }, + "menu_option_dialog": { + "title": "Menu option", + "menu_option": "Menu option", + "match": "Match", + "no_match": "No match" + } + }, "check_cid": { "check_cid": "Check Cid", "tooltip": "Handles inspection of incoming caller id and branching to a child callflow node accordingly.", diff --git a/src/apps/callflows/style/app.css b/src/apps/callflows/style/app.css index 8a337d9..aff678c 100644 --- a/src/apps/callflows/style/app.css +++ b/src/apps/callflows/style/app.css @@ -15,6 +15,7 @@ @import url('../submodules/branchbnumber/branchbnumber.css'); @import url('../submodules/branchvariable/branchvariable.css'); @import url('../submodules/checkcid/checkcid.css'); +@import url('../submodules/cidlistmatch/cidlistmatch.css'); @import url('../../../css/vendor/bootstrap-tour.css'); /* style.css */ #ws_callflow > .callflow { diff --git a/src/apps/callflows/submodules/cidlistmatch/cidlistmatch.css b/src/apps/callflows/submodules/cidlistmatch/cidlistmatch.css new file mode 100644 index 0000000..735cca7 --- /dev/null +++ b/src/apps/callflows/submodules/cidlistmatch/cidlistmatch.css @@ -0,0 +1,3 @@ +.cid-list-match-form { + margin: 15px 0 0; +} diff --git a/src/apps/callflows/submodules/cidlistmatch/cidlistmatch.js b/src/apps/callflows/submodules/cidlistmatch/cidlistmatch.js new file mode 100644 index 0000000..f83126b --- /dev/null +++ b/src/apps/callflows/submodules/cidlistmatch/cidlistmatch.js @@ -0,0 +1,145 @@ +define(function(require) { + var $ = require('jquery'), + monster = require('monster'); + + var app = { + requests: { + 'callflows.cidlistmatch.lists.get': { + 'verb': 'GET', + 'url': 'accounts/{accountId}/lists' + } + }, + + subscribe: { + 'callflows.fetchActions': 'cidlistmatchDefineActions' + }, + + cidlistmatchDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions, + i18n = self.i18n.active().callflows.cid_list_match; + + $.extend(callflow_nodes, { + 'cidlistmatch[id=*]': { + name: i18n.cid_list_match, + icon: 'group', + category: self.i18n.active().oldCallflows.caller_id_cat, + module: 'cidlistmatch', + tip: i18n.tooltip, + data: {}, + rules: [ + { + type: 'quantity', + maxSize: '2' + } + ], + isUsable: 'true', + weight: 48, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + self.cidlistmatchShowEditDialog(node, callback); + }, + key_caption: function(child_node, caption_map) { + if(child_node.key === 'match') { + return i18n.menu_option_dialog.match; + } else if(child_node.key === 'nomatch') { + return i18n.menu_option_dialog.no_match; + } + return child_node.key; + }, + key_edit: function(child_node, callback) { + var $dialog, $popup; + + $popup = $(self.getTemplate({ + name: 'dialogMenuOption', + data: { + selected: child_node.key + }, + submodule: 'cidlistmatch' + })); + + $popup.find('.js-save').on('click', function() { + var $menuOption = $('#cid-list-match_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.cid_list_match.menu_option_dialog.title, + minHeight: '0', + width: 450, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + } + } + }); + }, + + cidlistmatchShowEditDialog: function (node, callback) { + var self = this, + $popup, + $dialog, + listId = node.getMetadata('id'); + + self.cidlistmatchGetLists(function (lists) { + $dialog = $(self.getTemplate({ + name: 'dialogEdit', + data: { + listId: listId, + lists: lists + }, + submodule: 'cidlistmatch' + })); + + $popup = monster.ui.dialog($dialog, { + title: self.i18n.active().callflows.cid_list_match.edit_dialog.title, + minHeight: '0', + width: 450, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + + $dialog.find('.js-save').click(function() { + var $selectedOption = $('#cid-list-match_id option:selected'); + var listId = $selectedOption.val(); + + node.setMetadata('id', listId); + if (typeof callback === 'function') { + callback(); + } + + $popup.dialog('close'); + }); + }) + }, + + cidlistmatchGetLists: function(callback){ + var self = this; + + monster.request({ + resource: 'callflows.cidlistmatch.lists.get', + data: { + accountId: self.accountId, + generateError: false + }, + success: function (data) { + if(typeof(callback) === 'function') { + callback(data.data); + } + } + }); + }, + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/cidlistmatch/views/dialogEdit.html b/src/apps/callflows/submodules/cidlistmatch/views/dialogEdit.html new file mode 100644 index 0000000..52f3e17 --- /dev/null +++ b/src/apps/callflows/submodules/cidlistmatch/views/dialogEdit.html @@ -0,0 +1,27 @@ +
+
+
+ + +
+
+ +
+ +
+
diff --git a/src/apps/callflows/submodules/cidlistmatch/views/dialogMenuOption.html b/src/apps/callflows/submodules/cidlistmatch/views/dialogMenuOption.html new file mode 100644 index 0000000..f29ae35 --- /dev/null +++ b/src/apps/callflows/submodules/cidlistmatch/views/dialogMenuOption.html @@ -0,0 +1,22 @@ +
+
+
+ +
+
+
+ +
+