From 2ae5c222f573fd8121415cb878899448bc71c260 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Tue, 13 Jul 2021 14:14:08 +0300 Subject: [PATCH 01/11] [DE mobile] Make encoding --- apps/documenteditor/mobile/locale/en.json | 5 +- .../src/controller/settings/Download.jsx | 127 +++++++++--------- .../src/controller/settings/Encoding.jsx | 25 ++++ .../mobile/src/store/encoding.js | 44 ++++++ .../mobile/src/store/mainStore.js | 2 + .../mobile/src/view/settings/Encoding.jsx | 60 +++++++++ .../mobile/src/view/settings/Settings.jsx | 10 ++ 7 files changed, 211 insertions(+), 62 deletions(-) create mode 100644 apps/documenteditor/mobile/src/controller/settings/Encoding.jsx create mode 100644 apps/documenteditor/mobile/src/store/encoding.js create mode 100644 apps/documenteditor/mobile/src/view/settings/Encoding.jsx diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index bbd70cc3f..5604188d0 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -340,7 +340,10 @@ "textMarginsW": "Left and right margins are too high for a given page width", "textMarginsH": "Top and bottom margins are too high for a given page height", "textCollaboration": "Collaboration", - "textFindAndReplaceAll": "Find and Replace All" + "textFindAndReplaceAll": "Find and Replace All", + "textChooseTxtOptions": "Choose TXT Options", + "txtDownloadTxt": "Download TXT", + "textChooseEncoding": "Choose Encoding" }, "Edit": { "textClose": "Close", diff --git a/apps/documenteditor/mobile/src/controller/settings/Download.jsx b/apps/documenteditor/mobile/src/controller/settings/Download.jsx index 81cfa0dfe..2b1cfb2d1 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Download.jsx @@ -25,7 +25,6 @@ class DownloadController extends Component { const _t = t("Settings", { returnObjects: true }); if(format) { - this.closeModal(); if (format == Asc.c_oAscFileType.TXT || format == Asc.c_oAscFileType.RTF) { f7.dialog.confirm( (format === Asc.c_oAscFileType.TXT) ? _t.textDownloadTxt : _t.textDownloadRtf, @@ -33,9 +32,13 @@ class DownloadController extends Component { () => { if (format == Asc.c_oAscFileType.TXT) { const isDocReady = this.props.storeAppOptions.isDocReady; - onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.TXT, api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format), _t, isDocReady, isDRM); + 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, api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format), _t, isDocReady); } else { + this.closeModal(); setTimeout(() => { api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); }, 400); @@ -44,6 +47,7 @@ class DownloadController extends Component { ); } else { + this.closeModal(); setTimeout(() => { api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); }, 400); @@ -58,71 +62,72 @@ class DownloadController extends Component { } } -const DownloadWithTranslation = inject("storeAppOptions")(observer(withTranslation()(DownloadController))); +const DownloadWithTranslation = inject("storeAppOptions", "storeEncoding")(observer(withTranslation()(DownloadController))); const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady, canRequestClose, isDRM) => { if ($$('.dlg-adv-options.modal-in').length > 0) return; const api = Common.EditorApi.get(); if (type == Asc.c_oAscAdvancedOptionsID.TXT) { - let picker; - const pages = []; - const pagesName = []; - for (let page of advOptions.asc_getCodePages()) { - pages.push(page.asc_getCodePage()); - pagesName.push(page.asc_getCodePageName()); - } - Common.Notifications.trigger('preloader:close'); - Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); - const buttons = []; - if (mode === 2) { - buttons.push({ - text: _t.textCancel - }); - } - buttons.push({ - text: 'OK', - bold: true, - onClick: function() { - const encoding = picker.value; - if (mode==2) { - formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding)); - api.asc_DownloadAs(formatOptions); - } else { - api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding)); - } - if (!isDocReady) { - Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); - } - } - }); - const dialog = f7.dialog.create({ - title: _t.advTxtOptions, - text: '', - content: - '
' + - '
' + - '
' + _t.textEncoding + '
' + - '
' + - '
' + - '
', - buttons: buttons, - cssClass: 'dlg-adv-options' - }).open(); - dialog.on('opened', () => { - picker = f7.picker.create({ - containerEl: document.getElementById('txt-encoding'), - cols: [ - { - values: pages, - displayValues: pagesName - } - ], - toolbar: false, - rotateEffect: true, - value: [advOptions.asc_getRecommendedSettings().asc_getCodePage()], - }); - }); + f7.views.current.router.navigate('/encoding/'); + // let picker; + // const pages = []; + // const pagesName = []; + // for (let page of advOptions.asc_getCodePages()) { + // pages.push(page.asc_getCodePage()); + // pagesName.push(page.asc_getCodePageName()); + // } + // Common.Notifications.trigger('preloader:close'); + // Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); + // const buttons = []; + // if (mode === 2) { + // buttons.push({ + // text: _t.textCancel + // }); + // } + // buttons.push({ + // text: 'OK', + // bold: true, + // onClick: function() { + // const encoding = picker.value; + // if (mode==2) { + // formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding)); + // api.asc_DownloadAs(formatOptions); + // } else { + // api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding)); + // } + // if (!isDocReady) { + // Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); + // } + // } + // }); + // const dialog = f7.dialog.create({ + // title: _t.advTxtOptions, + // text: '', + // content: + // '
' + + // '
' + + // '
' + _t.textEncoding + '
' + + // '
' + + // '
' + + // '
', + // buttons: buttons, + // cssClass: 'dlg-adv-options' + // }).open(); + // dialog.on('opened', () => { + // picker = f7.picker.create({ + // containerEl: document.getElementById('txt-encoding'), + // cols: [ + // { + // values: pages, + // displayValues: pagesName + // } + // ], + // toolbar: false, + // rotateEffect: true, + // value: [advOptions.asc_getRecommendedSettings().asc_getCodePage()], + // }); + // }); } else if (type == Asc.c_oAscAdvancedOptionsID.DRM) { Common.Notifications.trigger('preloader:close'); Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); diff --git a/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx b/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx new file mode 100644 index 000000000..f594149bf --- /dev/null +++ b/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx @@ -0,0 +1,25 @@ +import React, { Component } from 'react'; +import { Device } from '../../../../../common/mobile/utils/device'; +import { f7, Page, Navbar, List, ListItem, BlockTitle, ListButton, Popover, Popup } from "framework7-react"; +import { withTranslation } from 'react-i18next'; +import { observer, inject } from "mobx-react"; +import { Encoding } from "../../view/settings/Encoding"; + +class EncodingController extends Component { + constructor(props) { + super(props); + } + + onSaveFormat(type, value) { + const api = Common.EditorApi.get(); + api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(value)); + } + + render() { + return ( + + ); + } +} + +export default EncodingController; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/store/encoding.js b/apps/documenteditor/mobile/src/store/encoding.js new file mode 100644 index 000000000..03b8b6fa4 --- /dev/null +++ b/apps/documenteditor/mobile/src/store/encoding.js @@ -0,0 +1,44 @@ +import {action, observable, makeObservable} from 'mobx'; + +export class storeEncoding { + constructor() { + makeObservable(this, { + type: observable, + advOptions: observable, + formatOptions: observable, + pages: observable, + pagesName: observable, + initOptions: action, + valueEncoding: observable, + nameEncoding: observable, + initPages: action, + changeEncoding: action + }); + } + + pages = []; + pagesName = []; + type; + advOptions; + formatOptions; + valueEncoding; + nameEncoding; + + initOptions ({type, advOptions, formatOptions}) { + this.type= type; + this.advOptions = advOptions; + this.formatOptions = formatOptions; + } + + initPages() { + for (let page of this.advOptions.asc_getCodePages()) { + this.pages.push(page.asc_getCodePage()); + this.pagesName.push(page.asc_getCodePageName()); + } + } + + changeEncoding(value) { + this.nameEncoding = this.pagesName[this.pages.indexOf(value)]; + this.valueEncoding = value; + } +} diff --git a/apps/documenteditor/mobile/src/store/mainStore.js b/apps/documenteditor/mobile/src/store/mainStore.js index 57fa6ee88..d649831f6 100644 --- a/apps/documenteditor/mobile/src/store/mainStore.js +++ b/apps/documenteditor/mobile/src/store/mainStore.js @@ -10,6 +10,7 @@ import {storeTableSettings} from "./tableSettings"; import {storeChartSettings} from "./chartSettings"; import {storeDocumentInfo} from "./documentInfo"; import {storeApplicationSettings} from './applicationSettings'; +import {storeEncoding} from "./encoding"; import {storeAppOptions} from "./appOptions"; import {storePalette} from "./palette"; import {storeReview} from "./review"; @@ -20,6 +21,7 @@ export const stores = { storeFocusObjects: new storeFocusObjects(), storeDocumentSettings: new storeDocumentSettings(), users: new storeUsers(), + storeEncoding: new storeEncoding(), storeTextSettings: new storeTextSettings(), storeParagraphSettings: new storeParagraphSettings(), storeShapeSettings: new storeShapeSettings(), diff --git a/apps/documenteditor/mobile/src/view/settings/Encoding.jsx b/apps/documenteditor/mobile/src/view/settings/Encoding.jsx new file mode 100644 index 000000000..7fc6330fc --- /dev/null +++ b/apps/documenteditor/mobile/src/view/settings/Encoding.jsx @@ -0,0 +1,60 @@ +import React from 'react'; +import { observer, inject } from "mobx-react"; +import { f7, Page, Navbar, List, ListItem, BlockTitle, ListButton } from "framework7-react"; +import { useTranslation } from "react-i18next"; + +const PageEncoding = props => { + const { t } = useTranslation(); + const _t = t("Settings", { returnObjects: true }); + const storeEncoding = props.storeEncoding; + const nameEncoding = storeEncoding.nameEncoding; + const type = storeEncoding.type; + storeEncoding.initPages(); + const advOptions = storeEncoding.advOptions; + const pagesName = storeEncoding.pagesName; + + return ( + + + {_t.textEncoding} + + + + + props.onSaveFormat(type, storeEncoding.valueEncoding)}> + + + ) +} + +const PageEncodingList = props => { + const { t } = useTranslation(); + const _t = t("Settings", { returnObjects: true }); + const storeEncoding = props.storeEncoding; + const encoding = storeEncoding.encoding; + // const advOptions = storeEncoding.advOptions; + const pages = storeEncoding.pages; + const pagesName = storeEncoding.pagesName; + + return ( + + + {_t.textChooseEncoding} + + {pagesName.map((name, index) => { + return ( + { + storeEncoding.changeEncoding(pages[index]); + f7.views.current.router.back(); + }}> + ) + })} + + + ) +} + +const Encoding = inject("storeEncoding")(observer(PageEncoding)); +const EncodingList = inject("storeEncoding")(observer(PageEncodingList)); + +export {EncodingList, Encoding} \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/settings/Settings.jsx b/apps/documenteditor/mobile/src/view/settings/Settings.jsx index 93f40c4aa..48a930fcb 100644 --- a/apps/documenteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/documenteditor/mobile/src/view/settings/Settings.jsx @@ -12,6 +12,8 @@ import ApplicationSettingsController from "../../controller/settings/Application import { DocumentFormats, DocumentMargins, DocumentColorSchemes } from "./DocumentSettings"; import { MacrosSettings } from "./ApplicationSettings"; import About from '../../../../../common/mobile/lib/view/About'; +import EncodingController from '../../controller/settings/Encoding'; +import { EncodingList } from '../../view/settings/Encoding'; const routes = [ { @@ -53,6 +55,14 @@ const routes = [ { path: '/about/', component: About + }, + { + path: '/encoding/', + component: EncodingController + }, + { + path: '/encoding-list/', + component: EncodingList } ]; From de1ac14073acc2a38d98a69fe15fd11581b8e7b2 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Tue, 13 Jul 2021 17:09:20 +0300 Subject: [PATCH 02/11] [DE mobile] Added encoding options --- .../src/controller/settings/Download.jsx | 68 ++----------------- .../src/controller/settings/Encoding.jsx | 20 ++++-- .../mobile/src/view/settings/Encoding.jsx | 13 ++-- 3 files changed, 25 insertions(+), 76 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/settings/Download.jsx b/apps/documenteditor/mobile/src/controller/settings/Download.jsx index 2b1cfb2d1..06b13bb85 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Download.jsx @@ -31,11 +31,12 @@ class DownloadController extends Component { _t.notcriticalErrorTitle, () => { if (format == Asc.c_oAscFileType.TXT) { - const isDocReady = this.props.storeAppOptions.isDocReady; 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, api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format), _t, isDocReady); + this.props.storeEncoding.initPages(); + this.props.storeEncoding.changeEncoding(advOptions.asc_getRecommendedSettings().asc_getCodePage()); + f7.views.current.router.navigate('/encoding/'); } else { this.closeModal(); @@ -68,67 +69,8 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady if ($$('.dlg-adv-options.modal-in').length > 0) return; const api = Common.EditorApi.get(); - if (type == Asc.c_oAscAdvancedOptionsID.TXT) { - f7.views.current.router.navigate('/encoding/'); - // let picker; - // const pages = []; - // const pagesName = []; - // for (let page of advOptions.asc_getCodePages()) { - // pages.push(page.asc_getCodePage()); - // pagesName.push(page.asc_getCodePageName()); - // } - // Common.Notifications.trigger('preloader:close'); - // Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); - // const buttons = []; - // if (mode === 2) { - // buttons.push({ - // text: _t.textCancel - // }); - // } - // buttons.push({ - // text: 'OK', - // bold: true, - // onClick: function() { - // const encoding = picker.value; - // if (mode==2) { - // formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding)); - // api.asc_DownloadAs(formatOptions); - // } else { - // api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding)); - // } - // if (!isDocReady) { - // Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); - // } - // } - // }); - // const dialog = f7.dialog.create({ - // title: _t.advTxtOptions, - // text: '', - // content: - // '
' + - // '
' + - // '
' + _t.textEncoding + '
' + - // '
' + - // '
' + - // '
', - // buttons: buttons, - // cssClass: 'dlg-adv-options' - // }).open(); - // dialog.on('opened', () => { - // picker = f7.picker.create({ - // containerEl: document.getElementById('txt-encoding'), - // cols: [ - // { - // values: pages, - // displayValues: pagesName - // } - // ], - // toolbar: false, - // rotateEffect: true, - // value: [advOptions.asc_getRecommendedSettings().asc_getCodePage()], - // }); - // }); - } else if (type == Asc.c_oAscAdvancedOptionsID.DRM) { + + if (type == Asc.c_oAscAdvancedOptionsID.DRM) { Common.Notifications.trigger('preloader:close'); Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); const buttons = [{ diff --git a/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx b/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx index f594149bf..2a272aa64 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx @@ -1,18 +1,28 @@ import React, { Component } from 'react'; import { Device } from '../../../../../common/mobile/utils/device'; -import { f7, Page, Navbar, List, ListItem, BlockTitle, ListButton, Popover, Popup } from "framework7-react"; -import { withTranslation } from 'react-i18next'; -import { observer, inject } from "mobx-react"; +import { f7 } from "framework7-react"; import { Encoding } from "../../view/settings/Encoding"; class EncodingController extends Component { constructor(props) { super(props); + this.onSaveFormat = this.onSaveFormat.bind(this); } - onSaveFormat(type, value) { + closeModal() { + if (Device.phone) { + f7.sheet.close('.settings-popup', true); + } else { + f7.popover.close('#settings-popover'); + } + } + + onSaveFormat(formatOptions, value) { const api = Common.EditorApi.get(); - api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(value)); + + this.closeModal(); + formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(value)); + api.asc_DownloadAs(formatOptions); } render() { diff --git a/apps/documenteditor/mobile/src/view/settings/Encoding.jsx b/apps/documenteditor/mobile/src/view/settings/Encoding.jsx index 7fc6330fc..f4acd2bd4 100644 --- a/apps/documenteditor/mobile/src/view/settings/Encoding.jsx +++ b/apps/documenteditor/mobile/src/view/settings/Encoding.jsx @@ -7,11 +7,9 @@ const PageEncoding = props => { const { t } = useTranslation(); const _t = t("Settings", { returnObjects: true }); const storeEncoding = props.storeEncoding; + const valueEncoding= storeEncoding.valueEncoding; const nameEncoding = storeEncoding.nameEncoding; - const type = storeEncoding.type; - storeEncoding.initPages(); - const advOptions = storeEncoding.advOptions; - const pagesName = storeEncoding.pagesName; + const formatOptions = storeEncoding.formatOptions; return ( @@ -21,7 +19,7 @@ const PageEncoding = props => { - props.onSaveFormat(type, storeEncoding.valueEncoding)}> + props.onSaveFormat(formatOptions, valueEncoding)}> ) @@ -31,8 +29,7 @@ const PageEncodingList = props => { const { t } = useTranslation(); const _t = t("Settings", { returnObjects: true }); const storeEncoding = props.storeEncoding; - const encoding = storeEncoding.encoding; - // const advOptions = storeEncoding.advOptions; + const valueEncoding = storeEncoding.valueEncoding; const pages = storeEncoding.pages; const pagesName = storeEncoding.pagesName; @@ -43,7 +40,7 @@ const PageEncodingList = props => { {pagesName.map((name, index) => { return ( - { + { storeEncoding.changeEncoding(pages[index]); f7.views.current.router.back(); }}> From e5b87b9aa698ada652eefd9b53a802de94e3ed88 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Wed, 14 Jul 2021 20:42:05 +0300 Subject: [PATCH 03/11] [SSE mobile] Add encoding options --- .../mobile/lib}/store/encoding.js | 21 ++- .../mobile/src/store/mainStore.js | 2 +- apps/spreadsheeteditor/mobile/locale/en.json | 11 +- .../src/controller/settings/Download.jsx | 157 ++++++++++-------- .../src/controller/settings/Encoding.jsx | 35 ++++ .../mobile/src/store/mainStore.js | 2 + .../mobile/src/view/settings/Encoding.jsx | 90 ++++++++++ .../mobile/src/view/settings/Settings.jsx | 14 ++ 8 files changed, 256 insertions(+), 76 deletions(-) rename apps/{documenteditor/mobile/src => common/mobile/lib}/store/encoding.js (62%) create mode 100644 apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx create mode 100644 apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx diff --git a/apps/documenteditor/mobile/src/store/encoding.js b/apps/common/mobile/lib/store/encoding.js similarity index 62% rename from apps/documenteditor/mobile/src/store/encoding.js rename to apps/common/mobile/lib/store/encoding.js index 03b8b6fa4..91835f105 100644 --- a/apps/documenteditor/mobile/src/store/encoding.js +++ b/apps/common/mobile/lib/store/encoding.js @@ -12,7 +12,13 @@ export class storeEncoding { valueEncoding: observable, nameEncoding: observable, initPages: action, - changeEncoding: action + changeEncoding: action, + valueDelimeter: observable, + nameDelimeter: observable, + changeDelimeter: action, + namesDelimeter: observable, + valuesDelimeter: observable, + initNamesDelimeter: action }); } @@ -23,6 +29,10 @@ export class storeEncoding { formatOptions; valueEncoding; nameEncoding; + namesDelimeter = []; + valuesDelimeter = [4, 2, 3, 1, 5]; + nameDelimeter; + valueDelimeter; initOptions ({type, advOptions, formatOptions}) { this.type= type; @@ -37,8 +47,17 @@ export class storeEncoding { } } + initNamesDelimeter(names) { + this.namesDelimeter = names; + } + changeEncoding(value) { this.nameEncoding = this.pagesName[this.pages.indexOf(value)]; this.valueEncoding = value; } + + changeDelimeter(value) { + this.nameDelimeter = this.namesDelimeter[this.valuesDelimeter.indexOf(value)]; + this.valueDelimeter = value; + } } diff --git a/apps/documenteditor/mobile/src/store/mainStore.js b/apps/documenteditor/mobile/src/store/mainStore.js index d649831f6..c880e30c2 100644 --- a/apps/documenteditor/mobile/src/store/mainStore.js +++ b/apps/documenteditor/mobile/src/store/mainStore.js @@ -10,7 +10,7 @@ import {storeTableSettings} from "./tableSettings"; import {storeChartSettings} from "./chartSettings"; import {storeDocumentInfo} from "./documentInfo"; import {storeApplicationSettings} from './applicationSettings'; -import {storeEncoding} from "./encoding"; +import {storeEncoding} from "../../../../common/mobile/lib/store/encoding"; import {storeAppOptions} from "./appOptions"; import {storePalette} from "./palette"; import {storeReview} from "./review"; diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index 02681d4f8..335ce5f1b 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -513,7 +513,16 @@ "textValues": "Values", "textNoTextFound": "Text not found", "textReplaceAll": "Replace All", - "textCollaboration": "Collaboration" + "textCollaboration": "Collaboration", + "textChooseCsvOptions": "Choose CSV Options", + "txtDownloadCsv": "Download CSV", + "textDelimeter": "Delimeter", + "textEncoding": "Encoding", + "textChooseEncoding": "Choose Encoding", + "textChooseDelimeter": "Choose Delimeter", + "txtComma": "Comma", + "txtSemicolon": "Semicolon", + "txtColon": "Colon" } }, "Statusbar": { diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx index 6e1ed4b25..7341708c4 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx @@ -3,6 +3,7 @@ import Download from "../../view/settings/Download"; import { Device } from '../../../../../common/mobile/utils/device'; import { withTranslation, useTranslation } from 'react-i18next'; import { f7 } from 'framework7-react'; +import { observer, inject } from "mobx-react"; class DownloadController extends Component { constructor(props) { @@ -17,11 +18,20 @@ class DownloadController extends Component { if (format) { if (format == Asc.c_oAscFileType.CSV) { + const advOptions = api.asc_getAdvancedOptions(); + const recommendedSettings = advOptions.asc_getRecommendedSettings(); + f7.dialog.confirm( _t.warnDownloadAs, _t.notcriticalErrorTitle, - function () { - onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format), _t, true); + () => { + 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); } ) } else { @@ -37,92 +47,93 @@ class DownloadController extends Component { } } -const DownloadWithTranslation = withTranslation()(DownloadController); +const DownloadWithTranslation = inject("storeEncoding")(observer(withTranslation()(DownloadController))); const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady, canRequestClose, isDRM) => { const api = Common.EditorApi.get(); - if (type == Asc.c_oAscAdvancedOptionsID.CSV) { - let picker; - const pages = []; - const pagesName = []; + // if (type == Asc.c_oAscAdvancedOptionsID.CSV) { + // let picker; + // const pages = []; + // const pagesName = []; - for (let page of advOptions.asc_getCodePages()) { - pages.push(page.asc_getCodePage()); - pagesName.push(page.asc_getCodePageName()); - } + // for (let page of advOptions.asc_getCodePages()) { + // pages.push(page.asc_getCodePage()); + // pagesName.push(page.asc_getCodePageName()); + // } - Common.Notifications.trigger('preloader:close'); - Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); + // Common.Notifications.trigger('preloader:close'); + // Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); - const buttons = []; + // const buttons = []; - if (mode === 2) { - buttons.push({ - text: _t.textCancel - }); - } + // if (mode === 2) { + // buttons.push({ + // text: _t.textCancel + // }); + // } - buttons.push({ - text: 'OK', - bold: true, - onClick: function() { - let encoding = picker.cols[0].value, - delimiter = picker.cols[1].value; + // buttons.push({ + // text: 'OK', + // bold: true, + // onClick: function() { + // let encoding = picker.cols[0].value, + // delimiter = picker.cols[1].value; - if (mode == 2) { - formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding, delimiter)); - api.asc_DownloadAs(formatOptions); - } else { - api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding, delimiter)); - } + // if (mode == 2) { + // formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding, delimiter)); + // api.asc_DownloadAs(formatOptions); + // } else { + // api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding, delimiter)); + // } - if (!isDocReady) { - Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); - } - } - }); + // if (!isDocReady) { + // Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); + // } + // } + // }); - const dialog = f7.dialog.create({ - title: _t.advCSVOptions, - text: '', - content: - '
' + - '
' + - '
' + _t.txtEncoding + '
' + - '
' + _t.txtDelimiter + '
' + - '
' + - '
' + - '
', - buttons: buttons, - cssClass: 'dlg-adv-options' - }).open(); + // const dialog = f7.dialog.create({ + // title: _t.advCSVOptions, + // text: '', + // content: + // '
' + + // '
' + + // '
' + _t.txtEncoding + '
' + + // '
' + _t.txtDelimiter + '
' + + // '
' + + // '
' + + // '
', + // buttons: buttons, + // cssClass: 'dlg-adv-options' + // }).open(); - const recommendedSettings = advOptions.asc_getRecommendedSettings(); + // const recommendedSettings = advOptions.asc_getRecommendedSettings(); - dialog.on('opened', () => { - picker = f7.picker.create({ - containerEl: document.getElementById('txt-encoding'), - cols: [{ - textAlign: 'left', - values: pages, - displayValues: pagesName - },{ - textAlign: 'right', - width: 120, - values: [4, 2, 3, 1, 5], - displayValues: [',', ';', ':', _t.txtTab, _t.txtSpace] - }], - toolbar: false, - rotateEffect: true, - value: [ - recommendedSettings && recommendedSettings.asc_getCodePage(), - (recommendedSettings && recommendedSettings.asc_getDelimiter()) ? recommendedSettings.asc_getDelimiter() : 4 - ], - }); - }); + // dialog.on('opened', () => { + // picker = f7.picker.create({ + // containerEl: document.getElementById('txt-encoding'), + // cols: [{ + // textAlign: 'left', + // values: pages, + // displayValues: pagesName + // },{ + // textAlign: 'right', + // width: 120, + // values: [4, 2, 3, 1, 5], + // displayValues: [',', ';', ':', _t.txtTab, _t.txtSpace] + // }], + // toolbar: false, + // rotateEffect: true, + // value: [ + // recommendedSettings && recommendedSettings.asc_getCodePage(), + // (recommendedSettings && recommendedSettings.asc_getDelimiter()) ? recommendedSettings.asc_getDelimiter() : 4 + // ], + // }); + // }); - } 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 = [{ diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx new file mode 100644 index 000000000..130d8a0e0 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx @@ -0,0 +1,35 @@ +import React, { Component } from 'react'; +import { Device } from '../../../../../common/mobile/utils/device'; +import { f7 } from "framework7-react"; +import { Encoding } from "../../view/settings/Encoding"; + +class EncodingController extends Component { + constructor(props) { + super(props); + this.onSaveFormat = this.onSaveFormat.bind(this); + } + + closeModal() { + if (Device.phone) { + f7.sheet.close('.settings-popup', true); + } else { + f7.popover.close('#settings-popover'); + } + } + + onSaveFormat(formatOptions, valueEncoding, valueDelimeter) { + const api = Common.EditorApi.get(); + + this.closeModal(); + formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); + api.asc_DownloadAs(formatOptions); + } + + render() { + return ( + + ); + } +} + +export default EncodingController; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/store/mainStore.js b/apps/spreadsheeteditor/mobile/src/store/mainStore.js index 0190760f3..e6b557326 100644 --- a/apps/spreadsheeteditor/mobile/src/store/mainStore.js +++ b/apps/spreadsheeteditor/mobile/src/store/mainStore.js @@ -11,6 +11,7 @@ import {storeShapeSettings} from "./shapeSettings"; import {storeCellSettings} from "./cellSettings"; import {storeSpreadsheetInfo} from "./spreadsheetInfo"; import {storeAppOptions} from "./appOptions"; +import {storeEncoding} from "../../../../common/mobile/lib/store/encoding"; // import {storeImageSettings} from "./imageSettings"; // import {storeTableSettings} from "./tableSettings"; import {storeChartSettings} from "./chartSettings"; @@ -22,6 +23,7 @@ export const stores = { storeSpreadsheetSettings: new storeSpreadsheetSettings(), storeApplicationSettings: new storeApplicationSettings(), users: new storeUsers(), + storeEncoding: new storeEncoding(), sheets: new storeWorksheets(), storeFunctions: new storeFunctions(), storeTextSettings: new storeTextSettings(), diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx new file mode 100644 index 000000000..7adaf1d04 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx @@ -0,0 +1,90 @@ +import React from 'react'; +import { observer, inject } from "mobx-react"; +import { f7, Page, Navbar, List, ListItem, BlockTitle, ListButton } from "framework7-react"; +import { useTranslation } from "react-i18next"; + +const PageEncoding = props => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeEncoding = props.storeEncoding; + const valueEncoding = storeEncoding.valueEncoding; + const nameDelimeter = storeEncoding.nameDelimeter; + const valueDelimeter = storeEncoding.valueDelimeter; + const nameEncoding = storeEncoding.nameEncoding; + const formatOptions = storeEncoding.formatOptions; + + return ( + + + {_t.textDelimeter} + + + + {_t.textEncoding} + + + + + props.onSaveFormat(formatOptions, valueEncoding, valueDelimeter)}> + + + ) +} + +const PageEncodingList = props => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeEncoding = props.storeEncoding; + const valueEncoding = storeEncoding.valueEncoding; + const pages = storeEncoding.pages; + const pagesName = storeEncoding.pagesName; + + return ( + + + {_t.textChooseEncoding} + + {pagesName.map((name, index) => { + return ( + { + storeEncoding.changeEncoding(pages[index]); + f7.views.current.router.back(); + }}> + ) + })} + + + ) +} + +const PageDelimeterList = props => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeEncoding = props.storeEncoding; + const valueDelimeter = storeEncoding.valueDelimeter; + const namesDelimeter = storeEncoding.namesDelimeter; + const valuesDelimeter = storeEncoding.valuesDelimeter; + + return ( + + + {_t.textChooseDelimeter} + + {namesDelimeter.map((name, index) => { + return ( + { + storeEncoding.changeDelimeter(valuesDelimeter[index]); + f7.views.current.router.back(); + }}> + ) + })} + + + ) +} + +const Encoding = inject("storeEncoding")(observer(PageEncoding)); +const EncodingList = inject("storeEncoding")(observer(PageEncodingList)); +const DelimeterList = inject("storeEncoding")(observer(PageDelimeterList)); + +export {EncodingList, Encoding, DelimeterList} \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx index ac8caca6e..df224fbf1 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx @@ -12,6 +12,8 @@ import {SpreadsheetColorSchemes, SpreadsheetFormats, SpreadsheetMargins} from '. import {MacrosSettings, RegionalSettings, FormulaLanguage} from './ApplicationSettings.jsx'; // import SpreadsheetAbout from './SpreadsheetAbout.jsx'; import About from '../../../../../common/mobile/lib/view/About'; +import EncodingController from '../../controller/settings/Encoding'; +import { EncodingList, DelimeterList } from '../../view/settings/Encoding'; const routes = [ { @@ -61,6 +63,18 @@ const routes = [ { path: '/about/', component: About + }, + { + path: '/encoding/', + component: EncodingController + }, + { + path: '/encoding-list/', + component: EncodingList + }, + { + path: '/delimeter-list/', + component: DelimeterList } ]; From 1b5397d222bb5a97f63d620da6fd77c725b8c7c3 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Fri, 16 Jul 2021 13:29:28 +0300 Subject: [PATCH 04/11] [DE SSE mobile] Correct encoding --- apps/common/mobile/lib/store/encoding.js | 11 +++++-- apps/documenteditor/mobile/locale/en.json | 3 +- .../mobile/src/controller/Main.jsx | 7 ++-- .../src/controller/settings/Download.jsx | 26 +++++++++++---- .../src/controller/settings/Encoding.jsx | 16 ++++++--- .../mobile/src/view/settings/Encoding.jsx | 4 +-- apps/spreadsheeteditor/mobile/locale/en.json | 3 +- .../mobile/src/controller/Main.jsx | 7 ++-- .../src/controller/settings/Download.jsx | 33 ++++++++++++------- .../src/controller/settings/Encoding.jsx | 16 ++++++--- .../mobile/src/view/settings/Encoding.jsx | 4 +-- 11 files changed, 91 insertions(+), 39 deletions(-) diff --git a/apps/common/mobile/lib/store/encoding.js b/apps/common/mobile/lib/store/encoding.js index 91835f105..bf69126b6 100644 --- a/apps/common/mobile/lib/store/encoding.js +++ b/apps/common/mobile/lib/store/encoding.js @@ -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; diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index 5604188d0..221c809ea 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -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", diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 4bf67dcf4..9ead45870 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -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; }); } diff --git a/apps/documenteditor/mobile/src/controller/settings/Download.jsx b/apps/documenteditor/mobile/src/controller/settings/Download.jsx index 06b13bb85..a5e693525 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Download.jsx @@ -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 = [{ diff --git a/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx b/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx index 2a272aa64..a86ecb784 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx @@ -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; \ No newline at end of file +export default inject("storeEncoding")(observer(EncodingController)); \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/settings/Encoding.jsx b/apps/documenteditor/mobile/src/view/settings/Encoding.jsx index f4acd2bd4..9b5d9740d 100644 --- a/apps/documenteditor/mobile/src/view/settings/Encoding.jsx +++ b/apps/documenteditor/mobile/src/view/settings/Encoding.jsx @@ -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 ( @@ -19,7 +19,7 @@ const PageEncoding = props => {
- props.onSaveFormat(formatOptions, valueEncoding)}> + props.onSaveFormat(mode, valueEncoding)}> ) diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index 335ce5f1b..6a8074e06 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -522,7 +522,8 @@ "textChooseDelimeter": "Choose Delimeter", "txtComma": "Comma", "txtSemicolon": "Semicolon", - "txtColon": "Colon" + "txtColon": "Colon", + "txtOk": "Ok" } }, "Statusbar": { diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index a021ed9e2..ef6bdd7ff 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -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; }); diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx index 7341708c4..b7b8b5ceb 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx @@ -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 = [{ diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx index 130d8a0e0..91db33941 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx @@ -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; \ No newline at end of file +export default inject("storeEncoding")(observer(EncodingController)); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx index 7adaf1d04..2150e6f1e 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx @@ -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 ( @@ -25,7 +25,7 @@ const PageEncoding = props => { - props.onSaveFormat(formatOptions, valueEncoding, valueDelimeter)}> + props.onSaveFormat(mode, valueEncoding, valueDelimeter)}> ) From 5a30ae5cc92fe838ef23ccf3f59f1ccfdc246020 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Tue, 20 Jul 2021 18:09:39 +0300 Subject: [PATCH 05/11] [SSE mobile] Correct Encoding --- apps/common/mobile/lib/store/encoding.js | 2 +- .../mobile/src/controller/settings/Download.jsx | 6 ++++-- .../mobile/src/controller/settings/Encoding.jsx | 11 ++++++----- apps/spreadsheeteditor/mobile/src/page/main.jsx | 5 +++-- .../mobile/src/view/settings/Encoding.jsx | 2 +- .../mobile/src/view/settings/Settings.jsx | 4 ++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/apps/common/mobile/lib/store/encoding.js b/apps/common/mobile/lib/store/encoding.js index bf69126b6..41ad838d6 100644 --- a/apps/common/mobile/lib/store/encoding.js +++ b/apps/common/mobile/lib/store/encoding.js @@ -25,7 +25,7 @@ export class storeEncoding { } type; - mode; + mode = 1; pages = []; pagesName = []; advOptions; diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx index b7b8b5ceb..d48a09f94 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx @@ -55,12 +55,14 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady storeEncoding.initOptions({type, advOptions, formatOptions}); storeEncoding.initPages(); - storeEncoding.initNamesDelimeter([_t.txtComma, _t.txtSemicolon, _t.txtColon, _t.txtTab, _t.txtSpace]); storeEncoding.setMode(mode); + storeEncoding.initNamesDelimeter([_t.txtComma, _t.txtSemicolon, _t.txtColon, _t.txtTab, _t.txtSpace]); storeEncoding.changeEncoding(recommendedSettings.asc_getCodePage()); storeEncoding.changeDelimeter(recommendedSettings && recommendedSettings.asc_getDelimiter() ? recommendedSettings.asc_getDelimiter() : 4); - f7.views.current.router.navigate('/encoding/'); + if(mode === 2) { + f7.views.current.router.navigate('/encoding/'); + } } // let picker; // const pages = []; diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx index 91db33941..17ed1cf0a 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx @@ -12,7 +12,7 @@ class EncodingController extends Component { closeModal() { if (Device.phone) { - f7.sheet.close('.settings-popup', true); + f7.sheet.close('.settings-popup', false); } else { f7.popover.close('#settings-popover'); } @@ -20,15 +20,16 @@ class EncodingController extends Component { onSaveFormat(mode, valueEncoding, valueDelimeter) { const api = Common.EditorApi.get(); - - this.closeModal(); + const storeEncoding = this.props.storeEncoding; if(mode === 2) { - const formatOptions = this.props.storeEncoding.formatOptions; + this.closeModal(); + const formatOptions = storeEncoding.formatOptions; formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); api.asc_DownloadAs(formatOptions); } else { - const type = this.props.storeEncoding.type; + storeEncoding.setMode(1); + const type = storeEncoding.type; api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); } } diff --git a/apps/spreadsheeteditor/mobile/src/page/main.jsx b/apps/spreadsheeteditor/mobile/src/page/main.jsx index c8221d3d3..33b61eaf4 100644 --- a/apps/spreadsheeteditor/mobile/src/page/main.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/main.jsx @@ -74,6 +74,7 @@ class MainPage extends Component { const config = appOptions.config; const showLogo = !(appOptions.canBrandingExt && (config.customization && (config.customization.loaderName || config.customization.loaderLogo))); const showPlaceholder = !appOptions.isDocReady && (!config.customization || !(config.customization.loaderName || config.customization.loaderLogo)); + return ( {/* Top Navbar */} @@ -105,7 +106,7 @@ class MainPage extends Component { } { - !this.state.settingsVisible ? null : + !this.state.settingsVisible && this.props.storeEncoding.mode ? null : } { @@ -124,4 +125,4 @@ class MainPage extends Component { } } -export default inject("storeAppOptions")(observer(MainPage)); \ No newline at end of file +export default inject("storeAppOptions", "storeEncoding")(observer(MainPage)); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx index 2150e6f1e..f7d9b1084 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx @@ -15,7 +15,7 @@ const PageEncoding = props => { return ( - + {_t.textDelimeter} diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx index df224fbf1..f5d0fab05 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx @@ -79,7 +79,7 @@ const routes = [ ]; -const SettingsList = inject("storeAppOptions")(observer(props => { +const SettingsList = inject("storeAppOptions", "storeEncoding")(observer(props => { const { t } = useTranslation(); const _t = t('View.Settings', {returnObjects: true}); const navbar = @@ -138,7 +138,7 @@ const SettingsList = inject("storeAppOptions")(observer(props => { } return ( - + {navbar} From b7d44ced9fb37c1755f911a1bd1247c1bf57986f Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Wed, 21 Jul 2021 21:24:04 +0300 Subject: [PATCH 06/11] [SSE mobile] Change Encoding --- .../mobile/src/controller/Encoding.jsx | 44 +++++ .../src/controller/settings/Download.jsx | 20 ++- .../mobile/src/page/main.jsx | 14 +- .../mobile/src/view/Encoding.jsx | 153 ++++++++++++++++++ .../mobile/src/view/settings/Settings.jsx | 29 ++-- 5 files changed, 240 insertions(+), 20 deletions(-) create mode 100644 apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx create mode 100644 apps/spreadsheeteditor/mobile/src/view/Encoding.jsx diff --git a/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx new file mode 100644 index 000000000..ac2134523 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx @@ -0,0 +1,44 @@ +import React, { Component } from 'react'; +import { Device } from '../../../../common/mobile/utils/device'; +import { f7 } from "framework7-react"; +import { Encoding } from "../view/Encoding"; +import { observer, inject } from "mobx-react"; + +class EncodingController extends Component { + constructor(props) { + super(props); + this.onSaveFormat = this.onSaveFormat.bind(this); + } + + closeModal() { + if (Device.phone) { + f7.sheet.close('.encoding-popup', false); + } else { + f7.popover.close('#encoding-popover'); + } + } + + onSaveFormat(mode, valueEncoding, valueDelimeter) { + const api = Common.EditorApi.get(); + const storeEncoding = this.props.storeEncoding; + + if(mode === 2) { + this.closeModal(); + const formatOptions = storeEncoding.formatOptions; + formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); + api.asc_DownloadAs(formatOptions); + } else { + storeEncoding.setMode(1); + const type = storeEncoding.type; + api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); + } + } + + render() { + return ( + + ); + } +} + +export default inject("storeEncoding")(observer(EncodingController)); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx index d48a09f94..c0a16c96b 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx @@ -4,6 +4,7 @@ import { Device } from '../../../../../common/mobile/utils/device'; import { withTranslation, useTranslation } from 'react-i18next'; import { f7 } from 'framework7-react'; import { observer, inject } from "mobx-react"; +// import MainPage from '../../page/main'; class DownloadController extends Component { constructor(props) { @@ -11,6 +12,14 @@ class DownloadController extends Component { this.onSaveFormat = this.onSaveFormat.bind(this); } + closeModal() { + if (Device.phone) { + f7.sheet.close('.settings-popup', false); + } else { + f7.popover.close('#settings-popover'); + } + } + onSaveFormat(format) { const api = Common.EditorApi.get(); const { t } = this.props; @@ -24,12 +33,15 @@ class DownloadController extends Component { f7.dialog.confirm( _t.warnDownloadAs, _t.notcriticalErrorTitle, - () => { + async () => { const canRequestClose = this.props.storeAppOptions.canRequestClose; + await this.closeModal(); onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, advOptions, 2, new Asc.asc_CDownloadOptions(format), _t, true, canRequestClose, false, storeEncoding); + this.props.openOptions('encoding'); } ) } else { + this.closeModal(); api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); } } @@ -60,9 +72,9 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady storeEncoding.changeEncoding(recommendedSettings.asc_getCodePage()); storeEncoding.changeDelimeter(recommendedSettings && recommendedSettings.asc_getDelimiter() ? recommendedSettings.asc_getDelimiter() : 4); - if(mode === 2) { - f7.views.current.router.navigate('/encoding/'); - } + // if(mode === 2) { + // f7.views.current.router.navigate('/encoding/'); + // } } // let picker; // const pages = []; diff --git a/apps/spreadsheeteditor/mobile/src/page/main.jsx b/apps/spreadsheeteditor/mobile/src/page/main.jsx index 33b61eaf4..79acd15eb 100644 --- a/apps/spreadsheeteditor/mobile/src/page/main.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/main.jsx @@ -16,6 +16,7 @@ import { f7 } from 'framework7-react'; import {FunctionGroups} from "../controller/add/AddFunction"; import ContextMenu from '../controller/ContextMenu'; import { Toolbar } from "../controller/Toolbar"; +import EncodingController from "../controller/Encoding"; class MainPage extends Component { constructor(props) { @@ -26,6 +27,7 @@ class MainPage extends Component { addShowOptions: null, settingsVisible: false, collaborationVisible: false, + encodingVisible: false }; } @@ -42,6 +44,8 @@ class MainPage extends Component { }; else if ( opts == 'settings' ) return {settingsVisible: true}; + else if ( opts == 'encoding' ) + return {encodingVisible: true}; else if ( opts == 'coauth' ) return {collaborationVisible: true}; }); @@ -60,6 +64,8 @@ class MainPage extends Component { return {addOptionsVisible: false}; else if ( opts == 'settings' ) return {settingsVisible: false}; + else if ( opts == 'encoding' ) + return {encodingVisible: false}; else if ( opts == 'coauth' ) return {collaborationVisible: false}; }); @@ -67,7 +73,7 @@ class MainPage extends Component { f7.navbar.show('.main-navbar'); } })(); - }; + }; render() { const appOptions = this.props.storeAppOptions; @@ -106,13 +112,17 @@ class MainPage extends Component { } { - !this.state.settingsVisible && this.props.storeEncoding.mode ? null : + !this.state.settingsVisible ? null : } { !this.state.collaborationVisible ? null : } + { + !this.state.encodingVisible && this.props.storeEncoding.mode ? null : + + } diff --git a/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx new file mode 100644 index 000000000..1350570bb --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx @@ -0,0 +1,153 @@ +import React, {Component, useEffect} from 'react'; +import { observer, inject } from "mobx-react"; +import { f7, Page, Navbar, List, ListItem, BlockTitle, ListButton, Popover, Popup, View, Link } from "framework7-react"; +import { useTranslation } from "react-i18next"; +import { Device } from '../../../../common/mobile/utils/device'; + +const routes = [ + { + path: '/encoding/', + component: PageEncoding + }, + { + path: '/encoding-list/', + component: PageEncodingList + }, + { + path: '/delimeter-list/', + component: PageDelimeterList + } +]; + +const PageEncoding = inject("storeEncoding")(observer(props => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeEncoding = props.storeEncoding; + const valueEncoding = storeEncoding.valueEncoding; + const nameDelimeter = storeEncoding.nameDelimeter; + const valueDelimeter = storeEncoding.valueDelimeter; + const nameEncoding = storeEncoding.nameEncoding; + const mode = storeEncoding.mode; + + return ( + + + + {_t.textDelimeter} + + + + {_t.textEncoding} + + + + + props.onSaveFormat(mode, valueEncoding, valueDelimeter)}> + + + + + ) +})); + +const PageEncodingList = inject("storeEncoding")(observer(props => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeEncoding = props.storeEncoding; + const valueEncoding = storeEncoding.valueEncoding; + const pages = storeEncoding.pages; + const pagesName = storeEncoding.pagesName; + + return ( + + + {_t.textChooseEncoding} + + {pagesName.map((name, index) => { + return ( + { + storeEncoding.changeEncoding(pages[index]); + f7.views.current.router.back(); + }}> + ) + })} + + + ) +})); + +const PageDelimeterList = inject("storeEncoding")(observer(props => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeEncoding = props.storeEncoding; + const valueDelimeter = storeEncoding.valueDelimeter; + const namesDelimeter = storeEncoding.namesDelimeter; + const valuesDelimeter = storeEncoding.valuesDelimeter; + + return ( + + + {_t.textChooseDelimeter} + + {namesDelimeter.map((name, index) => { + return ( + { + storeEncoding.changeDelimeter(valuesDelimeter[index]); + f7.views.current.router.back(); + }}> + ) + })} + + + ) +})); + +// const Encoding = inject("storeEncoding")(observer(PageEncoding)); +// const EncodingList = inject("storeEncoding")(observer(PageEncodingList)); +// const DelimeterList = inject("storeEncoding")(observer(PageDelimeterList)); + +class EncodingView extends Component { + constructor(props) { + super(props); + this.onoptionclick = this.onoptionclick.bind(this); + } + + onoptionclick(page){ + f7.views.current.router.navigate(page); + } + + render() { + const show_popover = this.props.usePopover; + return ( + show_popover ? + this.props.onclosed()}> + + : + this.props.onclosed()}> + + + ) + } +} + +const Encoding = props => { + useEffect(() => { + if ( Device.phone ) + f7.popup.open('.encoding-popup'); + else f7.popover.open('#encoding-popover'); + + return () => { + } + }); + + + const onviewclosed = () => { + if ( props.onclosed ) + props.onclosed(); + }; + + return +}; + +// export {EncodingList, Encoding, DelimeterList} +export {Encoding, PageEncodingList, PageDelimeterList} \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx index f5d0fab05..afde10636 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx @@ -64,18 +64,18 @@ const routes = [ path: '/about/', component: About }, - { - path: '/encoding/', - component: EncodingController - }, - { - path: '/encoding-list/', - component: EncodingList - }, - { - path: '/delimeter-list/', - component: DelimeterList - } + // { + // path: '/encoding/', + // component: EncodingController + // }, + // { + // path: '/encoding-list/', + // component: EncodingList + // }, + // { + // path: '/delimeter-list/', + // component: DelimeterList + // } ]; @@ -138,7 +138,8 @@ const SettingsList = inject("storeAppOptions", "storeEncoding")(observer(props = } return ( - + // onClick={onoptionclick.bind(this, "/download/")} + {navbar} @@ -160,7 +161,7 @@ const SettingsList = inject("storeAppOptions", "storeEncoding")(observer(props = - + From 850359ca6d505f942704bd166f24ab8f84ccd925 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Thu, 22 Jul 2021 02:06:46 +0300 Subject: [PATCH 07/11] [SSE mobile] Change Encoding v.2 --- .../mobile/src/controller/Encoding.jsx | 7 ++-- .../mobile/src/page/main.jsx | 16 ++++++++- .../mobile/src/view/Encoding.jsx | 34 ++++++------------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx index ac2134523..4e9198029 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx @@ -18,12 +18,13 @@ class EncodingController extends Component { } } - onSaveFormat(mode, valueEncoding, valueDelimeter) { + async onSaveFormat(mode, valueEncoding, valueDelimeter) { const api = Common.EditorApi.get(); const storeEncoding = this.props.storeEncoding; + await this.closeModal(); + if(mode === 2) { - this.closeModal(); const formatOptions = storeEncoding.formatOptions; formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); api.asc_DownloadAs(formatOptions); @@ -36,7 +37,7 @@ class EncodingController extends Component { render() { return ( - + ); } } diff --git a/apps/spreadsheeteditor/mobile/src/page/main.jsx b/apps/spreadsheeteditor/mobile/src/page/main.jsx index 79acd15eb..55f530939 100644 --- a/apps/spreadsheeteditor/mobile/src/page/main.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/main.jsx @@ -17,6 +17,19 @@ import {FunctionGroups} from "../controller/add/AddFunction"; import ContextMenu from '../controller/ContextMenu'; import { Toolbar } from "../controller/Toolbar"; import EncodingController from "../controller/Encoding"; +import {PageEncodingList, PageDelimeterList} from '../view/Encoding'; + + +const routes = [ + { + path: '/encoding-list/', + component: PageEncodingList + }, + { + path: '/delimeter-list/', + component: PageDelimeterList + } +]; class MainPage extends Component { constructor(props) { @@ -121,7 +134,8 @@ class MainPage extends Component { } { !this.state.encodingVisible && this.props.storeEncoding.mode ? null : - + } diff --git a/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx index 1350570bb..21e1d698f 100644 --- a/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx @@ -4,21 +4,6 @@ import { f7, Page, Navbar, List, ListItem, BlockTitle, ListButton, Popover, Popu import { useTranslation } from "react-i18next"; import { Device } from '../../../../common/mobile/utils/device'; -const routes = [ - { - path: '/encoding/', - component: PageEncoding - }, - { - path: '/encoding-list/', - component: PageEncodingList - }, - { - path: '/delimeter-list/', - component: PageDelimeterList - } -]; - const PageEncoding = inject("storeEncoding")(observer(props => { const { t } = useTranslation(); const _t = t("View.Settings", { returnObjects: true }); @@ -28,9 +13,10 @@ const PageEncoding = inject("storeEncoding")(observer(props => { const valueDelimeter = storeEncoding.valueDelimeter; const nameEncoding = storeEncoding.nameEncoding; const mode = storeEncoding.mode; + const routes = props.routes; return ( - + {_t.textDelimeter} @@ -42,6 +28,9 @@ const PageEncoding = inject("storeEncoding")(observer(props => { + {mode === 2 ? + + : null} props.onSaveFormat(mode, valueEncoding, valueDelimeter)}> @@ -102,10 +91,6 @@ const PageDelimeterList = inject("storeEncoding")(observer(props => { ) })); -// const Encoding = inject("storeEncoding")(observer(PageEncoding)); -// const EncodingList = inject("storeEncoding")(observer(PageEncodingList)); -// const DelimeterList = inject("storeEncoding")(observer(PageDelimeterList)); - class EncodingView extends Component { constructor(props) { super(props); @@ -121,10 +106,12 @@ class EncodingView extends Component { return ( show_popover ? this.props.onclosed()}> - + : this.props.onclosed()}> - + ) } @@ -146,8 +133,7 @@ const Encoding = props => { props.onclosed(); }; - return + return }; -// export {EncodingList, Encoding, DelimeterList} export {Encoding, PageEncodingList, PageDelimeterList} \ No newline at end of file From 116944b181df2412d1636ee63a1b6f0daf845680 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Thu, 22 Jul 2021 23:32:20 +0300 Subject: [PATCH 08/11] [SSE mobile] Changed encoding options --- .../mobile/src/controller/Encoding.jsx | 88 +++++++-- .../mobile/src/controller/Main.jsx | 15 +- .../src/controller/settings/Download.jsx | 183 ++++-------------- .../src/controller/settings/Encoding.jsx | 44 ----- .../mobile/src/page/main.jsx | 28 +-- .../mobile/src/view/Encoding.jsx | 158 ++++++++++----- .../mobile/src/view/settings/Encoding.jsx | 90 --------- .../mobile/src/view/settings/Settings.jsx | 19 +- 8 files changed, 233 insertions(+), 392 deletions(-) delete mode 100644 apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx delete mode 100644 apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx diff --git a/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx index 4e9198029..9dfa3ae64 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx @@ -2,44 +2,104 @@ import React, { Component } from 'react'; import { Device } from '../../../../common/mobile/utils/device'; import { f7 } from "framework7-react"; import { Encoding } from "../view/Encoding"; -import { observer, inject } from "mobx-react"; +import { withTranslation } from 'react-i18next'; class EncodingController extends Component { constructor(props) { super(props); + + const { t } = this.props; + const _t = t("View.Settings", { returnObjects: true }); + + this.valuesDelimeter = [4, 2, 3, 1, 5]; + this.namesDelimeter = [_t.txtComma, _t.txtSemicolon, _t.txtColon, _t.txtTab, _t.txtSpace]; this.onSaveFormat = this.onSaveFormat.bind(this); + this.closeModal = this.closeModal.bind(this); + this.state = { + isOpen: false + }; + + Common.Notifications.on('engineCreated', api => { + api.asc_registerCallback('asc_onAdvancedOptions', (type, advOptions, mode, formatOptions) => { + this.initEncoding(type, advOptions, mode, formatOptions); + }); + }); + + Common.Notifications.on('openEncoding', (type, advOptions, mode, formatOptions) => { + this.initEncoding(type, advOptions, mode, formatOptions); + }); + } + + initEncoding(type, advOptions, mode, formatOptions) { + if(type === Asc.c_oAscAdvancedOptionsID.CSV) { + Common.Notifications.trigger('preloader:close'); + Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); + + this.mode = mode; + this.advOptions = advOptions; + this.formatOptions = formatOptions; + this.pages = []; + this.pagesName = []; + + const recommendedSettings = this.advOptions.asc_getRecommendedSettings(); + + this.initPages(); + this.valueEncoding = recommendedSettings.asc_getCodePage(); + this.valueDelimeter = recommendedSettings && recommendedSettings.asc_getDelimiter() ? recommendedSettings.asc_getDelimiter() : 4; + + this.setState({ + isOpen: true + }); + } + } + + initPages() { + for (let page of this.advOptions.asc_getCodePages()) { + this.pages.push(page.asc_getCodePage()); + this.pagesName.push(page.asc_getCodePageName()); + } } closeModal() { if (Device.phone) { - f7.sheet.close('.encoding-popup', false); + f7.sheet.close('.encoding-popup', true); } else { f7.popover.close('#encoding-popover'); } + + this.setState({isOpen: false}); } - async onSaveFormat(mode, valueEncoding, valueDelimeter) { + onSaveFormat(valueEncoding, valueDelimeter) { const api = Common.EditorApi.get(); - const storeEncoding = this.props.storeEncoding; - await this.closeModal(); + this.closeModal(); - if(mode === 2) { - const formatOptions = storeEncoding.formatOptions; - formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); - api.asc_DownloadAs(formatOptions); + if(this.mode === 2) { + this.formatOptions && this.formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); + api.asc_DownloadAs(this.formatOptions); } else { - storeEncoding.setMode(1); - const type = storeEncoding.type; - api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); + api.asc_setAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); } } render() { return ( - + this.state.isOpen && + ); } } -export default inject("storeEncoding")(observer(EncodingController)); \ No newline at end of file +export default withTranslation()(EncodingController); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index ef6bdd7ff..825f7ea90 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -18,6 +18,7 @@ import ErrorController from "./Error"; import app from "../page/app"; import About from "../../../../common/mobile/lib/view/About"; import PluginsController from '../../../../common/mobile/lib/controller/Plugins.jsx'; +import EncodingController from "./Encoding"; @inject( "storeAppOptions", @@ -27,9 +28,8 @@ import PluginsController from '../../../../common/mobile/lib/controller/Plugins. "storeChartSettings", "storeSpreadsheetSettings", "storeSpreadsheetInfo", - "storeApplicationSettings", - "storeEncoding" - ) + "storeApplicationSettings" +) class MainController extends Component { constructor(props) { super(props); @@ -319,15 +319,15 @@ 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, storeEncoding); - if(type == Asc.c_oAscAdvancedOptionsID.DRM) this.isDRM = true; + if(type == Asc.c_oAscAdvancedOptionsID.DRM) { + onAdvancedOptions(type, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose, this.isDRM); + this.isDRM = true; + } }); } @@ -776,6 +776,7 @@ class MainController extends Component { + ) } diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx index c0a16c96b..5091c765b 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/settings/Download.jsx @@ -4,7 +4,6 @@ import { Device } from '../../../../../common/mobile/utils/device'; import { withTranslation, useTranslation } from 'react-i18next'; import { f7 } from 'framework7-react'; import { observer, inject } from "mobx-react"; -// import MainPage from '../../page/main'; class DownloadController extends Component { constructor(props) { @@ -27,17 +26,13 @@ class DownloadController extends Component { if (format) { if (format == Asc.c_oAscFileType.CSV) { - const advOptions = api.asc_getAdvancedOptions(); - const storeEncoding = this.props.storeEncoding; - f7.dialog.confirm( _t.warnDownloadAs, _t.notcriticalErrorTitle, - async () => { - const canRequestClose = this.props.storeAppOptions.canRequestClose; - await this.closeModal(); - onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, advOptions, 2, new Asc.asc_CDownloadOptions(format), _t, true, canRequestClose, false, storeEncoding); - this.props.openOptions('encoding'); + () => { + const advOptions = api.asc_getAdvancedOptions(); + this.closeModal(); + Common.Notifications.trigger('openEncoding', Asc.c_oAscAdvancedOptionsID.CSV, advOptions, 2, new Asc.asc_CDownloadOptions(format)); } ) } else { @@ -54,149 +49,51 @@ class DownloadController extends Component { } } -const DownloadWithTranslation = inject("storeAppOptions", "storeEncoding")(observer(withTranslation()(DownloadController))); +const DownloadWithTranslation = inject("storeAppOptions")(observer(withTranslation()(DownloadController))); -const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady, canRequestClose, isDRM, storeEncoding) => { +const onAdvancedOptions = (type, _t, isDocReady, canRequestClose, isDRM) => { const api = Common.EditorApi.get(); - 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.setMode(mode); - storeEncoding.initNamesDelimeter([_t.txtComma, _t.txtSemicolon, _t.txtColon, _t.txtTab, _t.txtSpace]); - storeEncoding.changeEncoding(recommendedSettings.asc_getCodePage()); - storeEncoding.changeDelimeter(recommendedSettings && recommendedSettings.asc_getDelimiter() ? recommendedSettings.asc_getDelimiter() : 4); - - // if(mode === 2) { - // f7.views.current.router.navigate('/encoding/'); - // } - } - // let picker; - // const pages = []; - // const pagesName = []; - - // for (let page of advOptions.asc_getCodePages()) { - // pages.push(page.asc_getCodePage()); - // pagesName.push(page.asc_getCodePageName()); - // } - - // Common.Notifications.trigger('preloader:close'); - // Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); - - // const buttons = []; - - // if (mode === 2) { - // buttons.push({ - // text: _t.textCancel - // }); - // } - - // buttons.push({ - // text: 'OK', - // bold: true, - // onClick: function() { - // let encoding = picker.cols[0].value, - // delimiter = picker.cols[1].value; - - // if (mode == 2) { - // formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding, delimiter)); - // api.asc_DownloadAs(formatOptions); - // } else { - // api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding, delimiter)); - // } - - // if (!isDocReady) { - // Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); - // } - // } - // }); - - // const dialog = f7.dialog.create({ - // title: _t.advCSVOptions, - // text: '', - // content: - // '
' + - // '
' + - // '
' + _t.txtEncoding + '
' + - // '
' + _t.txtDelimiter + '
' + - // '
' + - // '
' + - // '
', - // buttons: buttons, - // cssClass: 'dlg-adv-options' - // }).open(); - - // const recommendedSettings = advOptions.asc_getRecommendedSettings(); - - // dialog.on('opened', () => { - // picker = f7.picker.create({ - // containerEl: document.getElementById('txt-encoding'), - // cols: [{ - // textAlign: 'left', - // values: pages, - // displayValues: pagesName - // },{ - // textAlign: 'right', - // width: 120, - // values: [4, 2, 3, 1, 5], - // displayValues: [',', ';', ':', _t.txtTab, _t.txtSpace] - // }], - // toolbar: false, - // rotateEffect: true, - // value: [ - // recommendedSettings && recommendedSettings.asc_getCodePage(), - // (recommendedSettings && recommendedSettings.asc_getDelimiter()) ? recommendedSettings.asc_getDelimiter() : 4 - // ], - // }); - // }); - - // } else - 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 = [{ - text: 'OK', - bold: true, - onClick: function () { - const password = document.getElementById('modal-password').value; - api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(password)); - if (!isDocReady) { - Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); - } + Common.Notifications.trigger('preloader:close'); + Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); + const buttons = [{ + text: 'OK', + bold: true, + onClick: function () { + const password = document.getElementById('modal-password').value; + api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(password)); + if (!isDocReady) { + Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); } - }]; - - if(isDRM) { - f7.dialog.create({ - text: _t.txtIncorrectPwd, - buttons : [{ - text: 'OK', - bold: true, - }] - }).open(); } + }]; - if (canRequestClose) - buttons.push({ - text: _t.closeButtonText, - onClick: function () { - Common.Gateway.requestClose(); - } - }); - + if(isDRM) { f7.dialog.create({ - title: _t.advDRMOptions, - text: _t.textOpenFile, - content: Device.ios ? - '
' : '
', - buttons: buttons + text: _t.txtIncorrectPwd, + buttons : [{ + text: 'OK', + bold: true, + }] }).open(); } + + if (canRequestClose) + buttons.push({ + text: _t.closeButtonText, + onClick: function () { + Common.Gateway.requestClose(); + } + }); + + f7.dialog.create({ + title: _t.advDRMOptions, + text: _t.textOpenFile, + content: Device.ios ? + '
' : '
', + buttons: buttons + }).open(); + }; export { diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx deleted file mode 100644 index 17ed1cf0a..000000000 --- a/apps/spreadsheeteditor/mobile/src/controller/settings/Encoding.jsx +++ /dev/null @@ -1,44 +0,0 @@ -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) { - super(props); - this.onSaveFormat = this.onSaveFormat.bind(this); - } - - closeModal() { - if (Device.phone) { - f7.sheet.close('.settings-popup', false); - } else { - f7.popover.close('#settings-popover'); - } - } - - onSaveFormat(mode, valueEncoding, valueDelimeter) { - const api = Common.EditorApi.get(); - const storeEncoding = this.props.storeEncoding; - - if(mode === 2) { - this.closeModal(); - const formatOptions = storeEncoding.formatOptions; - formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); - api.asc_DownloadAs(formatOptions); - } else { - storeEncoding.setMode(1); - const type = storeEncoding.type; - api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(valueEncoding, valueDelimeter)); - } - } - - render() { - return ( - - ); - } -} - -export default inject("storeEncoding")(observer(EncodingController)); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/page/main.jsx b/apps/spreadsheeteditor/mobile/src/page/main.jsx index 55f530939..5ebe8ac2e 100644 --- a/apps/spreadsheeteditor/mobile/src/page/main.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/main.jsx @@ -16,20 +16,6 @@ import { f7 } from 'framework7-react'; import {FunctionGroups} from "../controller/add/AddFunction"; import ContextMenu from '../controller/ContextMenu'; import { Toolbar } from "../controller/Toolbar"; -import EncodingController from "../controller/Encoding"; -import {PageEncodingList, PageDelimeterList} from '../view/Encoding'; - - -const routes = [ - { - path: '/encoding-list/', - component: PageEncodingList - }, - { - path: '/delimeter-list/', - component: PageDelimeterList - } -]; class MainPage extends Component { constructor(props) { @@ -39,8 +25,7 @@ class MainPage extends Component { addOptionsVisible: false, addShowOptions: null, settingsVisible: false, - collaborationVisible: false, - encodingVisible: false + collaborationVisible: false }; } @@ -57,8 +42,6 @@ class MainPage extends Component { }; else if ( opts == 'settings' ) return {settingsVisible: true}; - else if ( opts == 'encoding' ) - return {encodingVisible: true}; else if ( opts == 'coauth' ) return {collaborationVisible: true}; }); @@ -77,8 +60,6 @@ class MainPage extends Component { return {addOptionsVisible: false}; else if ( opts == 'settings' ) return {settingsVisible: false}; - else if ( opts == 'encoding' ) - return {encodingVisible: false}; else if ( opts == 'coauth' ) return {collaborationVisible: false}; }); @@ -132,11 +113,6 @@ class MainPage extends Component { !this.state.collaborationVisible ? null : } - { - !this.state.encodingVisible && this.props.storeEncoding.mode ? null : - - } @@ -149,4 +125,4 @@ class MainPage extends Component { } } -export default inject("storeAppOptions", "storeEncoding")(observer(MainPage)); \ No newline at end of file +export default inject("storeAppOptions")(observer(MainPage)); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx index 21e1d698f..6046bde42 100644 --- a/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/Encoding.jsx @@ -1,51 +1,69 @@ -import React, {Component, useEffect} from 'react'; -import { observer, inject } from "mobx-react"; +import React, {Component, useEffect, useState} from 'react'; import { f7, Page, Navbar, List, ListItem, BlockTitle, ListButton, Popover, Popup, View, Link } from "framework7-react"; import { useTranslation } from "react-i18next"; import { Device } from '../../../../common/mobile/utils/device'; -const PageEncoding = inject("storeEncoding")(observer(props => { +const PageEncoding = props => { const { t } = useTranslation(); const _t = t("View.Settings", { returnObjects: true }); - const storeEncoding = props.storeEncoding; - const valueEncoding = storeEncoding.valueEncoding; - const nameDelimeter = storeEncoding.nameDelimeter; - const valueDelimeter = storeEncoding.valueDelimeter; - const nameEncoding = storeEncoding.nameEncoding; - const mode = storeEncoding.mode; - const routes = props.routes; + const pagesName = props.pagesName; + const pages = props.pages; + 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 nameDelimeter = namesDelimeter[valuesDelimeter.indexOf(stateDelimeter)]; + const mode = props.mode; + + const changeStateEncoding = value => { + setStateEncoding(value); + } + + const changeStateDelimeter = value => { + setStateDelimeter(value); + } return ( - + {_t.textDelimeter} - + {_t.textEncoding} - + {mode === 2 ? - + props.closeModal()}> : null} - props.onSaveFormat(mode, valueEncoding, valueDelimeter)}> + props.onSaveFormat(stateEncoding, stateDelimeter)}> ) -})); +}; -const PageEncodingList = inject("storeEncoding")(observer(props => { +const PageEncodingList = props => { const { t } = useTranslation(); const _t = t("View.Settings", { returnObjects: true }); - const storeEncoding = props.storeEncoding; - const valueEncoding = storeEncoding.valueEncoding; - const pages = storeEncoding.pages; - const pagesName = storeEncoding.pagesName; + const [currentEncoding, changeCurrentEncoding] = useState(props.stateEncoding); + const pages = props.pages; + const pagesName = props.pagesName; return ( @@ -54,8 +72,9 @@ const PageEncodingList = inject("storeEncoding")(observer(props => { {pagesName.map((name, index) => { return ( - { - storeEncoding.changeEncoding(pages[index]); + { + changeCurrentEncoding(pages[index]); + props.changeStateEncoding(pages[index]); f7.views.current.router.back(); }}> ) @@ -63,15 +82,14 @@ const PageEncodingList = inject("storeEncoding")(observer(props => { ) -})); +}; -const PageDelimeterList = inject("storeEncoding")(observer(props => { +const PageDelimeterList = props => { const { t } = useTranslation(); const _t = t("View.Settings", { returnObjects: true }); - const storeEncoding = props.storeEncoding; - const valueDelimeter = storeEncoding.valueDelimeter; - const namesDelimeter = storeEncoding.namesDelimeter; - const valuesDelimeter = storeEncoding.valuesDelimeter; + const [currentDelimeter, changeCurrentDelimeter] = useState(props.stateDelimeter); + const namesDelimeter = props.namesDelimeter; + const valuesDelimeter = props.valuesDelimeter; return ( @@ -80,8 +98,9 @@ const PageDelimeterList = inject("storeEncoding")(observer(props => { {namesDelimeter.map((name, index) => { return ( - { - storeEncoding.changeDelimeter(valuesDelimeter[index]); + { + changeCurrentDelimeter(valuesDelimeter[index]); + props.changeStateDelimeter(valuesDelimeter[index]); f7.views.current.router.back(); }}> ) @@ -89,51 +108,88 @@ const PageDelimeterList = inject("storeEncoding")(observer(props => { ) -})); +}; class EncodingView extends Component { constructor(props) { super(props); - this.onoptionclick = this.onoptionclick.bind(this); - } - - onoptionclick(page){ - f7.views.current.router.navigate(page); } render() { const show_popover = this.props.usePopover; + return ( show_popover ? - this.props.onclosed()}> - + + : - this.props.onclosed()}> - + + ) } } +const routes = [ + { + path: '/encoding-list/', + component: PageEncodingList + }, + { + path: '/delimeter-list/', + component: PageDelimeterList + } +]; + const Encoding = props => { useEffect(() => { if ( Device.phone ) f7.popup.open('.encoding-popup'); - else f7.popover.open('#encoding-popover'); + else f7.popover.open('#encoding-popover', "#btn-settings"); return () => { } }); - - const onviewclosed = () => { - if ( props.onclosed ) - props.onclosed(); - }; - - return + return ( + + ) }; export {Encoding, PageEncodingList, PageDelimeterList} \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx deleted file mode 100644 index f7d9b1084..000000000 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Encoding.jsx +++ /dev/null @@ -1,90 +0,0 @@ -import React from 'react'; -import { observer, inject } from "mobx-react"; -import { f7, Page, Navbar, List, ListItem, BlockTitle, ListButton } from "framework7-react"; -import { useTranslation } from "react-i18next"; - -const PageEncoding = props => { - const { t } = useTranslation(); - const _t = t("View.Settings", { returnObjects: true }); - const storeEncoding = props.storeEncoding; - const valueEncoding = storeEncoding.valueEncoding; - const nameDelimeter = storeEncoding.nameDelimeter; - const valueDelimeter = storeEncoding.valueDelimeter; - const nameEncoding = storeEncoding.nameEncoding; - const mode = storeEncoding.mode; - - return ( - - - {_t.textDelimeter} - - - - {_t.textEncoding} - - - - - props.onSaveFormat(mode, valueEncoding, valueDelimeter)}> - - - ) -} - -const PageEncodingList = props => { - const { t } = useTranslation(); - const _t = t("View.Settings", { returnObjects: true }); - const storeEncoding = props.storeEncoding; - const valueEncoding = storeEncoding.valueEncoding; - const pages = storeEncoding.pages; - const pagesName = storeEncoding.pagesName; - - return ( - - - {_t.textChooseEncoding} - - {pagesName.map((name, index) => { - return ( - { - storeEncoding.changeEncoding(pages[index]); - f7.views.current.router.back(); - }}> - ) - })} - - - ) -} - -const PageDelimeterList = props => { - const { t } = useTranslation(); - const _t = t("View.Settings", { returnObjects: true }); - const storeEncoding = props.storeEncoding; - const valueDelimeter = storeEncoding.valueDelimeter; - const namesDelimeter = storeEncoding.namesDelimeter; - const valuesDelimeter = storeEncoding.valuesDelimeter; - - return ( - - - {_t.textChooseDelimeter} - - {namesDelimeter.map((name, index) => { - return ( - { - storeEncoding.changeDelimeter(valuesDelimeter[index]); - f7.views.current.router.back(); - }}> - ) - })} - - - ) -} - -const Encoding = inject("storeEncoding")(observer(PageEncoding)); -const EncodingList = inject("storeEncoding")(observer(PageEncodingList)); -const DelimeterList = inject("storeEncoding")(observer(PageDelimeterList)); - -export {EncodingList, Encoding, DelimeterList} \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx index afde10636..4e5d384a6 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx @@ -12,8 +12,6 @@ import {SpreadsheetColorSchemes, SpreadsheetFormats, SpreadsheetMargins} from '. import {MacrosSettings, RegionalSettings, FormulaLanguage} from './ApplicationSettings.jsx'; // import SpreadsheetAbout from './SpreadsheetAbout.jsx'; import About from '../../../../../common/mobile/lib/view/About'; -import EncodingController from '../../controller/settings/Encoding'; -import { EncodingList, DelimeterList } from '../../view/settings/Encoding'; const routes = [ { @@ -63,19 +61,7 @@ const routes = [ { path: '/about/', component: About - }, - // { - // path: '/encoding/', - // component: EncodingController - // }, - // { - // path: '/encoding-list/', - // component: EncodingList - // }, - // { - // path: '/delimeter-list/', - // component: DelimeterList - // } + } ]; @@ -138,7 +124,6 @@ const SettingsList = inject("storeAppOptions", "storeEncoding")(observer(props = } return ( - // onClick={onoptionclick.bind(this, "/download/")} {navbar} @@ -161,7 +146,7 @@ const SettingsList = inject("storeAppOptions", "storeEncoding")(observer(props = - + From 33bf343709e70d13d4a1929f5fb7f355d29fca65 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Sat, 24 Jul 2021 01:38:54 +0300 Subject: [PATCH 09/11] [DE mobile] Changed encoding options --- apps/common/mobile/lib/store/encoding.js | 70 --------- .../mobile/src/controller/Encoding.jsx | 94 ++++++++++++ .../mobile/src/controller/Main.jsx | 17 +-- .../src/controller/settings/Download.jsx | 91 +++++------- .../src/controller/settings/Encoding.jsx | 43 ------ .../mobile/src/store/mainStore.js | 2 - .../mobile/src/view/Encoding.jsx | 136 ++++++++++++++++++ .../mobile/src/view/settings/Encoding.jsx | 57 -------- .../mobile/src/view/settings/Settings.jsx | 10 -- .../mobile/src/controller/Encoding.jsx | 1 - .../mobile/src/store/mainStore.js | 2 - .../mobile/src/view/Encoding.jsx | 3 - .../mobile/src/view/settings/Settings.jsx | 2 +- 13 files changed, 278 insertions(+), 250 deletions(-) delete mode 100644 apps/common/mobile/lib/store/encoding.js create mode 100644 apps/documenteditor/mobile/src/controller/Encoding.jsx delete mode 100644 apps/documenteditor/mobile/src/controller/settings/Encoding.jsx create mode 100644 apps/documenteditor/mobile/src/view/Encoding.jsx delete mode 100644 apps/documenteditor/mobile/src/view/settings/Encoding.jsx diff --git a/apps/common/mobile/lib/store/encoding.js b/apps/common/mobile/lib/store/encoding.js deleted file mode 100644 index 41ad838d6..000000000 --- a/apps/common/mobile/lib/store/encoding.js +++ /dev/null @@ -1,70 +0,0 @@ -import {action, observable, makeObservable} from 'mobx'; - -export class storeEncoding { - constructor() { - makeObservable(this, { - type: observable, - mode: observable, - setMode: action, - advOptions: observable, - formatOptions: observable, - pages: observable, - pagesName: observable, - initOptions: action, - valueEncoding: observable, - nameEncoding: observable, - initPages: action, - changeEncoding: action, - valueDelimeter: observable, - nameDelimeter: observable, - changeDelimeter: action, - namesDelimeter: observable, - valuesDelimeter: observable, - initNamesDelimeter: action - }); - } - - type; - mode = 1; - pages = []; - pagesName = []; - advOptions; - formatOptions; - valueEncoding; - nameEncoding; - namesDelimeter = []; - valuesDelimeter = [4, 2, 3, 1, 5]; - nameDelimeter; - valueDelimeter; - - initOptions ({type, advOptions, formatOptions}) { - this.type = type; - this.advOptions = advOptions; - this.formatOptions = formatOptions; - } - - initPages() { - for (let page of this.advOptions.asc_getCodePages()) { - this.pages.push(page.asc_getCodePage()); - this.pagesName.push(page.asc_getCodePageName()); - } - } - - initNamesDelimeter(names) { - this.namesDelimeter = names; - } - - setMode(value) { - this.mode = value; - } - - changeEncoding(value) { - this.nameEncoding = this.pagesName[this.pages.indexOf(value)]; - this.valueEncoding = value; - } - - changeDelimeter(value) { - this.nameDelimeter = this.namesDelimeter[this.valuesDelimeter.indexOf(value)]; - this.valueDelimeter = value; - } -} diff --git a/apps/documenteditor/mobile/src/controller/Encoding.jsx b/apps/documenteditor/mobile/src/controller/Encoding.jsx new file mode 100644 index 000000000..87c4c434f --- /dev/null +++ b/apps/documenteditor/mobile/src/controller/Encoding.jsx @@ -0,0 +1,94 @@ +import React, { Component } from 'react'; +import { Device } from '../../../../common/mobile/utils/device'; +import { f7 } from "framework7-react"; +import { Encoding } from "../view/Encoding"; + +class EncodingController extends Component { + constructor(props) { + super(props); + + this.onSaveFormat = this.onSaveFormat.bind(this); + this.closeModal = this.closeModal.bind(this); + this.state = { + isOpen: false + }; + + Common.Notifications.on('engineCreated', api => { + api.asc_registerCallback('asc_onAdvancedOptions', (type, advOptions, mode, formatOptions) => { + this.initEncoding(type, advOptions, mode, formatOptions); + }); + }); + + Common.Notifications.on('openEncoding', (type, advOptions, mode, formatOptions) => { + this.initEncoding(type, advOptions, mode, formatOptions); + }); + } + + initEncoding(type, advOptions, mode, formatOptions) { + if(type === Asc.c_oAscAdvancedOptionsID.CSV) { + Common.Notifications.trigger('preloader:close'); + Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); + + this.mode = mode; + this.advOptions = advOptions; + this.formatOptions = formatOptions; + this.pages = []; + this.pagesName = []; + + const recommendedSettings = this.advOptions.asc_getRecommendedSettings(); + + this.initPages(); + this.valueEncoding = recommendedSettings.asc_getCodePage(); + + this.setState({ + isOpen: true + }); + } + } + + initPages() { + for (let page of this.advOptions.asc_getCodePages()) { + this.pages.push(page.asc_getCodePage()); + this.pagesName.push(page.asc_getCodePageName()); + } + } + + closeModal() { + if (Device.phone) { + f7.sheet.close('.encoding-popup', true); + } else { + f7.popover.close('#encoding-popover'); + } + + this.setState({isOpen: false}); + } + + onSaveFormat(valueEncoding) { + const api = Common.EditorApi.get(); + + this.closeModal(); + + if(this.mode === 2) { + this.formatOptions && this.formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding)); + api.asc_DownloadAs(this.formatOptions); + } else { + api.asc_setAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, new Asc.asc_CTextOptions(valueEncoding)); + } + } + + render() { + return ( + this.state.isOpen && + + ); + } +} + +export default EncodingController; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 9ead45870..fdd3dd364 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -16,7 +16,7 @@ import EditorUIController from '../lib/patch'; import ErrorController from "./Error"; import LongActionsController from "./LongActions"; import PluginsController from '../../../../common/mobile/lib/controller/Plugins.jsx'; - +import EncodingController from "./Encoding"; @inject( "storeAppOptions", "storeDocumentSettings", @@ -26,9 +26,8 @@ import PluginsController from '../../../../common/mobile/lib/controller/Plugins. "storeTableSettings", "storeDocumentInfo", "storeChartSettings", - "storeApplicationSettings", - "storeEncoding" - ) + "storeApplicationSettings" +) class MainController extends Component { constructor(props) { super(props); @@ -608,14 +607,15 @@ 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, storeEncoding); - if(type == Asc.c_oAscAdvancedOptionsID.DRM) this.isDRM = true; + if(type == Asc.c_oAscAdvancedOptionsID.DRM) { + onAdvancedOptions(type, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose, this.isDRM); + this.isDRM = true; + } }); } @@ -821,6 +821,7 @@ class MainController extends Component { {EditorUIController.getEditCommentControllers && EditorUIController.getEditCommentControllers()} + ) } diff --git a/apps/documenteditor/mobile/src/controller/settings/Download.jsx b/apps/documenteditor/mobile/src/controller/settings/Download.jsx index a5e693525..c4b4182db 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Download.jsx @@ -13,7 +13,7 @@ class DownloadController extends Component { closeModal() { if (Device.phone) { - f7.sheet.close('.settings-popup', true); + f7.sheet.close('.settings-popup', false); } else { f7.popover.close('#settings-popover'); } @@ -31,11 +31,10 @@ 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.closeModal(); + Common.Notifications.trigger('openEncoding', Asc.c_oAscAdvancedOptionsID.TXT, advOptions, 2, new Asc.asc_CDownloadOptions(format)); - onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.TXT, advOptions, 2, new Asc.asc_CDownloadOptions(format), _t, true, canRequestClose, false, storeEncoding); } else { this.closeModal(); @@ -62,67 +61,53 @@ class DownloadController extends Component { } } -const DownloadWithTranslation = inject("storeAppOptions", "storeEncoding")(observer(withTranslation()(DownloadController))); +const DownloadWithTranslation = inject("storeAppOptions")(observer(withTranslation()(DownloadController))); -const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady, canRequestClose, isDRM, storeEncoding) => { +const onAdvancedOptions = (type, _t, isDocReady, canRequestClose, isDRM) => { if ($$('.dlg-adv-options.modal-in').length > 0) return; const api = Common.EditorApi.get(); - 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(); + Common.Notifications.trigger('preloader:close'); + Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); - 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 = [{ - text: 'OK', - bold: true, - onClick: function () { - const password = document.getElementById('modal-password').value; - api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(password)); - if (!isDocReady) { - Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); - } + const buttons = [{ + text: 'OK', + bold: true, + onClick: function () { + const password = document.getElementById('modal-password').value; + api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(password)); + if (!isDocReady) { + Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); } - }]; - - if(isDRM) { - f7.dialog.create({ - text: _t.txtIncorrectPwd, - buttons : [{ - text: 'OK', - bold: true, - }] - }).open(); } + }]; - if (canRequestClose) - buttons.push({ - text: _t.closeButtonText, - onClick: function () { - Common.Gateway.requestClose(); - } - }); + if(isDRM) { f7.dialog.create({ - title: _t.advDRMOptions, - text: _t.textOpenFile, - content: Device.ios ? - '
' : '
', - buttons: buttons, - cssClass: 'dlg-adv-options' + text: _t.txtIncorrectPwd, + buttons : [{ + text: 'OK', + bold: true, + }] }).open(); } + + if (canRequestClose) + buttons.push({ + text: _t.closeButtonText, + onClick: function () { + Common.Gateway.requestClose(); + } + }); + f7.dialog.create({ + title: _t.advDRMOptions, + text: _t.textOpenFile, + content: Device.ios ? + '
' : '
', + buttons: buttons, + cssClass: 'dlg-adv-options' + }).open(); }; diff --git a/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx b/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx deleted file mode 100644 index a86ecb784..000000000 --- a/apps/documenteditor/mobile/src/controller/settings/Encoding.jsx +++ /dev/null @@ -1,43 +0,0 @@ -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) { - super(props); - this.onSaveFormat = this.onSaveFormat.bind(this); - } - - closeModal() { - if (Device.phone) { - f7.sheet.close('.settings-popup', true); - } else { - f7.popover.close('#settings-popover'); - } - } - - onSaveFormat(mode, valueEncoding) { - const api = Common.EditorApi.get(); - - this.closeModal(); - - 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() { - return ( - - ); - } -} - -export default inject("storeEncoding")(observer(EncodingController)); \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/store/mainStore.js b/apps/documenteditor/mobile/src/store/mainStore.js index c880e30c2..57fa6ee88 100644 --- a/apps/documenteditor/mobile/src/store/mainStore.js +++ b/apps/documenteditor/mobile/src/store/mainStore.js @@ -10,7 +10,6 @@ import {storeTableSettings} from "./tableSettings"; import {storeChartSettings} from "./chartSettings"; import {storeDocumentInfo} from "./documentInfo"; import {storeApplicationSettings} from './applicationSettings'; -import {storeEncoding} from "../../../../common/mobile/lib/store/encoding"; import {storeAppOptions} from "./appOptions"; import {storePalette} from "./palette"; import {storeReview} from "./review"; @@ -21,7 +20,6 @@ export const stores = { storeFocusObjects: new storeFocusObjects(), storeDocumentSettings: new storeDocumentSettings(), users: new storeUsers(), - storeEncoding: new storeEncoding(), storeTextSettings: new storeTextSettings(), storeParagraphSettings: new storeParagraphSettings(), storeShapeSettings: new storeShapeSettings(), diff --git a/apps/documenteditor/mobile/src/view/Encoding.jsx b/apps/documenteditor/mobile/src/view/Encoding.jsx new file mode 100644 index 000000000..2898bc53d --- /dev/null +++ b/apps/documenteditor/mobile/src/view/Encoding.jsx @@ -0,0 +1,136 @@ +import React, {Component, useEffect, useState} from 'react'; +import { f7, Page, Navbar, List, ListItem, BlockTitle, ListButton, Popover, Popup, View, Link } from "framework7-react"; +import { useTranslation } from "react-i18next"; +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 [stateEncoding, setStateEncoding] = useState(props.valueEncoding); + const nameEncoding = pagesName[pages.indexOf(stateEncoding)]; + const mode = props.mode; + + const changeStateEncoding = value => { + setStateEncoding(value); + } + + return ( + + + + {_t.textEncoding} + + + + + {mode === 2 ? + props.closeModal()}> + : null} + props.onSaveFormat(stateEncoding)}> + + + + + ) +}; + +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; + + return ( + + + {_t.textChooseEncoding} + + {pagesName.map((name, index) => { + return ( + { + changeCurrentEncoding(pages[index]); + props.changeStateEncoding(pages[index]); + f7.views.current.router.back(); + }}> + ) + })} + + + ) +}; + +class EncodingView extends Component { + constructor(props) { + super(props); + } + + render() { + const show_popover = this.props.usePopover; + + return ( + show_popover ? + + + : + + + + ) + } +} + +const routes = [ + { + path: '/encoding-list/', + component: PageEncodingList + } +]; + +const Encoding = props => { + useEffect(() => { + if ( Device.phone ) + f7.popup.open('.encoding-popup'); + else f7.popover.open('#encoding-popover', "#btn-settings"); + + return () => { + } + }); + + return ( + + ) +}; + +export {Encoding, PageEncodingList} \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/settings/Encoding.jsx b/apps/documenteditor/mobile/src/view/settings/Encoding.jsx deleted file mode 100644 index 9b5d9740d..000000000 --- a/apps/documenteditor/mobile/src/view/settings/Encoding.jsx +++ /dev/null @@ -1,57 +0,0 @@ -import React from 'react'; -import { observer, inject } from "mobx-react"; -import { f7, Page, Navbar, List, ListItem, BlockTitle, ListButton } from "framework7-react"; -import { useTranslation } from "react-i18next"; - -const PageEncoding = props => { - const { t } = useTranslation(); - const _t = t("Settings", { returnObjects: true }); - const storeEncoding = props.storeEncoding; - const valueEncoding= storeEncoding.valueEncoding; - const nameEncoding = storeEncoding.nameEncoding; - const mode = storeEncoding.mode; - - return ( - - - {_t.textEncoding} - - - - - props.onSaveFormat(mode, valueEncoding)}> - - - ) -} - -const PageEncodingList = props => { - const { t } = useTranslation(); - const _t = t("Settings", { returnObjects: true }); - const storeEncoding = props.storeEncoding; - const valueEncoding = storeEncoding.valueEncoding; - const pages = storeEncoding.pages; - const pagesName = storeEncoding.pagesName; - - return ( - - - {_t.textChooseEncoding} - - {pagesName.map((name, index) => { - return ( - { - storeEncoding.changeEncoding(pages[index]); - f7.views.current.router.back(); - }}> - ) - })} - - - ) -} - -const Encoding = inject("storeEncoding")(observer(PageEncoding)); -const EncodingList = inject("storeEncoding")(observer(PageEncodingList)); - -export {EncodingList, Encoding} \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/settings/Settings.jsx b/apps/documenteditor/mobile/src/view/settings/Settings.jsx index 48a930fcb..93f40c4aa 100644 --- a/apps/documenteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/documenteditor/mobile/src/view/settings/Settings.jsx @@ -12,8 +12,6 @@ import ApplicationSettingsController from "../../controller/settings/Application import { DocumentFormats, DocumentMargins, DocumentColorSchemes } from "./DocumentSettings"; import { MacrosSettings } from "./ApplicationSettings"; import About from '../../../../../common/mobile/lib/view/About'; -import EncodingController from '../../controller/settings/Encoding'; -import { EncodingList } from '../../view/settings/Encoding'; const routes = [ { @@ -55,14 +53,6 @@ const routes = [ { path: '/about/', component: About - }, - { - path: '/encoding/', - component: EncodingController - }, - { - path: '/encoding-list/', - component: EncodingList } ]; diff --git a/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx b/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx index 9dfa3ae64..068a9f563 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Encoding.jsx @@ -89,7 +89,6 @@ class EncodingController extends Component { { closeModal={props.closeModal} onSaveFormat={props.onSaveFormat} mode={props.mode} - formatOptions={props.formatOptions} pages={props.pages} pagesName={props.pagesName} namesDelimeter={props.namesDelimeter} diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx index 4e5d384a6..2a0e42c8e 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx @@ -65,7 +65,7 @@ const routes = [ ]; -const SettingsList = inject("storeAppOptions", "storeEncoding")(observer(props => { +const SettingsList = inject("storeAppOptions")(observer(props => { const { t } = useTranslation(); const _t = t('View.Settings', {returnObjects: true}); const navbar = From 735228e51d6e32076c778f6abc4bddb4f982e409 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Mon, 26 Jul 2021 17:58:28 +0300 Subject: [PATCH 10/11] [DE SSE mobile] Correct encoding options --- .../mobile/src/controller/Encoding.jsx | 11 ++-- .../src/controller/settings/Download.jsx | 5 +- .../mobile/src/view/Encoding.jsx | 50 ++++++----------- .../mobile/src/controller/Encoding.jsx | 7 +-- .../mobile/src/store/applicationSettings.js | 2 +- .../mobile/src/view/Encoding.jsx | 53 ++++++------------- 6 files changed, 39 insertions(+), 89 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/Encoding.jsx b/apps/documenteditor/mobile/src/controller/Encoding.jsx index 87c4c434f..100819aba 100644 --- a/apps/documenteditor/mobile/src/controller/Encoding.jsx +++ b/apps/documenteditor/mobile/src/controller/Encoding.jsx @@ -6,7 +6,7 @@ import { Encoding } from "../view/Encoding"; class EncodingController extends Component { constructor(props) { super(props); - + this.onSaveFormat = this.onSaveFormat.bind(this); this.closeModal = this.closeModal.bind(this); this.state = { @@ -25,7 +25,7 @@ class EncodingController extends Component { } initEncoding(type, advOptions, mode, formatOptions) { - if(type === Asc.c_oAscAdvancedOptionsID.CSV) { + if(type === Asc.c_oAscAdvancedOptionsID.TXT) { Common.Notifications.trigger('preloader:close'); Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256, true); @@ -54,12 +54,7 @@ class EncodingController extends Component { } closeModal() { - if (Device.phone) { - f7.sheet.close('.encoding-popup', true); - } else { - f7.popover.close('#encoding-popover'); - } - + f7.sheet.close('.encoding-popup', true); this.setState({isOpen: false}); } diff --git a/apps/documenteditor/mobile/src/controller/settings/Download.jsx b/apps/documenteditor/mobile/src/controller/settings/Download.jsx index c4b4182db..ba1df754d 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Download.jsx @@ -30,11 +30,10 @@ class DownloadController extends Component { (format === Asc.c_oAscFileType.TXT) ? _t.textDownloadTxt : _t.textDownloadRtf, _t.notcriticalErrorTitle, () => { - if (format == Asc.c_oAscFileType.TXT) { + if (format === Asc.c_oAscFileType.TXT) { const advOptions = api.asc_getAdvancedOptions(); this.closeModal(); - Common.Notifications.trigger('openEncoding', Asc.c_oAscAdvancedOptionsID.TXT, advOptions, 2, new Asc.asc_CDownloadOptions(format)); - + Common.Notifications.trigger('openEncoding', Asc.c_oAscAdvancedOptionsID.TXT, advOptions, 2, new Asc.asc_CDownloadOptions(format)); } else { this.closeModal(); diff --git a/apps/documenteditor/mobile/src/view/Encoding.jsx b/apps/documenteditor/mobile/src/view/Encoding.jsx index 2898bc53d..3911a2d85 100644 --- a/apps/documenteditor/mobile/src/view/Encoding.jsx +++ b/apps/documenteditor/mobile/src/view/Encoding.jsx @@ -5,7 +5,7 @@ import { Device } from '../../../../common/mobile/utils/device'; const PageEncoding = props => { const { t } = useTranslation(); - const _t = t("View.Settings", { returnObjects: true }); + const _t = t("Settings", { returnObjects: true }); const pagesName = props.pagesName; const pages = props.pages; const [stateEncoding, setStateEncoding] = useState(props.valueEncoding); @@ -19,7 +19,7 @@ const PageEncoding = props => { return ( - + {_t.textEncoding} { const PageEncodingList = props => { const { t } = useTranslation(); - const _t = t("View.Settings", { returnObjects: true }); + const _t = t("Settings", { returnObjects: true }); const [currentEncoding, changeCurrentEncoding] = useState(props.stateEncoding); const pages = props.pages; const pagesName = props.pagesName; return ( - + {_t.textChooseEncoding} {pagesName.map((name, index) => { @@ -73,32 +73,17 @@ class EncodingView extends Component { } render() { - const show_popover = this.props.usePopover; - return ( - show_popover ? - - - : - - - + + + ) } } @@ -112,17 +97,14 @@ const routes = [ const Encoding = props => { useEffect(() => { - if ( Device.phone ) - f7.popup.open('.encoding-popup'); - else f7.popover.open('#encoding-popover', "#btn-settings"); - + f7.popup.open('.encoding-popup'); + return () => { } }); return ( - -
: - - - + + + ) } } @@ -165,17 +147,14 @@ const routes = [ const Encoding = props => { useEffect(() => { - if ( Device.phone ) - f7.popup.open('.encoding-popup'); - else f7.popover.open('#encoding-popover', "#btn-settings"); - + f7.popup.open('.encoding-popup'); + return () => { } }); return ( - Date: Mon, 26 Jul 2021 19:15:18 +0300 Subject: [PATCH 11/11] [DE mobile] Corrected save format --- apps/documenteditor/mobile/src/controller/Encoding.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/documenteditor/mobile/src/controller/Encoding.jsx b/apps/documenteditor/mobile/src/controller/Encoding.jsx index 100819aba..52ad79181 100644 --- a/apps/documenteditor/mobile/src/controller/Encoding.jsx +++ b/apps/documenteditor/mobile/src/controller/Encoding.jsx @@ -67,7 +67,7 @@ class EncodingController extends Component { this.formatOptions && this.formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(valueEncoding)); api.asc_DownloadAs(this.formatOptions); } else { - api.asc_setAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, new Asc.asc_CTextOptions(valueEncoding)); + api.asc_setAdvancedOptions(Asc.c_oAscAdvancedOptionsID.TXT, new Asc.asc_CTextOptions(valueEncoding)); } }