[SSE mobile] Add protection in comments v.2

This commit is contained in:
SergeyEzhin 2021-10-21 23:45:19 +04:00
parent 6044b95c2f
commit bdac3a4521
2 changed files with 15 additions and 63 deletions

View file

@ -5,7 +5,7 @@ import {Device} from '../../../../../common/mobile/utils/device';
import { withTranslation} from 'react-i18next';
import { LocalStorage } from '../../../utils/LocalStorage';
import {AddComment, EditComment, AddReply, EditReply, ViewComments, ViewCurrentComments, ViewAllComments} from '../../view/collaboration/Comments';
import {AddComment, EditComment, AddReply, EditReply, ViewComments, ViewCurrentComments} from '../../view/collaboration/Comments';
// utils
const timeZoneOffsetInMs = (new Date()).getTimezoneOffset() * 60000;
@ -613,9 +613,9 @@ class ViewCommentsController extends Component {
render() {
return(
<Fragment>
{this.props.allComments && <ViewComments onCommentMenuClick={this.onCommentMenuClick} onResolveComment={this.onResolveComment}
{this.props.allComments && <ViewComments wsProps={this.props?.storeWorksheets?.wsProps} onCommentMenuClick={this.onCommentMenuClick} onResolveComment={this.onResolveComment}
showComment={this.showComment} />}
{this.state.isOpenViewCurComments && <ViewCurrentComments opened={this.state.isOpenViewCurComments}
{this.state.isOpenViewCurComments && <ViewCurrentComments wsProps={this.props?.storeWorksheets?.wsProps} opened={this.state.isOpenViewCurComments}
closeCurComments={this.closeViewCurComments}
onCommentMenuClick={this.onCommentMenuClick}
onResolveComment={this.onResolveComment}
@ -629,20 +629,6 @@ class ViewCommentsSheetsController extends ViewCommentsController {
constructor(props) {
super(props);
}
render() {
return (
<Fragment>
{this.props.allComments && <ViewAllComments wsProps={this.props.storeWorksheets.wsProps} onCommentMenuClick={this.onCommentMenuClick} onResolveComment={this.onResolveComment}
showComment={this.showComment} />}
{this.state.isOpenViewCurComments && <ViewCurrentComments opened={this.state.isOpenViewCurComments}
closeCurComments={this.closeViewCurComments}
onCommentMenuClick={this.onCommentMenuClick}
onResolveComment={this.onResolveComment}
/>}
</Fragment>
)
}
}
const _CommentsController = inject('storeAppOptions', 'storeComments', 'users', "storeApplicationSettings")(observer(CommentsController));

View file

@ -674,8 +674,8 @@ const ViewComments = inject("storeComments", "storeAppOptions", "storeReview")(o
</div>
{!viewMode &&
<div className='right'>
{(comment.editable && displayMode === 'markup') && <div className='comment-resolve' onClick={() => {onResolveComment(comment);}}><Icon icon={comment.resolved ? 'icon-resolve-comment check' : 'icon-resolve-comment'} /></div> }
{displayMode === 'markup' &&
{(comment.editable && displayMode === 'markup' && !wsProps?.Objects) && <div className='comment-resolve' onClick={() => {onResolveComment(comment);}}><Icon icon={comment.resolved ? 'icon-resolve-comment check' : 'icon-resolve-comment'} /></div> }
{(displayMode === 'markup' && !wsProps?.Objects) &&
<div className='comment-menu'
onClick={() => {setComment(comment); openActionComment(true);}}>
<Icon icon='icon-menu-comment'/>
@ -741,8 +741,7 @@ const ViewComments = inject("storeComments", "storeAppOptions", "storeReview")(o
// const _ViewComments = inject('storeComments', 'storeAppOptions', "storeReview")(observer(ViewComments));
const CommentList = inject("storeComments", "storeAppOptions", "storeReview")(observer(({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment, storeReview}) => {
const CommentList = inject("storeComments", "storeAppOptions", "storeReview")(observer(({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment, storeReview, wsProps}) => {
const { t } = useTranslation();
const _t = t('Common.Collaboration', {returnObjects: true});
const isAndroid = Device.android;
@ -785,8 +784,8 @@ const CommentList = inject("storeComments", "storeAppOptions", "storeReview")(ob
return (
<Fragment>
<Toolbar position='bottom'>
{!viewMode &&
<Link className='btn-add-reply' href='#' onClick={() => {onCommentMenuClick('addReply', comment);}}>{_t.textAddReply}</Link>
{!viewMode &&
<Link className={`btn-add-reply${wsProps?.Objects ? ' disabled' : ''}`} href='#' onClick={() => {onCommentMenuClick('addReply', comment);}}>{_t.textAddReply}</Link>
}
<div className='comment-navigation row'>
<Link href='#' onClick={onViewPrevComment}><Icon slot='media' icon='icon-prev'/></Link>
@ -807,8 +806,8 @@ const CommentList = inject("storeComments", "storeAppOptions", "storeReview")(ob
</div>
{!viewMode &&
<div className='right'>
{(comment.editable && displayMode === 'markup') && <div className='comment-resolve' onClick={() => {onResolveComment(comment);}}><Icon icon={comment.resolved ? 'icon-resolve-comment check' : 'icon-resolve-comment'}/></div>}
{displayMode === 'markup' &&
{(comment.editable && displayMode === 'markup' && !wsProps?.Objects) && <div className='comment-resolve' onClick={() => {onResolveComment(comment);}}><Icon icon={comment.resolved ? 'icon-resolve-comment check' : 'icon-resolve-comment'}/></div>}
{(displayMode === 'markup' && !wsProps?.Objects) &&
<div className='comment-menu'
onClick={() => {openActionComment(true);}}>
<Icon icon='icon-menu-comment'/>
@ -871,7 +870,7 @@ const CommentList = inject("storeComments", "storeAppOptions", "storeReview")(ob
}));
const ViewCommentSheet = ({closeCurComments, onCommentMenuClick, onResolveComment}) => {
const ViewCommentSheet = ({closeCurComments, onCommentMenuClick, onResolveComment, wsProps}) => {
useEffect(() => {
f7.sheet.open('#view-comment-sheet');
});
@ -917,47 +916,23 @@ const ViewCommentSheet = ({closeCurComments, onCommentMenuClick, onResolveCommen
<div id='swipe-handler' className='swipe-container' onTouchStart={handleTouchStart} onTouchMove={handleTouchMove} onTouchEnd={handleTouchEnd}>
<Icon icon='icon-swipe'/>
</div>
<CommentList onCommentMenuClick={onCommentMenuClick} onResolveComment={onResolveComment}/>
<CommentList wsProps={wsProps} onCommentMenuClick={onCommentMenuClick} onResolveComment={onResolveComment}/>
</Sheet>
)
};
const ViewCommentPopover = ({onCommentMenuClick, onResolveComment}) => {
const ViewCommentPopover = ({onCommentMenuClick, onResolveComment, wsProps}) => {
useEffect(() => {
f7.popover.open('#view-comment-popover', '#btn-coauth');
});
return (
<Popover id='view-comment-popover' style={{height: '410px'}} closeByOutsideClick={false}>
<CommentList onCommentMenuClick={onCommentMenuClick} onResolveComment={onResolveComment} />
<CommentList wsProps={wsProps} onCommentMenuClick={onCommentMenuClick} onResolveComment={onResolveComment} />
</Popover>
)
};
const ViewCommentsPopover = ({wsProps, onCommentMenuClick, onResolveComment, showComment}) => {
useEffect(() => {
f7.popover.open('#view-comments-popover', '#btn-coauth');
});
return (
<Popover id='view-comments-popover' style={{height: '410px'}} closeByOutsideClick={false}>
<ViewComments wsProps={wsProps} onCommentMenuClick={onCommentMenuClick} onResolveComment={onResolveComment} showComment={showComment} />
</Popover>
)
}
const ViewCommentsSheet = ({wsProps, onCommentMenuClick, onResolveComment, showComment}) => {
useEffect(() => {
f7.sheet.open('#view-comments-sheet');
});
return (
<Sheet id='view-comments-sheet'>
<ViewComments wsProps={wsProps} onCommentMenuClick={onCommentMenuClick} onResolveComment={onResolveComment} showComment={showComment} />
</Sheet>
)
}
const ViewCurrentComments = props => {
return (
Device.phone ?
@ -966,14 +941,6 @@ const ViewCurrentComments = props => {
)
};
const ViewAllComments = props => {
return (
Device.phone ?
<ViewCommentsSheet {...props}/> :
<ViewCommentsPopover {...props}/>
)
}
export {
AddComment,
EditComment,
@ -981,6 +948,5 @@ export {
EditReply,
ViewComments,
// _ViewComments as ViewComments,
ViewCurrentComments,
ViewAllComments
ViewCurrentComments
};