redux store changed to mobx
This commit is contained in:
parent
ce969e9ca6
commit
14ffba35b7
|
@ -1,30 +1,35 @@
|
||||||
import React, { useState } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { resetUsers } from '../store/actions/actions.js'
|
|
||||||
import Notifications from '../../utils/notifications.js'
|
import Notifications from '../../utils/notifications.js'
|
||||||
|
import {observer, inject} from "mobx-react"
|
||||||
|
|
||||||
const Collaboration = () => {
|
|
||||||
const onChangeEditUsers = (users) => {
|
@inject('users')
|
||||||
const store = Common.Store.get();
|
class CollaborationController extends Component {
|
||||||
store.dispatch(resetUsers(Object.values(users)));
|
constructor(props){
|
||||||
|
super(props)
|
||||||
|
|
||||||
|
Common.Notifications.on('engineCreated', api => {
|
||||||
|
// this.api = api;
|
||||||
|
api.asc_registerCallback('asc_onAuthParticipantsChanged', this.onChangeEditUsers.bind(this));
|
||||||
|
api.asc_registerCallback('asc_onParticipantsChanged', this.onChangeEditUsers.bind(this));
|
||||||
|
// this.api.asc_registerCallback('asc_onAddComment', _.bind(this.onApiAddComment, this));
|
||||||
|
// this.api.asc_registerCallback('asc_onAddComments', _.bind(this.onApiAddComments, this));
|
||||||
|
// this.api.asc_registerCallback('asc_onChangeCommentData', _.bind(this.onApiChangeCommentData, this));
|
||||||
|
// this.api.asc_registerCallback('asc_onRemoveComment', _.bind(this.onApiRemoveComment, this));
|
||||||
|
// this.api.asc_registerCallback('asc_onRemoveComments', _.bind(this.onApiRemoveComments, this));
|
||||||
|
// this.api.asc_registerCallback('asc_onShowComment', _.bind(this.apiShowComments, this));
|
||||||
|
// this.api.asc_registerCallback('asc_onHideComment', _.bind(this.apiHideComments, this));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangeEditUsers(users) {
|
||||||
|
const storeUsers = this.props.users;
|
||||||
|
storeUsers.reset(users);
|
||||||
};
|
};
|
||||||
|
|
||||||
Common.Notifications.on('engineCreated', api => {
|
render() {
|
||||||
// this.api = api;
|
return null
|
||||||
api.asc_registerCallback('asc_onAuthParticipantsChanged', onChangeEditUsers);
|
|
||||||
api.asc_registerCallback('asc_onParticipantsChanged', onChangeEditUsers);
|
|
||||||
// this.api.asc_registerCallback('asc_onAddComment', _.bind(this.onApiAddComment, this));
|
|
||||||
// this.api.asc_registerCallback('asc_onAddComments', _.bind(this.onApiAddComments, this));
|
|
||||||
// this.api.asc_registerCallback('asc_onChangeCommentData', _.bind(this.onApiChangeCommentData, this));
|
|
||||||
// this.api.asc_registerCallback('asc_onRemoveComment', _.bind(this.onApiRemoveComment, this));
|
|
||||||
// this.api.asc_registerCallback('asc_onRemoveComments', _.bind(this.onApiRemoveComments, this));
|
|
||||||
// this.api.asc_registerCallback('asc_onShowComment', _.bind(this.apiShowComments, this));
|
|
||||||
// this.api.asc_registerCallback('asc_onHideComment', _.bind(this.apiHideComments, this));
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
setApi(api) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export {Collaboration as CollaborationController}
|
export default CollaborationController;
|
|
@ -1,11 +1,10 @@
|
||||||
import * as actionTypes from './actions/actions'
|
|
||||||
|
|
||||||
const usersReducer = (state = [], action) => {
|
import {observable, action} from 'mobx';
|
||||||
if (action.type == actionTypes.RESET_USERS) {
|
|
||||||
return [...action.payload];
|
export class storeUsers {
|
||||||
|
@observable users = []
|
||||||
|
|
||||||
|
@action reset(users) {
|
||||||
|
this.users = Object.values(users)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return state;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default usersReducer
|
|
||||||
|
|
|
@ -1,24 +1,33 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { observer, inject } from "mobx-react";
|
||||||
import { Popover, List, ListItem, Navbar, NavTitle, NavRight } from 'framework7-react';
|
import { Popover, List, ListItem, Navbar, NavTitle, NavRight } from 'framework7-react';
|
||||||
import { Sheet, Toolbar, BlockTitle, Link, Page, View, Icon } from 'framework7-react';
|
import { Sheet, Toolbar, BlockTitle, Link, Page, View, Icon } from 'framework7-react';
|
||||||
import { withTranslation, useTranslation } from 'react-i18next';
|
import { withTranslation, useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
const PageUsers = () => {
|
@inject('users')
|
||||||
const { t } = useTranslation();
|
@observer
|
||||||
const userlist = useSelector(state => state.users);
|
class PageUsers extends Component {
|
||||||
return (
|
constructor(props){
|
||||||
<Page name="collab__users">
|
super(props)
|
||||||
<Navbar title="Users" backLink="Back"></Navbar>
|
}
|
||||||
<BlockTitle>{t("Collaboration.textEditUser")}</BlockTitle>
|
|
||||||
<List className="coauth__list">
|
render() {
|
||||||
{userlist.map((model, i) => (
|
const { t } = this.props;
|
||||||
<ListItem title={model.asc_getUserName()} key={i}>
|
const userlist = this.props.users;
|
||||||
<Icon slot="media" icon="coauth__list__icon" style={{ backgroundColor:model.asc_getColor() }}></Icon>
|
return (
|
||||||
</ListItem>
|
<Page name="collab__users">
|
||||||
))}
|
<Navbar title="Users" backLink="Back"></Navbar>
|
||||||
</List>
|
<BlockTitle>{t("Collaboration.textEditUser")}</BlockTitle>
|
||||||
</Page>)
|
<List className="coauth__list">
|
||||||
|
{userlist.users.map((model, i) => (
|
||||||
|
<ListItem title={model.asc_getUserName()} key={i}>
|
||||||
|
<Icon slot="media" icon="coauth__list__icon"
|
||||||
|
style={{backgroundColor: model.asc_getColor()}}></Icon>
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
</Page>)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const PageCollaboration = () => {
|
const PageCollaboration = () => {
|
||||||
|
@ -77,5 +86,6 @@ class CollaborationSheet extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pageusers = withTranslation()(PageUsers);
|
||||||
// export withTranslation()(CollaborationPopover);
|
// export withTranslation()(CollaborationPopover);
|
||||||
export {CollaborationPopover, CollaborationSheet, PageCollaboration, PageUsers, }
|
export {CollaborationPopover, CollaborationSheet, PageCollaboration, pageusers as PageUsers}
|
|
@ -1,33 +1,11 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import {
|
import {App,Panel,Views,View,Popup,Page,Navbar,Toolbar,NavRight,Link,Block,BlockTitle,LoginScreen,LoginScreenTitle,List,ListItem,ListInput,ListButton,BlockFooter} from 'framework7-react';
|
||||||
App,
|
|
||||||
Panel,
|
|
||||||
Views,
|
|
||||||
View,
|
|
||||||
Popup,
|
|
||||||
Page,
|
|
||||||
Navbar,
|
|
||||||
Toolbar,
|
|
||||||
NavRight,
|
|
||||||
Link,
|
|
||||||
Block,
|
|
||||||
BlockTitle,
|
|
||||||
LoginScreen,
|
|
||||||
LoginScreenTitle,
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
ListInput,
|
|
||||||
ListButton,
|
|
||||||
BlockFooter
|
|
||||||
} from 'framework7-react';
|
|
||||||
|
|
||||||
import i18n from '../js/i18n';
|
|
||||||
import routes from '../js/routes';
|
import routes from '../js/routes';
|
||||||
|
|
||||||
import '../../../../common/Gateway.js';
|
import '../../../../common/Gateway.js';
|
||||||
import '../../../../common/main/lib/util/utils.js';
|
import '../../../../common/main/lib/util/utils.js';
|
||||||
import { CollaborationController } from '../../../../common/mobile/lib/controller/Collaboration.jsx';
|
|
||||||
import Notifications from '../../../../common/mobile/utils/notifications.js'
|
import Notifications from '../../../../common/mobile/utils/notifications.js'
|
||||||
import MainController from '../controller/Main';
|
import MainController from '../controller/Main';
|
||||||
|
|
||||||
|
@ -52,9 +30,6 @@ export default class extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
Common.Notifications = new Notifications();
|
Common.Notifications = new Notifications();
|
||||||
|
|
||||||
Common.Controllers = {};
|
|
||||||
Common.Controllers.Collaboration = new CollaborationController();
|
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import { connect } from 'react-redux';
|
import {observer, inject} from "mobx-react";
|
||||||
import {
|
import {Page,Navbar,List,ListItem,BlockTitle} from 'framework7-react';
|
||||||
Page,
|
|
||||||
Navbar,
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
BlockTitle
|
|
||||||
} from 'framework7-react';
|
|
||||||
|
|
||||||
const DocumentSettings = props => {
|
const DocumentSettings = props => {
|
||||||
const textDocumentSettings = "Document Settings";
|
const textDocumentSettings = "Document Settings";
|
||||||
|
@ -20,13 +14,14 @@ const DocumentSettings = props => {
|
||||||
const format = "A4";
|
const format = "A4";
|
||||||
const formatSize = "21 cm x 29.7 cm";
|
const formatSize = "21 cm x 29.7 cm";
|
||||||
|
|
||||||
|
const storeSettings = props.storeDocumentSettings;
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<Navbar title={textDocumentSettings} backLink={textBack} />
|
<Navbar title={textDocumentSettings} backLink={textBack} />
|
||||||
<BlockTitle>{textOrientation}</BlockTitle>
|
<BlockTitle>{textOrientation}</BlockTitle>
|
||||||
<List>
|
<List>
|
||||||
<ListItem radio title={textPortrait} name="orientation-checkbox" checked={props.isPortrait} onClick={e => props.onPageOrientation('portrait')}></ListItem>
|
<ListItem radio title={textPortrait} name="orientation-checkbox" checked={storeSettings.isPortrait} onClick={e => props.onPageOrientation('portrait')}></ListItem>
|
||||||
<ListItem radio title={textLandscape} name="orientation-checkbox" checked={!props.isPortrait} onClick={e => props.onPageOrientation('landscape')}></ListItem>
|
<ListItem radio title={textLandscape} name="orientation-checkbox" checked={!storeSettings.isPortrait} onClick={e => props.onPageOrientation('landscape')}></ListItem>
|
||||||
</List>
|
</List>
|
||||||
<BlockTitle>{textFormat}</BlockTitle>
|
<BlockTitle>{textFormat}</BlockTitle>
|
||||||
<List mediaList>
|
<List mediaList>
|
||||||
|
@ -37,8 +32,4 @@ const DocumentSettings = props => {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
export default inject("storeDocumentSettings")(observer(DocumentSettings));
|
||||||
return state.settings;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(DocumentSettings);
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
|
||||||
import {Component} from 'react'
|
import React, {Component} from 'react'
|
||||||
import {connect} from 'react-redux'
|
import {inject} from "mobx-react";
|
||||||
import * as Actions from '../store/actions/actions'
|
import CollaborationController from '../../../../common/mobile/lib/controller/Collaboration.jsx'
|
||||||
|
|
||||||
|
@inject("storeDocumentSettings")
|
||||||
class MainController extends Component {
|
class MainController extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
@ -157,15 +158,15 @@ class MainController extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
bindEvents() {
|
bindEvents() {
|
||||||
const {dispatch} = this.props;
|
const storeSettings = this.props.storeDocumentSettings;
|
||||||
this.api.asc_registerCallback('asc_onPageOrient', isPortrait => {
|
this.api.asc_registerCallback('asc_onPageOrient', isPortrait => {
|
||||||
dispatch(Actions.changePageOrientation(isPortrait === true));
|
storeSettings.isPortrait = isPortrait === true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return null
|
return <CollaborationController />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(null,null,null,{forwardRef:true})(MainController);
|
export default MainController;
|
||||||
|
|
|
@ -24,8 +24,8 @@ import App from '../components/app.jsx';
|
||||||
import { I18nextProvider } from 'react-i18next';
|
import { I18nextProvider } from 'react-i18next';
|
||||||
import i18n from './i18n';
|
import i18n from './i18n';
|
||||||
|
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'mobx-react'
|
||||||
import { store } from '../store/store.js'
|
import { stores } from '../store/mainStore'
|
||||||
|
|
||||||
// Init F7 React Plugin
|
// Init F7 React Plugin
|
||||||
Framework7.use(Framework7React)
|
Framework7.use(Framework7React)
|
||||||
|
@ -33,7 +33,7 @@ Framework7.use(Framework7React)
|
||||||
// Mount React App
|
// Mount React App
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<I18nextProvider i18n={i18n}>
|
<I18nextProvider i18n={i18n}>
|
||||||
<Provider store={store}>
|
<Provider {...stores}>
|
||||||
<Suspense fallback="loading">
|
<Suspense fallback="loading">
|
||||||
<App />
|
<App />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|
6
apps/documenteditor/mobile/src/store/documentSettings.js
Normal file
6
apps/documenteditor/mobile/src/store/documentSettings.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
import {action, observable} from 'mobx';
|
||||||
|
|
||||||
|
export class storeDocumentSettings {
|
||||||
|
@observable isPortrait = true
|
||||||
|
}
|
9
apps/documenteditor/mobile/src/store/mainStore.js
Normal file
9
apps/documenteditor/mobile/src/store/mainStore.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
import {storeDocumentSettings} from './documentSettings'
|
||||||
|
import {storeUsers} from '../../../../common/mobile/lib/store/users'
|
||||||
|
|
||||||
|
export const stores = {
|
||||||
|
storeDocumentSettings: new storeDocumentSettings(),
|
||||||
|
users: new storeUsers()
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue