[DE SSE mobile] Correct encoding
This commit is contained in:
parent
e5b87b9aa6
commit
1b5397d222
|
@ -4,6 +4,8 @@ export class storeEncoding {
|
|||
constructor() {
|
||||
makeObservable(this, {
|
||||
type: observable,
|
||||
mode: observable,
|
||||
setMode: action,
|
||||
advOptions: observable,
|
||||
formatOptions: observable,
|
||||
pages: observable,
|
||||
|
@ -22,9 +24,10 @@ export class storeEncoding {
|
|||
});
|
||||
}
|
||||
|
||||
type;
|
||||
mode;
|
||||
pages = [];
|
||||
pagesName = [];
|
||||
type;
|
||||
advOptions;
|
||||
formatOptions;
|
||||
valueEncoding;
|
||||
|
@ -35,7 +38,7 @@ export class storeEncoding {
|
|||
valueDelimeter;
|
||||
|
||||
initOptions ({type, advOptions, formatOptions}) {
|
||||
this.type= type;
|
||||
this.type = type;
|
||||
this.advOptions = advOptions;
|
||||
this.formatOptions = formatOptions;
|
||||
}
|
||||
|
@ -51,6 +54,10 @@ export class storeEncoding {
|
|||
this.namesDelimeter = names;
|
||||
}
|
||||
|
||||
setMode(value) {
|
||||
this.mode = value;
|
||||
}
|
||||
|
||||
changeEncoding(value) {
|
||||
this.nameEncoding = this.pagesName[this.pages.indexOf(value)];
|
||||
this.valueEncoding = value;
|
||||
|
|
|
@ -343,7 +343,8 @@
|
|||
"textFindAndReplaceAll": "Find and Replace All",
|
||||
"textChooseTxtOptions": "Choose TXT Options",
|
||||
"txtDownloadTxt": "Download TXT",
|
||||
"textChooseEncoding": "Choose Encoding"
|
||||
"textChooseEncoding": "Choose Encoding",
|
||||
"txtOk": "Ok"
|
||||
},
|
||||
"Edit": {
|
||||
"textClose": "Close",
|
||||
|
|
|
@ -26,7 +26,8 @@ import PluginsController from '../../../../common/mobile/lib/controller/Plugins.
|
|||
"storeTableSettings",
|
||||
"storeDocumentInfo",
|
||||
"storeChartSettings",
|
||||
"storeApplicationSettings"
|
||||
"storeApplicationSettings",
|
||||
"storeEncoding"
|
||||
)
|
||||
class MainController extends Component {
|
||||
constructor(props) {
|
||||
|
@ -607,11 +608,13 @@ class MainController extends Component {
|
|||
storeDocumentSettings.addSchemes(arr);
|
||||
});
|
||||
|
||||
const storeEncoding = this.props.storeEncoding;
|
||||
|
||||
// Downloaded Advanced Options
|
||||
this.api.asc_registerCallback('asc_onAdvancedOptions', (type, advOptions, mode, formatOptions) => {
|
||||
const {t} = this.props;
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -31,12 +31,11 @@ class DownloadController extends Component {
|
|||
_t.notcriticalErrorTitle,
|
||||
() => {
|
||||
if (format == Asc.c_oAscFileType.TXT) {
|
||||
const canRequestClose = this.props.storeAppOptions.canRequestClose;
|
||||
const storeEncoding = this.props.storeEncoding;
|
||||
const advOptions = api.asc_getAdvancedOptions();
|
||||
|
||||
this.props.storeEncoding.initOptions({type: Asc.c_oAscAdvancedOptionsID.TXT, advOptions, formatOptions: new Asc.asc_CDownloadOptions(format)});
|
||||
this.props.storeEncoding.initPages();
|
||||
this.props.storeEncoding.changeEncoding(advOptions.asc_getRecommendedSettings().asc_getCodePage());
|
||||
f7.views.current.router.navigate('/encoding/');
|
||||
|
||||
onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.TXT, advOptions, 2, new Asc.asc_CDownloadOptions(format), _t, true, canRequestClose, false, storeEncoding);
|
||||
}
|
||||
else {
|
||||
this.closeModal();
|
||||
|
@ -65,12 +64,25 @@ class DownloadController extends Component {
|
|||
|
||||
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;
|
||||
|
||||
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:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true);
|
||||
const buttons = [{
|
||||
|
|
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
|||
import { Device } from '../../../../../common/mobile/utils/device';
|
||||
import { f7 } from "framework7-react";
|
||||
import { Encoding } from "../../view/settings/Encoding";
|
||||
import { observer, inject } from "mobx-react";
|
||||
|
||||
class EncodingController extends Component {
|
||||
constructor(props) {
|
||||
|
@ -17,12 +18,19 @@ class EncodingController extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
onSaveFormat(formatOptions, value) {
|
||||
onSaveFormat(mode, valueEncoding) {
|
||||
const api = Common.EditorApi.get();
|
||||
|
||||
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() {
|
||||
|
@ -32,4 +40,4 @@ class EncodingController extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default EncodingController;
|
||||
export default inject("storeEncoding")(observer(EncodingController));
|
|
@ -9,7 +9,7 @@ const PageEncoding = props => {
|
|||
const storeEncoding = props.storeEncoding;
|
||||
const valueEncoding= storeEncoding.valueEncoding;
|
||||
const nameEncoding = storeEncoding.nameEncoding;
|
||||
const formatOptions = storeEncoding.formatOptions;
|
||||
const mode = storeEncoding.mode;
|
||||
|
||||
return (
|
||||
<Page>
|
||||
|
@ -19,7 +19,7 @@ const PageEncoding = props => {
|
|||
<ListItem title={nameEncoding} href="/encoding-list/"></ListItem>
|
||||
</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>
|
||||
</Page>
|
||||
)
|
||||
|
|
|
@ -522,7 +522,8 @@
|
|||
"textChooseDelimeter": "Choose Delimeter",
|
||||
"txtComma": "Comma",
|
||||
"txtSemicolon": "Semicolon",
|
||||
"txtColon": "Colon"
|
||||
"txtColon": "Colon",
|
||||
"txtOk": "Ok"
|
||||
}
|
||||
},
|
||||
"Statusbar": {
|
||||
|
|
|
@ -27,7 +27,8 @@ import PluginsController from '../../../../common/mobile/lib/controller/Plugins.
|
|||
"storeChartSettings",
|
||||
"storeSpreadsheetSettings",
|
||||
"storeSpreadsheetInfo",
|
||||
"storeApplicationSettings"
|
||||
"storeApplicationSettings",
|
||||
"storeEncoding"
|
||||
)
|
||||
class MainController extends Component {
|
||||
constructor(props) {
|
||||
|
@ -318,12 +319,14 @@ class MainController extends Component {
|
|||
this.props.storeSpreadsheetSettings.addSchemes(schemes);
|
||||
});
|
||||
|
||||
const storeEncoding = this.props.storeEncoding;
|
||||
|
||||
// Downloaded Advanced Options
|
||||
|
||||
this.api.asc_registerCallback('asc_onAdvancedOptions', (type, advOptions, mode, formatOptions) => {
|
||||
const {t} = this.props;
|
||||
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;
|
||||
});
|
||||
|
||||
|
|
|
@ -19,19 +19,14 @@ class DownloadController extends Component {
|
|||
if (format) {
|
||||
if (format == Asc.c_oAscFileType.CSV) {
|
||||
const advOptions = api.asc_getAdvancedOptions();
|
||||
const recommendedSettings = advOptions.asc_getRecommendedSettings();
|
||||
const storeEncoding = this.props.storeEncoding;
|
||||
|
||||
f7.dialog.confirm(
|
||||
_t.warnDownloadAs,
|
||||
_t.notcriticalErrorTitle,
|
||||
() => {
|
||||
this.props.storeEncoding.initOptions({type: Asc.c_oAscAdvancedOptionsID.CSV, advOptions, formatOptions: new Asc.asc_CDownloadOptions(format)});
|
||||
this.props.storeEncoding.initPages();
|
||||
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);
|
||||
const canRequestClose = this.props.storeAppOptions.canRequestClose;
|
||||
onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, advOptions, 2, new Asc.asc_CDownloadOptions(format), _t, true, canRequestClose, false, storeEncoding);
|
||||
}
|
||||
)
|
||||
} 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();
|
||||
|
||||
// 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;
|
||||
// const pages = [];
|
||||
// const pagesName = [];
|
||||
|
@ -133,7 +142,7 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady
|
|||
// });
|
||||
|
||||
// } else
|
||||
if (type == Asc.c_oAscAdvancedOptionsID.DRM) {
|
||||
else if (type == Asc.c_oAscAdvancedOptionsID.DRM) {
|
||||
Common.Notifications.trigger('preloader:close');
|
||||
Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true);
|
||||
const buttons = [{
|
||||
|
|
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
|||
import { Device } from '../../../../../common/mobile/utils/device';
|
||||
import { f7 } from "framework7-react";
|
||||
import { Encoding } from "../../view/settings/Encoding";
|
||||
import { observer, inject } from "mobx-react";
|
||||
|
||||
class EncodingController extends Component {
|
||||
constructor(props) {
|
||||
|
@ -17,12 +18,19 @@ class EncodingController extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
onSaveFormat(formatOptions, valueEncoding, valueDelimeter) {
|
||||
onSaveFormat(mode, valueEncoding, valueDelimeter) {
|
||||
const api = Common.EditorApi.get();
|
||||
|
||||
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() {
|
||||
|
@ -32,4 +40,4 @@ class EncodingController extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default EncodingController;
|
||||
export default inject("storeEncoding")(observer(EncodingController));
|
|
@ -11,7 +11,7 @@ const PageEncoding = props => {
|
|||
const nameDelimeter = storeEncoding.nameDelimeter;
|
||||
const valueDelimeter = storeEncoding.valueDelimeter;
|
||||
const nameEncoding = storeEncoding.nameEncoding;
|
||||
const formatOptions = storeEncoding.formatOptions;
|
||||
const mode = storeEncoding.mode;
|
||||
|
||||
return (
|
||||
<Page>
|
||||
|
@ -25,7 +25,7 @@ const PageEncoding = props => {
|
|||
<ListItem title={nameEncoding} href="/encoding-list/"></ListItem>
|
||||
</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>
|
||||
</Page>
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue