[SSE mobile] Added show panels and target element props to add modal
This commit is contained in:
parent
f0d343403b
commit
43c7bcf98e
|
@ -15,7 +15,8 @@ const CellEditor = props => {
|
||||||
setCellName(typeof(info)=='string' ? info : info.asc_getName());
|
setCellName(typeof(info)=='string' ? info : info.asc_getName());
|
||||||
};
|
};
|
||||||
|
|
||||||
return <CellEditorView cellName={cellName} />
|
return <CellEditorView cellName={cellName}
|
||||||
|
onClickToOpenAddOptions={props.onClickToOpenAddOptions}/>
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CellEditor;
|
export default CellEditor;
|
|
@ -15,17 +15,21 @@ export default class MainPage extends Component {
|
||||||
this.state = {
|
this.state = {
|
||||||
editOptionsVisible: false,
|
editOptionsVisible: false,
|
||||||
addOptionsVisible: false,
|
addOptionsVisible: false,
|
||||||
|
addShowOptions: null,
|
||||||
settingsVisible: false,
|
settingsVisible: false,
|
||||||
collaborationVisible: false,
|
collaborationVisible: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClickToOpenOptions = opts => {
|
handleClickToOpenOptions = (opts, showOpts) => {
|
||||||
this.setState(state => {
|
this.setState(state => {
|
||||||
if ( opts == 'edit' )
|
if ( opts == 'edit' )
|
||||||
return {editOptionsVisible: true};
|
return {editOptionsVisible: true};
|
||||||
else if ( opts == 'add' )
|
else if ( opts == 'add' )
|
||||||
return {addOptionsVisible: true};
|
return {
|
||||||
|
addOptionsVisible: true,
|
||||||
|
addShowOptions: showOpts
|
||||||
|
};
|
||||||
else if ( opts == 'settings' )
|
else if ( opts == 'settings' )
|
||||||
return {settingsVisible: true};
|
return {settingsVisible: true};
|
||||||
else if ( opts == 'coauth' )
|
else if ( opts == 'coauth' )
|
||||||
|
@ -65,7 +69,7 @@ export default class MainPage extends Component {
|
||||||
<Link id='btn-settings' icon='icon-settings' href={false} onClick={e => this.handleClickToOpenOptions('settings')}></Link>
|
<Link id='btn-settings' icon='icon-settings' href={false} onClick={e => this.handleClickToOpenOptions('settings')}></Link>
|
||||||
</NavRight>
|
</NavRight>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
<CellEditor />
|
<CellEditor onClickToOpenAddOptions={(panels, button) => this.handleClickToOpenOptions('add', {panels: panels, button: button})}/>
|
||||||
{/* Page content */}
|
{/* Page content */}
|
||||||
<View id="editor_sdk" />
|
<View id="editor_sdk" />
|
||||||
{
|
{
|
||||||
|
@ -74,7 +78,7 @@ export default class MainPage extends Component {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
!this.state.addOptionsVisible ? null :
|
!this.state.addOptionsVisible ? null :
|
||||||
<AddOptions onclosed={this.handleOptionsViewClosed.bind(this, 'add')} />
|
<AddOptions onclosed={this.handleOptionsViewClosed.bind(this, 'add')} showOptions={this.state.addShowOptions} />
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
!this.state.settingsVisible ? null :
|
!this.state.settingsVisible ? null :
|
||||||
|
|
|
@ -20,7 +20,7 @@ const CellEditorView = props => {
|
||||||
return <View id="idx-celleditor" style={viewStyle} className={expanded?'expanded':'collapsed'}>
|
return <View id="idx-celleditor" style={viewStyle} className={expanded?'expanded':'collapsed'}>
|
||||||
<div id="box-cell-name" className="ce-group">
|
<div id="box-cell-name" className="ce-group">
|
||||||
<span id="idx-cell-name">{props.cellName}</span>
|
<span id="idx-cell-name">{props.cellName}</span>
|
||||||
<a href="#" id="idx-btn-function" className="link icon-only">
|
<a href="#" id="idx-btn-function" className="link icon-only" onClick={() => {props.onClickToOpenAddOptions('formula', '#idx-btn-function');}}>
|
||||||
<i className="icon icon-function" />
|
<i className="icon icon-function" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -44,19 +44,24 @@ const AddLayoutContent = ({ tabs }) => {
|
||||||
const AddTabs = props => {
|
const AddTabs = props => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const _t = t('Add', {returnObjects: true});
|
const _t = t('Add', {returnObjects: true});
|
||||||
|
const showPanels = props.showPanels;
|
||||||
const tabs = [];
|
const tabs = [];
|
||||||
|
if (!showPanels) {
|
||||||
tabs.push({
|
tabs.push({
|
||||||
caption: _t.textChart,
|
caption: _t.textChart,
|
||||||
id: 'add-chart',
|
id: 'add-chart',
|
||||||
icon: 'icon-add-chart',
|
icon: 'icon-add-chart',
|
||||||
component: <AddChartController/>
|
component: <AddChartController/>
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
if (!showPanels || showPanels === 'formula') {
|
||||||
tabs.push({
|
tabs.push({
|
||||||
caption: _t.textFormula,
|
caption: _t.textFormula,
|
||||||
id: 'add-formula',
|
id: 'add-formula',
|
||||||
icon: 'icon-add-formula',
|
icon: 'icon-add-formula',
|
||||||
component: <AddFormulaController/>
|
component: <AddFormulaController/>
|
||||||
});
|
});
|
||||||
|
}
|
||||||
/*tabs.push({
|
/*tabs.push({
|
||||||
caption: _t.textShape,
|
caption: _t.textShape,
|
||||||
id: 'add-shape',
|
id: 'add-shape',
|
||||||
|
@ -93,10 +98,10 @@ class AddView extends Component {
|
||||||
return (
|
return (
|
||||||
show_popover ?
|
show_popover ?
|
||||||
<Popover id="add-popover" className="popover__titled" onPopoverClosed={() => this.props.onclosed()}>
|
<Popover id="add-popover" className="popover__titled" onPopoverClosed={() => this.props.onclosed()}>
|
||||||
<AddTabs inPopover={true} onOptionClick={this.onoptionclick} style={{height: '410px'}} />
|
<AddTabs inPopover={true} onOptionClick={this.onoptionclick} style={{height: '410px'}} showPanels={this.props.showPanels}/>
|
||||||
</Popover> :
|
</Popover> :
|
||||||
<Popup className="add-popup" onPopupClosed={() => this.props.onclosed()}>
|
<Popup className="add-popup" onPopupClosed={() => this.props.onclosed()}>
|
||||||
<AddTabs onOptionClick={this.onoptionclick} />
|
<AddTabs onOptionClick={this.onoptionclick} showPanels={this.props.showPanels}/>
|
||||||
</Popup>
|
</Popup>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -104,9 +109,12 @@ class AddView extends Component {
|
||||||
|
|
||||||
const Add = props => {
|
const Add = props => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if ( Device.phone )
|
if ( Device.phone ) {
|
||||||
f7.popup.open('.add-popup');
|
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 () => {
|
return () => {
|
||||||
// component will unmount
|
// component will unmount
|
||||||
|
@ -116,7 +124,10 @@ const Add = props => {
|
||||||
if ( props.onclosed )
|
if ( props.onclosed )
|
||||||
props.onclosed();
|
props.onclosed();
|
||||||
};
|
};
|
||||||
return <AddView usePopover={!Device.phone} onclosed={onviewclosed} />
|
return <AddView usePopover={!Device.phone}
|
||||||
|
onclosed={onviewclosed}
|
||||||
|
showPanels={props.showOptions ? props.showOptions.panels : undefined}
|
||||||
|
/>
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Add;
|
export default Add;
|
Loading…
Reference in a new issue