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