[SSE mobile] Fix Bug 55874

This commit is contained in:
SergeyEzhin 2022-03-04 20:12:14 +04:00
parent 6bec944f6f
commit 83170b1a12
2 changed files with 25 additions and 14 deletions

View file

@ -4,10 +4,9 @@ import CellEditorView from '../view/CellEditor';
import { f7 } from 'framework7-react'; import { f7 } from 'framework7-react';
import { Device } from '../../../../common/mobile/utils/device'; import { Device } from '../../../../common/mobile/utils/device';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import {observer, inject} from "mobx-react";
const CellEditor = props => { const CellEditor = inject("storeFunctions")(observer(props => {
const { t } = useTranslation();
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));
@ -16,6 +15,7 @@ const CellEditor = props => {
}); });
}, []); }, []);
const { t } = useTranslation();
const [cellName, setCellName] = useState(''); const [cellName, setCellName] = useState('');
const [stateFunctions, setFunctionshDisabled] = useState(null); const [stateFunctions, setFunctionshDisabled] = useState(null);
const [stateFuncArr, setFuncArr] = useState(''); const [stateFuncArr, setFuncArr] = useState('');
@ -40,6 +40,10 @@ const CellEditor = props => {
} }
const onFormulaCompleteMenu = funcArr => { const onFormulaCompleteMenu = funcArr => {
const api = Common.EditorApi.get();
const storeFunctions = props.storeFunctions;
const functions = storeFunctions.functions;
if(funcArr) { if(funcArr) {
funcArr.sort(function (a, b) { funcArr.sort(function (a, b) {
let atype = a.asc_getType(), let atype = a.asc_getType(),
@ -60,27 +64,33 @@ const CellEditor = props => {
let hintArr = funcArr.map(item => { let hintArr = funcArr.map(item => {
let type = item.asc_getType(), let type = item.asc_getType(),
name = item.asc_getName(true), name = item.asc_getName(true),
hint = ''; origName = api.asc_getFormulaNameByLocale(name),
args = functions[origName]?.args || '',
caption = name,
descr = '';
switch (type) { switch (type) {
case Asc.c_oAscPopUpSelectorType.Func:
descr = functions && functions[origName] ? functions[origName].descr : '';
break;
case Asc.c_oAscPopUpSelectorType.TableThisRow: case Asc.c_oAscPopUpSelectorType.TableThisRow:
hint = t('View.Add.textThisRowHint'); descr = t('View.Add.textThisRowHint');
break; break;
case Asc.c_oAscPopUpSelectorType.TableAll: case Asc.c_oAscPopUpSelectorType.TableAll:
hint = t('View.Add.textAllTableHint'); descr = t('View.Add.textAllTableHint');
break; break;
case Asc.c_oAscPopUpSelectorType.TableData: case Asc.c_oAscPopUpSelectorType.TableData:
hint = t('View.Add.textDataTableHint'); descr = t('View.Add.textDataTableHint');
break; break;
case Asc.c_oAscPopUpSelectorType.TableHeaders: case Asc.c_oAscPopUpSelectorType.TableHeaders:
hint = t('View.Add.textHeadersTableHint'); descr = t('View.Add.textHeadersTableHint');
break; break;
case Asc.c_oAscPopUpSelectorType.TableTotals: case Asc.c_oAscPopUpSelectorType.TableTotals:
hint = t('View.Add.textTotalsTableHint'); descr = t('View.Add.textTotalsTableHint');
break; break;
} }
return {name, type, hint}; return {name, type, descr, caption, args};
}); });
setHintArr(hintArr); setHintArr(hintArr);
@ -108,6 +118,6 @@ const CellEditor = props => {
insertFormula={insertFormula} insertFormula={insertFormula}
/> />
) )
}; }));
export default CellEditor; export default CellEditor;

View file

@ -29,7 +29,7 @@ const FunctionInfo = props => {
</Navbar> </Navbar>
<div className='function-info'> <div className='function-info'>
<h3>{functionInfo.caption && functionInfo.args ? `${functionInfo.caption} ${functionInfo.args}` : functionInfo.name}</h3> <h3>{functionInfo.caption && functionInfo.args ? `${functionInfo.caption} ${functionInfo.args}` : functionInfo.name}</h3>
<p>{functionInfo.descr || functionInfo.hint}</p> <p>{functionInfo.descr}</p>
</div> </div>
</Page> </Page>
) )
@ -47,11 +47,12 @@ const FunctionsList = props => {
{funcArr.map((elem, index) => { {funcArr.map((elem, index) => {
return ( return (
<ListItem key={index} title={elem.name} className="no-indicator" onClick={() => props.insertFormula(elem.name, elem.type)}> <ListItem key={index} title={elem.name} className="no-indicator" onClick={() => props.insertFormula(elem.name, elem.type)}>
{(functions[elem.name] || hintArr[index]?.hint) && {(functions[elem.name] || hintArr[index]?.descr) &&
<div slot='after' <div slot='after'
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
let functionInfo = functions[elem.name] || hintArr[index]; let functionInfo = functions[elem.name] || hintArr[index];
if(functionInfo) { if(functionInfo) {
f7.views.current.router.navigate('/function-info/', {props: {functionInfo, functionObj: elem, insertFormula: props.insertFormula}}); f7.views.current.router.navigate('/function-info/', {props: {functionInfo, functionObj: elem, insertFormula: props.insertFormula}});
} }