This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new e7fa21c  [OPENMEETINGS-2000] js errors in quick-poll should be fixed
e7fa21c is described below

commit e7fa21c0a2c8ae5ed2fcb019f2d3fae65da66922
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Sun Dec 27 15:12:59 2020 +0700

    [OPENMEETINGS-2000] js errors in quick-poll should be fixed
---
 .../src/main/front/room/src/quick-poll.js          |  4 +--
 openmeetings-web/src/main/front/room/src/room.js   |  3 +-
 .../src/main/front/room/src/user-list-util.js      | 29 +++++++++++++++++
 .../src/main/front/room/src/user-list.js           | 37 ++++++----------------
 4 files changed, 42 insertions(+), 31 deletions(-)

diff --git a/openmeetings-web/src/main/front/room/src/quick-poll.js 
b/openmeetings-web/src/main/front/room/src/quick-poll.js
index 66422a5..50ffcc1 100644
--- a/openmeetings-web/src/main/front/room/src/quick-poll.js
+++ b/openmeetings-web/src/main/front/room/src/quick-poll.js
@@ -1,10 +1,10 @@
 /* Licensed under the Apache License, Version 2.0 (the "License") 
http://www.apache.org/licenses/LICENSE-2.0 */
-const UserList = require('./user-list');
+const UserListUtil = require('./user-list-util');
 
 function _setQuickPollRights() {
        const close = $('#quick-vote .close-btn');
        if (close.length === 1) {
-               if (UserList.hasRight(['PRESENTER'])) {
+               if (UserListUtil.hasRight(['PRESENTER'])) {
                        close.show();
                        if (typeof(close.data('bs.confirmation')) === 'object') 
{
                                return;
diff --git a/openmeetings-web/src/main/front/room/src/room.js 
b/openmeetings-web/src/main/front/room/src/room.js
index 6e603b6..2891503 100644
--- a/openmeetings-web/src/main/front/room/src/room.js
+++ b/openmeetings-web/src/main/front/room/src/room.js
@@ -4,6 +4,7 @@ const VideoManager = require('./video-manager');
 const Sharer = require('./sharer');
 const Activities = require('./activities');
 const SipDialer = require('./sip-dialer');
+const UserListUtil = require('./user-list-util');
 const UserList = require('./user-list');
 const QuickPoll = require('./quick-poll');
 
@@ -234,7 +235,7 @@ module.exports = {
        , unload: _unload
        , showClipboard: _showClipboard
        , quickPoll: QuickPoll.update
-       , hasRight: UserList.hasRight
+       , hasRight: UserListUtil.hasRight
        , setCssVar: function(key, val) {
                ($('.main.room')[0]).style.setProperty(key, val);
        }
diff --git a/openmeetings-web/src/main/front/room/src/user-list-util.js 
b/openmeetings-web/src/main/front/room/src/user-list-util.js
new file mode 100644
index 0000000..335371e
--- /dev/null
+++ b/openmeetings-web/src/main/front/room/src/user-list-util.js
@@ -0,0 +1,29 @@
+/* Licensed under the Apache License, Version 2.0 (the "License") 
http://www.apache.org/licenses/LICENSE-2.0 */
+let options;
+
+function _hasRight(_inRights, _ref) {
+       const ref = _ref || options.rights;
+       let _rights;
+       if (Array.isArray(_inRights)) {
+               _rights = _inRights;
+       } else {
+               if ('SUPER_MODERATOR' === _inRights) {
+                       return ref.includes(_inRights);
+               }
+               _rights = [_inRights];
+       }
+       const rights = ['SUPER_MODERATOR', 'MODERATOR', ..._rights];
+       for (let i = 0; i < rights.length; ++i) {
+               if (ref.includes(rights[i])) {
+                       return true;
+               }
+       }
+       return false;
+}
+
+module.exports = {
+       init: function(opts) {
+               options = opts;
+       }
+       , hasRight: _hasRight
+};
diff --git a/openmeetings-web/src/main/front/room/src/user-list.js 
b/openmeetings-web/src/main/front/room/src/user-list.js
index 66169e6..f437581 100644
--- a/openmeetings-web/src/main/front/room/src/user-list.js
+++ b/openmeetings-web/src/main/front/room/src/user-list.js
@@ -1,29 +1,10 @@
 /* Licensed under the Apache License, Version 2.0 (the "License") 
http://www.apache.org/licenses/LICENSE-2.0 */
 const VideoManager = require('./video-manager');
+const UserListUtil = require('./user-list-util');
 const QuickPoll = require('./quick-poll');
 
 let options;
 
-function _hasRight(_inRights, _ref) {
-       const ref = _ref || options.rights;
-       let _rights;
-       if (Array.isArray(_inRights)) {
-               _rights = _inRights;
-       } else {
-               if ('SUPER_MODERATOR' === _inRights) {
-                       return ref.includes(_inRights);
-               }
-               _rights = [_inRights];
-       }
-       const rights = ['SUPER_MODERATOR', 'MODERATOR', ..._rights];
-       for (let i = 0; i < rights.length; ++i) {
-               if (ref.includes(rights[i])) {
-                       return true;
-               }
-       }
-       return false;
-}
-
 function __activityAVIcon(elem, selector, predicate, onfunc, disabledfunc) {
        let icon = elem.find(selector);
        if (predicate()) {
@@ -65,11 +46,11 @@ function __activityIcon(elem, selector, predicate, action, 
confirm) {
 }
 function __rightIcon(c, elem, rights, selector, predicate) {
        const self = c.uid === options.uid
-               , hasRight = _hasRight(rights, c.rights);
+               , hasRight = UserListUtil.hasRight(rights, c.rights);
        let icon = elem.find(selector);
-       if (predicate() && !_hasRight('SUPER_MODERATOR', c.rights) && (
+       if (predicate() && !UserListUtil.hasRight('SUPER_MODERATOR', c.rights) 
&& (
                (self && options.questions && !hasRight)
-               || (!self && _hasRight('MODERATOR'))
+               || (!self && UserListUtil.hasRight('MODERATOR'))
        )) {
                if (icon.length === 0) {
                        icon = OmUtil.tmpl('#user-actions-stub ' + selector);
@@ -172,7 +153,7 @@ function _updateClient(c) {
        speaks.hide().removeClass('clickable').attr('title', 
speaks.data('speaks')).off();
        if (hasAudio) {
                speaks.show();
-               if(_hasRight('MUTE_OTHERS')) {
+               if(UserListUtil.hasRight('MUTE_OTHERS')) {
                        speaks.addClass('clickable').click(function () {
                                VideoManager.clickMuteOthers(c.uid);
                        }).attr('title', speaks.attr('title') + 
speaks.data('mute'));
@@ -188,7 +169,7 @@ function _updateClient(c) {
                __rightAudioIcon(c, actions);
                __rightOtherIcons(c, actions);
                __activityIcon(actions, '.kick'
-                       , () => !self && _hasRight('MODERATOR') && 
!_hasRight('SUPER_MODERATOR', c.rights)
+                       , () => !self && UserListUtil.hasRight('MODERATOR') && 
!UserListUtil.hasRight('SUPER_MODERATOR', c.rights)
                        , null
                        , {
                                confirmationEvent: 'om-kick'
@@ -209,11 +190,11 @@ function _updateClient(c) {
                options.activities = c.activities;
                const header = $('#room-sidebar-tab-users .header');
                __rightVideoIcon(c, header);
-               __activityAVIcon(header, '.activity.cam', () => 
!options.audioOnly && _hasRight('VIDEO')
+               __activityAVIcon(header, '.activity.cam', () => 
!options.audioOnly && UserListUtil.hasRight('VIDEO')
                        , () => hasVideo
                        , () => Settings.load().video.cam < 0);
                __rightAudioIcon(c, header);
-               __activityAVIcon(header, '.activity.mic', () => 
_hasRight('AUDIO')
+               __activityAVIcon(header, '.activity.mic', () => 
UserListUtil.hasRight('AUDIO')
                        , () => hasAudio
                        , () => Settings.load().video.mic < 0);
                __rightOtherIcons(c, header);
@@ -224,8 +205,8 @@ function _updateClient(c) {
 module.exports = {
        init: function(opts) {
                options = opts;
+               UserListUtil.init(opts);
        }
-       , hasRight: _hasRight
        , addClient: _addClient
        , updateClient: function(c) {
                _updateClient(c);

Reply via email to