From 34091f07731e17b44a660b97868cbfb2e1e26e11 Mon Sep 17 00:00:00 2001 From: Vladimir Barkasov Date: Sun, 16 Feb 2020 21:39:27 +0700 Subject: [PATCH] Language submodule --- src/apps/callflows/app.js | 1 + src/apps/callflows/i18n/en-US.json | 12 +- src/apps/callflows/style/app.css | 1 + .../submodules/language/language.css | 3 + .../callflows/submodules/language/language.js | 111 ++++++++++++++++++ .../submodules/language/views/dialogEdit.html | 26 ++++ src/apps/callflows/submodules/misc/misc.js | 50 -------- .../submodules/misc/views/language.html | 14 --- 8 files changed, 151 insertions(+), 67 deletions(-) create mode 100644 src/apps/callflows/submodules/language/language.css create mode 100644 src/apps/callflows/submodules/language/language.js create mode 100644 src/apps/callflows/submodules/language/views/dialogEdit.html delete mode 100644 src/apps/callflows/submodules/misc/views/language.html diff --git a/src/apps/callflows/app.js b/src/apps/callflows/app.js index 50003fc..3eee193 100644 --- a/src/apps/callflows/app.js +++ b/src/apps/callflows/app.js @@ -20,6 +20,7 @@ define(function(require) { 'featurecodes', 'flushdtmf', 'groups', + 'language', 'media', 'menu', 'misc', diff --git a/src/apps/callflows/i18n/en-US.json b/src/apps/callflows/i18n/en-US.json index 660c75f..6f221de 100644 --- a/src/apps/callflows/i18n/en-US.json +++ b/src/apps/callflows/i18n/en-US.json @@ -1370,6 +1370,15 @@ } }, + "language": { + "language": "Language", + "tooltip": "Prompts and other content take optional language settings to know which to fetch. Use this callflow action to set the language for the call.", + "edit_dialog": { + "title": "Language", + "language": "Language" + } + }, + "__comment": "UI-1929: adding time of day sets to adv. callflows", "__version": "v4.1", "temporalset": { @@ -1633,9 +1642,6 @@ "resource_name": "Resource", "this_callflow_is_outdated": "This callflow is outdated, please resave this callflow before continuing.", "hot_desking_name": "Hot Desking", - "language_title": "Language", - "language": "Language", - "language_tip": "This callflow action lets you change the language of the prompts used in this callflow!", "searchLink": "Search on the server for", "searchReset": "Click again to clear the search", "__comment": "UI-1742: Add a flag to list callflows in Main Numbers", diff --git a/src/apps/callflows/style/app.css b/src/apps/callflows/style/app.css index 8adc494..a505ec0 100644 --- a/src/apps/callflows/style/app.css +++ b/src/apps/callflows/style/app.css @@ -18,6 +18,7 @@ @import url('../submodules/cidlistmatch/cidlistmatch.css'); @import url('../submodules/faxdetect/faxdetect.css'); @import url('../submodules/flushdtmf/flushdtmf.css'); +@import url('../submodules/language/language.css'); @import url('../../../css/vendor/bootstrap-tour.css'); /* style.css */ #ws_callflow > .callflow { diff --git a/src/apps/callflows/submodules/language/language.css b/src/apps/callflows/submodules/language/language.css new file mode 100644 index 0000000..1f51255 --- /dev/null +++ b/src/apps/callflows/submodules/language/language.css @@ -0,0 +1,3 @@ +.language-form { + margin: 15px 0 0; +} diff --git a/src/apps/callflows/submodules/language/language.js b/src/apps/callflows/submodules/language/language.js new file mode 100644 index 0000000..8079226 --- /dev/null +++ b/src/apps/callflows/submodules/language/language.js @@ -0,0 +1,111 @@ +define(function(require) { + var $ = require('jquery'), + monster = require('monster'); + + var languagesList = monster.supportedLanguages.map(function(code) { + var shortLangCode = code.split('-')[0]; + var monsterLanguages = monster.apps.core.i18n.active().monsterLanguages; + var fullLabel = monster.util.tryI18n(monsterLanguages, code); + var labelWithShortLangCode = fullLabel.split(' ')[0] + ' (' + shortLangCode + ')'; + return { + value: code.split('-')[0], + label: labelWithShortLangCode + }; + }); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'languageDefineActions' + }, + + languageDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions, + i18n = self.i18n.active().callflows.language; + + $.extend(callflow_nodes, { + 'language[]': { + name: i18n.language, + icon: 'language', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'language', + tip: i18n.tooltip, + data: {}, + rules: [{ + type: 'quantity', + maxSize: 1 + }], + isUsable: 'true', + weight: 48, + caption: function(node, caption_map) { + var langShortCode = node.getMetadata('language') || ''; + return self.languageGetCaption(langShortCode); + }, + edit: function(node, callback) { + self.languageShowEditDialog(node, callback); + } + } + }); + }, + + languageGetCaption: function(langShortCode) { + var captionText = ''; + if(langShortCode) { + for(var i=0, len=languagesList.length; i +
+
+ +
+
+ +
+ +
+ diff --git a/src/apps/callflows/submodules/misc/misc.js b/src/apps/callflows/submodules/misc/misc.js index 3cc081e..2aaf2f9 100644 --- a/src/apps/callflows/submodules/misc/misc.js +++ b/src/apps/callflows/submodules/misc/misc.js @@ -547,56 +547,6 @@ define(function(require) { }); } }, - 'language[]': { - name: self.i18n.active().oldCallflows.language, - icon: 'language', - category: self.i18n.active().oldCallflows.advanced_cat, - module: 'language', - tip: self.i18n.active().oldCallflows.language_tip, - data: { - }, - rules: [ - { - type: 'quantity', - maxSize: '1' - } - ], - isUsable: 'true', - weight: 50, - caption: function(node) { - return node.getMetadata('language') || ''; - }, - edit: function(node, callback) { - var popup, popup_html; - - popup_html = $(self.getTemplate({ - name: 'language', - data: { - data_language: { - 'language': node.getMetadata('language') || '' - } - }, - submodule: 'misc' - })); - - $('#add', popup_html).click(function() { - var language = $('#language_id_input', popup_html).val(); - node.setMetadata('language', language); - node.caption = language; - - popup.dialog('close'); - }); - - popup = monster.ui.dialog(popup_html, { - title: self.i18n.active().oldCallflows.language_title, - beforeClose: function() { - if (typeof callback === 'function') { - callback(); - } - } - }); - } - }, 'group_pickup[]': { name: self.i18n.active().oldCallflows.group_pickup, icon: 'hand-pointer-o', diff --git a/src/apps/callflows/submodules/misc/views/language.html b/src/apps/callflows/submodules/misc/views/language.html deleted file mode 100644 index 6c71e14..0000000 --- a/src/apps/callflows/submodules/misc/views/language.html +++ /dev/null @@ -1,14 +0,0 @@ -
-

{{ i18n.oldCallflows.language }}

-
-
- -
-
-
- -
-