From 720dc5b4cd8ce368817cbf08f0252585c53d900c Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Thu, 10 Aug 2023 17:05:23 +0300 Subject: [PATCH] [SSE mobile] Change routing and props --- .../mobile/src/controller/add/Add.jsx | 45 ++++ .../mobile/src/controller/add/AddChart.jsx | 3 +- .../mobile/src/controller/add/AddFunction.jsx | 4 +- .../mobile/src/controller/add/AddLink.jsx | 4 +- .../mobile/src/controller/add/AddOther.jsx | 2 - .../mobile/src/controller/add/AddShape.jsx | 3 +- .../mobile/src/controller/edit/EditLink.jsx | 5 +- .../src/controller/settings/Settings.jsx | 76 ++++++ .../mobile/src/page/main.jsx | 150 ++++++----- .../mobile/src/view/add/Add.jsx | 243 +++--------------- .../mobile/src/view/add/AddFunction.jsx | 27 +- .../mobile/src/view/add/AddLink.jsx | 17 +- .../mobile/src/view/add/AddOther.jsx | 7 +- .../mobile/src/view/add/AddingPage.jsx | 130 ++++++++++ .../mobile/src/view/edit/Edit.jsx | 224 +++------------- .../mobile/src/view/edit/EditingPage.jsx | 155 +++++++++++ .../mobile/src/view/settings/Settings.jsx | 242 +++-------------- .../mobile/src/view/settings/SettingsPage.jsx | 112 ++++++++ 18 files changed, 733 insertions(+), 716 deletions(-) create mode 100644 apps/spreadsheeteditor/mobile/src/controller/add/Add.jsx create mode 100644 apps/spreadsheeteditor/mobile/src/controller/settings/Settings.jsx create mode 100644 apps/spreadsheeteditor/mobile/src/view/add/AddingPage.jsx create mode 100644 apps/spreadsheeteditor/mobile/src/view/edit/EditingPage.jsx create mode 100644 apps/spreadsheeteditor/mobile/src/view/settings/SettingsPage.jsx diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/Add.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/Add.jsx new file mode 100644 index 0000000000..16be3f3661 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/controller/add/Add.jsx @@ -0,0 +1,45 @@ +import React, { createContext } from "react"; +import AddView from "../../view/add/Add"; + +export const AddingContext = createContext(); + +const AddingController = props => { + const api = Common.EditorApi.get(); + const cellinfo = api.asc_getCellInfo(); + const seltype = cellinfo.asc_getSelectionType(); + const iscelllocked = cellinfo.asc_getLocked(); + const isAddShapeHyperlink = api.asc_canAddShapeHyperlink(); + let options; + + if(!iscelllocked) { + options = props.showOptions; + + if(!options) { + switch(seltype) { + case Asc.c_oAscSelectionType.RangeCells: + case Asc.c_oAscSelectionType.RangeRow: + case Asc.c_oAscSelectionType.RangeCol: + case Asc.c_oAscSelectionType.RangeMax: break; + case Asc.c_oAscSelectionType.RangeImage: + case Asc.c_oAscSelectionType.RangeShape: + case Asc.c_oAscSelectionType.RangeChart: + case Asc.c_oAscSelectionType.RangeChartText: + case Asc.c_oAscSelectionType.RangeShapeText: + options = {panels: ['image','shape']}; + break; + } + } + } + + return ( + + + + + ) +} + +export default AddingController; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddChart.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddChart.jsx index b560d95199..42b9f4f2d0 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddChart.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddChart.jsx @@ -43,8 +43,7 @@ class AddChartController extends Component { render () { return ( - + ) } } diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddFunction.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddFunction.jsx index a6adeb1dad..7725cf180b 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddFunction.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddFunction.jsx @@ -87,9 +87,7 @@ class AddFunctionController extends Component { render () { return ( - + ) } } diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddLink.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddLink.jsx index 075f113631..08fc94bd05 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddLink.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddLink.jsx @@ -141,7 +141,7 @@ class AddLinkController extends Component { return ( !this.props.isNavigate ? Device.phone ? - this.props.onClosed('add-link')}> + this.props.closeOptions('add-link')}> : - this.props.onClosed('add-link')}> + this.props.closeOptions('add-link')}> ) } diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddShape.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddShape.jsx index 0c7209c530..b36e4dcd3b 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddShape.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddShape.jsx @@ -26,8 +26,7 @@ class AddShapeController extends Component { render () { return ( - + ) } } diff --git a/apps/spreadsheeteditor/mobile/src/controller/edit/EditLink.jsx b/apps/spreadsheeteditor/mobile/src/controller/edit/EditLink.jsx index 927a779534..c5642dd207 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/edit/EditLink.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/edit/EditLink.jsx @@ -1,7 +1,6 @@ import React, { Component } from 'react'; import { f7, Popup, Popover, View } from 'framework7-react'; import { Device } from '../../../../../common/mobile/utils/device'; -import {observer, inject} from "mobx-react"; import { withTranslation } from 'react-i18next'; import { EditLink, PageEditTypeLink, PageEditSheet} from '../../view/edit/EditLink'; @@ -149,7 +148,7 @@ class EditLinkController extends Component { return ( !this.props.isNavigate ? Device.phone ? - this.props.onClosed('edit-link')}> + this.props.closeOptions('edit-link')}> : - this.props.onClosed('edit-link')}> + this.props.closeOptions('edit-link')}> { + const closeModal = () => { + if(Device.phone) { + f7.sheet.close('.settings-popup', false); + } else { + f7.popover.close('#settings-popover', false); + } + }; + + const onPrint = () => { + const api = Common.EditorApi.get(); + + closeModal(); + setTimeout(() => { + api.asc_Print(); + }, 400); + }; + + const showHelp = () => { + // let url = '{{HELP_URL}}'; + // let url = 'https://helpcenter.onlyoffice.com'; + let url = __HELP_URL__; + + if (url.charAt(url.length-1) !== '/') { + url += '/'; + } + + if (Device.sailfish || Device.android) { + url+='mobile-applications/documents/mobile-web-editors/android/index.aspx'; + } + else { + url+='mobile-applications/documents/mobile-web-editors/ios/index.aspx'; + } + + closeModal(); + window.open(url, "_blank"); + }; + + const showFeedback = () => { + let config = props.storeAppOptions.config; + + closeModal(); + if(config && !!config.feedback && !!config.feedback.url) { + window.open(config.feedback.url, "_blank"); + } else window.open(__SUPPORT_URL__, "_blank"); + }; + + const onDownloadOrigin = () => { + closeModal(); + setTimeout(() => { + Common.EditorApi.get().asc_DownloadOrigin(); + }, 0); + }; + + return ( + + + + ); +})); + +export default SettingsController; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/page/main.jsx b/apps/spreadsheeteditor/mobile/src/page/main.jsx index 6d0979df3c..5ad60998dc 100644 --- a/apps/spreadsheeteditor/mobile/src/page/main.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/main.jsx @@ -1,23 +1,22 @@ -import React, { Component, Fragment } from 'react'; -import { Page, View, Navbar, Subnavbar, Icon } from 'framework7-react'; +import React, { Component, Fragment, createContext } from 'react'; +import { Page, View, Navbar, Subnavbar, Icon, f7 } from 'framework7-react'; import { observer, inject } from "mobx-react"; import { Device } from '../../../../common/mobile/utils/device'; - -import Settings from '../view/settings/Settings'; -import { Collaboration } from '../../../../common/mobile/lib/view/collaboration/Collaboration.jsx' +import CollaborationView from '../../../../common/mobile/lib/view/collaboration/Collaboration.jsx' import CellEditor from '../controller/CellEditor'; import { Statusbar } from '../controller/Statusbar'; import FilterOptionsController from '../controller/FilterOptions.jsx' -import AddOptions from "../view/add/Add"; -import EditOptions from "../view/edit/Edit"; import { Search, SearchSettings } from '../controller/Search'; -import { f7, Link } from 'framework7-react'; - -import {FunctionGroups} from "../controller/add/AddFunction"; +import { FunctionGroups } from "../controller/add/AddFunction"; import ContextMenu from '../controller/ContextMenu'; import { Toolbar } from "../controller/Toolbar"; import { AddLinkController } from '../controller/add/AddLink'; import { EditLinkController } from '../controller/edit/EditLink'; +import SettingsController from '../controller/settings/Settings'; +import AddingController from '../controller/add/Add'; +import EditView from '../view/edit/Edit'; + +export const MainContext = createContext(); class MainPage extends Component { constructor(props) { @@ -128,67 +127,78 @@ class MainPage extends Component { } return ( - - {/* Top Navbar */} - - {!isHideLogo &&
{ - window.open(`${__PUBLISHER_URL__}`, "_blank"); - }}>
} - - - - -
- - this.handleClickToOpenOptions('add', {panels: panels, button: button})}/> - {/* Page content */} - - {isShowPlaceholder ? -
-
-
-
: - null - } - - { - !this.state.editOptionsVisible ? null : - - } - { - !this.state.addOptionsVisible ? null : - - } - { - !this.state.addLinkSettingsVisible ? null : - - } - { - !this.state.editLinkSettingsVisible ? null : - - } - { - !this.state.settingsVisible ? null : - - } - { - !this.state.collaborationVisible ? null : - - } - - {appOptions.isDocReady && - - - - - } + + + {/* Top Navbar */} + + {!isHideLogo && +
{ + window.open(`${__PUBLISHER_URL__}`, "_blank"); + }}> + +
+ } + + + + +
- - - {/* hidden component*/} -
+ this.handleClickToOpenOptions('add', {panels: panels, button: button})} /> + {/* Page content */} + + {isShowPlaceholder ? +
+
+
+
: + null + } + + {!this.state.editOptionsVisible ? null : } + {!this.state.addOptionsVisible ? null : + + } + {!this.state.addLinkSettingsVisible ? null : + + } + {!this.state.editLinkSettingsVisible ? null : + + } + {!this.state.settingsVisible ? null : } + {!this.state.collaborationVisible ? null : + + } + {appOptions.isDocReady && + + + + + } + + + {/* hidden component*/} +
+ ) } } diff --git a/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx b/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx index 99149ebb81..3d506e7578 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx @@ -1,24 +1,23 @@ -import React, {Component, useEffect} from 'react'; -import {View,Page,Navbar,NavTitle,NavRight,Link,Popup,Popover,Icon,Tabs,Tab} from 'framework7-react'; -import { useTranslation } from 'react-i18next'; -import {f7} from 'framework7-react'; -import { observer, inject } from "mobx-react"; -import {Device} from '../../../../../common/mobile/utils/device'; - -import {AddChartController} from "../../controller/add/AddChart"; -import {AddFunctionController} from "../../controller/add/AddFunction"; -import {PageFunctionGroup, PageFunctionInfo} from "./AddFunction"; -import AddShapeController from "../../controller/add/AddShape"; -import {AddOtherController} from "../../controller/add/AddOther"; -import {AddImageController} from "../../controller/add/AddImage"; -import {PageImageLinkSettings} from "./AddImage"; -import {AddLinkController} from "../../controller/add/AddLink"; -import {EditLinkController} from "../../controller/edit/EditLink"; -import {PageTypeLink, PageSheet} from "./AddLink"; -import {PageEditTypeLink, PageEditSheet} from "../../view/edit/EditLink"; +import React, { useContext, useEffect } from 'react'; +import { View, Popup, Popover, f7 } from 'framework7-react'; +import { Device } from '../../../../../common/mobile/utils/device'; +import { PageFunctionGroup, PageFunctionInfo } from "./AddFunction"; +import { AddImageController } from "../../controller/add/AddImage"; +import { PageImageLinkSettings } from "./AddImage"; +import { AddLinkController } from "../../controller/add/AddLink"; +import { EditLinkController } from "../../controller/edit/EditLink"; +import { PageTypeLink, PageSheet } from "./AddLink"; +import { PageEditTypeLink, PageEditSheet } from "../../view/edit/EditLink"; import AddFilterController from "../../controller/add/AddFilter"; +import AddingPage from './AddingPage'; +import { MainContext } from '../../page/main'; const routes = [ + { + path: '/adding-page/', + component: AddingPage, + keepAlive: true + }, // Functions { path: '/add-function-group/', @@ -76,201 +75,31 @@ routes.forEach(route => { }; }); -const AddLayoutNavbar = ({ tabs, inPopover }) => { - const isAndroid = Device.android; +const AddView = props => { + const mainContext = useContext(MainContext); - if(!tabs.length) return null; - - return ( - - {tabs.length > 1 ? -
- {tabs.map((item, index) => - - - )} - {isAndroid && } -
: {tabs[0].caption} - } - { !inPopover && } -
- ) -}; - -const AddLayoutContent = ({ tabs }) => { - if(!tabs.length) return null; - - return ( - - {tabs.map((item, index) => - - {item.component} - - )} - - ) -}; - -const AddTabs = props => { - const { t } = useTranslation(); - const _t = t('View.Add', {returnObjects: true}); - const wsLock = props.wsLock; - const wsProps = props.wsProps; - const showPanels = props.showPanels; - const tabs = []; - - if(!wsProps.Objects) { - if (!showPanels) { - tabs.push({ - caption: _t.textChart, - id: 'add-chart', - icon: 'icon-add-chart', - component: - }); - } - if (!showPanels || showPanels === 'function') { - tabs.push({ - caption: _t.textFunction, - id: 'add-function', - icon: 'icon-add-formula', - component: - }); - } - if (!showPanels || showPanels.indexOf('shape') > 0) { - tabs.push({ - caption: _t.textShape, - id: 'add-shape', - icon: 'icon-add-shape', - component: - }); - } - - // if (showPanels && showPanels.indexOf('image') !== -1) { - // tabs.push({ - // caption: _t.textImage, - // id: 'add-image', - // icon: 'icon-add-image', - // component: - // }); - // } - } - - if (!showPanels && (!wsProps.InsertHyperlinks || !wsProps.Objects || !wsProps.Sort)) { - tabs.push({ - caption: _t.textOther, - id: 'add-other', - icon: 'icon-add-other', - component: - }); - } - - // if (((showPanels && showPanels === 'hyperlink') || props.isAddShapeHyperlink) && !wsProps.InsertHyperlinks) { - // tabs.push({ - // caption: _t.textAddLink, - // id: 'add-link', - // icon: 'icon-link', - // component: - // }); - // } - - if(!tabs.length) { - if (Device.phone) { - f7.popup.close('.add-popup', false); - } else { - f7.popover.close('#add-popover', false); - } - - return null; - } - - return ( - - - - - - - ) -}; - -class AddView extends Component { - constructor(props) { - super(props); - - this.onoptionclick = this.onoptionclick.bind(this); - } - onoptionclick(page, props){ - f7.views.current.router.navigate(page, props); - } - render() { - const show_popover = this.props.usePopover; - return ( - show_popover ? - this.props.onclosed()}> - - : - this.props.onclosed()}> - - - ) - } -} - -const Add = props => { - const api = Common.EditorApi.get(); - const cellinfo = api.asc_getCellInfo(); - const seltype = cellinfo.asc_getSelectionType(); - const iscelllocked = cellinfo.asc_getLocked(); - const isAddShapeHyperlink = api.asc_canAddShapeHyperlink(); - - let options; - useEffect(() => { - if ( Device.phone ) { + if(Device.phone) { f7.popup.open('.add-popup'); } else { const targetElem = !props.showOptions || !props.showOptions.button ? '#btn-add' : props.showOptions.button; f7.popover.open('#add-popover', targetElem); } + }, []); - return () => { - // component will unmount - } - }); + return ( + !Device.phone ? + mainContext.closeOptions('add')}> + + + + : + mainContext.closeOptions('add')}> + + + + + ) +} - const onviewclosed = () => { - if ( props.onclosed ) { - props.onclosed(); - } - }; - - if ( !iscelllocked ) { - options = props.showOptions; - if ( !options ) { - switch (seltype) { - case Asc.c_oAscSelectionType.RangeCells: - case Asc.c_oAscSelectionType.RangeRow: - case Asc.c_oAscSelectionType.RangeCol: - case Asc.c_oAscSelectionType.RangeMax: break; - case Asc.c_oAscSelectionType.RangeImage: - case Asc.c_oAscSelectionType.RangeShape: - case Asc.c_oAscSelectionType.RangeChart: - case Asc.c_oAscSelectionType.RangeChartText: - case Asc.c_oAscSelectionType.RangeShapeText: - options = {panels: ['image','shape']}; - break; - } - } - } - - return -}; - -export default Add; \ No newline at end of file +export default AddView; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/add/AddFunction.jsx b/apps/spreadsheeteditor/mobile/src/view/add/AddFunction.jsx index 82cc52a230..fcb8e6c76a 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/AddFunction.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/AddFunction.jsx @@ -1,7 +1,7 @@ -import React, {Fragment, useState} from 'react'; -import {observer, inject} from "mobx-react"; +import React, { Fragment } from 'react'; +import { observer, inject } from "mobx-react"; import { useTranslation } from 'react-i18next'; -import {List, ListItem, Page, Navbar, Icon, BlockTitle} from 'framework7-react'; +import { List, ListItem, Page, Navbar, Icon, BlockTitle, f7 } from 'framework7-react'; const PageInfo = props => { const { t } = useTranslation(); @@ -94,6 +94,10 @@ const AddFunction = props => { }) } + const onOptionClick = (page, props) => { + f7.views.current.router.navigate(page, props); + } + return ( @@ -105,15 +109,14 @@ const AddFunction = props => { link='#' onClick={() => {props.onInsertFunction(f.type);}} > -
{ - props.onOptionClick('/add-function-info/', { - props: { - functionInfo: f - } - }); - event.stopPropagation(); - }}> +
{ + onOptionClick('/add-function-info/', { + props: { + functionInfo: f + } + }); + e.stopPropagation(); + }}>
diff --git a/apps/spreadsheeteditor/mobile/src/view/add/AddLink.jsx b/apps/spreadsheeteditor/mobile/src/view/add/AddLink.jsx index 63383b80ee..92613a6c8e 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/AddLink.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/AddLink.jsx @@ -117,15 +117,16 @@ const AddLink = props => { }}/> } {typeLink === 'ext' && - { - setLink(event.target.value); + { + setLink(event.target.value); if(stateAutoUpdate && !displayDisabled) setDisplayText(event.target.value); - }} - className={isIos ? 'list-input-right' : ''} + }} /> } {typeLink === 'int' && diff --git a/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx b/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx index 23ad2f5533..972dcd2b47 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx @@ -1,7 +1,8 @@ -import React from 'react'; +import React, { useContext } from 'react'; import { inject, observer } from 'mobx-react'; import {List, ListItem, Icon} from 'framework7-react'; import { useTranslation } from 'react-i18next'; +import { MainContext } from '../../page/main'; const AddOther = inject("storeFocusObjects", "storeAppOptions")(observer(props => { const { t } = useTranslation(); @@ -11,7 +12,8 @@ const AddOther = inject("storeFocusObjects", "storeAppOptions")(observer(props = const canModifyFilter = storeAppOptions.canModifyFilter; const isHyperLink = storeFocusObjects.selections.indexOf('hyperlink') > -1; const hideAddComment = props.hideAddComment(); - const wsProps = props.wsProps; + const mainContext = useContext(MainContext); + const wsProps = mainContext.wsProps; return ( @@ -28,7 +30,6 @@ const AddOther = inject("storeFocusObjects", "storeAppOptions")(observer(props = diff --git a/apps/spreadsheeteditor/mobile/src/view/add/AddingPage.jsx b/apps/spreadsheeteditor/mobile/src/view/add/AddingPage.jsx new file mode 100644 index 0000000000..f31e2f8811 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/view/add/AddingPage.jsx @@ -0,0 +1,130 @@ +import React, { useContext } from 'react'; +import { Page, Navbar, NavTitle, NavRight, Link, Icon, Tabs, Tab, f7 } from 'framework7-react'; +import { useTranslation } from 'react-i18next'; +import { AddChartController } from "../../controller/add/AddChart"; +import { AddFunctionController } from "../../controller/add/AddFunction"; +import AddShapeController from "../../controller/add/AddShape"; +import { AddOtherController } from "../../controller/add/AddOther"; +import { Device } from "../../../../../common/mobile/utils/device"; +import { MainContext } from '../../page/main'; +import { AddingContext } from '../../controller/add/Add'; + +const AddLayoutNavbar = ({ tabs }) => { + const isAndroid = Device.android; + if(!tabs.length) return null; + + return ( + + {tabs.length > 1 ? +
+ {tabs.map((item, index) => + + + )} + {isAndroid && } +
: {tabs[0].caption} + } + {Device.phone && } +
+ ) +}; + +const AddLayoutContent = ({ tabs }) => { + if(!tabs.length) return null; + + return ( + + {tabs.map((item, index) => + + {item.component} + + )} + + ) +}; + +const AddingPage = () => { + const { t } = useTranslation(); + const _t = t('View.Add', {returnObjects: true}); + const mainContext = useContext(MainContext); + const addingContext = useContext(AddingContext); + // const wsLock = mainContext.wsLock; + const wsProps = mainContext.wsProps; + const showPanels = addingContext.showPanels; + const tabs = []; + + if(!wsProps.Objects) { + if(!showPanels) { + tabs.push({ + caption: _t.textChart, + id: 'add-chart', + icon: 'icon-add-chart', + component: + }); + } + + if(!showPanels || showPanels === 'function') { + tabs.push({ + caption: _t.textFunction, + id: 'add-function', + icon: 'icon-add-formula', + component: + }); + } + + if(!showPanels || showPanels.indexOf('shape') > 0) { + tabs.push({ + caption: _t.textShape, + id: 'add-shape', + icon: 'icon-add-shape', + component: + }); + } + + // if (showPanels && showPanels.indexOf('image') !== -1) { + // tabs.push({ + // caption: _t.textImage, + // id: 'add-image', + // icon: 'icon-add-image', + // component: + // }); + // } + } + + if (!showPanels && (!wsProps.InsertHyperlinks || !wsProps.Objects || !wsProps.Sort)) { + tabs.push({ + caption: _t.textOther, + id: 'add-other', + icon: 'icon-add-other', + component: + }); + } + + // if (((showPanels && showPanels === 'hyperlink') || props.isAddShapeHyperlink) && !wsProps.InsertHyperlinks) { + // tabs.push({ + // caption: _t.textAddLink, + // id: 'add-link', + // icon: 'icon-link', + // component: + // }); + // } + + if(!tabs.length) { + if (Device.phone) { + f7.popup.close('.add-popup', false); + } else { + f7.popover.close('#add-popover', false); + } + + return null; + } + + return ( + + + + + ) +}; + +export default AddingPage; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/edit/Edit.jsx b/apps/spreadsheeteditor/mobile/src/view/edit/Edit.jsx index 33e6832866..b4f4da120c 100644 --- a/apps/spreadsheeteditor/mobile/src/view/edit/Edit.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/edit/Edit.jsx @@ -1,28 +1,24 @@ -import React, {useState, useEffect} from 'react'; -import {observer, inject} from "mobx-react"; -import { Popover, Sheet, View, Page, Navbar, NavRight, NavLeft, NavTitle, Tabs, Tab, Link } from 'framework7-react'; +import React, { useContext, useEffect } from 'react'; +import { Popover, Sheet, View } from 'framework7-react'; import { f7 } from 'framework7-react'; -import { useTranslation } from 'react-i18next'; -import {Device} from '../../../../../common/mobile/utils/device'; - -import EditCellController from "../../controller/edit/EditCell"; -import EditShapeController from "../../controller/edit/EditShape"; -import EditImageController from "../../controller/edit/EditImage"; -import EditTextController from "../../controller/edit/EditText"; -import EditChartController from "../../controller/edit/EditChart"; +import { Device } from '../../../../../common/mobile/utils/device'; // import { EditLinkController } from "../../controller/edit/EditLink"; - import { PageShapeStyle, PageShapeStyleNoFill, PageReplaceContainer, PageReorderContainer, PageShapeBorderColor, PageShapeCustomBorderColor, PageShapeCustomFillColor } from './EditShape'; import { PageImageReplace, PageImageReorder, PageLinkSettings } from './EditImage'; import { TextColorCell, FillColorCell, CustomTextColorCell, CustomFillColorCell, FontsCell, TextFormatCell, TextOrientationCell, BorderStyleCell, BorderColorCell, CustomBorderColorCell, BorderSizeCell, PageFormatCell, PageAccountingFormatCell, PageCurrencyFormatCell, PageDateFormatCell, PageTimeFormatCell, CellStyle, PageCreationCustomFormat, CustomFormats } from './EditCell'; import { PageTextFonts, PageTextFontColor, PageTextCustomFontColor } from './EditText'; import { PageChartDesign, PageChartDesignType, PageChartDesignStyle, PageChartDesignFill, PageChartDesignBorder, PageChartCustomFillColor, PageChartBorderColor, PageChartCustomBorderColor, PageChartReorder, PageChartLayout, PageLegend, PageChartTitle, PageHorizontalAxisTitle, PageVerticalAxisTitle, PageHorizontalGridlines, PageVerticalGridlines, PageDataLabels, PageChartVerticalAxis, PageVertAxisCrosses, PageDisplayUnits, PageVertMajorType, PageVertMinorType, PageVertLabelPosition, PageChartHorizontalAxis, PageHorAxisCrosses, PageHorAxisPosition, PageHorMajorType, PageHorMinorType, PageHorLabelPosition } from './EditChart'; import { PageEditTypeLink, PageEditSheet } from './EditLink'; +import EditingPage from './EditingPage'; +import { MainContext } from '../../page/main'; const routes = [ - + { + path: '/editing-page/', + component: EditingPage, + keepAlive: true + }, // Shape - { path: '/edit-style-shape/', component: PageShapeStyle @@ -306,188 +302,34 @@ routes.forEach(route => { }; }); -const EmptyEditLayout = () => { - const { t } = useTranslation(); - const _t = t('View.Edit', {returnObjects: true}); - return ( - -
-
-

{_t.textSelectObjectToEdit}

-
-
-
- ) -}; +const EditView = () => { + const mainContext = useContext(MainContext); + // const api = Common.EditorApi.get(); + // const cellinfo = api.asc_getCellInfo(); + // const hyperinfo = cellinfo.asc_getHyperlink(); + // const isAddShapeHyperlink = api.asc_canAddShapeHyperlink(); -const EditLayoutNavbar = ({ editors, inPopover }) => { - const isAndroid = Device.android; - const { t } = useTranslation(); - const _t = t('View.Edit', {returnObjects: true}); - - if(!editors.length) return null; + useEffect(() => { + if(Device.phone) { + f7.sheet.open('#edit-sheet'); + } else { + f7.popover.open('#edit-popover', '#btn-edit'); + } + }, []); return ( - - { - editors.length > 1 ? -
- {editors.map((item, index) => {item.caption})} - {isAndroid && } -
: { editors[0].caption } - } - { !inPopover && } -
- ) -}; - -const EditLayoutContent = ({ editors }) => { - if(!editors.length) return null; - - if (editors.length > 1) { - return ( - - {editors.map((item, index) => - - {item.component} - - )} - - ) - } else { - return ( - - {editors[0].component} - - ) - } -}; - -const EditTabs = props => { - const { t } = useTranslation(); - const _t = t('View.Edit', {returnObjects: true}); - const store = props.storeFocusObjects; - const wsProps = props.wsProps; - const settings = !store.focusOn ? [] : (store.focusOn === 'obj' ? store.objects : store.selections); - let editors = []; - - if (settings.length < 1) { - editors.push({ - caption: _t.textSettings, - component: - }); - } else { - if (!(wsProps.Objects && store.isLockedShape) && settings.indexOf('image') > -1) { - editors.push({ - caption: _t.textImage, - id: 'edit-image', - component: - }) - } - if (!(wsProps.Objects && store.isLockedShape) && settings.indexOf('shape') > -1) { - editors.push({ - caption: _t.textShape, - id: 'edit-shape', - component: - }) - } - if (settings.indexOf('cell') > -1) { - editors.push({ - caption: _t.textCell, - id: 'edit-text', - component: - }) - } - if (!(wsProps.Objects && store.isLockedShape) && settings.indexOf('chart') > -1) { - editors.push({ - caption: _t.textChart, - id: 'edit-chart', - component: - }) - } - if (!(wsProps.Objects && store.isLockedText) && settings.indexOf('text') > -1) { - editors.push({ - caption: _t.textText, - id: 'edit-text', - component: - }) - } - - // if(!wsProps.Objects) { - // if (settings.indexOf('hyperlink') > -1 || (props.hyperinfo && props.isAddShapeHyperlink)) { - // editors.push({ - // caption: _t.textHyperlink, - // id: 'edit-link', - // component: - // }) - // } - // } - } - - if(!editors.length) { - if (Device.phone) { - f7.sheet.close('#edit-sheet', false); - } else { - f7.popover.close('#edit-popover', false); - } - - return null; - } - - return ( - - - - - - - - ) -}; - -const EditTabsContainer = inject("storeFocusObjects")(observer(EditTabs)); - -const EditView = props => { - const onOptionClick = (page) => { - $f7.views.current.router.navigate(page); - }; - const show_popover = props.usePopover; - return ( - show_popover ? - props.onClosed()}> - + !Device.phone ? + mainContext.closeOptions('edit')}> + + + : - props.onClosed()}> - + mainContext.closeOptions('edit')}> + + + ) }; -const EditOptions = props => { - const api = Common.EditorApi.get(); - const cellinfo = api.asc_getCellInfo(); - const hyperinfo = cellinfo.asc_getHyperlink(); - const isAddShapeHyperlink = api.asc_canAddShapeHyperlink(); - - useEffect(() => { - if ( Device.phone ) - f7.sheet.open('#edit-sheet'); - else f7.popover.open('#edit-popover', '#btn-edit'); - - return () => { - // component will unmount - } - }); - - const onviewclosed = () => { - if ( props.onclosed ) { - props.onclosed(); - } - }; - - return ( - - ) -}; - -export default EditOptions; \ No newline at end of file +export default EditView; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/edit/EditingPage.jsx b/apps/spreadsheeteditor/mobile/src/view/edit/EditingPage.jsx new file mode 100644 index 0000000000..f4a7c373e9 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/view/edit/EditingPage.jsx @@ -0,0 +1,155 @@ +import React, { useContext } from 'react'; +import { observer, inject } from "mobx-react"; +import { Page, Navbar, NavRight, NavTitle, Tabs, Tab, Link, f7 } from 'framework7-react'; +import { useTranslation } from 'react-i18next'; +import EditCellController from "../../controller/edit/EditCell"; +import EditShapeController from "../../controller/edit/EditShape"; +import EditImageController from "../../controller/edit/EditImage"; +import EditTextController from "../../controller/edit/EditText"; +import EditChartController from "../../controller/edit/EditChart"; +import { Device } from "../../../../../common/mobile/utils/device"; +import { MainContext } from '../../page/main'; + +const EmptyEditLayout = () => { + const { t } = useTranslation(); + const _t = t('View.Edit', {returnObjects: true}); + + return ( + +
+
+

{_t.textSelectObjectToEdit}

+
+
+
+ ) +}; + +const EditLayoutNavbar = ({ editors }) => { + const isAndroid = Device.android; + const { t } = useTranslation(); + const _t = t('View.Edit', {returnObjects: true}); + + if(!editors.length) return null; + + return ( + + {editors.length > 1 ? +
+ {editors.map((item, index) => {item.caption})} + {isAndroid && } +
: + {editors[0].caption} + } + {Device.phone && + + + + } +
+ ) +}; + +const EditLayoutContent = ({ editors }) => { + if(!editors.length) return null; + + if (editors.length > 1) { + return ( + + {editors.map((item, index) => + + {item.component} + + )} + + ) + } else { + return ( + + {editors[0].component} + + ) + } +}; + +const EditingPage = inject('storeFocusObjects')(observer(props => { + const { t } = useTranslation(); + const _t = t('View.Edit', {returnObjects: true}); + const mainContext = useContext(MainContext); + const store = props.storeFocusObjects; + const wsProps = mainContext.wsProps; + const settings = !store.focusOn ? [] : (store.focusOn === 'obj' ? store.objects : store.selections); + let editors = []; + + if (settings.length < 1) { + editors.push({ + caption: _t.textSettings, + component: + }); + } else { + if (!(wsProps.Objects && store.isLockedShape) && settings.indexOf('image') > -1) { + editors.push({ + caption: _t.textImage, + id: 'edit-image', + component: + }) + } + if (!(wsProps.Objects && store.isLockedShape) && settings.indexOf('shape') > -1) { + editors.push({ + caption: _t.textShape, + id: 'edit-shape', + component: + }) + } + if (settings.indexOf('cell') > -1) { + editors.push({ + caption: _t.textCell, + id: 'edit-text', + component: + }) + } + if (!(wsProps.Objects && store.isLockedShape) && settings.indexOf('chart') > -1) { + editors.push({ + caption: _t.textChart, + id: 'edit-chart', + component: + }) + } + if (!(wsProps.Objects && store.isLockedText) && settings.indexOf('text') > -1) { + editors.push({ + caption: _t.textText, + id: 'edit-text', + component: + }) + } + + // if(!wsProps.Objects) { + // if (settings.indexOf('hyperlink') > -1 || (props.hyperinfo && props.isAddShapeHyperlink)) { + // editors.push({ + // caption: _t.textHyperlink, + // id: 'edit-link', + // component: + // }) + // } + // } + } + + if(!editors.length) { + if (Device.phone) { + f7.sheet.close('#edit-sheet', false); + } else { + f7.popover.close('#edit-popover', false); + } + + return null; + } + + return ( + + + + + ) +})); + +export default EditingPage; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx index a5f741637b..03ccc6ac38 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx @@ -1,24 +1,24 @@ -import React, {Component, useEffect} from 'react'; -import {View,Page,Navbar,NavRight,Link,Popup,Popover,Icon,ListItem,List} from 'framework7-react'; -import { useTranslation } from 'react-i18next'; -import {f7} from 'framework7-react'; -import {Device} from '../../../../../common/mobile/utils/device'; -import { observer, inject } from "mobx-react"; +import React, { useContext, useEffect } from 'react'; +import { View, Popup, Popover, f7 } from 'framework7-react'; +import { Device } from '../../../../../common/mobile/utils/device'; import SpreadsheetSettingsController from '../../controller/settings/SpreadsheetSettings.jsx'; import ApplicationSettingsController from '../../controller/settings/ApplicationSettings.jsx'; import SpreadsheetInfoController from '../../controller/settings/SpreadsheetInfo.jsx'; -import {DownloadWithTranslation} from '../../controller/settings/Download.jsx'; -import {SpreadsheetColorSchemes, SpreadsheetFormats, SpreadsheetMargins} from './SpreadsheetSettings.jsx'; -import {MacrosSettings, RegionalSettings, FormulaLanguage} from './ApplicationSettings.jsx'; +import { DownloadWithTranslation } from '../../controller/settings/Download.jsx'; +import { SpreadsheetColorSchemes, SpreadsheetFormats, SpreadsheetMargins } from './SpreadsheetSettings.jsx'; +import { MacrosSettings, RegionalSettings, FormulaLanguage } from './ApplicationSettings.jsx'; // import SpreadsheetAbout from './SpreadsheetAbout.jsx'; import About from '../../../../../common/mobile/lib/view/About'; import { Direction } from '../../../../../spreadsheeteditor/mobile/src/view/settings/ApplicationSettings'; -import SharingSettings from "../../../../../common/mobile/lib/view/SharingSettings"; +// import SharingSettings from "../../../../../common/mobile/lib/view/SharingSettings"; +import SettingsPage from './SettingsPage'; +import { MainContext } from '../../page/main'; const routes = [ { - path: '/', - component: 'TSettingsView' + path: '/settings-page/', + component: SettingsPage, + keepAlive: true }, { path: '/spreadsheet-settings/', @@ -77,210 +77,30 @@ routes.forEach(route => { }; }); -const SettingsList = inject("storeAppOptions")(observer(props => { - const { t } = useTranslation(); - const _t = t('View.Settings', {returnObjects: true}); - const navbar = - {!props.inPopover && {_t.textDone}} - ; +const SettingsView = () => { + const mainContext = useContext(MainContext); - const onoptionclick = page => { - if ( props.onOptionClick ) - props.onOptionClick(page) - }; - - const closeModal = () => { - if (Device.phone) { - f7.sheet.close('.settings-popup', false); + useEffect(() => { + if(Device.phone) { + f7.popup.open('.settings-popup'); } else { - f7.popover.close('#settings-popover', false); + f7.popover.open('#settings-popover', '#btn-settings'); } - }; + }, []); - const onOpenCollaboration = async () => { - await closeModal(); - await props.openOptions('coauth'); - } - - const onPrint = () => { - const api = Common.EditorApi.get(); - - closeModal(); - setTimeout(() => { - api.asc_Print(); - }, 400); - }; - - const showHelp = () => { - // let url = '{{HELP_URL}}'; - // let url = 'https://helpcenter.onlyoffice.com'; - let url = __HELP_URL__; - - if (url.charAt(url.length-1) !== '/') { - url += '/'; - } - - if (Device.sailfish || Device.android) { - url+='mobile-applications/documents/mobile-web-editors/android/index.aspx'; - } - else { - url+='mobile-applications/documents/mobile-web-editors/ios/index.aspx'; - } - - closeModal(); - window.open(url, "_blank"); - }; - - const showFeedback = () => { - let config = props.storeAppOptions.config; - - closeModal(); - if(config && !!config.feedback && !!config.feedback.url) { - window.open(config.feedback.url, "_blank"); - } else window.open(__SUPPORT_URL__, "_blank"); - }; - - const appOptions = props.storeAppOptions; - let _isEdit = false, - _canDownload = false, - _canDownloadOrigin = false, - _canAbout = true, - _canHelp = true, - _canPrint = false, - _canFeedback = true; - - if (appOptions.isDisconnected) { - _isEdit = false; - if (!appOptions.enableDownload) - _canPrint = _canDownload = _canDownloadOrigin = false; - } else { - _isEdit = appOptions.isEdit; - _canDownload = appOptions.canDownload; - _canDownloadOrigin = appOptions.canDownloadOrigin; - _canPrint = appOptions.canPrint; - - if (appOptions.customization && appOptions.canBrandingExt) { - _canAbout = appOptions.customization.about !== false; - } - - if (appOptions.customization) { - _canHelp = appOptions.customization.help !== false; - _canFeedback = appOptions.customization.feedback !== false; - } - } - - const onDownloadOrigin = () => { - closeModal(); - setTimeout(() => { - Common.EditorApi.get().asc_DownloadOrigin(); - }, 0); - }; - return ( - - - {navbar} - - {!props.inPopover && - - - - } - {window.matchMedia("(max-width: 359px)").matches ? - - - - : null} - {_isEdit && - - - - } - - - - {_canDownload && - - - - } - {_canDownloadOrigin && - - - - } - {_canPrint && - - - - } - - - - {_canHelp && - - - - } - {_canAbout && - - - - } - {_canFeedback && - - - - } - - - + !Device.phone ? + mainContext.closeOptions('settings')}> + + + + : + mainContext.closeOptions('settings')}> + + + + ) -})); - -class SettingsView extends Component { - constructor(props) { - super(props); - - this.onoptionclick = this.onoptionclick.bind(this); - } - - onoptionclick(page){ - f7.views.current.router.navigate(page); - } - - render() { - const show_popover = this.props.usePopover; - return ( - show_popover ? - this.props.onclosed()}> - - : - this.props.onclosed()}> - - - ) - } } -const Settings = props => { - useEffect(() => { - if ( Device.phone ) - f7.popup.open('.settings-popup'); - else f7.popover.open('#settings-popover', '#btn-settings'); - - return () => { - } - }); - - - const onviewclosed = () => { - if ( props.onclosed ) { - props.onclosed(); - } - }; - - return -}; - -export default Settings; \ No newline at end of file +export default SettingsView; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/SettingsPage.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/SettingsPage.jsx new file mode 100644 index 0000000000..cc13fc48e6 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/view/settings/SettingsPage.jsx @@ -0,0 +1,112 @@ +import React, { useContext } from 'react'; +import { Page, Navbar, NavRight, Link, Icon, ListItem, List, f7 } from 'framework7-react'; +import { useTranslation } from 'react-i18next'; +import { Device } from '../../../../../common/mobile/utils/device'; +import { observer, inject } from "mobx-react"; +import { MainContext } from '../../page/main'; +import { SettingsContext } from '../../controller/settings/Settings'; + +const SettingsPage = inject('storeAppOptions')(observer(props => { + const { t } = useTranslation(); + const appOptions = props.storeAppOptions; + const mainContext = useContext(MainContext); + const settingsContext = useContext(SettingsContext); + const _t = t('View.Settings', {returnObjects: true}); + const navbar = + {Device.phone && {_t.textDone}} + ; + + const onOpenOptions = name => { + settingsContext.closeModal(); + mainContext.openOptions(name); + } + + let _isEdit = false, + _canDownload = false, + _canDownloadOrigin = false, + _canAbout = true, + _canHelp = true, + _canPrint = false, + _canFeedback = true; + + if (appOptions.isDisconnected) { + _isEdit = false; + if (!appOptions.enableDownload) + _canPrint = _canDownload = _canDownloadOrigin = false; + } else { + _isEdit = appOptions.isEdit; + _canDownload = appOptions.canDownload; + _canDownloadOrigin = appOptions.canDownloadOrigin; + _canPrint = appOptions.canPrint; + + if (appOptions.customization && appOptions.canBrandingExt) { + _canAbout = appOptions.customization.about !== false; + } + + if (appOptions.customization) { + _canHelp = appOptions.customization.help !== false; + _canFeedback = appOptions.customization.feedback !== false; + } + } + + return ( + + {navbar} + + {!props.inPopover && + + + + } + {window.matchMedia("(max-width: 359px)").matches ? + onOpenOptions('coauth')} className='no-indicator'> + + + : null} + {_isEdit && + + + + } + + + + {_canDownload && + + + + } + {_canDownloadOrigin && + + + + } + {_canPrint && + + + + } + + + + {_canHelp && + + + + } + {_canAbout && + + + + } + {_canFeedback && + + + + } + + + ) +})); + +export default SettingsPage; \ No newline at end of file