Browse Source

Check CID submodule

pull/4/head
Vladimir Barkasov 6 years ago
parent
commit
670bd9c8f1
8 changed files with 467 additions and 1 deletions
  1. +1
    -0
      src/apps/callflows/app.js
  2. +29
    -0
      src/apps/callflows/i18n/en-US.json
  3. +21
    -1
      src/apps/callflows/style/app.css
  4. +7
    -0
      src/apps/callflows/submodules/checkcid/checkcid.css
  5. +278
    -0
      src/apps/callflows/submodules/checkcid/checkcid.js
  6. +81
    -0
      src/apps/callflows/submodules/checkcid/views/dialogEdit.html
  7. +32
    -0
      src/apps/callflows/submodules/checkcid/views/dialogMenuOption.html
  8. +18
    -0
      src/apps/callflows/submodules/checkcid/views/dialogWarning.html

+ 1
- 0
src/apps/callflows/app.js View File

@ -9,6 +9,7 @@ define(function(require) {
'branchbnumber',
'branchvariable',
'callcenter',
'checkcid',
'conference',
'device',
'directory',


+ 29
- 0
src/apps/callflows/i18n/en-US.json View File

@ -160,6 +160,35 @@
"merged": "Merged",
"user": "User"
},
"check_cid": {
"check_cid": "Check Cid",
"tooltip": "Handles inspection of incoming caller id and branching to a child callflow node accordingly.",
"edit_dialog": {
"title": "Check Cid",
"cid_external_name": "Caller id external name",
"cid_external_number": "Caller id external number",
"use_absolute_mode": "Use absolute mode",
"use_absolute_mode_tooltip": "If true, direct call down a branch that matches the caller ID",
"regex": "Regex",
"regex_tooltip": "Determine match/nomatch when \"Use absolute mode\" param is disabled",
"user_id": "User ID",
"user_id_tooltip": "User ID to use as owner instead of detected owner"
},
"menu_option_dialog": {
"title": "Menu option",
"menu_option": "Menu option",
"match": "Match",
"no_match": "No match",
"caller_id": "Caller ID"
},
"warning_dialog": {
"change_mode_warning": "Change mode warning",
"change_mode_warning_message": "You have changed to the absolute mode. Since your callflow has children elements created in another mode, they may not work correctly. You can delete them and recreate them, or make the necessary changes to existing nodes.",
"remove_all_children": "Remove all children",
"change_children_later": "I will change later",
"cancel": "Cancel"
}
},
"conference": {
"conference": "Conference",
"conference_tip": "Connect a caller to a Meet-Me conference bridge",


+ 21
- 1
src/apps/callflows/style/app.css View File

@ -14,6 +14,7 @@
@import url('../submodules/afterbridge/afterbridge.css');
@import url('../submodules/branchbnumber/branchbnumber.css');
@import url('../submodules/branchvariable/branchvariable.css');
@import url('../submodules/checkcid/checkcid.css');
@import url('../../../css/vendor/bootstrap-tour.css');
/* style.css */
#ws_callflow > .callflow {
@ -1396,7 +1397,6 @@
max-width: 214px;
}
.dialog_popup .form_content .checkbox-label-wrapper {
padding-left: 140px;
text-align: left;
@ -1406,6 +1406,20 @@
padding-top: 0;
}
.dialog_popup .dialog_content-part {
margin: 15px 0;
}
.dialog_popup .buttons-center,
.dialog_popup .buttons-center {
padding: 10px 0 0;
}
.dialog_popup .buttons-center button,
.dialog_popup .buttons-center .monster-button {
margin: 0 6px 14px;
}
.callflows-port form label:not(.monster-invalid) {
float: left;
font-size: 15px;
@ -1421,6 +1435,12 @@
width: auto;
}
.callflows-port form label.monster-checkbox {
margin-top: 5px;
display: inline-block;
width: auto;
}
.callflows-port label.monster-invalid {
position: relative;
color: orange;


+ 7
- 0
src/apps/callflows/submodules/checkcid/checkcid.css View File

@ -0,0 +1,7 @@
.check-cid-dialog.callflows-port form label:not(.monster-invalid) {
width: 160px;
}
.no-close .ui-dialog-titlebar-close {
display: none;
}

+ 278
- 0
src/apps/callflows/submodules/checkcid/checkcid.js View File

@ -0,0 +1,278 @@
define(function(require) {
var $ = require('jquery'),
monster = require('monster');
var useAbsoluteMode;
var app = {
requests: {},
subscribe: {
'callflows.fetchActions': 'checkcidDefineActions'
},
checkcidDefineActions: function(args) {
var self = this,
callflow_nodes = args.actions,
i18n = self.i18n.active().callflows.check_cid;
$.extend(callflow_nodes, {
'check_cid[]': {
name: i18n.check_cid,
icon: 'check',
category: self.i18n.active().oldCallflows.caller_id_cat,
module: 'check_cid',
tip: i18n.tooltip,
data: {
use_absolute_mode: false
},
rules: [{
type: 'quantity',
maxSize: 2
}],
isUsable: 'true',
weight: 48,
caption: function(node, caption_map) {
return self.checkcidGetCaptionFromNode(node);
},
edit: function(node, callback) {
self.checkcidShowEditDialog(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: {
useAbsoluteMode: useAbsoluteMode,
selected: child_node.key === '_' ? '' : child_node.key
},
submodule: 'checkcid'
}));
$popup.find('.js-save').on('click', function() {
if(useAbsoluteMode) {
var callerID = $('#check-cid_caller-id', $popup).val();
child_node.key = callerID;
child_node.key_caption = callerID;
} else {
var $regexKeySelectedOption = $('#check-cid_regex-menu-options option:selected', $popup);
var regexKeyVal = $regexKeySelectedOption.val();
var regexKeyText = $regexKeySelectedOption.text();
child_node.key = regexKeyVal;
child_node.key_caption = regexKeyText;
}
$dialog.dialog('close');
});
$dialog = monster.ui.dialog($popup, {
title: self.i18n.active().callflows.check_cid.menu_option_dialog.title,
minHeight: '0',
width: 450,
beforeClose: function() {
if (typeof callback === 'function') {
callback();
}
}
});
}
}
});
},
checkcidGetCaptionFromNode: function (node) {
var caption = '';
useAbsoluteMode = node.getMetadata('use_absolute_mode');
var callerID = node.getMetadata('caller_id');
var regex = node.getMetadata('regex');
if(useAbsoluteMode && callerID && callerID.external) {
if(callerID.external.hasOwnProperty('name')) {
caption = Object.values(callerID.external).join(', ')
}
} else if(regex) {
caption = regex;
}
return caption;
},
checkcidShowEditDialog: function (node, callback) {
var self = this;
self.checkcidGetUsers(function(users) {
var $dialogHtml,
$dialog,
i18n = self.i18n.active().callflows.check_cid,
caller_id = node.getMetadata('caller_id') || {},
regex = node.getMetadata('regex') || '',
user_id = node.getMetadata('user_id') || '';
useAbsoluteMode = node.getMetadata('use_absolute_mode') || false;
$dialogHtml = $(self.getTemplate({
name: 'dialogEdit',
data: {
caller_id: caller_id,
regex: regex,
use_absolute_mode: useAbsoluteMode,
user_id: user_id,
users: users
},
submodule: 'checkcid'
}));
$dialog = monster.ui.dialog($dialogHtml, {
title: self.i18n.active().callflows.check_cid.edit_dialog.title,
minHeight: '0',
width: 450,
beforeClose: function() {
if (typeof callback === 'function') {
callback();
}
}
});
monster.ui.tooltips($dialogHtml);
$('#check-cid_use_absolute_mode', $dialog).change(function (e) {
e.preventDefault();
var useAbsoluteMode = $(this).is(':checked');
if(useAbsoluteMode) {
self.checkcidShowChildNodesWarning({
node: node,
successCallback: function () {
node.rules = [{
type: 'quantity',
maxSize: 999
}];
$('.js-caller-id-mode', $dialog).removeClass('hidden');
$('.js-regexp-mode', $dialog).addClass('hidden');
$('#check-cid_use_absolute_mode', $dialog).prop('checked', useAbsoluteMode);
},
failCallback: function () {
$('#check-cid_use_absolute_mode', $dialog).prop('checked', !useAbsoluteMode);
}
});
} else {
self.checkcidShowChildNodesWarning({
node: node,
successCallback: function () {
node.rules = [{
type: 'quantity',
maxSize: 2
}];
$('.js-caller-id-mode').addClass('hidden');
$('.js-regexp-mode').removeClass('hidden');
$('#check-cid_use_absolute_mode', $dialog).prop('checked', useAbsoluteMode);
},
failCallback: function () {
$('#check-cid_use_absolute_mode', $dialog).prop('checked', !useAbsoluteMode);
}
});
}
});
$dialogHtml.find('.js-save').click(function() {
var $form = $(this)
.closest('.js-check-cid-dialog')
.find('.js-check-cid-form');
var formData = monster.ui.getFormData($form[0]);
useAbsoluteMode = formData.use_absolute_mode;
node.setMetadata('use_absolute_mode', useAbsoluteMode);
if(formData.caller_id && formData.caller_id.hasOwnProperty('external')) {
var external = formData.caller_id.external;
if(external.name || external.number) {
node.setMetadata('caller_id', formData.caller_id);
} else {
node.deleteMetadata('caller_id');
}
}
formData.user_id ? node.setMetadata('user_id', formData.user_id) : node.deleteMetadata('user_id');
formData.regex ? node.setMetadata('regex', formData.regex) : node.deleteMetadata('regex');
node.caption = self.checkcidGetCaptionFromNode(node);
if (typeof callback === 'function') {
callback();
}
$dialog.dialog('close');
});
});
},
checkcidShowChildNodesWarning: function (data) {
var self = this,
$dialog,
$dialogHtml,
node = data.node,
successCallback = data.successCallback,
failCallback = data.failCallback;
if(node.children.length === 0) {
successCallback();
return;
}
$dialogHtml = $(self.getTemplate({
name: 'dialogWarning',
data: {},
submodule: 'checkcid'
}));
$dialog = monster.ui.dialog($dialogHtml, {
title: self.i18n.active().callflows.check_cid.edit_dialog.title,
minHeight: '0',
width: 450,
dialogClass: 'no-close',
});
$('.js-remove-all-children', $dialogHtml).on('click', function (e) {
e.preventDefault();
node.children = [];
self.repaintFlow();
successCallback();
$dialog.dialog('close');
});
$('.js-change-later', $dialogHtml).on('click', function (e) {
e.preventDefault();
successCallback();
$dialog.dialog('close');
});
$('.js-cancel', $dialogHtml).on('click', function (event) {
event.preventDefault();
failCallback();
$dialog.dialog('close');
});
},
checkcidGetUsers: function (callback) {
var self = this;
self.getAll({
resource: 'user.list',
data: {
accountId: self.accountId,
filters: { paginate: false },
generateError: false
},
success: function(users, status) {
callback && callback(users.data);
}
});
},
};
return app;
});

+ 81
- 0
src/apps/callflows/submodules/checkcid/views/dialogEdit.html View File

@ -0,0 +1,81 @@
<div class="dialog_popup callflows-port check-cid-dialog js-check-cid-dialog">
<form method="post" action="#" class="check-cid-form js-check-cid-form">
<div class="form_content">
<div class="popup_field clear">
<label for="check-cid_use_absolute_mode">
{{ i18n.callflows.check_cid.edit_dialog.use_absolute_mode }}
<i class="help-popover fa fa-question-circle"
data-original-title="{{ i18n.callflows.check_cid.edit_dialog.use_absolute_mode_tooltip }}"
data-placement="right"
data-toggle="tooltip"></i>
</label>
<div class="field_wrapper">
{{#monsterCheckbox}}
<input id="check-cid_use_absolute_mode" name="use_absolute_mode" type="checkbox"{{#if use_absolute_mode}} checked="checked"{{/if}}>
{{/monsterCheckbox}}
</div>
</div>
<div class="js-caller-id-mode {{#unless use_absolute_mode}}hidden{{/unless}}">
<div class="popup_field clear">
<label for="check-cid_ext-name">
{{ i18n.callflows.check_cid.edit_dialog.cid_external_name }}
</label>
<div class="field_wrapper">
<input name="caller_id[external][name]" type="text" value="{{ caller_id.external.name }}" id="check-cid_ext-name"/>
</div>
</div>
<div class="popup_field clear">
<label for="check-cid_ext-number">
{{ i18n.callflows.check_cid.edit_dialog.cid_external_number }}
</label>
<div class="field_wrapper">
<input name="caller_id[external][number]" type="text" value="{{ caller_id.external.number }}" id="check-cid_ext-number"/>
</div>
</div>
<div class="popup_field clear">
<label for="check-cid_user-id">
{{ i18n.callflows.check_cid.edit_dialog.user_id }}
<i class="help-popover fa fa-question-circle"
data-original-title="{{ i18n.callflows.check_cid.edit_dialog.user_id_tooltip }}"
data-placement="right"
data-toggle="tooltip"></i>
</label>
<div class="select_wrapper">
<select name="user_id" id="check-cid_user-id">
{{#select user_id}}
<option value=""></option>
{{#each users}}
<option value="{{ this.id }}">{{ this.username }}</option>
{{/each}}
{{/select}}
</select>
</div>
</div>
</div>
<div class="js-regexp-mode {{#if use_absolute_mode}}hidden{{/if}}">
<div class="popup_field clear">
<label for="check-cid_regex">
{{ i18n.callflows.check_cid.edit_dialog.regex }}
<i class="help-popover fa fa-question-circle"
data-original-title="{{ i18n.callflows.check_cid.edit_dialog.regex_tooltip }}"
data-placement="right"
data-toggle="tooltip"></i>
</label>
<div class="field_wrapper">
<input name="regex" placeholder=".*" type="text" value="{{ regex }}" id="check-cid_regex"/>
</div>
</div>
</div>
</div>
</form>
<div class="buttons-center">
<button class="monster-button monster-button-primary js-save">
{{ i18n.save }}
</button>
</div>
</div>

+ 32
- 0
src/apps/callflows/submodules/checkcid/views/dialogMenuOption.html View File

@ -0,0 +1,32 @@
<div class="dialog_popup">
<form name="form" method="post" action="#">
<div class="form_content">
<div class="popup_field clear {{#if useAbsoluteMode }}hidden{{/if}}">
<label for="check-cid_regex-menu-options">
{{ i18n.callflows.check_cid.menu_option_dialog.menu_option }}
</label>
<div class="select_wrapper">
<select name="regex-menu-options" id="check-cid_regex-menu-options">
{{#select selected }}
<option value="match">{{ i18n.callflows.check_cid.menu_option_dialog.match }}</option>
<option value="nomatch">{{ i18n.callflows.check_cid.menu_option_dialog.no_match }}</option>
{{/select}}
</select>
</div>
</div>
</div>
<div class="popup_field clear {{#unless useAbsoluteMode }}hidden{{/unless}}">
<label for="check-cid_caller-id">
{{ i18n.callflows.check_cid.menu_option_dialog.caller_id }}
</label>
<div class="field_wrapper">
<input name="caller_id" type="text" value="{{ selected }}" id="check-cid_caller-id"/>
</div>
</div>
</form>
<div class="buttons-center">
<button class="js-save monster-button monster-button-primary">{{ i18n.save }}</button>
</div>
</div>

+ 18
- 0
src/apps/callflows/submodules/checkcid/views/dialogWarning.html View File

@ -0,0 +1,18 @@
<div class="dialog_popup callflows-port checkcid-warning-dialog js-checkcid-warning-dialog">
{{#monsterPanelText i18n.callflows.check_cid.warning_dialog.change_mode_warning 'warning' 'fill-width'}}
{{{ i18n.callflows.check_cid.warning_dialog.change_mode_warning_message }}}
{{/monsterPanelText}}
<div class="buttons-center">
<button class="monster-button monster-button-danger js-remove-all-children">
{{{ i18n.callflows.check_cid.warning_dialog.remove_all_children }}}
</button>
<button class="monster-button monster-button-primary js-change-later">
{{{ i18n.callflows.check_cid.warning_dialog.change_children_later }}}
</button>
</div>
<div class="buttons-center">
<button class="monster-button monster-button-secondary js-cancel">
{{{ i18n.callflows.check_cid.warning_dialog.cancel }}}
</button>
</div>
</div>

Loading…
Cancel
Save