From b58b5013034cf4fe5d8db6f8a4cf1c425e2d8a7e Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Thu, 3 Mar 2022 21:02:08 +0400 Subject: [PATCH] [SSE mobile] Fix Bug 55857 --- apps/spreadsheeteditor/mobile/locale/en.json | 7 ++- .../mobile/src/controller/CellEditor.jsx | 52 ++++++++++++++++++- .../mobile/src/view/CellEditor.jsx | 35 +++++++------ 3 files changed, 76 insertions(+), 18 deletions(-) diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index af000bd4f..0a633752c 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -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", diff --git a/apps/spreadsheeteditor/mobile/src/controller/CellEditor.jsx b/apps/spreadsheeteditor/mobile/src/controller/CellEditor.jsx index d78b7fa7d..3195e8a7e 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/CellEditor.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/CellEditor.jsx @@ -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} /> ) diff --git a/apps/spreadsheeteditor/mobile/src/view/CellEditor.jsx b/apps/spreadsheeteditor/mobile/src/view/CellEditor.jsx index ebd441776..e7e337a54 100644 --- a/apps/spreadsheeteditor/mobile/src/view/CellEditor.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/CellEditor.jsx @@ -28,18 +28,21 @@ const FunctionInfo = props => {
-

{`${functionInfo.caption} ${functionInfo.args}`}

-

{functionInfo.descr}

+ {/* {(functionInfo.caption && functionInfo.args) && +

{`${functionInfo.caption} ${functionInfo.args}`}

+ } */} +

{functionInfo.caption && functionInfo.args ? `${functionInfo.caption} ${functionInfo.args}` : functionInfo.name}

+

{functionInfo.descr || functionInfo.hint}

) } const FunctionsList = props => { - const { t } = useTranslation(); const isPhone = Device.isPhone; const functions = props.functions; const funcArr = props.funcArr; + const hintArr = props.hintArr; return (
@@ -47,16 +50,18 @@ const FunctionsList = props => { {funcArr.map((elem, index) => { return ( props.insertFormula(elem.name, elem.type)}> -
{ - e.stopPropagation(); - let functionInfo = functions[elem.name]; - if(functionInfo) { - f7.views.current.router.navigate('/function-info/', {props: {functionInfo, functionObj: elem, insertFormula: props.insertFormula}}); - } - }}> - -
+ {(functions[elem.name] || hintArr[index]?.hint) && +
{ + 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}}); + } + }}> + +
+ }
) })} @@ -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 => {