[mobile] Open add comment from context menu
This commit is contained in:
parent
7cf42452ae
commit
79e1acb89d
|
@ -218,8 +218,20 @@ class CommentsController extends Component {
|
|||
class AddCommentController extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.closeAddComment = this.closeAddComment.bind(this);
|
||||
this.getUserInfo = this.getUserInfo.bind(this);
|
||||
this.onAddNewComment = this.onAddNewComment.bind(this);
|
||||
|
||||
this.state = {
|
||||
isOpen: false
|
||||
};
|
||||
|
||||
Common.Notifications.on('addcomment', () => {
|
||||
this.setState({isOpen: true});
|
||||
});
|
||||
}
|
||||
closeAddComment () {
|
||||
this.setState({isOpen: false});
|
||||
}
|
||||
getUserInfo () {
|
||||
this.currentUser = this.props.users.currentUser;
|
||||
|
@ -255,13 +267,8 @@ class AddCommentController extends Component {
|
|||
return false;
|
||||
}
|
||||
render() {
|
||||
const isOpen = this.props.storeComments.isOpenAddComment;
|
||||
let userInfo;
|
||||
if (isOpen) {
|
||||
userInfo = this.getUserInfo();
|
||||
}
|
||||
return(
|
||||
isOpen ? <AddComment userInfo={userInfo} onAddNewComment={this.onAddNewComment} /> : null
|
||||
this.state.isOpen ? <AddComment userInfo={this.getUserInfo()} onAddNewComment={this.onAddNewComment} closeAddComment={this.closeAddComment}/> : null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,15 +102,6 @@ export class storeComments {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Add comment modal window
|
||||
@observable isOpenAddComment = false;
|
||||
|
||||
@action openAddComment (open) {
|
||||
if (open !== this.isOpenAddComment) {
|
||||
this.isOpenAddComment = open;
|
||||
}
|
||||
}
|
||||
|
||||
// Edit comment
|
||||
currentComment = null;
|
||||
@observable isOpenEditComment = false;
|
||||
|
|
|
@ -19,7 +19,7 @@ const AddCommentPopup = inject("storeComments")(observer(props => {
|
|||
<Navbar>
|
||||
<NavLeft>
|
||||
<Link onClick={() => {
|
||||
props.storeComments.openAddComment(false);
|
||||
props.closeAddComment();
|
||||
f7.popup.close('.add-comment-popup');
|
||||
}}>{_t.textCancel}</Link>
|
||||
</NavLeft>
|
||||
|
@ -28,7 +28,7 @@ const AddCommentPopup = inject("storeComments")(observer(props => {
|
|||
<Link className={stateText.length === 0 && 'disabled'}
|
||||
onClick={() => {
|
||||
if (props.onAddNewComment(stateText, false)) {
|
||||
props.storeComments.openAddComment(false);
|
||||
props.closeAddComment();
|
||||
f7.popup.close('.add-comment-popup');
|
||||
}
|
||||
}}>
|
||||
|
@ -87,14 +87,14 @@ const AddCommentDialog = inject("storeComments")(observer(props => {
|
|||
const cancel = document.getElementById('comment-cancel');
|
||||
cancel.addEventListener('click', () => {
|
||||
f7.dialog.close();
|
||||
props.storeComments.openAddComment(false);
|
||||
props.closeAddComment();
|
||||
});
|
||||
const done = document.getElementById('comment-done');
|
||||
done.addEventListener('click', () => {
|
||||
const value = document.getElementById('comment-text').value;
|
||||
if (value.length > 0 && props.onAddNewComment(value, false)) {
|
||||
f7.dialog.close();
|
||||
props.storeComments.openAddComment(false);
|
||||
props.closeAddComment();
|
||||
}
|
||||
});
|
||||
const area = document.getElementById('comment-text');
|
||||
|
@ -118,8 +118,8 @@ const AddCommentDialog = inject("storeComments")(observer(props => {
|
|||
const AddComment = props => {
|
||||
return (
|
||||
Device.phone ?
|
||||
<AddCommentPopup userInfo={props.userInfo} onAddNewComment={props.onAddNewComment} /> :
|
||||
<AddCommentDialog userInfo={props.userInfo} onAddNewComment={props.onAddNewComment} />
|
||||
<AddCommentPopup {...props} /> :
|
||||
<AddCommentDialog {...props} />
|
||||
)
|
||||
};
|
||||
|
||||
|
|
|
@ -47,6 +47,12 @@ class ContextMenu extends ContextMenuController {
|
|||
onMenuItemClick(action) {
|
||||
super.onMenuItemClick(action);
|
||||
|
||||
switch (action) {
|
||||
case 'addcomment':
|
||||
Common.Notifications.trigger('addcomment');
|
||||
break;
|
||||
}
|
||||
|
||||
console.log("click context menu item: " + action);
|
||||
}
|
||||
|
||||
|
@ -78,7 +84,7 @@ class ContextMenu extends ContextMenuController {
|
|||
});
|
||||
}
|
||||
|
||||
if ( canViewComments && this.isComments && isEdit ) {
|
||||
if ( canViewComments && this.isComments && !isEdit ) {
|
||||
itemsText.push({
|
||||
caption: /*me.menuViewComment*/'View Comment',
|
||||
event: 'viewcomment'
|
||||
|
@ -152,6 +158,24 @@ class ContextMenu extends ContextMenuController {
|
|||
});
|
||||
}
|
||||
|
||||
// For test
|
||||
if ( this.isComments && canViewComments ) {
|
||||
itemsText.push({
|
||||
caption: /*me.menuViewComment*/'View Comment',
|
||||
event: 'viewcomment'
|
||||
});
|
||||
}
|
||||
|
||||
const isObject = isShape || isChart || isImage || isTable;
|
||||
const hideAddComment = !canViewComments || api.can_AddQuotedComment() === false || lockedText || lockedTable || lockedImage || lockedHeader || (!isText && isObject);
|
||||
if ( !hideAddComment ) {
|
||||
itemsText.push({
|
||||
caption: /*me.menuAddComment*/'Add Comment',
|
||||
event: 'addcomment'
|
||||
});
|
||||
}
|
||||
// end test
|
||||
|
||||
if ( isTable && api.CheckBeforeMergeCells() && !lockedTable && !lockedHeader) {
|
||||
itemsText.push({
|
||||
caption: /*me.menuMerge*/'Merge',
|
||||
|
@ -215,14 +239,14 @@ class ContextMenu extends ContextMenuController {
|
|||
});
|
||||
}
|
||||
|
||||
const isObject = isShape || isChart || isImage || isTable;
|
||||
/*const isObject = isShape || isChart || isImage || isTable;
|
||||
const hideAddComment = !canViewComments || api.can_AddQuotedComment() === false || lockedText || lockedTable || lockedImage || lockedHeader || (!isText && isObject);
|
||||
if ( !hideAddComment ) {
|
||||
itemsText.push({
|
||||
caption: /*me.menuAddComment*/'Add Comment',
|
||||
caption: 'Add Comment',
|
||||
event: 'addcomment'
|
||||
});
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import EditOptions from '../view/edit/Edit';
|
|||
import AddOptions from '../view/add/Add';
|
||||
import Settings from '../view/settings/Settings';
|
||||
import Collaboration from '../../../../common/mobile/lib/view/collaboration/Collaboration.jsx'
|
||||
import { AddCommentController } from '../../../../common/mobile/lib/controller/collaboration/Comments.jsx';
|
||||
import { Device } from '../../../../common/mobile/utils/device'
|
||||
import { Search, SearchSettings } from '../controller/Search';
|
||||
import ContextMenu from '../controller/ContextMenu';
|
||||
|
|
|
@ -202,7 +202,7 @@ const AddOther = props => {
|
|||
<List>
|
||||
<ListItem title={_t.textComment} onClick={() => {
|
||||
props.closeModal();
|
||||
props.storeComments.openAddComment(true);
|
||||
Common.Notifications.trigger('addcomment');
|
||||
}}>
|
||||
<Icon slot="media" icon="icon-insert-comment"></Icon>
|
||||
</ListItem>
|
||||
|
|
Loading…
Reference in a new issue