[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\"",
"txtSorting": "Sorting",
"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": {
"notcriticalErrorTitle": "Warning",

View file

@ -3,8 +3,11 @@ import React, { useEffect, useState } from 'react';
import CellEditorView from '../view/CellEditor';
import { f7 } from 'framework7-react';
import { Device } from '../../../../common/mobile/utils/device';
import { useTranslation } from 'react-i18next';
const CellEditor = props => {
const { t } = useTranslation();
useEffect(() => {
Common.Notifications.on('engineCreated', api => {
api.asc_registerCallback('asc_onSelectionNameChanged', onApiCellSelection.bind(this));
@ -16,6 +19,7 @@ const CellEditor = props => {
const [cellName, setCellName] = useState('');
const [stateFunctions, setFunctionshDisabled] = useState(null);
const [stateFuncArr, setFuncArr] = useState('');
const [stateHintArr, setHintArr] = useState('');
const onApiCellSelection = info => {
setCellName(typeof(info)=='string' ? info : info.asc_getName());
@ -36,9 +40,52 @@ const CellEditor = props => {
}
const onFormulaCompleteMenu = funcArr => {
setFuncArr(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');
} else {
f7.popover.close('#idx-functions-list');
@ -56,6 +103,7 @@ const CellEditor = props => {
stateFunctions={stateFunctions}
onClickToOpenAddOptions={props.onClickToOpenAddOptions}
funcArr={stateFuncArr}
hintArr={stateHintArr}
insertFormula={insertFormula}
/>
)

View file

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