Browse Source

Set Variable submodule

pull/4/head
Vladimir Barkasov 6 years ago
parent
commit
6394a7c2da
4 changed files with 183 additions and 0 deletions
  1. +1
    -0
      src/apps/callflows/app.js
  2. +15
    -0
      src/apps/callflows/i18n/en-US.json
  3. +111
    -0
      src/apps/callflows/submodules/setvariable/setvariable.js
  4. +56
    -0
      src/apps/callflows/submodules/setvariable/views/dialogEdit.html

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

@ -19,6 +19,7 @@ define(function(require) {
'media',
'menu',
'misc',
'setvariable',
'qubicle',
'resource',
'temporalset',


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

@ -659,6 +659,21 @@
"use_carriers_from_specific_account": "Use carriers from a specific account",
"account_id": "Account ID"
},
"set_variable": {
"set_variable": "Set variable",
"tooltip": "Sets a variable on the current leg",
"edit_dialog": {
"title": "Set variable",
"channel": "Channel",
"channel_a": "A (caller)",
"channel_both": "Both",
"channel_tooltip": "Which channel to set the variable on",
"value": "Value",
"value_tooltip": "The value to set \"variable\"",
"variable": "Variable",
"variable_tooltip": "The variable name to set on the leg(s)"
}
},
"timeofday": {
"time_of_day": "Time of Day",
"time_of_day_cat": "Time of Day",


+ 111
- 0
src/apps/callflows/submodules/setvariable/setvariable.js View File

@ -0,0 +1,111 @@
define(function(require) {
var $ = require('jquery'),
monster = require('monster');
var app = {
requests: {},
subscribe: {
'callflows.fetchActions': 'setvariableDefineActions'
},
setvariableDefineActions: function(args) {
var self = this,
callflow_nodes = args.actions,
i18n = self.i18n.active().callflows.set_variable;
$.extend(callflow_nodes, {
'set_variable[]': {
name: i18n.set_variable,
icon: 'check',
category: self.i18n.active().oldCallflows.advanced_cat,
module: 'set_variable',
tip: i18n.tooltip,
data: {
channel: 'a'
},
rules: [
{
type: 'quantity',
maxSize: '9999'
}
],
isUsable: 'true',
weight: 48,
caption: function(node, caption_map) {
return node.getMetadata('variable') || '';
},
edit: function(node, callback) {
self.setvariableShowEditDialog(node, callback);
}
}
});
},
setvariableShowEditDialog: function (node, callback) {
var self = this,
$popup,
$dialog,
i18n = self.i18n.active().callflows.set_variable,
variable = node.getMetadata('variable') || '',
value = node.getMetadata('value') || '',
channel = node.getMetadata('channel') || '';
$dialog = $(self.getTemplate({
name: 'dialogEdit',
data: {
variable: variable,
value: value,
channel: channel,
channels: [
{
'name': i18n.edit_dialog.channel_a,
'value': 'a'
}, {
'name': i18n.edit_dialog.channel_both,
'value': 'both'
}
]
},
submodule: 'setvariable'
}));
$popup = monster.ui.dialog($dialog, {
title: self.i18n.active().callflows.set_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() {
var $form = $(this)
.closest('.js-set-variable-dialog')
.find('.js-set-variable-form');
var formData = monster.ui.getFormData($form[0]);
node.deleteMetadata('variable');
node.deleteMetadata('value');
node.deleteMetadata('channel');
formData.variable && node.setMetadata('variable', formData.variable);
formData.value && node.setMetadata('value', formData.value);
formData.channel && node.setMetadata('channel', formData.channel);
node.caption = formData.variable || '';
if (typeof callback === 'function') {
callback();
}
$popup.dialog('close');
});
}
};
return app;
});

+ 56
- 0
src/apps/callflows/submodules/setvariable/views/dialogEdit.html View File

@ -0,0 +1,56 @@
<div class="dialog_popup callflows-port set-variable-dialog js-set-variable-dialog">
<form method="post" action="#" class="set-variable-form js-set-variable-form">
<div class="form_content">
<div class="popup_field clear">
<label for="set-variable_variable">
{{ i18n.callflows.set_variable.edit_dialog.variable }}
<i class="help-popover fa fa-question-circle"
data-original-title="{{ i18n.callflows.set_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="set-variable_variable"/>
</div>
</div>
<div class="popup_field clear">
<label for="set-variable_value">
{{ i18n.callflows.set_variable.edit_dialog.value }}
<i class="help-popover fa fa-question-circle"
data-original-title="{{ i18n.callflows.set_variable.edit_dialog.value_tooltip}}"
data-placement="right"
data-toggle="tooltip"></i>
</label>
<div class="field_wrapper">
<input name="value" type="text" value="{{ value }}" id="set-variable_value"/>
</div>
</div>
<div class="popup_field clear">
<label for="set-variable_channel">
{{ i18n.callflows.set_variable.edit_dialog.channel }}
<i class="help-popover fa fa-question-circle"
data-original-title="{{ i18n.callflows.set_variable.edit_dialog.channel_tooltip }}"
data-placement="right"
data-toggle="tooltip"></i>
</label>
<div class="select_wrapper">
<select name="channel" id="set-variable_channel">
{{#select channel}}
{{#each channels}}
<option value="{{ this.value }}">{{ this.name }}</option>
{{/each}}
{{/select}}
</select>
</div>
</div>
</div>
</form>
<div class="buttons-center">
<button class="monster-button monster-button-primary js-save">
{{ i18n.save }}
</button>
</div>
</div>

Loading…
Cancel
Save