From 43c7bcf98e1f7be9b41d4ba49fd93ffc01388c14 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 29 Jan 2021 21:03:38 +0300 Subject: [PATCH] [SSE mobile] Added show panels and target element props to add modal --- .../mobile/src/controller/CellEditor.jsx | 3 +- .../mobile/src/page/main.jsx | 12 +++-- .../mobile/src/view/CellEditor.jsx | 2 +- .../mobile/src/view/add/Add.jsx | 45 ++++++++++++------- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/apps/spreadsheeteditor/mobile/src/controller/CellEditor.jsx b/apps/spreadsheeteditor/mobile/src/controller/CellEditor.jsx index 79f782f80..1170be25b 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/CellEditor.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/CellEditor.jsx @@ -15,7 +15,8 @@ const CellEditor = props => { setCellName(typeof(info)=='string' ? info : info.asc_getName()); }; - return + return }; export default CellEditor; \ 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 5d51c1992..19910cd86 100644 --- a/apps/spreadsheeteditor/mobile/src/page/main.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/main.jsx @@ -15,17 +15,21 @@ export default class MainPage extends Component { this.state = { editOptionsVisible: false, addOptionsVisible: false, + addShowOptions: null, settingsVisible: false, collaborationVisible: false, }; } - handleClickToOpenOptions = opts => { + handleClickToOpenOptions = (opts, showOpts) => { this.setState(state => { if ( opts == 'edit' ) return {editOptionsVisible: true}; else if ( opts == 'add' ) - return {addOptionsVisible: true}; + return { + addOptionsVisible: true, + addShowOptions: showOpts + }; else if ( opts == 'settings' ) return {settingsVisible: true}; else if ( opts == 'coauth' ) @@ -65,7 +69,7 @@ export default class MainPage extends Component { this.handleClickToOpenOptions('settings')}> - + this.handleClickToOpenOptions('add', {panels: panels, button: button})}/> {/* Page content */} { @@ -74,7 +78,7 @@ export default class MainPage extends Component { } { !this.state.addOptionsVisible ? null : - + } { !this.state.settingsVisible ? null : diff --git a/apps/spreadsheeteditor/mobile/src/view/CellEditor.jsx b/apps/spreadsheeteditor/mobile/src/view/CellEditor.jsx index e9b889a78..4e677c492 100644 --- a/apps/spreadsheeteditor/mobile/src/view/CellEditor.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/CellEditor.jsx @@ -20,7 +20,7 @@ const CellEditorView = props => { return diff --git a/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx b/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx index 619b8983a..2f6d0b440 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx @@ -44,19 +44,24 @@ const AddLayoutContent = ({ tabs }) => { const AddTabs = props => { const { t } = useTranslation(); const _t = t('Add', {returnObjects: true}); + const showPanels = props.showPanels; const tabs = []; - tabs.push({ - caption: _t.textChart, - id: 'add-chart', - icon: 'icon-add-chart', - component: - }); - tabs.push({ - caption: _t.textFormula, - id: 'add-formula', - icon: 'icon-add-formula', - component: - }); + if (!showPanels) { + tabs.push({ + caption: _t.textChart, + id: 'add-chart', + icon: 'icon-add-chart', + component: + }); + } + if (!showPanels || showPanels === 'formula') { + tabs.push({ + caption: _t.textFormula, + id: 'add-formula', + icon: 'icon-add-formula', + component: + }); + } /*tabs.push({ caption: _t.textShape, id: 'add-shape', @@ -93,10 +98,10 @@ class AddView extends Component { return ( show_popover ? this.props.onclosed()}> - + : this.props.onclosed()}> - + ) } @@ -104,9 +109,12 @@ class AddView extends Component { const Add = props => { useEffect(() => { - if ( Device.phone ) + if ( Device.phone ) { f7.popup.open('.add-popup'); - else f7.popover.open('#add-popover', '#btn-add'); + } else { + const targetElem = !props.showOptions ? '#btn-add' : props.showOptions.button; + f7.popover.open('#add-popover', targetElem); + } return () => { // component will unmount @@ -116,7 +124,10 @@ const Add = props => { if ( props.onclosed ) props.onclosed(); }; - return + return }; export default Add; \ No newline at end of file