From e9b359cae821f88ed0b48c215459fe847f93eee6 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Wed, 25 Nov 2020 22:27:34 +0300 Subject: [PATCH] [DE mobile] Make Application Settings --- apps/documenteditor/mobile/locale/en.json | 19 +++- .../settings/ApplicationSettings.jsx | 17 ++++ .../mobile/src/store/applicationSettings.js | 31 +++++++ .../mobile/src/store/mainStore.js | 4 +- .../src/view/settings/ApplicationSettings.jsx | 86 +++++++++++++++++++ .../mobile/src/view/settings/Settings.jsx | 12 ++- 6 files changed, 166 insertions(+), 3 deletions(-) create mode 100644 apps/documenteditor/mobile/src/controller/settings/ApplicationSettings.jsx create mode 100644 apps/documenteditor/mobile/src/store/applicationSettings.js create mode 100644 apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index cbd0bb9d2..055a7ebe9 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -29,7 +29,24 @@ "textLastModified": "Last Modified", "textApplication": "Application", "textLoading": "Loading...", - "textAuthor": "Author" + "textAuthor": "Author", + "textUnitOfMeasurement": "Unit Of Measurement", + "textCentimeter": "Centimeter", + "textPoint": "Point", + "textInch": "Inch", + "textSpellcheck": "Spell Checking", + "textNoCharacters": "Nonprinting Characters", + "textHiddenTableBorders": "Hidden Table Borders", + "textCommentsDisplay": "Comments Display", + "textComments": "Comments", + "textResolvedComments": "Resolved Comments", + "textMacrosSettings": "Macros Settings", + "textDisableAll": "Disable All", + "textDisableAllMacrosWithoutNotification": "Disable all macros without notification", + "textShowNotification": "Show Notification", + "textDisableAllMacrosWithNotification": "Disable all macros with notification", + "textEnableAll": "Enable All", + "textEnableAllMacrosWithoutNotification": "Enable all macros without notification" }, "Collaboration": { "textEditUser": "Users who are editing the file:" diff --git a/apps/documenteditor/mobile/src/controller/settings/ApplicationSettings.jsx b/apps/documenteditor/mobile/src/controller/settings/ApplicationSettings.jsx new file mode 100644 index 000000000..4f5da84f0 --- /dev/null +++ b/apps/documenteditor/mobile/src/controller/settings/ApplicationSettings.jsx @@ -0,0 +1,17 @@ +import React, { Component } from "react"; +import { ApplicationSettings } from "../../view/settings/ApplicationSettings"; + +class ApplicationSettingsController extends Component { + constructor(props) { + super(props); + } + + render() { + return ( + + ) + } +} + + +export default ApplicationSettingsController; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/store/applicationSettings.js b/apps/documenteditor/mobile/src/store/applicationSettings.js new file mode 100644 index 000000000..dfa1f6bb7 --- /dev/null +++ b/apps/documenteditor/mobile/src/store/applicationSettings.js @@ -0,0 +1,31 @@ +import {action, observable, computed} from 'mobx'; + +export class storeApplicationSettings { + @observable isActiveUnitCentimeter = false; + @observable isActiveUnitPoint = true; + @observable isActiveUnitInch = false; + + @action changeUnitMeasurement(value) { + const api = Common.EditorApi.get(); + console.log(value); + if(+value === Common.Utils.Metric.c_MetricUnits.inch) { + api.asc_SetDocumentUnits(Asc.c_oAscDocumentUnits.Inch); + this.isActiveUnitCentimeter = false; + this.isActiveUnitPoint = false; + this.isActiveUnitInch = true; + } + else if(+value === Common.Utils.Metric.c_MetricUnits.pt) { + api.asc_SetDocumentUnits(Asc.c_oAscDocumentUnits.Point); + this.isActiveUnitCentimeter = false; + this.isActiveUnitPoint = true; + this.isActiveUnitInch = false; + } + else { + api.asc_SetDocumentUnits(Asc.c_oAscDocumentUnits.Millimeter); + this.isActiveUnitCentimeter = true; + this.isActiveUnitPoint = false; + this.isActiveUnitInch = false; + } + } + +} \ 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 c6e323d75..d8dc92404 100644 --- a/apps/documenteditor/mobile/src/store/mainStore.js +++ b/apps/documenteditor/mobile/src/store/mainStore.js @@ -9,6 +9,7 @@ import {storeImageSettings} from "./imageSettings"; import {storeTableSettings} from "./tableSettings"; import {storeChartSettings} from "./chartSettings"; import {storeDocumentInfo} from "./documentInfo"; +import {storeApplicationSettings} from './applicationSettings'; export const stores = { storeFocusObjects: new storeFocusObjects(), @@ -20,6 +21,7 @@ export const stores = { storeChartSettings: new storeChartSettings(), storeImageSettings: new storeImageSettings(), storeTableSettings: new storeTableSettings(), - storeDocumentInfo: new storeDocumentInfo() + storeDocumentInfo: new storeDocumentInfo(), + storeApplicationSettings: new storeApplicationSettings() }; diff --git a/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx b/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx new file mode 100644 index 000000000..16541d292 --- /dev/null +++ b/apps/documenteditor/mobile/src/view/settings/ApplicationSettings.jsx @@ -0,0 +1,86 @@ +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("Settings", { returnObjects: true }); + const store = props.storeApplicationSettings; + const isActiveUnitCentimeter = store.isActiveUnitCentimeter; + const isActiveUnitPoint = store.isActiveUnitPoint; + const isActiveUnitInch = store.isActiveUnitInch; + // const changeUnitMeasurement = store.changeUnitMeasurement; + + // const unitMeasurementChange = e => { + // const api = Common.EditorApi.get(); + // let value = e.target.value; + // value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); + // Common.Utils.Metric.setCurrentMetric(value); + // // Common.localStorage.setItem("de-mobile-settings-unit", value); + // api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); + // } + + return ( + + + {_t.textUnitOfMeasurement} + + store.changeUnitMeasurement(e.target.value)}> + store.changeUnitMeasurement(e.target.value)}> + store.changeUnitMeasurement(e.target.value)}> + + + + {_t.textSpellcheck} + + + + + + {_t.textNoCharacters} + + + + {_t.textHiddenTableBorders} + + + + {_t.textCommentsDisplay} + + + {_t.textComments} + + + + {_t.textResolvedComments} + + + + + + + + ); +}; + +const PageMacrosSettings = () => { + const { t } = useTranslation(); + const _t = t("Settings", { returnObjects: true }); + + return ( + + + + + + + + + ) +} + +const ApplicationSettings = inject("storeApplicationSettings")(observer(PageApplicationSettings)); +const MacrosSettings = inject("storeApplicationSettings")(observer(PageMacrosSettings)); + +export {ApplicationSettings, MacrosSettings}; \ 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 4852b981f..6ff5b5cde 100644 --- a/apps/documenteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/documenteditor/mobile/src/view/settings/Settings.jsx @@ -6,7 +6,9 @@ import {Device} from '../../../../../common/mobile/utils/device'; import DocumentSettingsController from "../../controller/settings/DocumentSettings"; import DocumentInfoController from "../../controller/settings/DocumentInfo"; +import ApplicationSettingsController from "../../controller/settings/ApplicationSettings"; import { DocumentFormats, DocumentMargins } from "./DocumentSettings"; +import { MacrosSettings } from "./ApplicationSettings"; const routes = [ { @@ -28,6 +30,14 @@ const routes = [ { path: "/document-info/", component: DocumentInfoController, + }, + { + path: '/application-settings', + component: ApplicationSettingsController + }, + { + path: '/macros-settings/', + component: MacrosSettings } ]; @@ -60,7 +70,7 @@ const SettingsList = withTranslation()(props => { - +