[PE mobile] Add checking of hide insert comment, connecting comment components

This commit is contained in:
JuliaSvinareva 2021-03-22 14:35:16 +03:00
parent db7c7343c5
commit 7fb9407ef6
8 changed files with 81 additions and 9 deletions

View file

@ -6,8 +6,7 @@ class CollaborationController extends Component {
constructor(props){
super(props);
Common.Notifications.on('configOptionsFill', () => {
const api = Common.EditorApi.get();
Common.Notifications.on('engineCreated', (api) => {
api.asc_registerCallback('asc_onAuthParticipantsChanged', this.onChangeEditUsers.bind(this));
api.asc_registerCallback('asc_onParticipantsChanged', this.onChangeEditUsers.bind(this));
api.asc_registerCallback('asc_onConnectionStateChanged', this.onUserConnection.bind(this));

View file

@ -238,6 +238,9 @@ class AddCommentController extends Component {
}
getUserInfo () {
this.currentUser = this.props.users.currentUser;
if (!this.currentUser) {
this.currentUser = this.props.users.setCurrentUser(this.props.storeAppOptions.user.id);
}
const name = this.currentUser.asc_getUserName();
return {
name: name,

View file

@ -28,6 +28,7 @@ export class storeUsers {
this.currentUser = item;
}
});
return this.currentUser;
}
connection (change) {

View file

@ -267,6 +267,27 @@
"textThemeColors": "Theme Colors",
"textStandartColors": "Standard Colors",
"textCustomColors": "Custom Colors"
},
"Collaboration": {
"textCollaboration": "Collaboration",
"textBack": "Back",
"textUsers": "Users",
"textEditUser": "Users who are editing the file:",
"textComments": "Comments",
"textAddComment": "Add Comment",
"textCancel": "Cancel",
"textDone": "Done",
"textNoComments": "This document doesn't contain comments",
"textEdit": "Edit",
"textResolve": "Resolve",
"textReopen": "Reopen",
"textAddReply": "Add Reply",
"textDeleteComment": "Delete Comment",
"textMessageDeleteComment": "Do you really want to delete this comment?",
"textMessageDeleteReply": "Do you really want to delete this reply?",
"textDeleteReply": "Delete Reply",
"textEditComment": "Edit Comment",
"textEditReply": "Edit Reply"
}
}
}

View file

@ -1,9 +1,15 @@
import React, { Component } from 'react'
import React, { Component, Fragment } from 'react'
import { inject } from "mobx-react";
import { f7 } from "framework7-react";
import { withTranslation } from 'react-i18next';
import CollaborationController from '../../../../common/mobile/lib/controller/collaboration/Collaboration.jsx'
import CollaborationController from '../../../../common/mobile/lib/controller/collaboration/Collaboration.jsx';
import {
CommentsController,
AddCommentController,
EditCommentController,
ViewCommentsController
} from "../../../../common/mobile/lib/controller/collaboration/Comments";
@inject("storeFocusObjects", "storeAppOptions", "storePresentationInfo", "storePresentationSettings", "storeSlideSettings", "storeTextSettings", "storeTableSettings", "storeChartSettings", "storeLinkSettings")
class MainController extends Component {
@ -346,7 +352,15 @@ class MainController extends Component {
}
render() {
return <CollaborationController />
return (
<Fragment>
<CollaborationController />
<CommentsController />
<AddCommentController />
<EditCommentController />
<ViewCommentsController />
</Fragment>
)
}
componentDidMount() {

View file

@ -88,10 +88,38 @@ class AddOtherController extends Component {
});
}
hideAddComment () {
const api = Common.EditorApi.get();
const stack = api.getSelectedElements();
let isText = false,
isChart = false;
stack.forEach((item) => {
const objectType = item.get_ObjectType();
if (objectType === Asc.c_oAscTypeSelectElement.Paragraph) {
isText = true;
} else if (objectType === Asc.c_oAscTypeSelectElement.Chart) {
isChart = true;
}
});
if (stack.length > 0) {
const topObject = stack[stack.length - 1];
const topObjectValue = topObject.get_ObjectValue();
let objectLocked = typeof topObjectValue.get_Locked === 'function' ? topObjectValue.get_Locked() : false;
!objectLocked && (objectLocked = typeof topObjectValue.get_LockDelete === 'function' ? topObjectValue.get_LockDelete() : false);
if (!objectLocked) {
return ((isText && isChart) || api.can_AddQuotedComment() === false);
}
}
return true;
}
render () {
return (
<AddOther onStyleClick={this.onStyleClick}
<AddOther closeModal={this.closeModal}
onStyleClick={this.onStyleClick}
initStyleTable={this.initStyleTable}
hideAddComment={this.hideAddComment}
/>
)
}

View file

@ -16,6 +16,7 @@ import { storeLinkSettings } from "./linkSettings";
// import {storeParagraphSettings} from "./paragraphSettings";
// import {storeShapeSettings} from "./shapeSettings";
// import {storeImageSettings} from "./imageSettings";
import {storeComments} from "../../../../common/mobile/lib/store/comments";
export const stores = {
storeAppOptions: new storeAppOptions(),
@ -31,10 +32,11 @@ export const stores = {
storeShapeSettings: new storeShapeSettings(),
storeTableSettings: new storeTableSettings(),
storeChartSettings: new storeChartSettings(),
storeLinkSettings: new storeLinkSettings()
storeLinkSettings: new storeLinkSettings(),
// storeTextSettings: new storeTextSettings(),
// storeParagraphSettings: new storeParagraphSettings(),
// storeShapeSettings: new storeShapeSettings(),
// storeChartSettings: new storeChartSettings(),
storeComments: new storeComments()
};

View file

@ -33,6 +33,7 @@ const AddOther = props => {
const { t } = useTranslation();
const _t = t('View.Add', {returnObjects: true});
const showInsertLink = props.storeLinkSettings.canAddLink && !props.storeFocusObjects.paragraphLocked;
const hideAddComment = props.hideAddComment();
return (
<List>
<ListItem title={_t.textTable} link={'/add-table/'} routeProps={{
@ -41,9 +42,12 @@ const AddOther = props => {
}}>
<Icon slot="media" icon="icon-add-table"></Icon>
</ListItem>
<ListItem title={_t.textComment}>
{!hideAddComment && <ListItem title={_t.textComment} onClick={() => {
props.closeModal();
Common.Notifications.trigger('addcomment');
}}>
<Icon slot="media" icon="icon-insert-comment"></Icon>
</ListItem>
</ListItem>}
{showInsertLink &&
<ListItem title={_t.textLink} link={'/add-link/'}>
<Icon slot="media" icon="icon-link"></Icon>