From 935b7c7d570a6f578978a5e211ae9c030f97b4ec Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Tue, 23 Feb 2021 17:17:44 +0300 Subject: [PATCH] [SSE mobile] Added Application Settings without Regional Settings --- apps/spreadsheeteditor/mobile/locale/en.json | 19 +- .../settings/ApplicationSettings.jsx | 95 ++++++++++ .../mobile/src/store/applicationSettings.js | 89 +++++++++ .../mobile/src/store/mainStore.js | 3 +- .../src/view/settings/ApplicationSettings.jsx | 179 ++++++++++++++++++ .../mobile/src/view/settings/Settings.jsx | 20 +- 6 files changed, 402 insertions(+), 3 deletions(-) create mode 100644 apps/spreadsheeteditor/mobile/src/controller/settings/ApplicationSettings.jsx create mode 100644 apps/spreadsheeteditor/mobile/src/store/applicationSettings.js create mode 100644 apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index beffa0415..0f7ab8d02 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -256,7 +256,24 @@ "advDRMPassword": "Password", "closeButtonText": "Close File", "txtProtected": "Once you enter the password and open the file, the current password to the file will be reset", - "textCancel": "Cancel" + "textCancel": "Cancel", + "textUnitOfMeasurement": "Unit Of Measurement", + "textCentimeter": "Centimeter", + "textPoint": "Point", + "textInch": "Inch", + "textMacrosSettings": "Macros Settings", + "textFormulaLanguage": "Formula Language", + "textRegionalSettings": "Regional Settings", + "textCommentingDisplay": "Commenting Display", + "textComments": "Comments", + "textResolvedComments": "Resolved Comments", + "textR1C1Style": "R1C1 Reference Style", + "textDisableAll": "Disable All", + "textDisableAllMacrosWithoutNotification": "Disable all macros without a notification", + "textShowNotification": "Show Notification", + "textDisableAllMacrosWithNotification": "Disable all macros with a notification", + "textEnableAll": "Enable All", + "textEnableAllMacrosWithoutNotification": "Enable all macros without a notification" } }, "Common": { diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/ApplicationSettings.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/ApplicationSettings.jsx new file mode 100644 index 000000000..17a307311 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/controller/settings/ApplicationSettings.jsx @@ -0,0 +1,95 @@ +import React, { Component } from "react"; +import { ApplicationSettings } from "../../view/settings/ApplicationSettings"; +import {observer, inject} from "mobx-react"; + +class ApplicationSettingsController extends Component { + constructor(props) { + super(props); + this.onFormulaLangChange = this.onFormulaLangChange.bind(this); + this.initRegSettings(); + } + + initRegSettings() { + + // this.props.storeApplicationSettings.initRegSettings(); + + const info = new Asc.asc_CFormatCellsInfo(); + const api = Common.EditorApi.get(); + const regSettings = this.props.storeApplicationSettings.reqSettings; + + info.asc_setType(Asc.c_oAscNumFormatType.None); + info.asc_setSymbol(regSettings); + + let arr = api.asc_getFormatCells(info); + let text = api.asc_getLocaleExample(arr[4], 1000.01, regSettings); + + text = text + ' ' + api.asc_getLocaleExample(arr[5], Asc.cDate().getExcelDateWithTime(), regSettings); + text = text + ' ' + api.asc_getLocaleExample(arr[6], Asc.cDate().getExcelDateWithTime(), regSettings); + + this.textRegSettingsExample = text; + } + + onChangeDisplayComments(displayComments) { + const api = Common.EditorApi.get(); + + if (!displayComments) { + api.asc_hideComments(); + // Common.localStorage.setBool("sse-settings-resolvedcomment", false); + } else { + // let resolved = Common.localStorage.getBool("sse-settings-resolvedcomment"); + api.asc_showComments(displayComments); + } + + // Common.localStorage.setBool("sse-mobile-settings-livecomment", displayComments); + } + + onChangeDisplayResolved(value) { + const api = Common.EditorApi.get(); + // let displayComments = Common.localStorage.getBool("sse-mobile-settings-livecomment"); + + // if (displayComments) { + api.asc_showComments(value); + // Common.localStorage.setBool("sse-settings-resolvedcomment", resolved); + // } + } + + clickR1C1Style(checked) { + const api = Common.EditorApi.get(); + // Common.localStorage.setBool('sse-settings-r1c1', checked); + api.asc_setR1C1Mode(checked); + } + + unitMeasurementChange(value) { + value = value ? +value : Common.Utils.Metric.getDefaultMetric(); + Common.Utils.Metric.setCurrentMetric(value); + // Common.localStorage.setItem("se-mobile-settings-unit", value); + } + + onChangeMacrosSettings(value) { + Common.Utils.InternalSettings.set("sse-mobile-macros-mode", +value); + // Common.localStorage.setItem("sse-mobile-macros-mode", +value); + } + + onFormulaLangChange(value) { + // Common.localStorage.setItem("sse-settings-func-lang", value); + this.initRegSettings(); + // SSE.getController('AddFunction').onDocumentReady(); + } + + render() { + return ( + + ) + } +} + + +export default inject("storeApplicationSettings")(observer(ApplicationSettingsController)); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/store/applicationSettings.js b/apps/spreadsheeteditor/mobile/src/store/applicationSettings.js new file mode 100644 index 000000000..051a38dc8 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/store/applicationSettings.js @@ -0,0 +1,89 @@ +import {action, observable} from 'mobx'; + +export class storeApplicationSettings { + + @observable unitMeasurement = Common.Utils.Metric.getCurrentMetric(); + @observable macrosMode = 0; + @observable formulaLang = Common.Locale.currentLang || dataLang[0].value; + @observable regSettings = 0x0409; + @observable regData = []; + @observable isRefStyle = false; + @observable isComments = true; + @observable isResolvedComments = true; + + getFormulaLanguages() { + const dataLang = [ + { value: 'en', displayValue: 'English', exampleValue: ' SUM; MIN; MAX; COUNT' }, + { value: 'de', displayValue: 'Deutsch', exampleValue: ' SUMME; MIN; MAX; ANZAHL' }, + { value: 'es', displayValue: 'Spanish', exampleValue: ' SUMA; MIN; MAX; CALCULAR' }, + { value: 'fr', displayValue: 'French', exampleValue: ' SOMME; MIN; MAX; NB' }, + { value: 'it', displayValue: 'Italian', exampleValue: ' SOMMA; MIN; MAX; CONTA.NUMERI' }, + { value: 'ru', displayValue: 'Russian', exampleValue: ' СУММ; МИН; МАКС; СЧЁТ' }, + { value: 'pl', displayValue: 'Polish', exampleValue: ' SUMA; MIN; MAX; ILE.LICZB' } + ] + + return dataLang; + } + + getRegDataCodes() { + const regDataCode = [ + { value: 0x042C }, { value: 0x0402 }, { value: 0x0405 }, { value: 0x0407 }, {value: 0x0807}, { value: 0x0408 }, { value: 0x0C09 }, { value: 0x0809 }, { value: 0x0409 }, { value: 0x0C0A }, { value: 0x080A }, + { value: 0x040B }, { value: 0x040C }, { value: 0x0410 }, { value: 0x0411 }, { value: 0x0412 }, { value: 0x0426 }, { value: 0x0413 }, { value: 0x0415 }, { value: 0x0416 }, + { value: 0x0816 }, { value: 0x0419 }, { value: 0x041B }, { value: 0x0424 }, { value: 0x081D }, { value: 0x041D }, { value: 0x041F }, { value: 0x0422 }, { value: 0x042A }, { value: 0x0804 } + ]; + + return regDataCode; + } + + // @action initRegData() { + // const regDataCodes = this.getRegDataCodes(); + // regDataCodes.forEach(item => { + // let langInfo = Common.util.LanguageInfo.getLocalLanguageName(item.value); + // this.regData.push({code: item.value, displayName: langInfo[1], langName: langInfo[0]}); + // }) + // } + + // @action initRegSettings() { + // const regData = this.getRegDataCodes(); + // let value = Number(Common.localStorage.getItem('sse-settings-regional')); + + // if(!value) { + // this.regSettings = 0x0409; + // } else { + // regData.forEach(obj => { + // if(obj.value === value) { + // this.regSettings = obj.value; + // } + // }); + // } + // } + + @action changeRegSettings(value) { + this.regSettings = value; + } + + @action changeUnitMeasurement(value) { + this.unitMeasurement = +value; + } + + @action changeMacrosSettings(value) { + this.macrosMode = +value; + } + + @action changeDisplayComments(value) { + this.isComments = value; + if (!value) this.changeDisplayResolved(value); + } + + @action changeDisplayResolved(value) { + this.isResolvedComments = value; + } + + @action changeRefStyle(value) { + this.isRefStyle = value; + } + + @action changeFormulaLang(value) { + this.formulaLang = value; + } +} \ 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 ebf80f0ac..c7d17b90d 100644 --- a/apps/spreadsheeteditor/mobile/src/store/mainStore.js +++ b/apps/spreadsheeteditor/mobile/src/store/mainStore.js @@ -6,7 +6,7 @@ import {storeWorksheets} from './sheets'; import {storeFunctions} from './functions'; import {storePalette} from "./palette"; import {storeTextSettings} from "./textSettings"; -// import {storeParagraphSettings} from "./paragraphSettings"; +import {storeApplicationSettings} from "./applicationSettings"; import {storeShapeSettings} from "./shapeSettings"; import {storeCellSettings} from "./cellSettings"; // import {storeImageSettings} from "./imageSettings"; @@ -17,6 +17,7 @@ import {storeSpreadsheetSettings} from "./spreadsheetSettings"; export const stores = { storeFocusObjects: new storeFocusObjects(), storeSpreadsheetSettings: new storeSpreadsheetSettings(), + storeApplicationSettings: new storeApplicationSettings(), users: new storeUsers(), sheets: new storeWorksheets(), storeFunctions: new storeFunctions(), diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx new file mode 100644 index 000000000..fd69d7adb --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/view/settings/ApplicationSettings.jsx @@ -0,0 +1,179 @@ +import React, {Fragment} from "react"; +import { observer, inject } from "mobx-react"; +import { Page, Navbar, List, ListItem, BlockTitle, Toggle } from "framework7-react"; +import { useTranslation } from "react-i18next"; + +const PageApplicationSettings = props => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeApplicationSettings = props.storeApplicationSettings; + const unitMeasurement = storeApplicationSettings.unitMeasurement; + const formulaLang = storeApplicationSettings.formulaLang; + // const regSettings = storeApplicationSettings.regSettings; + const dataLang = storeApplicationSettings.getFormulaLanguages(); + const dataRegCodes = storeApplicationSettings.getRegDataCodes(); + const defineFormulaLang = () => dataLang.find(obj => obj.value === formulaLang); + // const defineRegSettings = () => dataRegCodes.find(obj => obj.value === regSettings); + const currentFormulaLang = defineFormulaLang(); + // const currentRegSettings = defineRegSettings(); + const textRegSettingsExample = props.textRegSettingsExample; + const isRefStyle = storeApplicationSettings.isRefStyle; + const isComments = storeApplicationSettings.isComments; + const isResolvedComments = storeApplicationSettings.isResolvedComments; + + const changeMeasureSettings = value => { + storeApplicationSettings.changeUnitMeasurement(value); + props.unitMeasurementChange(value); + }; + + // set mode + // const appOptions = props.storeAppOptions; + // const _isEdit = appOptions.isEdit; + // const _isShowMacros = (!appOptions.isDisconnected && appOptions.customization) ? appOptions.customization.macros !== false : true; + + return ( + + + {/* {_isEdit && */} + + {_t.textUnitOfMeasurement} + + changeMeasureSettings(0)}> + changeMeasureSettings(1)}> + changeMeasureSettings(2)}> + + {_t.textFormulaLanguage} + + + + + {_t.textRegionalSettings} + + + + {_t.textCommentingDisplay} + + + {_t.textComments} + { + storeApplicationSettings.changeDisplayComments(!isComments); + props.onChangeDisplayComments(!isComments); + }} + /> + + + {_t.textResolvedComments} + { + storeApplicationSettings.changeDisplayResolved(!isResolvedComments); + props.onChangeDisplayResolved(!isResolvedComments); + }} + /> + + + + + {_t.textR1C1Style} + { + storeApplicationSettings.changeRefStyle(!isRefStyle); + props.clickR1C1Style(!isRefStyle); + }} + /> + + + + {/* } */} + {/* {_isShowMacros && */} + + + + {/* } */} + + ); +}; + +const PageRegionalSettings = props => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeApplicationSettings = props.storeApplicationSettings; + + return ( + + + + ) +} + +const PageFormulaLanguage = props => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeApplicationSettings = props.storeApplicationSettings; + const formulaLang = storeApplicationSettings.formulaLang; + const dataLang = storeApplicationSettings.getFormulaLanguages(); + + return ( + + + + {dataLang.map((elem, index) => { + return ( + { + storeApplicationSettings.changeFormulaLang(elem.value); + props.onFormulaLangChange(elem.value); + }}> + + ) + })} + + + ) +} + +const PageMacrosSettings = props => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeApplicationSettings = props.storeApplicationSettings; + const macrosMode = storeApplicationSettings.macrosMode; + + const changeMacros = value => { + storeApplicationSettings.changeMacrosSettings(value); + props.onChangeMacrosSettings(value); + }; + + return ( + + + + changeMacros(2)}> + changeMacros(0)}> + changeMacros(1)}> + + + ); +}; + +const ApplicationSettings = inject("storeApplicationSettings")(observer(PageApplicationSettings)); +const MacrosSettings = inject("storeApplicationSettings")(observer(PageMacrosSettings)); +const RegionalSettings = inject("storeApplicationSettings")(observer(PageRegionalSettings)); +const FormulaLanguage = inject("storeApplicationSettings")(observer(PageFormulaLanguage)); + +export { + ApplicationSettings, + MacrosSettings, + RegionalSettings, + FormulaLanguage +}; \ 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 7b25b93cf..2d79a71e9 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx @@ -4,8 +4,10 @@ import { withTranslation } from 'react-i18next'; import {f7} from 'framework7-react'; import {Device} from '../../../../../common/mobile/utils/device'; import SpreadsheetSettingsController from '../../controller/settings/SpreadsheetSettings.jsx'; +import ApplicationSettingsController from '../../controller/settings/ApplicationSettings.jsx'; import {DownloadWithTranslation} from '../../controller/settings/Download.jsx'; import {SpreadsheetColorSchemes, SpreadsheetFormats, SpreadsheetMargins} from './SpreadsheetSettings.jsx'; +import {MacrosSettings, RegionalSettings, FormulaLanguage} from './ApplicationSettings.jsx'; const routes = [ { @@ -31,6 +33,22 @@ const routes = [ { path: '/download/', component: DownloadWithTranslation + }, + { + path: '/application-settings/', + component: ApplicationSettingsController + }, + { + path: '/macros-settings/', + component: MacrosSettings + }, + { + path: '/regional-settings/', + component: RegionalSettings + }, + { + path: '/formula-languages/', + component: FormulaLanguage } ]; @@ -94,7 +112,7 @@ const SettingsList = withTranslation()(props => { - +