[DE SSE mobile] Correct encoding

This commit is contained in:
SergeyEzhin 2021-07-16 13:29:28 +03:00
parent e5b87b9aa6
commit 1b5397d222
11 changed files with 91 additions and 39 deletions

View file

@ -4,6 +4,8 @@ export class storeEncoding {
constructor() { constructor() {
makeObservable(this, { makeObservable(this, {
type: observable, type: observable,
mode: observable,
setMode: action,
advOptions: observable, advOptions: observable,
formatOptions: observable, formatOptions: observable,
pages: observable, pages: observable,
@ -22,9 +24,10 @@ export class storeEncoding {
}); });
} }
type;
mode;
pages = []; pages = [];
pagesName = []; pagesName = [];
type;
advOptions; advOptions;
formatOptions; formatOptions;
valueEncoding; valueEncoding;
@ -35,7 +38,7 @@ export class storeEncoding {
valueDelimeter; valueDelimeter;
initOptions ({type, advOptions, formatOptions}) { initOptions ({type, advOptions, formatOptions}) {
this.type= type; this.type = type;
this.advOptions = advOptions; this.advOptions = advOptions;
this.formatOptions = formatOptions; this.formatOptions = formatOptions;
} }
@ -51,6 +54,10 @@ export class storeEncoding {
this.namesDelimeter = names; this.namesDelimeter = names;
} }
setMode(value) {
this.mode = value;
}
changeEncoding(value) { changeEncoding(value) {
this.nameEncoding = this.pagesName[this.pages.indexOf(value)]; this.nameEncoding = this.pagesName[this.pages.indexOf(value)];
this.valueEncoding = value; this.valueEncoding = value;

View file

@ -343,7 +343,8 @@
"textFindAndReplaceAll": "Find and Replace All", "textFindAndReplaceAll": "Find and Replace All",
"textChooseTxtOptions": "Choose TXT Options", "textChooseTxtOptions": "Choose TXT Options",
"txtDownloadTxt": "Download TXT", "txtDownloadTxt": "Download TXT",
"textChooseEncoding": "Choose Encoding" "textChooseEncoding": "Choose Encoding",
"txtOk": "Ok"
}, },
"Edit": { "Edit": {
"textClose": "Close", "textClose": "Close",

View file

@ -26,7 +26,8 @@ import PluginsController from '../../../../common/mobile/lib/controller/Plugins.
"storeTableSettings", "storeTableSettings",
"storeDocumentInfo", "storeDocumentInfo",
"storeChartSettings", "storeChartSettings",
"storeApplicationSettings" "storeApplicationSettings",
"storeEncoding"
) )
class MainController extends Component { class MainController extends Component {
constructor(props) { constructor(props) {
@ -607,11 +608,13 @@ class MainController extends Component {
storeDocumentSettings.addSchemes(arr); storeDocumentSettings.addSchemes(arr);
}); });
const storeEncoding = this.props.storeEncoding;
// Downloaded Advanced Options // Downloaded Advanced Options
this.api.asc_registerCallback('asc_onAdvancedOptions', (type, advOptions, mode, formatOptions) => { this.api.asc_registerCallback('asc_onAdvancedOptions', (type, advOptions, mode, formatOptions) => {
const {t} = this.props; const {t} = this.props;
const _t = t("Settings", { returnObjects: true }); const _t = t("Settings", { returnObjects: true });
onAdvancedOptions(type, advOptions, mode, formatOptions, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose, this.isDRM); onAdvancedOptions(type, advOptions, mode, formatOptions, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose, this.isDRM, storeEncoding);
if(type == Asc.c_oAscAdvancedOptionsID.DRM) this.isDRM = true; if(type == Asc.c_oAscAdvancedOptionsID.DRM) this.isDRM = true;
}); });
} }

View file

@ -31,12 +31,11 @@ class DownloadController extends Component {
_t.notcriticalErrorTitle, _t.notcriticalErrorTitle,
() => { () => {
if (format == Asc.c_oAscFileType.TXT) { if (format == Asc.c_oAscFileType.TXT) {
const canRequestClose = this.props.storeAppOptions.canRequestClose;
const storeEncoding = this.props.storeEncoding;
const advOptions = api.asc_getAdvancedOptions(); const advOptions = api.asc_getAdvancedOptions();
this.props.storeEncoding.initOptions({type: Asc.c_oAscAdvancedOptionsID.TXT, advOptions, formatOptions: new Asc.asc_CDownloadOptions(format)}); onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.TXT, advOptions, 2, new Asc.asc_CDownloadOptions(format), _t, true, canRequestClose, false, storeEncoding);
this.props.storeEncoding.initPages();
this.props.storeEncoding.changeEncoding(advOptions.asc_getRecommendedSettings().asc_getCodePage());
f7.views.current.router.navigate('/encoding/');
} }
else { else {
this.closeModal(); this.closeModal();
@ -65,12 +64,25 @@ class DownloadController extends Component {
const DownloadWithTranslation = inject("storeAppOptions", "storeEncoding")(observer(withTranslation()(DownloadController))); const DownloadWithTranslation = inject("storeAppOptions", "storeEncoding")(observer(withTranslation()(DownloadController)));
const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady, canRequestClose, isDRM) => { const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady, canRequestClose, isDRM, storeEncoding) => {
if ($$('.dlg-adv-options.modal-in').length > 0) return; if ($$('.dlg-adv-options.modal-in').length > 0) return;
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
if (type == Asc.c_oAscAdvancedOptionsID.DRM) { if (type == Asc.c_oAscAdvancedOptionsID.TXT) {
Common.Notifications.trigger('preloader:close');
Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true);
const recommendedSettings = advOptions.asc_getRecommendedSettings();
storeEncoding.initOptions({type, advOptions, formatOptions});
storeEncoding.initPages();
storeEncoding.setMode(mode);
storeEncoding.changeEncoding(recommendedSettings.asc_getCodePage());
f7.views.current.router.navigate('/encoding/');
}
else if (type == Asc.c_oAscAdvancedOptionsID.DRM) {
Common.Notifications.trigger('preloader:close'); Common.Notifications.trigger('preloader:close');
Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true);
const buttons = [{ const buttons = [{

View file

@ -2,6 +2,7 @@ import React, { Component } from 'react';
import { Device } from '../../../../../common/mobile/utils/device'; import { Device } from '../../../../../common/mobile/utils/device';
import { f7 } from "framework7-react"; import { f7 } from "framework7-react";
import { Encoding } from "../../view/settings/Encoding"; import { Encoding } from "../../view/settings/Encoding";
import { observer, inject } from "mobx-react";
class EncodingController extends Component { class EncodingController extends Component {
constructor(props) { constructor(props) {
@ -17,12 +18,19 @@ class EncodingController extends Component {
} }
} }
onSaveFormat(formatOptions, value) { onSaveFormat(mode, valueEncoding) {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
this.closeModal(); this.closeModal();
formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(value));
api.asc_DownloadAs(formatOptions); if(mode === 2) {
const formatOptions = this.props.storeEncoding.formatOptions;
formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding));
api.asc_DownloadAs(formatOptions);
} else {
const type = this.props.storeEncoding.type;
api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(valueEncoding));
}
} }
render() { render() {
@ -32,4 +40,4 @@ class EncodingController extends Component {
} }
} }
export default EncodingController; export default inject("storeEncoding")(observer(EncodingController));

View file

@ -9,7 +9,7 @@ const PageEncoding = props => {
const storeEncoding = props.storeEncoding; const storeEncoding = props.storeEncoding;
const valueEncoding= storeEncoding.valueEncoding; const valueEncoding= storeEncoding.valueEncoding;
const nameEncoding = storeEncoding.nameEncoding; const nameEncoding = storeEncoding.nameEncoding;
const formatOptions = storeEncoding.formatOptions; const mode = storeEncoding.mode;
return ( return (
<Page> <Page>
@ -19,7 +19,7 @@ const PageEncoding = props => {
<ListItem title={nameEncoding} href="/encoding-list/"></ListItem> <ListItem title={nameEncoding} href="/encoding-list/"></ListItem>
</List> </List>
<List className="buttons-list"> <List className="buttons-list">
<ListButton className='button-fill button-raised' title={_t.textDownload} onClick={() => props.onSaveFormat(formatOptions, valueEncoding)}></ListButton> <ListButton className='button-fill button-raised' title={mode === 2 ?_t.textDownload : _t.textOk} onClick={() => props.onSaveFormat(mode, valueEncoding)}></ListButton>
</List> </List>
</Page> </Page>
) )

View file

@ -522,7 +522,8 @@
"textChooseDelimeter": "Choose Delimeter", "textChooseDelimeter": "Choose Delimeter",
"txtComma": "Comma", "txtComma": "Comma",
"txtSemicolon": "Semicolon", "txtSemicolon": "Semicolon",
"txtColon": "Colon" "txtColon": "Colon",
"txtOk": "Ok"
} }
}, },
"Statusbar": { "Statusbar": {

View file

@ -27,7 +27,8 @@ import PluginsController from '../../../../common/mobile/lib/controller/Plugins.
"storeChartSettings", "storeChartSettings",
"storeSpreadsheetSettings", "storeSpreadsheetSettings",
"storeSpreadsheetInfo", "storeSpreadsheetInfo",
"storeApplicationSettings" "storeApplicationSettings",
"storeEncoding"
) )
class MainController extends Component { class MainController extends Component {
constructor(props) { constructor(props) {
@ -318,12 +319,14 @@ class MainController extends Component {
this.props.storeSpreadsheetSettings.addSchemes(schemes); this.props.storeSpreadsheetSettings.addSchemes(schemes);
}); });
const storeEncoding = this.props.storeEncoding;
// Downloaded Advanced Options // Downloaded Advanced Options
this.api.asc_registerCallback('asc_onAdvancedOptions', (type, advOptions, mode, formatOptions) => { this.api.asc_registerCallback('asc_onAdvancedOptions', (type, advOptions, mode, formatOptions) => {
const {t} = this.props; const {t} = this.props;
const _t = t("View.Settings", { returnObjects: true }); const _t = t("View.Settings", { returnObjects: true });
onAdvancedOptions(type, advOptions, mode, formatOptions, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose,this.isDRM); onAdvancedOptions(type, advOptions, mode, formatOptions, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose, this.isDRM, storeEncoding);
if(type == Asc.c_oAscAdvancedOptionsID.DRM) this.isDRM = true; if(type == Asc.c_oAscAdvancedOptionsID.DRM) this.isDRM = true;
}); });

View file

@ -19,19 +19,14 @@ class DownloadController extends Component {
if (format) { if (format) {
if (format == Asc.c_oAscFileType.CSV) { if (format == Asc.c_oAscFileType.CSV) {
const advOptions = api.asc_getAdvancedOptions(); const advOptions = api.asc_getAdvancedOptions();
const recommendedSettings = advOptions.asc_getRecommendedSettings(); const storeEncoding = this.props.storeEncoding;
f7.dialog.confirm( f7.dialog.confirm(
_t.warnDownloadAs, _t.warnDownloadAs,
_t.notcriticalErrorTitle, _t.notcriticalErrorTitle,
() => { () => {
this.props.storeEncoding.initOptions({type: Asc.c_oAscAdvancedOptionsID.CSV, advOptions, formatOptions: new Asc.asc_CDownloadOptions(format)}); const canRequestClose = this.props.storeAppOptions.canRequestClose;
this.props.storeEncoding.initPages(); onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, advOptions, 2, new Asc.asc_CDownloadOptions(format), _t, true, canRequestClose, false, storeEncoding);
this.props.storeEncoding.initNamesDelimeter([_t.txtComma, _t.txtSemicolon, _t.txtColon, _t.txtTab, _t.txtSpace]);
this.props.storeEncoding.changeEncoding(recommendedSettings.asc_getCodePage());
this.props.storeEncoding.changeDelimeter(recommendedSettings && recommendedSettings.asc_getDelimiter() ? recommendedSettings.asc_getDelimiter() : 4);
f7.views.current.router.navigate('/encoding/');
// onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format), _t, true);
} }
) )
} else { } else {
@ -47,12 +42,26 @@ class DownloadController extends Component {
} }
} }
const DownloadWithTranslation = inject("storeEncoding")(observer(withTranslation()(DownloadController))); const DownloadWithTranslation = inject("storeAppOptions", "storeEncoding")(observer(withTranslation()(DownloadController)));
const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady, canRequestClose, isDRM) => { const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady, canRequestClose, isDRM, storeEncoding) => {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
// if (type == Asc.c_oAscAdvancedOptionsID.CSV) { if (type == Asc.c_oAscAdvancedOptionsID.CSV) {
Common.Notifications.trigger('preloader:close');
Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true);
const recommendedSettings = advOptions.asc_getRecommendedSettings();
storeEncoding.initOptions({type, advOptions, formatOptions});
storeEncoding.initPages();
storeEncoding.initNamesDelimeter([_t.txtComma, _t.txtSemicolon, _t.txtColon, _t.txtTab, _t.txtSpace]);
storeEncoding.setMode(mode);
storeEncoding.changeEncoding(recommendedSettings.asc_getCodePage());
storeEncoding.changeDelimeter(recommendedSettings && recommendedSettings.asc_getDelimiter() ? recommendedSettings.asc_getDelimiter() : 4);
f7.views.current.router.navigate('/encoding/');
}
// let picker; // let picker;
// const pages = []; // const pages = [];
// const pagesName = []; // const pagesName = [];
@ -133,7 +142,7 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady
// }); // });
// } else // } else
if (type == Asc.c_oAscAdvancedOptionsID.DRM) { else if (type == Asc.c_oAscAdvancedOptionsID.DRM) {
Common.Notifications.trigger('preloader:close'); Common.Notifications.trigger('preloader:close');
Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true);
const buttons = [{ const buttons = [{

View file

@ -2,6 +2,7 @@ import React, { Component } from 'react';
import { Device } from '../../../../../common/mobile/utils/device'; import { Device } from '../../../../../common/mobile/utils/device';
import { f7 } from "framework7-react"; import { f7 } from "framework7-react";
import { Encoding } from "../../view/settings/Encoding"; import { Encoding } from "../../view/settings/Encoding";
import { observer, inject } from "mobx-react";
class EncodingController extends Component { class EncodingController extends Component {
constructor(props) { constructor(props) {
@ -17,12 +18,19 @@ class EncodingController extends Component {
} }
} }
onSaveFormat(formatOptions, valueEncoding, valueDelimeter) { onSaveFormat(mode, valueEncoding, valueDelimeter) {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
this.closeModal(); this.closeModal();
formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding, valueDelimeter));
api.asc_DownloadAs(formatOptions); if(mode === 2) {
const formatOptions = this.props.storeEncoding.formatOptions;
formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding, valueDelimeter));
api.asc_DownloadAs(formatOptions);
} else {
const type = this.props.storeEncoding.type;
api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(valueEncoding, valueDelimeter));
}
} }
render() { render() {
@ -32,4 +40,4 @@ class EncodingController extends Component {
} }
} }
export default EncodingController; export default inject("storeEncoding")(observer(EncodingController));

View file

@ -11,7 +11,7 @@ const PageEncoding = props => {
const nameDelimeter = storeEncoding.nameDelimeter; const nameDelimeter = storeEncoding.nameDelimeter;
const valueDelimeter = storeEncoding.valueDelimeter; const valueDelimeter = storeEncoding.valueDelimeter;
const nameEncoding = storeEncoding.nameEncoding; const nameEncoding = storeEncoding.nameEncoding;
const formatOptions = storeEncoding.formatOptions; const mode = storeEncoding.mode;
return ( return (
<Page> <Page>
@ -25,7 +25,7 @@ const PageEncoding = props => {
<ListItem title={nameEncoding} href="/encoding-list/"></ListItem> <ListItem title={nameEncoding} href="/encoding-list/"></ListItem>
</List> </List>
<List className="buttons-list"> <List className="buttons-list">
<ListButton className='button-fill button-raised' title={_t.textDownload} onClick={() => props.onSaveFormat(formatOptions, valueEncoding, valueDelimeter)}></ListButton> <ListButton className='button-fill button-raised' title={mode === 2 ?_t.textDownload : _t.txtOk} onClick={() => props.onSaveFormat(mode, valueEncoding, valueDelimeter)}></ListButton>
</List> </List>
</Page> </Page>
) )