diff --git a/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx b/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx index 47212dde2..824933d80 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx @@ -9,14 +9,16 @@ import { idContextMenuElement } from '../../../../common/mobile/lib/view/Context import { Device } from '../../../../common/mobile/utils/device'; import EditorUIController from '../lib/patch'; -@inject ( stores => ({ +@inject (stores => ({ isEdit: stores.storeAppOptions.isEdit, canComments: stores.storeAppOptions.canComments, canViewComments: stores.storeAppOptions.canViewComments, canCoAuthoring: stores.storeAppOptions.canCoAuthoring, users: stores.users, isDisconnected: stores.users.isDisconnected, - storeSheets: stores.sheets + storeSheets: stores.sheets, + wsProps: stores.storeWorksheets.wsProps, + wsLock: stores.storeWorksheets.wsLock })) class ContextMenu extends ContextMenuController { constructor(props) { diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index 160d5a79f..266d522a0 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -402,24 +402,27 @@ class MainController extends Component { }); this.api.asc_registerCallback('asc_onChangeProtectWorksheet', this.onChangeProtectSheet.bind(this)); - this.api.asc_registerCallback('asc_onActiveSheetChanged', this.onChangeProtectSheet.bind(this)); + this.api.asc_registerCallback('asc_onActiveSheetChanged', this.onChangeProtectSheet.bind(this)); } onChangeProtectSheet() { const storeWorksheets = this.props.storeWorksheets; - let props = this.getWSProps(true); + let {wsLock, wsProps} = this.getWSProps(true); - storeWorksheets.setWsProps(props); + storeWorksheets.setWsLock(wsLock); + storeWorksheets.setWsProps(wsProps); } getWSProps(update) { const storeAppOptions = this.props.storeAppOptions; - let wsProps = {}; + let wsProtection = {}; if (!storeAppOptions.config || !storeAppOptions.isEdit && !storeAppOptions.isRestrictedEdit) return; if (update) { - let wsProtected = !!this.api.asc_isProtectedSheet(); - if (wsProtected) { + let wsLock = !!this.api.asc_isProtectedSheet(); + let wsProps = {}; + + if (wsLock) { let props = this.api.asc_getProtectedSheet(); props && this.wsLockOptions.forEach(function(item){ wsProps[item] = props['asc_get' + item] ? props['asc_get' + item]() : false; @@ -429,9 +432,11 @@ class MainController extends Component { wsProps[item] = false; }); } + + wsProtection = {wsLock, wsProps}; } - return wsProps; + return wsProtection; } _onLongActionEnd(type, id) { diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx index 5a94bdccc..e9efe41cc 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx @@ -1,6 +1,7 @@ import React, {Component} from 'react'; import { f7 } from 'framework7-react'; import { withTranslation } from 'react-i18next'; +import {observer, inject} from "mobx-react"; import AddSortAndFilter from '../../view/add/AddFilter'; @@ -120,9 +121,10 @@ class AddFilterController extends Component { onInsertSort={this.onInsertSort} onInsertFilter={this.onInsertFilter} isFilter={this.state.isFilter} + wsLock={this.props.storeWorksheets.wsLock} /> ) } } -export default withTranslation()(AddFilterController); \ No newline at end of file +export default inject("storeWorksheets")(observer(withTranslation()(AddFilterController))); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx index 0dbfae927..36250ffc7 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx @@ -30,8 +30,7 @@ class AddOtherController extends Component { return ( ) } diff --git a/apps/spreadsheeteditor/mobile/src/page/main.jsx b/apps/spreadsheeteditor/mobile/src/page/main.jsx index f8d57689d..ff9ab052d 100644 --- a/apps/spreadsheeteditor/mobile/src/page/main.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/main.jsx @@ -90,6 +90,7 @@ class MainPage extends Component { const appOptions = this.props.storeAppOptions; const storeWorksheets = this.props.storeWorksheets; const wsProps = storeWorksheets.wsProps; + const wsLock = storeWorksheets.wsLock; const config = appOptions.config; const showLogo = !(appOptions.canBrandingExt && (config.customization && (config.customization.loaderName || config.customization.loaderLogo))); const showPlaceholder = !appOptions.isDocReady && (!config.customization || !(config.customization.loaderName || config.customization.loaderLogo)); @@ -117,11 +118,11 @@ class MainPage extends Component { { !this.state.editOptionsVisible ? null : - + } { !this.state.addOptionsVisible ? null : - + } { !this.state.settingsVisible ? null : diff --git a/apps/spreadsheeteditor/mobile/src/store/sheets.js b/apps/spreadsheeteditor/mobile/src/store/sheets.js index 62d621314..7447b6872 100644 --- a/apps/spreadsheeteditor/mobile/src/store/sheets.js +++ b/apps/spreadsheeteditor/mobile/src/store/sheets.js @@ -93,7 +93,7 @@ export class storeWorksheets { let model = this.sheets[index]; if(model && model.locked !== locked) model.locked = locked; - this.isWorkbookLocked = locked; + this.isWorksheetLocked = locked; } isProtectedWorkbook = false; @@ -101,8 +101,13 @@ export class storeWorksheets { this.isProtectedWorkbook = value; } - wsProps; + wsProps = {}; setWsProps(value) { this.wsProps = value; } + + wsLock; + setWsLock(value) { + this.wsLock = value; + } } diff --git a/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx b/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx index 1c29e6639..325442ffa 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx @@ -58,6 +58,8 @@ const routes = [ const AddLayoutNavbar = ({ tabs, inPopover }) => { const isAndroid = Device.android; + if(!tabs.length) return null; + return ( {tabs.length > 1 ? @@ -67,8 +69,7 @@ const AddLayoutNavbar = ({ tabs, inPopover }) => { )} {isAndroid && } - : - {tabs[0].caption} + : {tabs[0].caption} } { !inPopover && } @@ -76,6 +77,8 @@ const AddLayoutNavbar = ({ tabs, inPopover }) => { }; const AddLayoutContent = ({ tabs }) => { + if(!tabs.length) return null; + return ( {tabs.map((item, index) => @@ -90,6 +93,7 @@ const AddLayoutContent = ({ tabs }) => { 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 = []; @@ -128,13 +132,12 @@ const AddTabs = props => { }); } } - if (!showPanels && (!wsProps.InsertHyperlinks || !wsProps.Objects)) { + if (!showPanels && (!wsProps.InsertHyperlinks || !wsProps.Objects || !wsProps.Sort)) { tabs.push({ caption: _t.textOther, id: 'add-other', icon: 'icon-add-other', - component: + component: }); } if (((showPanels && showPanels === 'hyperlink') || props.isAddShapeHyperlink) && !wsProps.InsertHyperlinks) { @@ -145,6 +148,17 @@ const AddTabs = props => { component: }); } + + if(!tabs.length) { + if (Device.phone) { + f7.popup.close('.add-popup', false); + } else { + f7.popover.close('#add-popover', false); + } + + return null; + } + return ( @@ -169,10 +183,10 @@ class AddView extends Component { return ( show_popover ? this.props.onclosed()}> - + : this.props.onclosed()}> - + ) } @@ -228,6 +242,7 @@ const Add = props => { showPanels={options ? options.panels : undefined} isAddShapeHyperlink = {isAddShapeHyperlink} wsProps={props.wsProps} + wsLock={props.wsLock} /> }; diff --git a/apps/spreadsheeteditor/mobile/src/view/add/AddFilter.jsx b/apps/spreadsheeteditor/mobile/src/view/add/AddFilter.jsx index 6f97ff992..4369fc5e0 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/AddFilter.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/AddFilter.jsx @@ -6,6 +6,8 @@ const AddSortAndFilter = props => { const { t } = useTranslation(); const _t = t('View.Add', {returnObjects: true}); const isFilter = props.isFilter; + const wsLock = props.wsLock; + return ( @@ -21,14 +23,16 @@ const AddSortAndFilter = props => { - - - { - props.onInsertFilter(!prev); - }}/> - - + {!wsLock && + + + { + props.onInsertFilter(!prev); + }}/> + + + } ) }; diff --git a/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx b/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx index a34d5e747..592929673 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/AddOther.jsx @@ -6,24 +6,23 @@ const AddOther = props => { const { t } = useTranslation(); const _t = t('View.Add', {returnObjects: true}); const hideAddComment = props.hideAddComment(); - const wsPropsHyperlinks = props.wsPropsHyperlinks; - const wsPropsObjects = props.wsPropsObjects; + const wsProps = props.wsProps; return ( - + - {(!hideAddComment && !wsPropsObjects) && { + {(!hideAddComment && !wsProps.Objects) && { props.closeModal(); Common.Notifications.trigger('addcomment'); }}> } - + - + diff --git a/apps/spreadsheeteditor/mobile/src/view/edit/Edit.jsx b/apps/spreadsheeteditor/mobile/src/view/edit/Edit.jsx index d2e4d301f..a2faab7b1 100644 --- a/apps/spreadsheeteditor/mobile/src/view/edit/Edit.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/edit/Edit.jsx @@ -290,6 +290,9 @@ const EditLayoutNavbar = ({ editors, inPopover }) => { const isAndroid = Device.android; const { t } = useTranslation(); const _t = t('View.Edit', {returnObjects: true}); + + if(!editors.length) return null; + return ( { @@ -297,8 +300,7 @@ const EditLayoutNavbar = ({ editors, inPopover }) => {
{editors.map((item, index) => {item.caption})} {isAndroid && } -
: - { editors[0].caption } + : { editors[0].caption } } { !inPopover && }
@@ -306,6 +308,8 @@ const EditLayoutNavbar = ({ editors, inPopover }) => { }; const EditLayoutContent = ({ editors }) => { + if(!editors.length) return null; + if (editors.length > 1) { return ( @@ -329,6 +333,7 @@ const EditTabs = props => { const { t } = useTranslation(); const _t = t('View.Edit', {returnObjects: true}); const store = props.storeFocusObjects; + const wsLock = props.wsLock; const wsProps = props.wsProps; const settings = !store.focusOn ? [] : (store.focusOn === 'obj' ? store.objects : store.selections); let editors = []; @@ -385,6 +390,16 @@ const EditTabs = props => { } } + if(!editors.length) { + if (Device.phone) { + f7.sheet.close('#edit-sheet', false); + } else { + f7.popover.close('#edit-popover', false); + } + + return null; + } + return ( @@ -406,10 +421,10 @@ const EditView = props => { return ( show_popover ? props.onClosed()}> - + : props.onClosed()}> - + ) }; @@ -436,7 +451,7 @@ const EditOptions = props => { const isAddShapeHyperlink = api.asc_canAddShapeHyperlink(); return ( - + ) };