[DE] added 'DocumentSettings' controller
This commit is contained in:
		
							parent
							
								
									37b297ca7e
								
							
						
					
					
						commit
						9ab2f40f19
					
				| 
						 | 
					@ -9,7 +9,8 @@ class DocumentSettingsController extends Component {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    onPageOrientation(value){
 | 
					    onPageOrientation(value){
 | 
				
			||||||
        console.log(`changed page orientation: ${value}`);
 | 
					        const api = Common.EditorApi.get();
 | 
				
			||||||
 | 
					        api.change_PageOrient(value=='portrait');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    render() {
 | 
					    render() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
import React, {Component} from 'react';
 | 
					import React, {Component} from 'react';
 | 
				
			||||||
 | 
					import { connect } from 'react-redux';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    Page,
 | 
					    Page,
 | 
				
			||||||
    Navbar,
 | 
					    Navbar,
 | 
				
			||||||
| 
						 | 
					@ -7,36 +8,37 @@ import {
 | 
				
			||||||
    BlockTitle
 | 
					    BlockTitle
 | 
				
			||||||
} from 'framework7-react';
 | 
					} from 'framework7-react';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class DocumentSettings extends Component {
 | 
					const DocumentSettings = props => {
 | 
				
			||||||
    constructor(props) {
 | 
					    const textDocumentSettings = "Document Settings";
 | 
				
			||||||
        super(props);
 | 
					    const textBack = "Back";
 | 
				
			||||||
    }
 | 
					    const textOrientation = "Orientation";
 | 
				
			||||||
    render() {
 | 
					    const textPortrait = "Portrait";
 | 
				
			||||||
        const textDocumentSettings = "Document Settings";
 | 
					    const textLandscape = "Landscape";
 | 
				
			||||||
        const textBack = "Back";
 | 
					    const textFormat = "Format";
 | 
				
			||||||
        const textOrientation = "Orientation";
 | 
					    const textMargins = "Margins";
 | 
				
			||||||
        const textPortrait = "Portrait";
 | 
					 | 
				
			||||||
        const textLandscape = "Landscape";
 | 
					 | 
				
			||||||
        const textFormat = "Format";
 | 
					 | 
				
			||||||
        const textMargins = "Margins";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const format = "A4";
 | 
					    const format = "A4";
 | 
				
			||||||
        const formatSize = "21 cm x 29.7 cm";
 | 
					    const formatSize = "21 cm x 29.7 cm";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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" defaultChecked onChange={e => this.props.onPageOrientation('portrait')}></ListItem>
 | 
					                <ListItem radio title={textPortrait} name="orientation-checkbox" checked={props.isPortrait} onClick={e => props.onPageOrientation('portrait')}></ListItem>
 | 
				
			||||||
                    <ListItem radio title={textLandscape} name="orientation-checkbox" onChange={e => this.props.onPageOrientation('landscape')}></ListItem>
 | 
					                <ListItem radio title={textLandscape} name="orientation-checkbox" checked={!props.isPortrait} onClick={e => props.onPageOrientation('landscape')}></ListItem>
 | 
				
			||||||
                </List>
 | 
					            </List>
 | 
				
			||||||
                <BlockTitle>{textFormat}</BlockTitle>
 | 
					            <BlockTitle>{textFormat}</BlockTitle>
 | 
				
			||||||
                <List mediaList>
 | 
					            <List mediaList>
 | 
				
			||||||
                    <ListItem title={format} subtitle={formatSize} link="/document-formats/"></ListItem>
 | 
					                <ListItem title={format} subtitle={formatSize} link="/document-formats/"></ListItem>
 | 
				
			||||||
                    <ListItem checkbox title={textMargins} link="/margins/"></ListItem>
 | 
					                <ListItem checkbox title={textMargins} link="/margins/"></ListItem>
 | 
				
			||||||
                </List>
 | 
					            </List>
 | 
				
			||||||
            </Page>
 | 
					        </Page>
 | 
				
			||||||
        )
 | 
					     )
 | 
				
			||||||
    }
 | 
					};
 | 
				
			||||||
};
 | 
					
 | 
				
			||||||
 | 
					const mapStateToProps = (state) => {
 | 
				
			||||||
 | 
					    return state.settings;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default connect(mapStateToProps)(DocumentSettings);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import {Component} from 'react'
 | 
					import {Component} from 'react'
 | 
				
			||||||
 | 
					import {connect} from 'react-redux'
 | 
				
			||||||
 | 
					import * as Actions from '../store/actions/actions'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MainController extends Component {
 | 
					class MainController extends Component {
 | 
				
			||||||
    constructor(props) {
 | 
					    constructor(props) {
 | 
				
			||||||
| 
						 | 
					@ -133,6 +135,7 @@ class MainController extends Component {
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    this.appOptions   = {};
 | 
					                    this.appOptions   = {};
 | 
				
			||||||
 | 
					                    this.bindEvents();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    Common.Gateway.on('init',           loadConfig);
 | 
					                    Common.Gateway.on('init',           loadConfig);
 | 
				
			||||||
                    // Common.Gateway.on('showmessage',    _.bind(me.onExternalMessage, me));
 | 
					                    // Common.Gateway.on('showmessage',    _.bind(me.onExternalMessage, me));
 | 
				
			||||||
| 
						 | 
					@ -140,6 +143,7 @@ class MainController extends Component {
 | 
				
			||||||
                    Common.Gateway.appReady();
 | 
					                    Common.Gateway.appReady();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    Common.Notifications.trigger('engineCreated', this.api);
 | 
					                    Common.Notifications.trigger('engineCreated', this.api);
 | 
				
			||||||
 | 
					                    Common.EditorApi = {get: () => this.api};
 | 
				
			||||||
                }, error => {
 | 
					                }, error => {
 | 
				
			||||||
                    console.log('promise failed ' + error);
 | 
					                    console.log('promise failed ' + error);
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
| 
						 | 
					@ -152,9 +156,16 @@ class MainController extends Component {
 | 
				
			||||||
        document.body.appendChild(script);
 | 
					        document.body.appendChild(script);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bindEvents() {
 | 
				
			||||||
 | 
					        const {dispatch} = this.props;
 | 
				
			||||||
 | 
					        this.api.asc_registerCallback('asc_onPageOrient', isPortrait => {
 | 
				
			||||||
 | 
					            dispatch(Actions.changePageOrientation(isPortrait === true));
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    render() {
 | 
					    render() {
 | 
				
			||||||
        return null
 | 
					        return null
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default MainController;
 | 
					export default connect(null,null,null,{forwardRef:true})(MainController);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										9
									
								
								apps/documenteditor/mobile/src/store/actions/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								apps/documenteditor/mobile/src/store/actions/actions.js
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const SETTINGS_PAGE_ORIENTATION_CHANGED = 'PAGE_ORIENTATION_CHANGED';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const changePageOrientation = isPortrait => {
 | 
				
			||||||
 | 
					    return {
 | 
				
			||||||
 | 
					        type: SETTINGS_PAGE_ORIENTATION_CHANGED,
 | 
				
			||||||
 | 
					        isPortrait: isPortrait
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -1,10 +1,15 @@
 | 
				
			||||||
import { combineReducers } from 'redux';
 | 
					import { combineReducers } from 'redux';
 | 
				
			||||||
 | 
					import settingsReducer from './settings'
 | 
				
			||||||
import usersReducer from '../../../../../common/mobile/lib/store/users'
 | 
					import usersReducer from '../../../../../common/mobile/lib/store/users'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const initialState = {
 | 
					export const initialState = {
 | 
				
			||||||
 | 
					    settings: {
 | 
				
			||||||
 | 
					        isPortrait: true
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    users: []
 | 
					    users: []
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const rootReducer = combineReducers({
 | 
					export const rootReducer = combineReducers({
 | 
				
			||||||
 | 
					    settings: settingsReducer,
 | 
				
			||||||
    users: usersReducer
 | 
					    users: usersReducer
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
							
								
								
									
										12
									
								
								apps/documenteditor/mobile/src/store/reducers/settings.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								apps/documenteditor/mobile/src/store/reducers/settings.js
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import * as actionTypes from '../actions/actions'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const settingsReducer = (state = [], action) => {
 | 
				
			||||||
 | 
					    if (action.type == actionTypes.SETTINGS_PAGE_ORIENTATION_CHANGED) {
 | 
				
			||||||
 | 
					        return {isPortrait: action.isPortrait};
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return state;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default settingsReducer;
 | 
				
			||||||
							
								
								
									
										1
									
								
								vendor/framework7-react/babel.config.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/framework7-react/babel.config.js
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -8,5 +8,6 @@ module.exports = {
 | 
				
			||||||
  plugins: [
 | 
					  plugins: [
 | 
				
			||||||
    '@babel/plugin-transform-runtime',
 | 
					    '@babel/plugin-transform-runtime',
 | 
				
			||||||
    '@babel/plugin-syntax-dynamic-import',
 | 
					    '@babel/plugin-syntax-dynamic-import',
 | 
				
			||||||
 | 
					    '@babel/plugin-proposal-class-properties',
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										1
									
								
								vendor/framework7-react/package.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/framework7-react/package.json
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -35,6 +35,7 @@
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "devDependencies": {
 | 
					  "devDependencies": {
 | 
				
			||||||
    "@babel/core": "^7.11.0",
 | 
					    "@babel/core": "^7.11.0",
 | 
				
			||||||
 | 
					    "@babel/plugin-proposal-class-properties": "^7.10.4",
 | 
				
			||||||
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
 | 
					    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
 | 
				
			||||||
    "@babel/plugin-transform-runtime": "^7.11.0",
 | 
					    "@babel/plugin-transform-runtime": "^7.11.0",
 | 
				
			||||||
    "@babel/preset-env": "^7.11.0",
 | 
					    "@babel/preset-env": "^7.11.0",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue