From ee06b1b5a1de466f6060272182fbbe0fe596fbc6 Mon Sep 17 00:00:00 2001 From: Remco van Vugt Date: Tue, 20 Feb 2018 17:53:20 +0100 Subject: [PATCH] Added check_cid callflow module to branch on A-number --- src/apps/callflows/i18n/en-US.json | 8 +- src/apps/callflows/submodules/misc/misc.js | 83 +++++++++++++++++++ .../views/check_cid-callflowEdit.html | 14 ++++ .../views/check_cid-childCallflow.html | 23 +++++ 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/apps/callflows/views/check_cid-callflowEdit.html create mode 100644 src/apps/callflows/views/check_cid-childCallflow.html diff --git a/src/apps/callflows/i18n/en-US.json b/src/apps/callflows/i18n/en-US.json index 67e6a23..29edeb1 100644 --- a/src/apps/callflows/i18n/en-US.json +++ b/src/apps/callflows/i18n/en-US.json @@ -1286,7 +1286,13 @@ "current": "Current", "original": "Original" } - } + }, + "check_cid": "Match caller number", + "check_cid_tip": "Branch in a callflow based on the A number", + "check_cid_match": "Match", + "check_cid_nomatch": "No match", + "check_cid_matchnomatch": "Match or no match?", + "regex": "Regex" }, "__comment": "UI-1260: created common control for carrier selection", "__version": "v3.20_s2", diff --git a/src/apps/callflows/submodules/misc/misc.js b/src/apps/callflows/submodules/misc/misc.js index 8eb18b0..3d0fb6c 100644 --- a/src/apps/callflows/submodules/misc/misc.js +++ b/src/apps/callflows/submodules/misc/misc.js @@ -395,6 +395,89 @@ define(function(require){ } } }, + 'check_cid[]': { + name: self.i18n.active().oldCallflows.check_cid, + icon: 'lightbulb-o', + category: self.i18n.active().oldCallflows.caller_id_cat, + module: 'check_cid', + tip: self.i18n.active().oldCallflows.check_cid_tip, + data: { + }, + rules: [ + { + type: 'quantity', + maxSize: 2 + } + ], + isUsable: 'true', + weight: 60, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'check_cid-callflowEdit', { + data_check_cid: { + 'regex': node.getMetadata('regex') || '' + } + })), + popup; + $('#add', popup_html).click(function() { + var regex = $('#regex_input', popup_html).val(); + node.setMetadata('regex', regex); + node.setMetadata('use_absolute_mode', false); + node.caption = regex; + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.check_cid_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + }, + key_caption: function(child_node, caption_map) { + var key = child_node.key; + return (key != '_') ? key : self.i18n.active().oldCallflows.check_cid_match; + }, + key_edit: function(child_node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'check_cid-childCallflow', { + items: { + 'match': self.i18n.active().oldCallflows.check_cid_match, + 'nomatch': self.i18n.active().oldCallflows.check_cid_nomatch + }, + selected: child_node.key + })); + + popup_html.find('#add').on('click', function() { + child_node.key = $('#check_cid_callflow_key_selector', popup_html).val(); + + child_node.key_caption = $('#check_cid_callflow_key_selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.check_cid_matchnomatch, + minHeight: '0', + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + + + } + + }, 'manual_presence[]': { name: self.i18n.active().oldCallflows.manual_presence, icon: 'lightbulb-o', diff --git a/src/apps/callflows/views/check_cid-callflowEdit.html b/src/apps/callflows/views/check_cid-callflowEdit.html new file mode 100644 index 0000000..911e633 --- /dev/null +++ b/src/apps/callflows/views/check_cid-callflowEdit.html @@ -0,0 +1,14 @@ +
+

{{ i18n.oldCallflows.check_cid }}

+
+
+ +
+
+
+ +
+
diff --git a/src/apps/callflows/views/check_cid-childCallflow.html b/src/apps/callflows/views/check_cid-childCallflow.html new file mode 100644 index 0000000..b28d001 --- /dev/null +++ b/src/apps/callflows/views/check_cid-childCallflow.html @@ -0,0 +1,23 @@ +
+
+
+ +
+
+
+ +
+