[SSE mobile] Fix Bug 55857

This commit is contained in:
SergeyEzhin 2022-03-03 21:02:08 +04:00
parent edfb2b9ae6
commit b58b501303
3 changed files with 76 additions and 18 deletions

View file

@ -360,7 +360,12 @@
"txtNotUrl": "This field should be a URL in the format \"http://www.example.com\"", "txtNotUrl": "This field should be a URL in the format \"http://www.example.com\"",
"txtSorting": "Sorting", "txtSorting": "Sorting",
"txtSortSelected": "Sort selected", "txtSortSelected": "Sort selected",
"txtYes": "Yes" "txtYes": "Yes",
"textThisRowHint": "Choose only this row of the specified column",
"textAllTableHint": "Returns the entire contents of the table or specified table columns including column headers, data and total rows",
"textDataTableHint": "Returns the data cells of the table or specified table columns",
"textHeadersTableHint": "Returns the column headers for the table or specified table columns",
"textTotalsTableHint": "Returns the total rows for the table or specified table columns"
}, },
"Edit": { "Edit": {
"notcriticalErrorTitle": "Warning", "notcriticalErrorTitle": "Warning",

View file

@ -3,8 +3,11 @@ import React, { useEffect, useState } from 'react';
import CellEditorView from '../view/CellEditor'; 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';
const CellEditor = props => { const CellEditor = 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 +19,7 @@ const CellEditor = props => {
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('');
const [stateHintArr, setHintArr] = useState('');
const onApiCellSelection = info => { const onApiCellSelection = info => {
setCellName(typeof(info)=='string' ? info : info.asc_getName()); setCellName(typeof(info)=='string' ? info : info.asc_getName());
@ -36,9 +40,52 @@ const CellEditor = props => {
} }
const onFormulaCompleteMenu = funcArr => { const onFormulaCompleteMenu = funcArr => {
setFuncArr(funcArr);
if(funcArr) { if(funcArr) {
funcArr.sort(function (a, b) {
let atype = a.asc_getType(),
btype = b.asc_getType(),
aname = a.asc_getName(true).toLocaleUpperCase(),
bname = b.asc_getName(true).toLocaleUpperCase();
if (atype === Asc.c_oAscPopUpSelectorType.TableThisRow) return -1;
if (btype === Asc.c_oAscPopUpSelectorType.TableThisRow) return 1;
if ((atype === Asc.c_oAscPopUpSelectorType.TableColumnName || btype === Asc.c_oAscPopUpSelectorType.TableColumnName) && atype !== btype)
return atype === Asc.c_oAscPopUpSelectorType.TableColumnName ? -1 : 1;
if (aname < bname) return -1;
if (aname > bname) return 1;
return 0;
});
let hintArr = funcArr.map(item => {
let type = item.asc_getType(),
name = item.asc_getName(true),
hint = '';
switch (type) {
case Asc.c_oAscPopUpSelectorType.TableThisRow:
hint = t('View.Add.textThisRowHint');
break;
case Asc.c_oAscPopUpSelectorType.TableAll:
hint = t('View.Add.textAllTableHint');
break;
case Asc.c_oAscPopUpSelectorType.TableData:
hint = t('View.Add.textDataTableHint');
break;
case Asc.c_oAscPopUpSelectorType.TableHeaders:
hint = t('View.Add.textHeadersTableHint');
break;
case Asc.c_oAscPopUpSelectorType.TableTotals:
hint = t('View.Add.textTotalsTableHint');
break;
}
return {name, type, hint};
});
setHintArr(hintArr);
setFuncArr(funcArr);
f7.popover.open('#idx-functions-list', '#idx-list-target'); f7.popover.open('#idx-functions-list', '#idx-list-target');
} else { } else {
f7.popover.close('#idx-functions-list'); f7.popover.close('#idx-functions-list');
@ -56,6 +103,7 @@ const CellEditor = props => {
stateFunctions={stateFunctions} stateFunctions={stateFunctions}
onClickToOpenAddOptions={props.onClickToOpenAddOptions} onClickToOpenAddOptions={props.onClickToOpenAddOptions}
funcArr={stateFuncArr} funcArr={stateFuncArr}
hintArr={stateHintArr}
insertFormula={insertFormula} insertFormula={insertFormula}
/> />
) )

View file

@ -28,18 +28,21 @@ const FunctionInfo = props => {
</NavRight> </NavRight>
</Navbar> </Navbar>
<div className='function-info'> <div className='function-info'>
<h3>{`${functionInfo.caption} ${functionInfo.args}`}</h3> {/* {(functionInfo.caption && functionInfo.args) &&
<p>{functionInfo.descr}</p> <h3>{`${functionInfo.caption} ${functionInfo.args}`}</h3>
} */}
<h3>{functionInfo.caption && functionInfo.args ? `${functionInfo.caption} ${functionInfo.args}` : functionInfo.name}</h3>
<p>{functionInfo.descr || functionInfo.hint}</p>
</div> </div>
</Page> </Page>
) )
} }
const FunctionsList = props => { const FunctionsList = props => {
const { t } = useTranslation();
const isPhone = Device.isPhone; const isPhone = Device.isPhone;
const functions = props.functions; const functions = props.functions;
const funcArr = props.funcArr; const funcArr = props.funcArr;
const hintArr = props.hintArr;
return ( return (
<div className={isPhone ? 'functions-list functions-list__mobile' : 'functions-list'}> <div className={isPhone ? 'functions-list functions-list__mobile' : 'functions-list'}>
@ -47,16 +50,18 @@ 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)}>
<div slot='after' {(functions[elem.name] || hintArr[index]?.hint) &&
onClick={(e) => { <div slot='after'
e.stopPropagation(); onClick={(e) => {
let functionInfo = functions[elem.name]; e.stopPropagation();
if(functionInfo) { let functionInfo = functions[elem.name] || hintArr[index];
f7.views.current.router.navigate('/function-info/', {props: {functionInfo, functionObj: elem, insertFormula: props.insertFormula}}); if(functionInfo) {
} f7.views.current.router.navigate('/function-info/', {props: {functionInfo, functionObj: elem, insertFormula: props.insertFormula}});
}}> }
<Icon icon='icon-info'/> }}>
</div> <Icon icon='icon-info'/>
</div>
}
</ListItem> </ListItem>
) )
})} })}
@ -65,8 +70,6 @@ const FunctionsList = props => {
) )
} }
const CellEditorView = props => { const CellEditorView = props => {
const [expanded, setExpanded] = useState(false); const [expanded, setExpanded] = useState(false);
const isPhone = Device.isPhone; const isPhone = Device.isPhone;
@ -78,6 +81,7 @@ const CellEditorView = props => {
const functions = storeFunctions.functions; const functions = storeFunctions.functions;
const isEdit = storeAppOptions.isEdit; const isEdit = storeAppOptions.isEdit;
const funcArr = props.funcArr; const funcArr = props.funcArr;
const hintArr = props.hintArr;
const expandClick = e => { const expandClick = e => {
setExpanded(!expanded); setExpanded(!expanded);
@ -115,6 +119,7 @@ const CellEditorView = props => {
<FunctionsList <FunctionsList
functions={functions} functions={functions}
funcArr={funcArr} funcArr={funcArr}
hintArr={hintArr}
insertFormula={props.insertFormula} insertFormula={props.insertFormula}
/> />
</Page> </Page>