[DE SSE mobile] Fix Bug 52821

This commit is contained in:
SergeyEzhin 2021-10-16 18:08:40 +04:00
parent c45fcb0ca5
commit 24705bec8c
4 changed files with 41 additions and 47 deletions

View file

@ -32,24 +32,26 @@ class EncodingController extends Component {
this.mode = mode; this.mode = mode;
this.advOptions = advOptions; this.advOptions = advOptions;
this.formatOptions = formatOptions; this.formatOptions = formatOptions;
this.pages = []; this.encodeData = [];
this.pagesName = [];
const recommendedSettings = this.advOptions.asc_getRecommendedSettings(); const recommendedSettings = this.advOptions.asc_getRecommendedSettings();
this.initPages(); this.initEncodeData();
this.valueEncoding = recommendedSettings.asc_getCodePage(); this.valueEncoding = recommendedSettings.asc_getCodePage();
this.setState({ this.setState({
isOpen: true isOpen: true
}); });
} }
} }
initPages() { initEncodeData() {
for (let page of this.advOptions.asc_getCodePages()) { for (let page of this.advOptions.asc_getCodePages()) {
this.pages.push(page.asc_getCodePage()); this.encodeData.push({
this.pagesName.push(page.asc_getCodePageName()); value: page.asc_getCodePage(),
displayValue: page.asc_getCodePageName(),
lcid: page.asc_getLcid()
});
} }
} }
@ -78,8 +80,7 @@ class EncodingController extends Component {
closeModal={this.closeModal} closeModal={this.closeModal}
mode={this.mode} mode={this.mode}
onSaveFormat={this.onSaveFormat} onSaveFormat={this.onSaveFormat}
pages={this.pages} encodeData={this.encodeData}
pagesName={this.pagesName}
valueEncoding={this.valueEncoding} valueEncoding={this.valueEncoding}
/> />
); );

View file

@ -6,10 +6,10 @@ import { Device } from '../../../../common/mobile/utils/device';
const PageEncoding = props => { const PageEncoding = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t("Settings", { returnObjects: true }); const _t = t("Settings", { returnObjects: true });
const pagesName = props.pagesName; const encodeData = props.encodeData;
const pages = props.pages;
const [stateEncoding, setStateEncoding] = useState(props.valueEncoding); 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 mode = props.mode;
const changeStateEncoding = value => { const changeStateEncoding = value => {
@ -24,8 +24,7 @@ const PageEncoding = props => {
<List> <List>
<ListItem title={nameEncoding} link="/encoding-list/" routeProps={{ <ListItem title={nameEncoding} link="/encoding-list/" routeProps={{
stateEncoding, stateEncoding,
pages: props.pages, encodeData,
pagesName: props.pagesName,
changeStateEncoding changeStateEncoding
}}></ListItem> }}></ListItem>
</List> </List>
@ -45,19 +44,18 @@ const PageEncodingList = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t("Settings", { returnObjects: true }); const _t = t("Settings", { returnObjects: true });
const [currentEncoding, changeCurrentEncoding] = useState(props.stateEncoding); const [currentEncoding, changeCurrentEncoding] = useState(props.stateEncoding);
const pages = props.pages; const encodeData = props.encodeData;
const pagesName = props.pagesName;
return ( return (
<Page> <Page>
<Navbar title={_t.txtDownloadTxt} backLink={_t.textBack} /> <Navbar title={_t.txtDownloadTxt} backLink={_t.textBack} />
<BlockTitle>{_t.textChooseEncoding}</BlockTitle> <BlockTitle>{_t.textChooseEncoding}</BlockTitle>
<List> <List>
{pagesName.map((name, index) => { {encodeData.map((encoding, index) => {
return ( return (
<ListItem radio checked={currentEncoding === pages[index]} title={name} key={index} value={pages[index]} onChange={() => { <ListItem radio checked={currentEncoding === encoding.value} title={encoding.displayValue} key={index} value={encoding.value} after={encoding.lcid} onChange={() => {
changeCurrentEncoding(pages[index]); changeCurrentEncoding(encoding.value);
props.changeStateEncoding(pages[index]); props.changeStateEncoding(encoding.value);
f7.views.current.router.back(); f7.views.current.router.back();
}}></ListItem> }}></ListItem>
) )
@ -79,8 +77,7 @@ class EncodingView extends Component {
onSaveFormat={this.props.onSaveFormat} onSaveFormat={this.props.onSaveFormat}
closeModal={this.props.closeModal} closeModal={this.props.closeModal}
mode={this.props.mode} mode={this.props.mode}
pages={this.props.pages} encodeData={this.props.encodeData}
pagesName={this.props.pagesName}
valueEncoding={this.props.valueEncoding} valueEncoding={this.props.valueEncoding}
/> />
</Popup> </Popup>
@ -108,8 +105,7 @@ const Encoding = props => {
closeModal={props.closeModal} closeModal={props.closeModal}
onSaveFormat={props.onSaveFormat} onSaveFormat={props.onSaveFormat}
mode={props.mode} mode={props.mode}
pages={props.pages} encodeData={props.encodeData}
pagesName={props.pagesName}
valueEncoding={props.valueEncoding} valueEncoding={props.valueEncoding}
/> />
) )

View file

@ -38,12 +38,11 @@ class EncodingController extends Component {
this.mode = mode; this.mode = mode;
this.advOptions = advOptions; this.advOptions = advOptions;
this.formatOptions = formatOptions; this.formatOptions = formatOptions;
this.pages = []; this.encodeData = [];
this.pagesName = [];
const recommendedSettings = this.advOptions.asc_getRecommendedSettings(); const recommendedSettings = this.advOptions.asc_getRecommendedSettings();
this.initPages(); this.initEncodeData();
this.valueEncoding = recommendedSettings.asc_getCodePage(); this.valueEncoding = recommendedSettings.asc_getCodePage();
this.valueDelimeter = recommendedSettings && recommendedSettings.asc_getDelimiter() ? recommendedSettings.asc_getDelimiter() : 4; 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()) { for (let page of this.advOptions.asc_getCodePages()) {
this.pages.push(page.asc_getCodePage()); this.encodeData.push({
this.pagesName.push(page.asc_getCodePageName()); value: page.asc_getCodePage(),
displayValue: page.asc_getCodePageName(),
lcid: page.asc_getLcid()
});
} }
} }
@ -85,8 +87,7 @@ class EncodingController extends Component {
closeModal={this.closeModal} closeModal={this.closeModal}
mode={this.mode} mode={this.mode}
onSaveFormat={this.onSaveFormat} onSaveFormat={this.onSaveFormat}
pages={this.pages} encodeData={this.encodeData}
pagesName={this.pagesName}
namesDelimeter={this.namesDelimeter} namesDelimeter={this.namesDelimeter}
valueEncoding={this.valueEncoding} valueEncoding={this.valueEncoding}
valueDelimeter={this.valueDelimeter} valueDelimeter={this.valueDelimeter}

View file

@ -6,13 +6,13 @@ import { Device } from '../../../../common/mobile/utils/device';
const PageEncoding = props => { const PageEncoding = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t("View.Settings", { returnObjects: true }); const _t = t("View.Settings", { returnObjects: true });
const pagesName = props.pagesName; const encodeData = props.encodeData;
const pages = props.pages;
const valuesDelimeter = props.valuesDelimeter; const valuesDelimeter = props.valuesDelimeter;
const namesDelimeter = props.namesDelimeter; const namesDelimeter = props.namesDelimeter;
const [stateEncoding, setStateEncoding] = useState(props.valueEncoding); const [stateEncoding, setStateEncoding] = useState(props.valueEncoding);
const [stateDelimeter, setStateDelimeter] = useState(props.valueDelimeter); 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 nameDelimeter = namesDelimeter[valuesDelimeter.indexOf(stateDelimeter)];
const mode = props.mode; const mode = props.mode;
@ -41,8 +41,7 @@ const PageEncoding = props => {
<List> <List>
<ListItem title={nameEncoding} link="/encoding-list/" routeProps={{ <ListItem title={nameEncoding} link="/encoding-list/" routeProps={{
stateEncoding, stateEncoding,
pages: props.pages, encodeData,
pagesName: props.pagesName,
changeStateEncoding changeStateEncoding
}}></ListItem> }}></ListItem>
</List> </List>
@ -62,19 +61,18 @@ const PageEncodingList = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t("View.Settings", { returnObjects: true }); const _t = t("View.Settings", { returnObjects: true });
const [currentEncoding, changeCurrentEncoding] = useState(props.stateEncoding); const [currentEncoding, changeCurrentEncoding] = useState(props.stateEncoding);
const pages = props.pages; const encodeData = props.encodeData;
const pagesName = props.pagesName;
return ( return (
<Page> <Page>
<Navbar title={_t.txtDownloadCsv} backLink={_t.textBack} /> <Navbar title={_t.txtDownloadCsv} backLink={_t.textBack} />
<BlockTitle>{_t.textChooseEncoding}</BlockTitle> <BlockTitle>{_t.textChooseEncoding}</BlockTitle>
<List> <List>
{pagesName.map((name, index) => { {encodeData.map((encoding, index) => {
return ( return (
<ListItem radio checked={currentEncoding === pages[index]} title={name} key={index} value={pages[index]} onChange={() => { <ListItem radio checked={currentEncoding === encoding.value} title={encoding.displayValue} key={index} value={encoding.value} after={encoding.lcid} onChange={() => {
changeCurrentEncoding(pages[index]); changeCurrentEncoding(encoding.value);
props.changeStateEncoding(pages[index]); props.changeStateEncoding(encoding.value);
f7.views.current.router.back(); f7.views.current.router.back();
}}></ListItem> }}></ListItem>
) )
@ -122,8 +120,7 @@ class EncodingView extends Component {
onSaveFormat={this.props.onSaveFormat} onSaveFormat={this.props.onSaveFormat}
closeModal={this.props.closeModal} closeModal={this.props.closeModal}
mode={this.props.mode} mode={this.props.mode}
pages={this.props.pages} encodeData={this.props.encodeData}
pagesName={this.props.pagesName}
namesDelimeter={this.props.namesDelimeter} namesDelimeter={this.props.namesDelimeter}
valueEncoding={this.props.valueEncoding} valueEncoding={this.props.valueEncoding}
valueDelimeter={this.props.valueDelimeter} valueDelimeter={this.props.valueDelimeter}
@ -158,8 +155,7 @@ const Encoding = props => {
closeModal={props.closeModal} closeModal={props.closeModal}
onSaveFormat={props.onSaveFormat} onSaveFormat={props.onSaveFormat}
mode={props.mode} mode={props.mode}
pages={props.pages} encodeData={props.encodeData}
pagesName={props.pagesName}
namesDelimeter={props.namesDelimeter} namesDelimeter={props.namesDelimeter}
valueEncoding={props.valueEncoding} valueEncoding={props.valueEncoding}
valueDelimeter={props.valueDelimeter} valueDelimeter={props.valueDelimeter}