From 2e0db02b052ffb4421bcf1ec6e05609de331b9ba Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Mon, 23 Nov 2020 17:04:38 +0300 Subject: [PATCH] [common] Update utils --- apps/common/main/lib/util/utils.js | 42 +++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index d58fa1cda..949b484e0 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -117,7 +117,8 @@ var utils = new(function() { Signature : 9, Pivot : 10, Cell : 11, - Slicer : 12 + Slicer : 12, + Form : 13 }, importTextType = { DRM: 0, @@ -727,6 +728,7 @@ Common.Utils.fillUserInfo = function(info, lang, defname) { var _user = info || {}; !_user.id && (_user.id = ('uid-' + Date.now())); _user.fullname = !_user.name ? defname : _user.name; + _user.group && (_user.fullname = (_user.group).toString() + Common.Utils.UserInfoParser.getSeparator() + _user.fullname); return _user; }; @@ -776,8 +778,10 @@ Common.Utils.loadConfig = function(url, callback) { return response.json(); else return 'error'; }).then(function(json){ - callback(json); - }); + callback(json); + }).catch(function(e) { + callback('error'); + }); }; Common.Utils.asyncCall = function (callback, scope, args) { @@ -974,4 +978,36 @@ Common.Utils.ModalWindow = new(function() { return count>0; } } +})(); + +Common.Utils.UserInfoParser = new(function() { + var parse = false; + var separator = String.fromCharCode(160); + return { + setParser: function(value) { + parse = !!value; + }, + + getSeparator: function() { + return separator; + }, + + getParsedName: function(username) { + if (parse && username) { + return username.substring(username.indexOf(separator)+1); + } else + return username; + }, + + getParsedGroups: function(username) { + if (parse && username) { + var idx = username.indexOf(separator), + groups = (idx>-1) ? username.substring(0, idx).split(',') : []; + for (var i=0; i