Merge pull request #958 from ONLYOFFICE/fix/mobile-comments
[Mobile] Fix user name in comments
This commit is contained in:
commit
d3f54b32bd
|
@ -18,6 +18,7 @@ class ContextMenuController extends Component {
|
||||||
extraItems: []
|
extraItems: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.fastCoAuthTips = [];
|
||||||
this.onMenuItemClick = this.onMenuItemClick.bind(this);
|
this.onMenuItemClick = this.onMenuItemClick.bind(this);
|
||||||
this.onMenuClosed = this.onMenuClosed.bind(this);
|
this.onMenuClosed = this.onMenuClosed.bind(this);
|
||||||
this.onActionClosed = this.onActionClosed.bind(this);
|
this.onActionClosed = this.onActionClosed.bind(this);
|
||||||
|
@ -161,9 +162,6 @@ class ContextMenuController extends Component {
|
||||||
/** coauthoring begin **/
|
/** coauthoring begin **/
|
||||||
const tipHeight = 20;
|
const tipHeight = 20;
|
||||||
|
|
||||||
if (!this.fastCoAuthTips) {
|
|
||||||
this.fastCoAuthTips = [];
|
|
||||||
}
|
|
||||||
let src;
|
let src;
|
||||||
for (let i=0; i<this.fastCoAuthTips.length; i++) {
|
for (let i=0; i<this.fastCoAuthTips.length; i++) {
|
||||||
if (this.fastCoAuthTips[i].attr('userid') === UserId) {
|
if (this.fastCoAuthTips[i].attr('userid') === UserId) {
|
||||||
|
|
|
@ -43,6 +43,9 @@ const dateToLocaleTimeString = (date) => {
|
||||||
// MM/dd/yyyy hh:mm AM
|
// MM/dd/yyyy hh:mm AM
|
||||||
return (date.getMonth() + 1) + '/' + (date.getDate()) + '/' + date.getFullYear() + ' ' + format(date);
|
return (date.getMonth() + 1) + '/' + (date.getDate()) + '/' + date.getFullYear() + ' ' + format(date);
|
||||||
};
|
};
|
||||||
|
const parseUserName = name => {
|
||||||
|
return AscCommon.UserInfoParser.getParsedName(name);
|
||||||
|
};
|
||||||
//end utils
|
//end utils
|
||||||
|
|
||||||
class CommentsController extends Component {
|
class CommentsController extends Component {
|
||||||
|
@ -123,10 +126,14 @@ class CommentsController extends Component {
|
||||||
((data.asc_getTime() === '') ? new Date() : new Date(stringUtcToLocalDate(data.asc_getTime())));
|
((data.asc_getTime() === '') ? new Date() : new Date(stringUtcToLocalDate(data.asc_getTime())));
|
||||||
|
|
||||||
let user = this.usersStore.searchUserById(data.asc_getUserId());
|
let user = this.usersStore.searchUserById(data.asc_getUserId());
|
||||||
|
const name = data.asc_getUserName();
|
||||||
|
const parsedName = parseUserName(name);
|
||||||
|
|
||||||
changeComment.comment = data.asc_getText();
|
changeComment.comment = data.asc_getText();
|
||||||
changeComment.userId = data.asc_getUserId();
|
changeComment.userId = data.asc_getUserId();
|
||||||
changeComment.userName = data.asc_getUserName();
|
changeComment.userName = name;
|
||||||
|
changeComment.parsedName = Common.Utils.String.htmlEncode(parsedName);
|
||||||
|
changeComment.userInitials = this.usersStore.getInitials(parsedName);
|
||||||
changeComment.userColor = (user) ? user.asc_getColor() : null;
|
changeComment.userColor = (user) ? user.asc_getColor() : null;
|
||||||
changeComment.resolved = data.asc_getSolved();
|
changeComment.resolved = data.asc_getSolved();
|
||||||
changeComment.quote = data.asc_getQuoteText();
|
changeComment.quote = data.asc_getQuoteText();
|
||||||
|
@ -146,15 +153,17 @@ class CommentsController extends Component {
|
||||||
|
|
||||||
user = this.usersStore.searchUserById(data.asc_getReply(i).asc_getUserId());
|
user = this.usersStore.searchUserById(data.asc_getReply(i).asc_getUserId());
|
||||||
const userName = data.asc_getReply(i).asc_getUserName();
|
const userName = data.asc_getReply(i).asc_getUserName();
|
||||||
|
const parsedName = parseUserName(userName);
|
||||||
replies.push({
|
replies.push({
|
||||||
ind: i,
|
ind: i,
|
||||||
userId: data.asc_getReply(i).asc_getUserId(),
|
userId: data.asc_getReply(i).asc_getUserId(),
|
||||||
userName: userName,
|
userName: userName,
|
||||||
|
parsedName: Common.Utils.String.htmlEncode(parsedName),
|
||||||
userColor: (user) ? user.asc_getColor() : null,
|
userColor: (user) ? user.asc_getColor() : null,
|
||||||
date: dateToLocaleTimeString(dateReply),
|
date: dateToLocaleTimeString(dateReply),
|
||||||
reply: data.asc_getReply(i).asc_getText(),
|
reply: data.asc_getReply(i).asc_getText(),
|
||||||
time: dateReply.getTime(),
|
time: dateReply.getTime(),
|
||||||
userInitials: this.usersStore.getInitials(userName),
|
userInitials: this.usersStore.getInitials(parsedName),
|
||||||
editable: this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId),
|
editable: this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId),
|
||||||
removable: this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)
|
removable: this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)
|
||||||
});
|
});
|
||||||
|
@ -172,10 +181,12 @@ class CommentsController extends Component {
|
||||||
const user = this.usersStore.searchUserById(data.asc_getUserId());
|
const user = this.usersStore.searchUserById(data.asc_getUserId());
|
||||||
const groupName = id.substr(0, id.lastIndexOf('_')+1).match(/^(doc|sheet[0-9_]+)_/);
|
const groupName = id.substr(0, id.lastIndexOf('_')+1).match(/^(doc|sheet[0-9_]+)_/);
|
||||||
const userName = data.asc_getUserName();
|
const userName = data.asc_getUserName();
|
||||||
|
const parsedName = parseUserName(userName);
|
||||||
const comment = {
|
const comment = {
|
||||||
uid : id,
|
uid : id,
|
||||||
userId : data.asc_getUserId(),
|
userId : data.asc_getUserId(),
|
||||||
userName : userName,
|
userName : userName,
|
||||||
|
parsedName : Common.Utils.String.htmlEncode(parsedName),
|
||||||
userColor : (user) ? user.asc_getColor() : null,
|
userColor : (user) ? user.asc_getColor() : null,
|
||||||
date : dateToLocaleTimeString(date),
|
date : dateToLocaleTimeString(date),
|
||||||
quote : data.asc_getQuoteText(),
|
quote : data.asc_getQuoteText(),
|
||||||
|
@ -185,7 +196,7 @@ class CommentsController extends Component {
|
||||||
time : date.getTime(),
|
time : date.getTime(),
|
||||||
replies : [],
|
replies : [],
|
||||||
groupName : (groupName && groupName.length>1) ? groupName[1] : null,
|
groupName : (groupName && groupName.length>1) ? groupName[1] : null,
|
||||||
userInitials : this.usersStore.getInitials(userName),
|
userInitials : this.usersStore.getInitials(parsedName),
|
||||||
editable : this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId),
|
editable : this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId),
|
||||||
removable : this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId)
|
removable : this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId)
|
||||||
};
|
};
|
||||||
|
@ -208,15 +219,17 @@ class CommentsController extends Component {
|
||||||
((data.asc_getReply(i).asc_getTime() === '') ? new Date() : new Date(stringUtcToLocalDate(data.asc_getReply(i).asc_getTime())));
|
((data.asc_getReply(i).asc_getTime() === '') ? new Date() : new Date(stringUtcToLocalDate(data.asc_getReply(i).asc_getTime())));
|
||||||
const user = this.usersStore.searchUserById(data.asc_getReply(i).asc_getUserId());
|
const user = this.usersStore.searchUserById(data.asc_getReply(i).asc_getUserId());
|
||||||
const userName = data.asc_getReply(i).asc_getUserName();
|
const userName = data.asc_getReply(i).asc_getUserName();
|
||||||
|
const parsedName = parseUserName(userName);
|
||||||
replies.push({
|
replies.push({
|
||||||
ind : i,
|
ind : i,
|
||||||
userId : data.asc_getReply(i).asc_getUserId(),
|
userId : data.asc_getReply(i).asc_getUserId(),
|
||||||
userName : userName,
|
userName : userName,
|
||||||
|
parsedName : Common.Utils.String.htmlEncode(parsedName),
|
||||||
userColor : (user) ? user.asc_getColor() : null,
|
userColor : (user) ? user.asc_getColor() : null,
|
||||||
date : dateToLocaleTimeString(date),
|
date : dateToLocaleTimeString(date),
|
||||||
reply : data.asc_getReply(i).asc_getText(),
|
reply : data.asc_getReply(i).asc_getText(),
|
||||||
time : date.getTime(),
|
time : date.getTime(),
|
||||||
userInitials : this.usersStore.getInitials(userName),
|
userInitials : this.usersStore.getInitials(parsedName),
|
||||||
editable : this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId),
|
editable : this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId),
|
||||||
removable : this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)
|
removable : this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId)
|
||||||
});
|
});
|
||||||
|
@ -252,9 +265,9 @@ class AddCommentController extends Component {
|
||||||
if (!this.currentUser) {
|
if (!this.currentUser) {
|
||||||
this.currentUser = this.props.users.setCurrentUser(this.props.storeAppOptions.user.id);
|
this.currentUser = this.props.users.setCurrentUser(this.props.storeAppOptions.user.id);
|
||||||
}
|
}
|
||||||
const name = this.currentUser.asc_getUserName();
|
const name = parseUserName(this.currentUser.asc_getUserName());
|
||||||
return {
|
return {
|
||||||
name: name,
|
name: Common.Utils.String.htmlEncode(name),
|
||||||
initials: this.props.users.getInitials(name),
|
initials: this.props.users.getInitials(name),
|
||||||
color: this.currentUser.asc_getColor()
|
color: this.currentUser.asc_getColor()
|
||||||
};
|
};
|
||||||
|
@ -296,9 +309,9 @@ class EditCommentController extends Component {
|
||||||
}
|
}
|
||||||
getUserInfo () {
|
getUserInfo () {
|
||||||
this.currentUser = this.props.users.currentUser;
|
this.currentUser = this.props.users.currentUser;
|
||||||
const name = this.currentUser.asc_getUserName();
|
const name = parseUserName(this.currentUser.asc_getUserName());
|
||||||
return {
|
return {
|
||||||
name: name,
|
name: Common.Utils.String.htmlEncode(name),
|
||||||
initials: this.props.users.getInitials(name),
|
initials: this.props.users.getInitials(name),
|
||||||
color: this.currentUser.asc_getColor()
|
color: this.currentUser.asc_getColor()
|
||||||
};
|
};
|
||||||
|
|
|
@ -468,13 +468,14 @@ class ReviewChange extends Component {
|
||||||
let change;
|
let change;
|
||||||
let goto = false;
|
let goto = false;
|
||||||
if (arrChangeReview.length > 0) {
|
if (arrChangeReview.length > 0) {
|
||||||
|
const name = AscCommon.UserInfoParser.getParsedName(arrChangeReview[0].user);
|
||||||
change = {
|
change = {
|
||||||
date: arrChangeReview[0].date,
|
date: arrChangeReview[0].date,
|
||||||
user: arrChangeReview[0].user,
|
user: arrChangeReview[0].user,
|
||||||
userName: Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(arrChangeReview[0].user)),
|
userName: Common.Utils.String.htmlEncode(name),
|
||||||
color: arrChangeReview[0].userColor.get_hex(),
|
color: arrChangeReview[0].userColor.get_hex(),
|
||||||
text: arrChangeReview[0].changeText,
|
text: arrChangeReview[0].changeText,
|
||||||
initials: this.props.users.getInitials(arrChangeReview[0].user),
|
initials: this.props.users.getInitials(name),
|
||||||
editable: arrChangeReview[0].editable
|
editable: arrChangeReview[0].editable
|
||||||
};
|
};
|
||||||
goto = arrChangeReview[0].goto;
|
goto = arrChangeReview[0].goto;
|
||||||
|
|
|
@ -70,6 +70,8 @@ export class storeComments {
|
||||||
comment.comment = changeComment.comment;
|
comment.comment = changeComment.comment;
|
||||||
comment.userId = changeComment.userId;
|
comment.userId = changeComment.userId;
|
||||||
comment.userName = changeComment.userName;
|
comment.userName = changeComment.userName;
|
||||||
|
comment.parsedName = changeComment.parsedName;
|
||||||
|
comment.userInitials = changeComment.userInitials;
|
||||||
comment.userColor = changeComment.userColor;
|
comment.userColor = changeComment.userColor;
|
||||||
comment.resolved = changeComment.resolved;
|
comment.resolved = changeComment.resolved;
|
||||||
comment.quote = changeComment.quote;
|
comment.quote = changeComment.quote;
|
||||||
|
|
|
@ -52,7 +52,7 @@ export class storeUsers {
|
||||||
}
|
}
|
||||||
|
|
||||||
getInitials (name) {
|
getInitials (name) {
|
||||||
const fio = AscCommon.UserInfoParser.getParsedName(name).split(' ');
|
const fio = name.split(' ');
|
||||||
let initials = fio[0].substring(0, 1).toUpperCase();
|
let initials = fio[0].substring(0, 1).toUpperCase();
|
||||||
for (let i = fio.length-1; i>0; i--) {
|
for (let i = fio.length-1; i>0; i--) {
|
||||||
if (fio[i][0]!=='(' && fio[i][0]!==')') {
|
if (fio[i][0]!=='(' && fio[i][0]!==')') {
|
||||||
|
|
|
@ -223,7 +223,7 @@ const EditCommentPopup = inject("storeComments")(observer(({storeComments, comme
|
||||||
<div className='initials' style={{backgroundColor: `${comment.userColor}`}}>{comment.userInitials}</div>
|
<div className='initials' style={{backgroundColor: `${comment.userColor}`}}>{comment.userInitials}</div>
|
||||||
}
|
}
|
||||||
<div>
|
<div>
|
||||||
<div className='name'>{comment.userName}</div>
|
<div className='name'>{comment.parsedName}</div>
|
||||||
<div className='comment-date'>{comment.date}</div>
|
<div className='comment-date'>{comment.date}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -260,7 +260,7 @@ const EditCommentDialog = inject("storeComments")(observer(({storeComments, comm
|
||||||
<div class="comment-header">
|
<div class="comment-header">
|
||||||
${Device.android ? templateInitials : ''}
|
${Device.android ? templateInitials : ''}
|
||||||
<div>
|
<div>
|
||||||
<div class='name'>${comment.userName}</div>
|
<div class='name'>${comment.parsedName}</div>
|
||||||
<div class='comment-date'>${comment.date}</div>
|
<div class='comment-date'>${comment.date}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -479,7 +479,7 @@ const EditReplyPopup = inject("storeComments")(observer(({storeComments, comment
|
||||||
<div className='initials' style={{backgroundColor: `${reply.userColor}`}}>{reply.userInitials}</div>
|
<div className='initials' style={{backgroundColor: `${reply.userColor}`}}>{reply.userInitials}</div>
|
||||||
}
|
}
|
||||||
<div>
|
<div>
|
||||||
<div className='name'>{reply.userName}</div>
|
<div className='name'>{reply.parsedName}</div>
|
||||||
<div className='reply-date'>{reply.date}</div>
|
<div className='reply-date'>{reply.date}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -516,7 +516,7 @@ const EditReplyDialog = inject("storeComments")(observer(({storeComments, commen
|
||||||
<div class="comment-header">
|
<div class="comment-header">
|
||||||
${Device.android ? templateInitials : ''}
|
${Device.android ? templateInitials : ''}
|
||||||
<div>
|
<div>
|
||||||
<div class='name'>${reply.userName}</div>
|
<div class='name'>${reply.parsedName}</div>
|
||||||
<div class='reply-date'>${reply.date}</div>
|
<div class='reply-date'>${reply.date}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -663,7 +663,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
|
||||||
<div className='left'>
|
<div className='left'>
|
||||||
{isAndroid && <div className='initials' style={{backgroundColor: `${comment.userColor ? comment.userColor : '#cfcfcf'}`}}>{comment.userInitials}</div>}
|
{isAndroid && <div className='initials' style={{backgroundColor: `${comment.userColor ? comment.userColor : '#cfcfcf'}`}}>{comment.userInitials}</div>}
|
||||||
<div>
|
<div>
|
||||||
<div className='user-name'>{comment.userName}</div>
|
<div className='user-name'>{comment.parsedName}</div>
|
||||||
<div className='comment-date'>{comment.date}</div>
|
<div className='comment-date'>{comment.date}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -693,7 +693,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
|
||||||
<div className='left'>
|
<div className='left'>
|
||||||
{isAndroid && <div className='initials' style={{backgroundColor: `${reply.userColor ? reply.userColor : '#cfcfcf'}`}}>{reply.userInitials}</div>}
|
{isAndroid && <div className='initials' style={{backgroundColor: `${reply.userColor ? reply.userColor : '#cfcfcf'}`}}>{reply.userInitials}</div>}
|
||||||
<div>
|
<div>
|
||||||
<div className='user-name'>{reply.userName}</div>
|
<div className='user-name'>{reply.parsedName}</div>
|
||||||
<div className='reply-date'>{reply.date}</div>
|
<div className='reply-date'>{reply.date}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -792,7 +792,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
|
||||||
<div className='left'>
|
<div className='left'>
|
||||||
{isAndroid && <div className='initials' style={{backgroundColor: `${comment.userColor ? comment.userColor : '#cfcfcf'}`}}>{comment.userInitials}</div>}
|
{isAndroid && <div className='initials' style={{backgroundColor: `${comment.userColor ? comment.userColor : '#cfcfcf'}`}}>{comment.userInitials}</div>}
|
||||||
<div>
|
<div>
|
||||||
<div className='user-name'>{comment.userName}</div>
|
<div className='user-name'>{comment.parsedName}</div>
|
||||||
<div className='comment-date'>{comment.date}</div>
|
<div className='comment-date'>{comment.date}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -822,7 +822,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
|
||||||
<div className='left'>
|
<div className='left'>
|
||||||
{isAndroid && <div className='initials' style={{backgroundColor: `${reply.userColor ? reply.userColor : '#cfcfcf'}`}}>{reply.userInitials}</div>}
|
{isAndroid && <div className='initials' style={{backgroundColor: `${reply.userColor ? reply.userColor : '#cfcfcf'}`}}>{reply.userInitials}</div>}
|
||||||
<div>
|
<div>
|
||||||
<div className='user-name'>{reply.userName}</div>
|
<div className='user-name'>{reply.parsedName}</div>
|
||||||
<div className='reply-date'>{reply.date}</div>
|
<div className='reply-date'>{reply.date}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue