[mobile] Fix user name in comments
This commit is contained in:
parent
64b8e12ff6
commit
12c0492c90
|
@ -43,6 +43,11 @@ const dateToLocaleTimeString = (date) => {
|
|||
// MM/dd/yyyy hh:mm AM
|
||||
return (date.getMonth() + 1) + '/' + (date.getDate()) + '/' + date.getFullYear() + ' ' + format(date);
|
||||
};
|
||||
const parseUserName = name => {
|
||||
return (
|
||||
Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(name))
|
||||
)
|
||||
};
|
||||
//end utils
|
||||
|
||||
class CommentsController extends Component {
|
||||
|
@ -123,10 +128,12 @@ 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();
|
||||
|
||||
changeComment.comment = data.asc_getText();
|
||||
changeComment.userId = data.asc_getUserId();
|
||||
changeComment.userName = data.asc_getUserName();
|
||||
changeComment.userName = name;
|
||||
changeComment.parsedName = parseUserName(name);
|
||||
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: 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 : 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 : 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,7 +265,7 @@ 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,
|
||||
initials: this.props.users.getInitials(name),
|
||||
|
@ -296,7 +309,7 @@ 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,
|
||||
initials: this.props.users.getInitials(name),
|
||||
|
|
|
@ -70,6 +70,7 @@ export class storeComments {
|
|||
comment.comment = changeComment.comment;
|
||||
comment.userId = changeComment.userId;
|
||||
comment.userName = changeComment.userName;
|
||||
comment.parsedName = changeComment.parsedName;
|
||||
comment.userColor = changeComment.userColor;
|
||||
comment.resolved = changeComment.resolved;
|
||||
comment.quote = changeComment.quote;
|
||||
|
|
|
@ -56,7 +56,7 @@ const AddCommentPopup = inject("storeComments")(observer(props => {
|
|||
{Device.android &&
|
||||
<div className='initials' style={{backgroundColor: `${userInfo.color}`}}>{userInfo.initials}</div>
|
||||
}
|
||||
<div className='name'>{GetUserName(userInfo.name)}</div>
|
||||
<div className='name'>{userInfo.name}</div>
|
||||
</div>
|
||||
<div className='wrap-textarea'>
|
||||
<Input type='textarea' placeholder={_t.textAddComment} autofocus value={stateText} onChange={(event) => {setText(event.target.value);}}></Input>
|
||||
|
@ -91,7 +91,7 @@ const AddCommentDialog = inject("storeComments")(observer(props => {
|
|||
<div class='wrap-comment'>
|
||||
<div class="comment-header">
|
||||
${Device.android ? templateInitials : ''}
|
||||
<div class='name'>${GetUserName(userInfo.name)}</div>
|
||||
<div class='name'>${userInfo.name}</div>
|
||||
</div>
|
||||
<div class='wrap-textarea'>
|
||||
<textarea id='comment-text' placeholder='${_t.textAddComment}' autofocus></textarea>
|
||||
|
@ -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'>{GetUserName(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'>${GetUserName(comment.userName)}</div>
|
||||
<div class='name'>${comment.parsedName}</div>
|
||||
<div class='comment-date'>${comment.date}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -352,7 +352,7 @@ const AddReplyPopup = inject("storeComments")(observer(({storeComments, userInfo
|
|||
{Device.android &&
|
||||
<div className='initials' style={{backgroundColor: `${userInfo.color}`}}>{userInfo.initials}</div>
|
||||
}
|
||||
<div className='name'>{GetUserName(userInfo.name)}</div>
|
||||
<div className='name'>{userInfo.name}</div>
|
||||
</div>
|
||||
<div className='wrap-textarea'>
|
||||
<Input type='textarea' placeholder={_t.textAddReply} autofocus value={stateText} onChange={(event) => {setText(event.target.value);}}></Input>
|
||||
|
@ -386,7 +386,7 @@ const AddReplyDialog = inject("storeComments")(observer(({storeComments, userInf
|
|||
<div class='wrap-comment'>
|
||||
<div class="comment-header">
|
||||
${Device.android ? templateInitials : ''}
|
||||
<div class='name'>${GetUserName(userInfo.name)}</div>
|
||||
<div class='name'>${userInfo.name}</div>
|
||||
</div>
|
||||
<div class='wrap-textarea'>
|
||||
<textarea id='reply-text' placeholder='${_t.textAddReply}' autofocus></textarea>
|
||||
|
@ -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'>{GetUserName(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'>${GetUserName(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'>{GetUserName(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'>{GetUserName(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'>{GetUserName(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'>{GetUserName(reply.userName)}</div>
|
||||
<div className='user-name'>{reply.parsedName}</div>
|
||||
<div className='reply-date'>{reply.date}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -929,12 +929,6 @@ const ViewCurrentComments = props => {
|
|||
)
|
||||
};
|
||||
|
||||
const GetUserName = name => {
|
||||
return (
|
||||
Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(name))
|
||||
)
|
||||
};
|
||||
|
||||
export {
|
||||
AddComment,
|
||||
EditComment,
|
||||
|
|
Loading…
Reference in a new issue