2020-10-06 18:51:32 +00:00
|
|
|
import React, { Component, useEffect } from 'react';
|
2020-09-29 18:59:57 +00:00
|
|
|
import { observer, inject } from "mobx-react";
|
2021-02-08 16:32:25 +00:00
|
|
|
import { Popover, List, ListItem, Navbar, NavRight, Sheet, BlockTitle, Page, View, Icon, Link } from 'framework7-react';
|
2020-10-06 18:51:32 +00:00
|
|
|
import { f7 } from 'framework7-react';
|
2021-02-08 16:32:25 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2021-02-11 23:34:01 +00:00
|
|
|
import {Device} from "../../../utils/device";
|
|
|
|
import {ReviewController, ReviewChangeController} from "../../controller/collaboration/Review";
|
|
|
|
import {PageDisplayMode} from "./Review";
|
2021-10-20 17:24:08 +00:00
|
|
|
import {ViewCommentsController, ViewCommentsSheetsController} from "../../controller/collaboration/Comments";
|
2022-11-18 11:59:43 +00:00
|
|
|
import SharingSettings from "../SharingSettings";
|
2021-02-25 16:26:42 +00:00
|
|
|
|
2021-02-08 16:32:25 +00:00
|
|
|
const PageUsers = inject("users")(observer(props => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const _t = t('Common.Collaboration', {returnObjects: true});
|
|
|
|
const storeUsers = props.users;
|
|
|
|
return (
|
2021-05-12 17:00:00 +00:00
|
|
|
<Page name="collab__users" className='page-users'>
|
2021-03-17 18:57:52 +00:00
|
|
|
<Navbar title={_t.textUsers} backLink={_t.textBack}>
|
|
|
|
{Device.phone &&
|
|
|
|
<NavRight>
|
|
|
|
<Link sheetClose=".coauth__sheet">
|
|
|
|
<Icon icon='icon-expand-down'/>
|
|
|
|
</Link>
|
|
|
|
</NavRight>
|
|
|
|
}
|
|
|
|
</Navbar>
|
2021-02-08 16:32:25 +00:00
|
|
|
<List className="coauth__list">
|
2021-05-14 11:03:06 +00:00
|
|
|
{storeUsers.editUsers.map((user, i) => (
|
|
|
|
<ListItem title={user.name + (user.count > 1 ? ` (${user.count})` : '')} key={i}>
|
|
|
|
<div slot="media" className='color' style={{backgroundColor: user.color}}>
|
|
|
|
{user.initials}
|
2021-05-12 17:00:00 +00:00
|
|
|
</div>
|
2021-02-08 16:32:25 +00:00
|
|
|
</ListItem>
|
|
|
|
))}
|
|
|
|
</List>
|
|
|
|
</Page>
|
|
|
|
)
|
|
|
|
}));
|
2020-09-29 18:59:57 +00:00
|
|
|
|
2021-02-08 16:32:25 +00:00
|
|
|
const routes = [
|
|
|
|
{
|
|
|
|
path: '/users/',
|
|
|
|
component: PageUsers
|
2021-02-11 23:34:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/review/',
|
|
|
|
component: ReviewController
|
|
|
|
},
|
2021-03-17 18:57:52 +00:00
|
|
|
{
|
|
|
|
path: '/cm-review/',
|
|
|
|
component: ReviewController,
|
|
|
|
options: {
|
|
|
|
props: {
|
|
|
|
noBack: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-02-11 23:34:01 +00:00
|
|
|
{
|
|
|
|
path: '/display-mode/',
|
|
|
|
component: PageDisplayMode
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/review-change/',
|
|
|
|
component: ReviewChangeController
|
2021-02-25 16:26:42 +00:00
|
|
|
},
|
2021-03-17 18:57:52 +00:00
|
|
|
{
|
|
|
|
path: '/cm-review-change/',
|
|
|
|
component: ReviewChangeController,
|
|
|
|
options: {
|
|
|
|
props: {
|
|
|
|
noBack: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-02-25 16:26:42 +00:00
|
|
|
{
|
|
|
|
path: '/comments/',
|
2021-10-22 11:11:14 +00:00
|
|
|
asyncComponent: () => window.editorType == 'sse' ? ViewCommentsSheetsController : ViewCommentsController,
|
2021-03-08 18:30:42 +00:00
|
|
|
options: {
|
|
|
|
props: {
|
|
|
|
allComments: true
|
|
|
|
}
|
|
|
|
}
|
2022-11-18 11:59:43 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/sharing-settings/',
|
|
|
|
component: SharingSettings
|
2020-09-29 18:59:57 +00:00
|
|
|
}
|
2021-02-08 16:32:25 +00:00
|
|
|
];
|
2020-08-31 17:31:05 +00:00
|
|
|
|
2021-08-10 16:38:55 +00:00
|
|
|
const PageCollaboration = inject('storeAppOptions', 'users')(observer(props => {
|
2021-02-08 16:32:25 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
const _t = t('Common.Collaboration', {returnObjects: true});
|
2021-04-13 15:23:37 +00:00
|
|
|
const appOptions = props.storeAppOptions;
|
2022-11-18 11:59:43 +00:00
|
|
|
const sharingSettingsUrl = appOptions.sharingSettingsUrl;
|
2022-08-11 15:39:56 +00:00
|
|
|
const isViewer = appOptions.isViewer;
|
|
|
|
|
2021-02-08 16:32:25 +00:00
|
|
|
return (
|
2021-03-17 18:57:52 +00:00
|
|
|
<View style={props.style} stackPages={true} routes={routes} url={props.page && `/${props.page}/`}>
|
2021-02-08 16:32:25 +00:00
|
|
|
<Page name="collab__main">
|
|
|
|
<Navbar title={_t.textCollaboration}>
|
2021-03-17 18:57:52 +00:00
|
|
|
{Device.phone &&
|
2021-02-08 16:32:25 +00:00
|
|
|
<NavRight>
|
|
|
|
<Link sheetClose=".coauth__sheet">
|
|
|
|
<Icon icon='icon-expand-down'/>
|
|
|
|
</Link>
|
|
|
|
</NavRight>
|
|
|
|
}
|
2020-08-31 17:31:05 +00:00
|
|
|
</Navbar>
|
|
|
|
<List>
|
2022-11-18 11:59:43 +00:00
|
|
|
{sharingSettingsUrl &&
|
|
|
|
<ListItem title={t('Common.Collaboration.textSharingSettings')} link="/sharing-settings/">
|
|
|
|
<Icon slot="media" icon="icon-sharing-settings"></Icon>
|
|
|
|
</ListItem>
|
|
|
|
}
|
2021-08-10 16:38:55 +00:00
|
|
|
{props.users.editUsers.length > 0 &&
|
|
|
|
<ListItem link={'/users/'} title={_t.textUsers}>
|
|
|
|
<Icon slot="media" icon="icon-users"></Icon>
|
|
|
|
</ListItem>
|
|
|
|
}
|
2021-04-13 15:23:37 +00:00
|
|
|
{appOptions.canViewComments &&
|
2021-02-28 17:47:47 +00:00
|
|
|
<ListItem link='/comments/' title={_t.textComments}>
|
|
|
|
<Icon slot="media" icon="icon-insert-comment"></Icon>
|
|
|
|
</ListItem>
|
|
|
|
}
|
2022-08-11 15:39:56 +00:00
|
|
|
{(window.editorType === 'de' && (appOptions.canReview || appOptions.canViewReview) && !isViewer) &&
|
2021-02-11 23:34:01 +00:00
|
|
|
<ListItem link={'/review/'} title={_t.textReview}>
|
|
|
|
<Icon slot="media" icon="icon-review"></Icon>
|
|
|
|
</ListItem>
|
|
|
|
}
|
2020-08-31 17:31:05 +00:00
|
|
|
</List>
|
2021-02-08 16:32:25 +00:00
|
|
|
</Page>
|
|
|
|
</View>
|
|
|
|
)
|
2020-08-31 17:31:05 +00:00
|
|
|
|
2021-02-28 17:47:47 +00:00
|
|
|
}));
|
2021-02-08 16:32:25 +00:00
|
|
|
class CollaborationView extends Component {
|
2020-08-31 17:31:05 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2021-02-08 16:32:25 +00:00
|
|
|
this.onoptionclick = this.onoptionclick.bind(this);
|
|
|
|
}
|
|
|
|
onoptionclick(page){
|
|
|
|
f7.views.current.router.navigate(page);
|
2020-08-31 17:31:05 +00:00
|
|
|
}
|
|
|
|
render() {
|
2021-02-08 16:32:25 +00:00
|
|
|
const show_popover = this.props.usePopover;
|
2020-08-31 17:31:05 +00:00
|
|
|
return (
|
2021-02-08 16:32:25 +00:00
|
|
|
show_popover ?
|
2021-04-27 12:28:25 +00:00
|
|
|
<Popover id="coauth-popover" className="popover__titled" onPopoverClosed={() => this.props.onclosed()} closeByOutsideClick={false}>
|
2021-03-17 18:57:52 +00:00
|
|
|
<PageCollaboration style={{height: '410px'}} page={this.props.page}/>
|
2021-02-08 16:32:25 +00:00
|
|
|
</Popover> :
|
|
|
|
<Sheet className="coauth__sheet" push onSheetClosed={() => this.props.onclosed()}>
|
2021-03-17 18:57:52 +00:00
|
|
|
<PageCollaboration page={this.props.page}/>
|
2021-02-08 16:32:25 +00:00
|
|
|
</Sheet>
|
2020-08-31 17:31:05 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-08 16:32:25 +00:00
|
|
|
const Collaboration = props => {
|
2020-10-06 18:51:32 +00:00
|
|
|
useEffect(() => {
|
2021-02-08 16:32:25 +00:00
|
|
|
if ( Device.phone ) {
|
|
|
|
f7.sheet.open('.coauth__sheet');
|
|
|
|
} else {
|
|
|
|
f7.popover.open('#coauth-popover', '#btn-coauth');
|
|
|
|
}
|
2020-10-06 18:51:32 +00:00
|
|
|
|
|
|
|
return () => {
|
|
|
|
// component will unmount
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const onviewclosed = () => {
|
2021-10-25 16:45:08 +00:00
|
|
|
if ( props.onclosed ) {
|
|
|
|
props.onclosed();
|
|
|
|
}
|
2020-10-06 18:51:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2021-03-17 18:57:52 +00:00
|
|
|
<CollaborationView usePopover={!Device.phone} onclosed={onviewclosed} page={props.page}/>
|
2020-10-06 18:51:32 +00:00
|
|
|
)
|
|
|
|
};
|
|
|
|
|
2021-02-08 16:32:25 +00:00
|
|
|
export {PageCollaboration}
|
|
|
|
export default Collaboration;
|