Merge pull request #1297 from ONLYOFFICE/feature/hide-coauth-users

Feature/hide coauth users
This commit is contained in:
Julia Radzhabova 2021-11-09 20:54:50 +03:00 committed by GitHub
commit 83654aae79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 114 additions and 21 deletions

View file

@ -64,10 +64,18 @@ define([
return this.filter(function(item){return item.get('online') && !item.get('view')}).length; return this.filter(function(item){return item.get('online') && !item.get('view')}).length;
}, },
getVisibleEditingCount: function() {
return this.filter(function(item){return item.get('online') && !item.get('view') && !item.get('hidden')}).length;
},
getEditingOriginalCount: function() { getEditingOriginalCount: function() {
return this.chain().filter(function(item){return item.get('online') && !item.get('view')}).groupBy(function(item) {return item.get('idOriginal');}).size().value(); return this.chain().filter(function(item){return item.get('online') && !item.get('view')}).groupBy(function(item) {return item.get('idOriginal');}).size().value();
}, },
getVisibleEditingOriginalCount: function() {
return this.chain().filter(function(item){return item.get('online') && !item.get('view') && !item.get('hidden')}).groupBy(function(item) {return item.get('idOriginal');}).size().value();
},
findUser: function(id) { findUser: function(id) {
return this.find( return this.find(
function(model){ function(model){

View file

@ -79,6 +79,7 @@ define([
this.placement = this.options.placement; this.placement = this.options.placement;
this.showLink = this.options.showLink; this.showLink = this.options.showLink;
this.showButton = this.options.showButton; this.showButton = this.options.showButton;
this.closable = this.options.closable;
this.textButton = this.options.textButton || ''; this.textButton = this.options.textButton || '';
}, },

View file

@ -89,6 +89,7 @@ define([
setMode: function(mode) { setMode: function(mode) {
this.mode = mode; this.mode = mode;
this.currentUserId = mode.user.id;
if (this.api) { if (this.api) {
if (this.mode.canCoAuthoring && this.mode.canChat) if (this.mode.canCoAuthoring && this.mode.canChat)
@ -142,7 +143,8 @@ define([
username : user.asc_getUserName(), username : user.asc_getUserName(),
online : true, online : true,
color : user.asc_getColor(), color : user.asc_getColor(),
view : user.asc_getView() view : user.asc_getView(),
hidden : !(user.asc_getIdOriginal()===this.currentUserId || AscCommon.UserInfoParser.isUserVisible(user.asc_getUserName()))
}); });
arrUsers[(user.asc_getId() == currentUserId ) ? 'unshift' : 'push'](usermodel); arrUsers[(user.asc_getId() == currentUserId ) ? 'unshift' : 'push'](usermodel);
} }
@ -165,7 +167,8 @@ define([
username : change.asc_getUserName(), username : change.asc_getUserName(),
online : change.asc_getState(), online : change.asc_getState(),
color : change.asc_getColor(), color : change.asc_getColor(),
view : change.asc_getView() view : change.asc_getView(),
hidden : !(change.asc_getIdOriginal()===this.currentUserId || AscCommon.UserInfoParser.isUserVisible(change.asc_getUserName()))
})); }));
} else { } else {
user.set({online: change.asc_getState()}); user.set({online: change.asc_getState()});

View file

@ -62,7 +62,8 @@ define([
color : '#fff', color : '#fff',
colorval : null, colorval : null,
online : false, online : false,
view : false view : false,
hidden : false
} }
} }
}); });

View file

@ -130,11 +130,11 @@ define([
'</section>'; '</section>';
function onResetUsers(collection, opts) { function onResetUsers(collection, opts) {
var usercount = collection.getEditingCount(); var usercount = collection.getVisibleEditingCount();
if ( $userList ) { if ( $userList ) {
if ( usercount > 1 || usercount > 0 && appConfig && !appConfig.isEdit && !appConfig.isRestrictedEdit) { if ( usercount > 1 || usercount > 0 && appConfig && !appConfig.isEdit && !appConfig.isRestrictedEdit) {
$userList.html(templateUserList({ $userList.html(templateUserList({
users: collection.chain().filter(function(item){return item.get('online') && !item.get('view')}).groupBy(function(item) {return item.get('idOriginal');}).value(), users: collection.chain().filter(function(item){return item.get('online') && !item.get('view') && !item.get('hidden')}).groupBy(function(item) {return item.get('idOriginal');}).value(),
usertpl: _.template(templateUserItem), usertpl: _.template(templateUserItem),
fnEncode: function(username) { fnEncode: function(username) {
return Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(username)); return Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(username));
@ -153,7 +153,7 @@ define([
} }
} }
applyUsers( usercount, collection.getEditingOriginalCount() ); applyUsers( usercount, collection.getVisibleEditingOriginalCount() );
}; };
function onUsersChanged(model) { function onUsersChanged(model) {
@ -270,7 +270,7 @@ define([
$panelUsers.find('.cousers-menu') $panelUsers.find('.cousers-menu')
.on('click', function(e) { return false; }); .on('click', function(e) { return false; });
var editingUsers = storeUsers.getEditingCount(); var editingUsers = storeUsers.getVisibleEditingCount();
$btnUsers.tooltip({ $btnUsers.tooltip({
title: (editingUsers > 1 || editingUsers>0 && !appConfig.isEdit && !appConfig.isRestrictedEdit) ? me.tipViewUsers : me.tipAccessRights, title: (editingUsers > 1 || editingUsers>0 && !appConfig.isEdit && !appConfig.isRestrictedEdit) ? me.tipViewUsers : me.tipAccessRights,
titleNorm: me.tipAccessRights, titleNorm: me.tipAccessRights,

View file

@ -366,6 +366,14 @@ define([
} }
return me.guestText; return me.guestText;
}; };
var isUserVisible = function(id){
if (usersStore){
var rec = usersStore.findUser(id);
if (rec)
return !rec.get('hidden');
}
return true;
};
/** coauthoring end **/ /** coauthoring end **/
@ -577,7 +585,7 @@ define([
screenTip.toolTip.getBSTip().$tip.css({top: showPoint[1] + 'px', left: showPoint[0] + 'px'}); screenTip.toolTip.getBSTip().$tip.css({top: showPoint[1] + 'px', left: showPoint[0] + 'px'});
} }
/** coauthoring begin **/ /** coauthoring begin **/
else if (moveData.get_Type()==Asc.c_oAscMouseMoveDataTypes.LockedObject && me.mode.isEdit) { // 2 - locked object else if (moveData.get_Type()==Asc.c_oAscMouseMoveDataTypes.LockedObject && me.mode.isEdit && isUserVisible(moveData.get_UserId())) { // 2 - locked object
var src; var src;
if (me.usertipcount >= me.usertips.length) { if (me.usertipcount >= me.usertips.length) {
src = $(document.createElement("div")); src = $(document.createElement("div"));
@ -613,6 +621,8 @@ define([
}; };
var onShowForeignCursorLabel = function(UserId, X, Y, color) { var onShowForeignCursorLabel = function(UserId, X, Y, color) {
if (!isUserVisible(UserId)) return;
/** coauthoring begin **/ /** coauthoring begin **/
var src; var src;
for (var i=0; i<me.fastcoauthtips.length; i++) { for (var i=0; i<me.fastcoauthtips.length; i++) {

View file

@ -370,6 +370,14 @@ define([
} }
return me.guestText; return me.guestText;
}; };
var isUserVisible = function(id){
if (usersStore){
var rec = usersStore.findUser(id);
if (rec)
return !rec.get('hidden');
}
return true;
};
/** coauthoring end **/ /** coauthoring end **/
var screenTip = { var screenTip = {
@ -534,7 +542,7 @@ define([
} }
} }
/** coauthoring begin **/ /** coauthoring begin **/
else if (moveData.get_Type()==2 && me.mode.isEdit) { // 2 - locked object else if (moveData.get_Type()==2 && me.mode.isEdit && isUserVisible(moveData.get_UserId())) { // 2 - locked object
var src; var src;
if (me.usertipcount >= me.usertips.length) { if (me.usertipcount >= me.usertips.length) {
src = $(document.createElement("div")); src = $(document.createElement("div"));
@ -568,6 +576,8 @@ define([
}; };
var onShowForeignCursorLabel = function(UserId, X, Y, color) { var onShowForeignCursorLabel = function(UserId, X, Y, color) {
if (!isUserVisible(UserId)) return;
/** coauthoring begin **/ /** coauthoring begin **/
var src; var src;
for (var i=0; i<me.fastcoauthtips.length; i++) { for (var i=0; i<me.fastcoauthtips.length; i++) {

View file

@ -1327,7 +1327,7 @@ define([
} }
if (me.permissions.isEdit) { if (me.permissions.isEdit) {
if (index_locked) { if (index_locked && me.isUserVisible(dataarray[index_locked-1].asc_getUserId())) {
data = dataarray[index_locked-1]; data = dataarray[index_locked-1];
if (!coAuthTip.XY) if (!coAuthTip.XY)
@ -1377,7 +1377,7 @@ define([
} }
} }
} }
if (index_foreign) { if (index_foreign && me.isUserVisible(dataarray[index_foreign-1].asc_getUserId())) {
data = dataarray[index_foreign-1]; data = dataarray[index_foreign-1];
if (!coAuthTip.XY) if (!coAuthTip.XY)
@ -3807,6 +3807,8 @@ define([
}, },
onShowForeignCursorLabel: function(UserId, X, Y, color) { onShowForeignCursorLabel: function(UserId, X, Y, color) {
if (!this.isUserVisible(UserId)) return;
/** coauthoring begin **/ /** coauthoring begin **/
var src; var src;
var me = this; var me = this;
@ -3863,6 +3865,16 @@ define([
return this.guestText; return this.guestText;
}, },
isUserVisible: function(id){
var usersStore = SSE.getCollection('Common.Collections.Users');
if (usersStore){
var rec = usersStore.findUser(id);
if (rec)
return !rec.get('hidden');
}
return true;
},
SetDisabled: function(state, canProtect) { SetDisabled: function(state, canProtect) {
this._isDisabled = state; this._isDisabled = state;
this._canProtect = canProtect; this._canProtect = canProtect;

View file

@ -286,7 +286,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
ruleChanged: false, // true if was edited in FormatRulesEditDlg or was created, need to send this rule to sdk if true ruleChanged: false, // true if was edited in FormatRulesEditDlg or was created, need to send this rule to sdk if true
props: rule, props: rule,
lock: (idlock!==null && idlock!==undefined), lock: (idlock!==null && idlock!==undefined),
lockuser: (idlock) ? this.getUserName(idlock) : this.guestText lockuser: (idlock) ? (this.isUserVisible(idlock) ? this.getUserName(idlock) : this.lockText) : this.guestText
}); });
} }
} }
@ -816,7 +816,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
var store = this.rulesList.store, var store = this.rulesList.store,
rec = store.findWhere({ruleId: ruleId}); rec = store.findWhere({ruleId: ruleId});
if (rec) { if (rec) {
rec.set('lockuser', (userId) ? this.getUserName(userId) : this.guestText); rec.set('lockuser', (userId) ? (this.isUserVisible(userId) ? this.getUserName(userId) : this.lockText) : this.guestText);
rec.set('lock', true); rec.set('lock', true);
this.updateButtons(); this.updateButtons();
} }
@ -845,6 +845,16 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
return this.guestText; return this.guestText;
}, },
isUserVisible: function(id){
var usersStore = SSE.getCollection('Common.Collections.Users');
if (usersStore){
var rec = usersStore.findUser(id);
if (rec)
return !rec.get('hidden');
}
return true;
},
txtTitle: 'Conditional Formatting', txtTitle: 'Conditional Formatting',
textNew: 'New', textNew: 'New',
textEdit: 'Edit', textEdit: 'Edit',
@ -886,7 +896,8 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
textDuplicate: 'Duplicate values', textDuplicate: 'Duplicate values',
textUnique: 'Unique values', textUnique: 'Unique values',
tipIsLocked: 'This element is being edited by another user.', tipIsLocked: 'This element is being edited by another user.',
guestText: 'Guest' guestText: 'Guest',
lockText: 'Locked'
}, SSE.Views.FormatRulesManagerDlg || {})); }, SSE.Views.FormatRulesManagerDlg || {}));
}); });

View file

@ -206,7 +206,7 @@ define([ 'text!spreadsheeteditor/main/app/template/NameManagerDlg.template',
scopeName: (scope===null) ? this.textWorkbook: this.sheetNames[scope], scopeName: (scope===null) ? this.textWorkbook: this.sheetNames[scope],
range: (type===Asc.c_oAscDefNameType.slicer) ? '' : this.ranges[i].asc_getRef(), range: (type===Asc.c_oAscDefNameType.slicer) ? '' : this.ranges[i].asc_getRef(),
lock: (id!==null && id!==undefined), lock: (id!==null && id!==undefined),
lockuser: (id) ? this.getUserName(id) : this.guestText, lockuser: (id) ? (this.isUserVisible(id) ? this.getUserName(id) : this.lockText) : this.guestText,
type: type, type: type,
isTable: type===Asc.c_oAscDefNameType.table, isTable: type===Asc.c_oAscDefNameType.table,
isSlicer: type===Asc.c_oAscDefNameType.slicer isSlicer: type===Asc.c_oAscDefNameType.slicer
@ -386,6 +386,16 @@ define([ 'text!spreadsheeteditor/main/app/template/NameManagerDlg.template',
return this.guestText; return this.guestText;
}, },
isUserVisible: function(id){
var usersStore = SSE.getCollection('Common.Collections.Users');
if (usersStore){
var rec = usersStore.findUser(id);
if (rec)
return !rec.get('hidden');
}
return true;
},
onSelectRangeItem: function(lisvView, itemView, record) { onSelectRangeItem: function(lisvView, itemView, record) {
if (!record) return; if (!record) return;
@ -451,7 +461,8 @@ define([ 'text!spreadsheeteditor/main/app/template/NameManagerDlg.template',
textWorkbook: 'Workbook', textWorkbook: 'Workbook',
guestText: 'Guest', guestText: 'Guest',
tipIsLocked: 'This element is being edited by another user.', tipIsLocked: 'This element is being edited by another user.',
warnDelete: 'Are you sure you want to delete the name {0}?' warnDelete: 'Are you sure you want to delete the name {0}?',
lockText: 'Locked'
}, SSE.Views.NameManagerDlg || {})); }, SSE.Views.NameManagerDlg || {}));
}); });

View file

@ -169,7 +169,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
range: ranges[i].asc_getSqref() || '', range: ranges[i].asc_getSqref() || '',
props: ranges[i], props: ranges[i],
lock: (id!==null && id!==undefined), lock: (id!==null && id!==undefined),
lockuser: (id) ? this.getUserName(id) : this.guestText lockuser: (id) ? (this.isUserVisible(id) ? this.getUserName(id) : this.lockText) : this.guestText
}); });
} }
this.rangeList.store.reset(arr); this.rangeList.store.reset(arr);
@ -334,6 +334,16 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
return this.guestText; return this.guestText;
}, },
isUserVisible: function(id){
var usersStore = SSE.getCollection('Common.Collections.Users');
if (usersStore){
var rec = usersStore.findUser(id);
if (rec)
return !rec.get('hidden');
}
return true;
},
onSelectRangeItem: function(lisvView, itemView, record) { onSelectRangeItem: function(lisvView, itemView, record) {
if (!record) return; if (!record) return;
@ -395,7 +405,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
var store = this.rulesList.store, var store = this.rulesList.store,
rec = store.findWhere({ruleId: ruleId}); rec = store.findWhere({ruleId: ruleId});
if (rec) { if (rec) {
rec.set('lockuser', (userId) ? this.getUserName(userId) : this.guestText); rec.set('lockuser', (userId) ? (this.isUserVisible(userId) ? this.getUserName(userId) : this.lockText) : this.guestText);
rec.set('lock', true); rec.set('lock', true);
this.updateButtons(); this.updateButtons();
} }
@ -438,7 +448,8 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
txtYes: 'Yes', txtYes: 'Yes',
txtNo: 'No', txtNo: 'No',
txtEditRange: 'Edit Range', txtEditRange: 'Edit Range',
txtNewRange: 'New Range' txtNewRange: 'New Range',
lockText: 'Locked'
}, SSE.Views.ProtectRangesDlg || {})); }, SSE.Views.ProtectRangesDlg || {}));
}); });

View file

@ -192,7 +192,7 @@ define([
active: view.asc_getIsActive(), active: view.asc_getIsActive(),
view: view, view: view,
lock: (id!==null && id!==undefined), lock: (id!==null && id!==undefined),
lockuser: (id) ? this.getUserName(id) : this.guestText lockuser: (id) ? (this.isUserVisible(id) ? this.getUserName(id) : this.lockText) : this.guestText
}); });
view.asc_getIsActive() && (active = i); view.asc_getIsActive() && (active = i);
} }
@ -315,6 +315,16 @@ define([
return this.guestText; return this.guestText;
}, },
isUserVisible: function(id){
var usersStore = SSE.getCollection('Common.Collections.Users');
if (usersStore){
var rec = usersStore.findUser(id);
if (rec)
return !rec.get('hidden');
}
return true;
},
onSelectItem: function(lisvView, itemView, record) { onSelectItem: function(lisvView, itemView, record) {
if (!record) return; if (!record) return;
@ -374,7 +384,8 @@ define([
textRenameLabel: 'Rename view', textRenameLabel: 'Rename view',
textRenameError: 'View name must not be empty.', textRenameError: 'View name must not be empty.',
warnDeleteView: "You are trying to delete the currently enabled view '%1'.<br>Close this view and delete it?", warnDeleteView: "You are trying to delete the currently enabled view '%1'.<br>Close this view and delete it?",
textLongName: 'Enter a name that is less than 128 characters.' textLongName: 'Enter a name that is less than 128 characters.',
lockText: 'Locked'
}, SSE.Views.ViewManagerDlg || {})); }, SSE.Views.ViewManagerDlg || {}));
}); });

View file

@ -2292,6 +2292,7 @@
"SSE.Views.FormatRulesManagerDlg.textUp": "Move rule up", "SSE.Views.FormatRulesManagerDlg.textUp": "Move rule up",
"SSE.Views.FormatRulesManagerDlg.tipIsLocked": "This element is being edited by another user.", "SSE.Views.FormatRulesManagerDlg.tipIsLocked": "This element is being edited by another user.",
"SSE.Views.FormatRulesManagerDlg.txtTitle": "Conditional Formatting", "SSE.Views.FormatRulesManagerDlg.txtTitle": "Conditional Formatting",
"SSE.Views.FormatRulesManagerDlg.lockText": "Locked",
"SSE.Views.FormatSettingsDialog.textCategory": "Category", "SSE.Views.FormatSettingsDialog.textCategory": "Category",
"SSE.Views.FormatSettingsDialog.textDecimal": "Decimal", "SSE.Views.FormatSettingsDialog.textDecimal": "Decimal",
"SSE.Views.FormatSettingsDialog.textFormat": "Format", "SSE.Views.FormatSettingsDialog.textFormat": "Format",
@ -2521,6 +2522,7 @@
"SSE.Views.NameManagerDlg.tipIsLocked": "This element is being edited by another user.", "SSE.Views.NameManagerDlg.tipIsLocked": "This element is being edited by another user.",
"SSE.Views.NameManagerDlg.txtTitle": "Name Manager", "SSE.Views.NameManagerDlg.txtTitle": "Name Manager",
"SSE.Views.NameManagerDlg.warnDelete": "Are you sure you want to delete the name {0}?", "SSE.Views.NameManagerDlg.warnDelete": "Are you sure you want to delete the name {0}?",
"SSE.Views.NameManagerDlg.lockText": "Locked",
"SSE.Views.PageMarginsDialog.textBottom": "Bottom", "SSE.Views.PageMarginsDialog.textBottom": "Bottom",
"SSE.Views.PageMarginsDialog.textLeft": "Left", "SSE.Views.PageMarginsDialog.textLeft": "Left",
"SSE.Views.PageMarginsDialog.textRight": "Right", "SSE.Views.PageMarginsDialog.textRight": "Right",
@ -2784,6 +2786,7 @@
"SSE.Views.ProtectRangesDlg.txtTitle": "Allow Users to Edit Ranges", "SSE.Views.ProtectRangesDlg.txtTitle": "Allow Users to Edit Ranges",
"SSE.Views.ProtectRangesDlg.txtYes": "Yes", "SSE.Views.ProtectRangesDlg.txtYes": "Yes",
"SSE.Views.ProtectRangesDlg.warnDelete": "Are you sure you want to delete the name {0}?", "SSE.Views.ProtectRangesDlg.warnDelete": "Are you sure you want to delete the name {0}?",
"SSE.Views.ProtectRangesDlg.lockText": "Locked",
"SSE.Views.RemoveDuplicatesDialog.textColumns": "Columns", "SSE.Views.RemoveDuplicatesDialog.textColumns": "Columns",
"SSE.Views.RemoveDuplicatesDialog.textDescription": "To delete duplicate values, select one or more columns that contain duplicates.", "SSE.Views.RemoveDuplicatesDialog.textDescription": "To delete duplicate values, select one or more columns that contain duplicates.",
"SSE.Views.RemoveDuplicatesDialog.textHeaders": "My data has headers", "SSE.Views.RemoveDuplicatesDialog.textHeaders": "My data has headers",
@ -3526,6 +3529,7 @@
"SSE.Views.ViewManagerDlg.tipIsLocked": "This element is being edited by another user.", "SSE.Views.ViewManagerDlg.tipIsLocked": "This element is being edited by another user.",
"SSE.Views.ViewManagerDlg.txtTitle": "Sheet View Manager", "SSE.Views.ViewManagerDlg.txtTitle": "Sheet View Manager",
"SSE.Views.ViewManagerDlg.warnDeleteView": "You are trying to delete the currently enabled view '%1'.<br>Close this view and delete it?", "SSE.Views.ViewManagerDlg.warnDeleteView": "You are trying to delete the currently enabled view '%1'.<br>Close this view and delete it?",
"SSE.Views.ViewManagerDlg.lockText": "Locked",
"SSE.Views.ViewTab.capBtnFreeze": "Freeze Panes", "SSE.Views.ViewTab.capBtnFreeze": "Freeze Panes",
"SSE.Views.ViewTab.capBtnSheetView": "Sheet View", "SSE.Views.ViewTab.capBtnSheetView": "Sheet View",
"SSE.Views.ViewTab.textClose": "Close", "SSE.Views.ViewTab.textClose": "Close",