[SSE mobile] Added functions list

This commit is contained in:
SergeyEzhin 2021-08-27 16:16:28 +03:00
parent fbbeb9fb85
commit 78cdc5f873
3 changed files with 65 additions and 5 deletions

View file

@ -871,6 +871,38 @@ input[type="number"]::-webkit-inner-spin-button {
} }
} }
// Functions List
.cell-editor {
overflow: initial;
}
.functions-list {
width: 100%;
height: 150px;
overflow-y: auto;
position: absolute;
top: 30px;
left: 0;
right: 0;
background-color: @white;
.list {
margin: 0;
ul:before {
display: none;
}
.item-content {
padding-left: 0;
}
.item-inner {
padding-left: calc(var(--f7-list-item-padding-horizontal) + var(--f7-safe-area-left) - var(--menu-list-offset));
}
.item-title {
font-size: 14px;
}
}
}

View file

@ -1,17 +1,20 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import CellEditorView from '../view/CellEditor'; import CellEditorView from '../view/CellEditor';
import { f7 } from 'framework7-react';
const CellEditor = props => { const CellEditor = props => {
useEffect(() => { useEffect(() => {
Common.Notifications.on('engineCreated', api => { Common.Notifications.on('engineCreated', api => {
api.asc_registerCallback('asc_onSelectionNameChanged', onApiCellSelection.bind(this)); api.asc_registerCallback('asc_onSelectionNameChanged', onApiCellSelection.bind(this));
api.asc_registerCallback('asc_onSelectionChanged', onApiSelectionChanged.bind(this)); api.asc_registerCallback('asc_onSelectionChanged', onApiSelectionChanged.bind(this));
api.asc_registerCallback('asc_onFormulaCompleteMenu', onFormulaCompleteMenu.bind(this));
}); });
}, []); }, []);
const [cellName, setCellName] = useState(''); const [cellName, setCellName] = useState('');
const [stateCoauth, setCoauthDisabled] = useState(null); const [stateCoauth, setCoauthDisabled] = useState(null);
const [stateFuncArr, setFuncArr] = useState('');
const onApiCellSelection = info => { const onApiCellSelection = info => {
setCellName(typeof(info)=='string' ? info : info.asc_getName()); setCellName(typeof(info)=='string' ? info : info.asc_getName());
@ -20,10 +23,23 @@ const CellEditor = props => {
const onApiSelectionChanged = info => { const onApiSelectionChanged = info => {
setCoauthDisabled(info.asc_getLocked() === true || info.asc_getLockedTable() === true || info.asc_getLockedPivotTable()===true); setCoauthDisabled(info.asc_getLocked() === true || info.asc_getLockedTable() === true || info.asc_getLockedPivotTable()===true);
} }
const onFormulaCompleteMenu = funcArr => setFuncArr(funcArr);
const insertFormula = (name, type) => {
const api = Common.EditorApi.get();
api.asc_insertInCell(name, type, false);
}
return <CellEditorView cellName={cellName} return (
stateCoauth = {stateCoauth} <CellEditorView
onClickToOpenAddOptions={props.onClickToOpenAddOptions}/> cellName={cellName}
stateCoauth={stateCoauth}
onClickToOpenAddOptions={props.onClickToOpenAddOptions}
funcArr={stateFuncArr}
insertFormula={insertFormula}
/>
)
}; };
export default CellEditor; export default CellEditor;

View file

@ -1,6 +1,6 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Input, View, Button, Link } from 'framework7-react'; import { Input, View, Button, Link, Popover, ListItem, List } from 'framework7-react';
import {observer, inject} from "mobx-react"; import {observer, inject} from "mobx-react";
const viewStyle = { const viewStyle = {
@ -15,12 +15,13 @@ const CellEditorView = props => {
const [expanded, setExpanded] = useState(false); const [expanded, setExpanded] = useState(false);
const storeAppOptions = props.storeAppOptions; const storeAppOptions = props.storeAppOptions;
const isEdit = storeAppOptions.isEdit; const isEdit = storeAppOptions.isEdit;
const funcArr = props.funcArr;
const expandClick = e => { const expandClick = e => {
setExpanded(!expanded); setExpanded(!expanded);
}; };
return <View id="idx-celleditor" style={viewStyle} className={expanded?'expanded':'collapsed'}> return <View id="idx-celleditor" style={viewStyle} className={expanded ? 'cell-editor expanded' : 'cell-editor 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' disabled={(!isEdit && true) || props.stateCoauth} onClick={() => {props.onClickToOpenAddOptions('function', '#idx-btn-function');}}> <a href="#" id="idx-btn-function" className='link icon-only' disabled={(!isEdit && true) || props.stateCoauth} onClick={() => {props.onClickToOpenAddOptions('function', '#idx-btn-function');}}>
@ -33,6 +34,17 @@ const CellEditorView = props => {
<div className="ce-group"> <div className="ce-group">
<Link icon="caret" onClick={expandClick} /> <Link icon="caret" onClick={expandClick} />
</div> </div>
{funcArr && funcArr.length &&
<div id="idx-functions-list" className="functions-list">
<List>
{funcArr.map((elem, index) => {
return (
<ListItem key={index} title={elem.name} onClick={() => props.insertFormula(elem.name, elem.type)}></ListItem>
)
})}
</List>
</div>
}
</View>; </View>;
}; };