Browse Source

Branch Variable submodule

pull/4/head
Vladimir Barkasov 6 years ago
parent
commit
f2aef26574
7 changed files with 263 additions and 0 deletions
  1. +1
    -0
      src/apps/callflows/app.js
  2. +21
    -0
      src/apps/callflows/i18n/en-US.json
  3. +1
    -0
      src/apps/callflows/style/app.css
  4. +12
    -0
      src/apps/callflows/submodules/branchvariable/branchvariable.css
  5. +164
    -0
      src/apps/callflows/submodules/branchvariable/branchvariable.js
  6. +43
    -0
      src/apps/callflows/submodules/branchvariable/views/dialog_edit.html
  7. +21
    -0
      src/apps/callflows/submodules/branchvariable/views/dialog_value.html

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

@ -6,6 +6,7 @@ define(function(require) {
'afterbridge',
'audiomacro',
'blacklist',
'branchvariable',
'callcenter',
'conference',
'device',


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

@ -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",


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

@ -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 {


+ 12
- 0
src/apps/callflows/submodules/branchvariable/branchvariable.css View File

@ -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;
}

+ 164
- 0
src/apps/callflows/submodules/branchvariable/branchvariable.js View File

@ -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;
});

+ 43
- 0
src/apps/callflows/submodules/branchvariable/views/dialog_edit.html View File

@ -0,0 +1,43 @@
<div class="js-branch-variable-dialog dialog_popup callflows-port branch-variable-dialog">
<form method="post" action="#" class="js-branch-variable-form branch-variable-form">
<div class="form_content">
<div class="popup_field clear">
<label for="branch-variable-scope">
{{ i18n.callflows.branch_variable.edit_dialog.scope_label }}
<i class="help-popover fa fa-question-circle"
data-original-title="{{ i18n.callflows.branch_variable.edit_dialog.scope_tooltip }}"
data-placement="right"
data-toggle="tooltip"></i>
</label>
<div class="select_wrapper">
<select name="scope" id="branch-variable-scope">
{{#select scope}}
{{#each scopeList}}
<option value="{{ this.value }}">{{ this.name }}</option>
{{/each}}
{{/select}}
</select>
</div>
</div>
<div class="popup_field clear">
<label for="branch-variable-variable">
{{ i18n.callflows.branch_variable.edit_dialog.variable_label }}
<i class="help-popover fa fa-question-circle"
data-original-title="{{ i18n.callflows.branch_variable.edit_dialog.variable_tooltip }}"
data-placement="right"
data-toggle="tooltip"></i>
</label>
<div class="field_wrapper">
<input name="variable" type="text" value="{{ variable }}" id="branch-variable-variable"/>
</div>
</div>
</div>
</form>
<div class="buttons-center">
<button class="monster-button monster-button-primary js-save">
{{ i18n.save }}
</button>
</div>
</div>

+ 21
- 0
src/apps/callflows/submodules/branchvariable/views/dialog_value.html View File

@ -0,0 +1,21 @@
<div class="js-value-dialog dialog_popup">
<form name="form" method="post" action="#">
<div class="form_content">
<div class="popup_field clear">
<label for="branch-variable-value">
{{ i18n.callflows.branch_variable.value_dialog.value_label }}
<i class="help-popover fa fa-question-circle"
data-original-title="{{ i18n.callflows.branch_variable.value_dialog.value_tooltip }}"
data-placement="right"
data-toggle="tooltip"></i>
</label>
<div class="field_wrapper">
<input name="value" type="text" value="{{ value }}" id="branch-variable-value"/>
</div>
</div>
</div>
</form>
<div class="buttons-center">
<button class="js-save monster-button monster-button-primary">{{ i18n.save }}</button>
</div>
</div>

Loading…
Cancel
Save