From 24705bec8c5a1eecd778fec2bfed8f8689317c88 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Sat, 16 Oct 2021 18:08:40 +0400 Subject: [PATCH] [DE SSE mobile] Fix Bug 52821 --- .../mobile/src/controller/Encoding.jsx | 19 +++++++------- .../mobile/src/view/Encoding.jsx | 26 ++++++++----------- .../mobile/src/controller/Encoding.jsx | 17 ++++++------ .../mobile/src/view/Encoding.jsx | 26 ++++++++----------- 4 files changed, 41 insertions(+), 47 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/Encoding.jsx b/apps/documenteditor/mobile/src/controller/Encoding.jsx index 52ad79181..e1ca68d82 100644 --- a/apps/documenteditor/mobile/src/controller/Encoding.jsx +++ b/apps/documenteditor/mobile/src/controller/Encoding.jsx @@ -32,24 +32,26 @@ class EncodingController extends Component { this.mode = mode; this.advOptions = advOptions; this.formatOptions = formatOptions; - this.pages = []; - this.pagesName = []; + this.encodeData = []; const recommendedSettings = this.advOptions.asc_getRecommendedSettings(); - this.initPages(); + this.initEncodeData(); this.valueEncoding = recommendedSettings.asc_getCodePage(); this.setState({ - isOpen: true + isOpen: true }); } } - initPages() { + initEncodeData() { for (let page of this.advOptions.asc_getCodePages()) { - this.pages.push(page.asc_getCodePage()); - this.pagesName.push(page.asc_getCodePageName()); + this.encodeData.push({ + value: page.asc_getCodePage(), + displayValue: page.asc_getCodePageName(), + lcid: page.asc_getLcid() + }); } } @@ -78,8 +80,7 @@ class EncodingController extends Component { closeModal={this.closeModal} mode={this.mode} onSaveFormat={this.onSaveFormat} - pages={this.pages} - pagesName={this.pagesName} + encodeData={this.encodeData} valueEncoding={this.valueEncoding} /> ); diff --git a/apps/documenteditor/mobile/src/view/Encoding.jsx b/apps/documenteditor/mobile/src/view/Encoding.jsx index 3911a2d85..de9bddb55 100644 --- a/apps/documenteditor/mobile/src/view/Encoding.jsx +++ b/apps/documenteditor/mobile/src/view/Encoding.jsx @@ -6,10 +6,10 @@ import { Device } from '../../../../common/mobile/utils/device'; const PageEncoding = props => { const { t } = useTranslation(); const _t = t("Settings", { returnObjects: true }); - const pagesName = props.pagesName; - const pages = props.pages; + const encodeData = props.encodeData; const [stateEncoding, setStateEncoding] = useState(props.valueEncoding); - const nameEncoding = pagesName[pages.indexOf(stateEncoding)]; + const getIndexNameEncoding = () => encodeData.findIndex(encoding => encoding.value === stateEncoding); + const nameEncoding = encodeData[getIndexNameEncoding()].displayValue; const mode = props.mode; const changeStateEncoding = value => { @@ -24,8 +24,7 @@ const PageEncoding = props => { @@ -45,19 +44,18 @@ const PageEncodingList = props => { const { t } = useTranslation(); const _t = t("Settings", { returnObjects: true }); const [currentEncoding, changeCurrentEncoding] = useState(props.stateEncoding); - const pages = props.pages; - const pagesName = props.pagesName; + const encodeData = props.encodeData; return ( {_t.textChooseEncoding} - {pagesName.map((name, index) => { + {encodeData.map((encoding, index) => { return ( - { - changeCurrentEncoding(pages[index]); - props.changeStateEncoding(pages[index]); + { + changeCurrentEncoding(encoding.value); + props.changeStateEncoding(encoding.value); f7.views.current.router.back(); }}> ) @@ -79,8 +77,7 @@ class EncodingView extends Component { onSaveFormat={this.props.onSaveFormat} closeModal={this.props.closeModal} mode={this.props.mode} - pages={this.props.pages} - pagesName={this.props.pagesName} + encodeData={this.props.encodeData} valueEncoding={this.props.valueEncoding} /> @@ -108,8 +105,7 @@ const Encoding = props => { closeModal={props.closeModal} onSaveFormat={props.onSaveFormat} mode={props.mode} - pages={props.pages} - pagesName={props.pagesName} + encodeData={props.encodeData} valueEncoding={props.valueEncoding} /> ) diff --git a/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx index d99271a38..9052a5bb9 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx @@ -38,12 +38,11 @@ class EncodingController extends Component { this.mode = mode; this.advOptions = advOptions; this.formatOptions = formatOptions; - this.pages = []; - this.pagesName = []; + this.encodeData = []; const recommendedSettings = this.advOptions.asc_getRecommendedSettings(); - this.initPages(); + this.initEncodeData(); this.valueEncoding = recommendedSettings.asc_getCodePage(); this.valueDelimeter = recommendedSettings && recommendedSettings.asc_getDelimiter() ? recommendedSettings.asc_getDelimiter() : 4; @@ -53,10 +52,13 @@ class EncodingController extends Component { } } - initPages() { + initEncodeData() { for (let page of this.advOptions.asc_getCodePages()) { - this.pages.push(page.asc_getCodePage()); - this.pagesName.push(page.asc_getCodePageName()); + this.encodeData.push({ + value: page.asc_getCodePage(), + displayValue: page.asc_getCodePageName(), + lcid: page.asc_getLcid() + }); } } @@ -85,8 +87,7 @@ class EncodingController extends Component { closeModal={this.closeModal} mode={this.mode} onSaveFormat={this.onSaveFormat} - pages={this.pages} - pagesName={this.pagesName} + encodeData={this.encodeData} namesDelimeter={this.namesDelimeter} valueEncoding={this.valueEncoding} valueDelimeter={this.valueDelimeter} diff --git a/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx index a746a38c9..8899d960f 100644 --- a/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx @@ -6,13 +6,13 @@ import { Device } from '../../../../common/mobile/utils/device'; const PageEncoding = props => { const { t } = useTranslation(); const _t = t("View.Settings", { returnObjects: true }); - const pagesName = props.pagesName; - const pages = props.pages; + const encodeData = props.encodeData; const valuesDelimeter = props.valuesDelimeter; const namesDelimeter = props.namesDelimeter; const [stateEncoding, setStateEncoding] = useState(props.valueEncoding); const [stateDelimeter, setStateDelimeter] = useState(props.valueDelimeter); - const nameEncoding = pagesName[pages.indexOf(stateEncoding)]; + const getIndexNameEncoding = () => encodeData.findIndex(encoding => encoding.value === stateEncoding); + const nameEncoding = encodeData[getIndexNameEncoding()].displayValue; const nameDelimeter = namesDelimeter[valuesDelimeter.indexOf(stateDelimeter)]; const mode = props.mode; @@ -41,8 +41,7 @@ const PageEncoding = props => { @@ -62,19 +61,18 @@ const PageEncodingList = props => { const { t } = useTranslation(); const _t = t("View.Settings", { returnObjects: true }); const [currentEncoding, changeCurrentEncoding] = useState(props.stateEncoding); - const pages = props.pages; - const pagesName = props.pagesName; + const encodeData = props.encodeData; return ( {_t.textChooseEncoding} - {pagesName.map((name, index) => { + {encodeData.map((encoding, index) => { return ( - { - changeCurrentEncoding(pages[index]); - props.changeStateEncoding(pages[index]); + { + changeCurrentEncoding(encoding.value); + props.changeStateEncoding(encoding.value); f7.views.current.router.back(); }}> ) @@ -122,8 +120,7 @@ class EncodingView extends Component { onSaveFormat={this.props.onSaveFormat} closeModal={this.props.closeModal} mode={this.props.mode} - pages={this.props.pages} - pagesName={this.props.pagesName} + encodeData={this.props.encodeData} namesDelimeter={this.props.namesDelimeter} valueEncoding={this.props.valueEncoding} valueDelimeter={this.props.valueDelimeter} @@ -158,8 +155,7 @@ const Encoding = props => { closeModal={props.closeModal} onSaveFormat={props.onSaveFormat} mode={props.mode} - pages={props.pages} - pagesName={props.pagesName} + encodeData={props.encodeData} namesDelimeter={props.namesDelimeter} valueEncoding={props.valueEncoding} valueDelimeter={props.valueDelimeter}