[DE mobile] Maked Application Settings

This commit is contained in:
SergeyEzhin 2020-11-28 00:17:03 +03:00
parent 6ee68be089
commit bde5266a8d
4 changed files with 66 additions and 29 deletions

View file

@ -18,8 +18,6 @@ class ApplicationSettingsController extends Component {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
// let state = value === '1' ? true : false; // let state = value === '1' ? true : false;
// Common.localStorage.setItem("de-mobile-spellcheck", value ? 1 : 0); // Common.localStorage.setItem("de-mobile-spellcheck", value ? 1 : 0);
// Common.Utils.InternalSettings.set("de-mobile-spellcheck", value);
Common.Utils.InternalSettings.set("de-mobile-spellcheck", value);
api.asc_setSpellCheck(value); api.asc_setSpellCheck(value);
} }
@ -57,6 +55,11 @@ class ApplicationSettingsController extends Component {
// Common.localStorage.setBool("de-settings-resolvedcomment", value); // Common.localStorage.setBool("de-settings-resolvedcomment", value);
} }
setMacrosSettings(value) {
Common.Utils.InternalSettings.set("de-mobile-macros-mode", +value);
// Common.localStorage.setItem("de-mobile-macros-mode", +value);
}
render() { render() {
return ( return (
<ApplicationSettings <ApplicationSettings
@ -65,7 +68,8 @@ class ApplicationSettingsController extends Component {
switchNoCharacters={this.switchNoCharacters} switchNoCharacters={this.switchNoCharacters}
switchShowTableEmptyLine={this.switchShowTableEmptyLine} switchShowTableEmptyLine={this.switchShowTableEmptyLine}
switchDisplayComments={this.switchDisplayComments} switchDisplayComments={this.switchDisplayComments}
switchDisplayResolved={this.switchDisplayResolved} switchDisplayResolved={this.switchDisplayResolved}
setMacrosSettings={this.setMacrosSettings}
/> />
) )
} }

View file

@ -13,10 +13,13 @@ export class storeApplicationSettings {
@observable isComments = true; @observable isComments = true;
@observable isResolvedComments = true; @observable isResolvedComments = true;
@action changeUnitMeasurement(value) { @observable isDisabledAllMacros = false;
value = (value !== null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); @observable isShowNotification = true;
console.log(value); @observable isEnabledAllMacros = false;
@action changeUnitMeasurement(value) {
value = (value !== null) ? +value : Common.Utils.Metric.getDefaultMetric();
if(value === Common.Utils.Metric.c_MetricUnits.inch) { if(value === Common.Utils.Metric.c_MetricUnits.inch) {
this.isActiveUnitCentimeter = false; this.isActiveUnitCentimeter = false;
this.isActiveUnitPoint = false; this.isActiveUnitPoint = false;
@ -36,27 +39,40 @@ export class storeApplicationSettings {
@action changeSpellCheck(value) { @action changeSpellCheck(value) {
this.isSpellChecking = value; this.isSpellChecking = value;
console.log(this.isSpellChecking);
} }
@action changeNoCharacters(value) { @action changeNoCharacters(value) {
this.isNonprintingCharacters = value; this.isNonprintingCharacters = value;
console.log(this.isNonprintingCharacters);
} }
@action changeShowTableEmptyLine(value) { @action changeShowTableEmptyLine(value) {
this.isHiddenTableBorders = value; this.isHiddenTableBorders = value;
console.log(this.isHiddenTableBorders);
} }
@action changeDisplayComments(value) { @action changeDisplayComments(value) {
this.isComments = value; this.isComments = value;
if (!value) this.changeDisplayResolved(value); if (!value) this.changeDisplayResolved(value);
console.log(this.isComments);
} }
@action changeDisplayResolved(value) { @action changeDisplayResolved(value) {
this.isResolvedComments = value; this.isResolvedComments = value;
console.log(this.isResolvedComments); }
@action changeMacrosSettings(value) {
if(+value === 2) {
this.isDisabledAllMacros = true;
this.isShowNotification = false;
this.isEnabledAllMacros = false;
}
else if(+value === 1) {
this.isDisabledAllMacros = false;
this.isShowNotification = false;
this.isEnabledAllMacros = true;
}
else {
this.isDisabledAllMacros = false;
this.isShowNotification = true;
this.isEnabledAllMacros = false;
}
} }
} }

View file

@ -1,9 +1,9 @@
import React, {Fragment} from "react"; import React from "react";
import { observer, inject } from "mobx-react"; import { observer, inject } from "mobx-react";
import { Page, Navbar, List, ListItem, BlockTitle, Toggle } from "framework7-react"; import { Page, Navbar, List, ListItem, BlockTitle, Toggle } from "framework7-react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
const PageApplicationSettings = (props) => { const PageApplicationSettings = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t("Settings", { returnObjects: true }); const _t = t("Settings", { returnObjects: true });
const store = props.storeApplicationSettings; const store = props.storeApplicationSettings;
@ -16,19 +16,22 @@ const PageApplicationSettings = (props) => {
const isComments = store.isComments; const isComments = store.isComments;
const isResolvedComments = store.isResolvedComments; const isResolvedComments = store.isResolvedComments;
const changeMeasure = (e) => { const changeMeasureSettings = value => {
store.changeUnitMeasurement(e.target.value); store.changeUnitMeasurement(value);
props.setUnitMeasurement(e.target.value); props.setUnitMeasurement(value);
} };
return ( return (
<Page> <Page>
<Navbar title={_t.textApplicationSettings} backLink={_t.textBack} /> <Navbar title={_t.textApplicationSettings} backLink={_t.textBack} />
<BlockTitle>{_t.textUnitOfMeasurement}</BlockTitle> <BlockTitle>{_t.textUnitOfMeasurement}</BlockTitle>
<List> <List>
<ListItem radio radioIcon="end" title={_t.textCentimeter} value="0" name="unit-of-measurement" checked={isActiveUnitCentimeter} onChange={changeMeasure}></ListItem> <ListItem radio radioIcon="end" title={_t.textCentimeter} value="0" name="unit-of-measurement" checked={isActiveUnitCentimeter}
<ListItem radio radioIcon="end" title={_t.textPoint} value="1" name="unit-of-measurement" checked={isActiveUnitPoint} onChange={changeMeasure}></ListItem> onChange={e => changeMeasureSettings(e.target.value)}></ListItem>
<ListItem radio radioIcon="end" title={_t.textInch} value="2" name="unit-of-measurement" checked={isActiveUnitInch} onChange={changeMeasure}></ListItem> <ListItem radio radioIcon="end" title={_t.textPoint} value="1" name="unit-of-measurement" checked={isActiveUnitPoint}
onChange={e => changeMeasureSettings(e.target.value)}></ListItem>
<ListItem radio radioIcon="end" title={_t.textInch} value="2" name="unit-of-measurement" checked={isActiveUnitInch}
onChange={e => changeMeasureSettings(e.target.value)}></ListItem>
</List> </List>
<List> <List>
<ListItem> <ListItem>
@ -69,7 +72,7 @@ const PageApplicationSettings = (props) => {
onChange={() => { onChange={() => {
store.changeDisplayComments(!isComments); store.changeDisplayComments(!isComments);
props.switchDisplayComments(!isComments); props.switchDisplayComments(!isComments);
}} }}
/> />
</ListItem> </ListItem>
<ListItem> <ListItem>
@ -83,27 +86,41 @@ const PageApplicationSettings = (props) => {
</ListItem> </ListItem>
</List> </List>
<List mediaList> <List mediaList>
<ListItem title={_t.textMacrosSettings} link="/macros-settings/"></ListItem> <ListItem title={_t.textMacrosSettings} link="/macros-settings/" routeProps={{
setMacrosSettings: props.setMacrosSettings
}}></ListItem>
</List> </List>
</Page> </Page>
); );
}; };
const PageMacrosSettings = () => { const PageMacrosSettings = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t("Settings", { returnObjects: true }); const _t = t("Settings", { returnObjects: true });
const store = props.storeApplicationSettings;
const isDisabledAllMacros = store.isDisabledAllMacros;
const isShowNotification = store.isShowNotification;
const isEnabledAllMacros = store.isEnabledAllMacros;
const changeMacros = value => {
store.changeMacrosSettings(value);
props.setMacrosSettings(value);
};
return ( return (
<Page> <Page>
<Navbar title={_t.textMacrosSettings} backLink={_t.textBack} /> <Navbar title={_t.textMacrosSettings} backLink={_t.textBack} />
<List mediaList> <List mediaList>
<ListItem radio name="demo-media-radio" value="1" title={_t.textDisableAll} text={_t.textDisableAllMacrosWithoutNotification}></ListItem> <ListItem radio name="macros-settings" value="2" title={_t.textDisableAll} text={_t.textDisableAllMacrosWithoutNotification}
<ListItem radio defaultChecked name="demo-media-radio" value="2" title={_t.textShowNotification} text={_t.textDisableAllMacrosWithNotification}></ListItem> checked={isDisabledAllMacros} onChange={e => changeMacros(e.target.value)}></ListItem>
<ListItem radio name="demo-media-radio" value="3" title={_t.textEnableAll} text={_t.textEnableAllMacrosWithoutNotification}></ListItem> <ListItem radio name="macros-settings" value="0" title={_t.textShowNotification} text={_t.textDisableAllMacrosWithNotification}
checked={isShowNotification} onChange={e => changeMacros(e.target.value)}></ListItem>
<ListItem radio name="macros-settings" value="1" title={_t.textEnableAll} text={_t.textEnableAllMacrosWithoutNotification}
checked={isEnabledAllMacros} onChange={e => changeMacros(e.target.value)}></ListItem>
</List> </List>
</Page> </Page>
) );
} };
const ApplicationSettings = inject("storeApplicationSettings")(observer(PageApplicationSettings)); const ApplicationSettings = inject("storeApplicationSettings")(observer(PageApplicationSettings));
const MacrosSettings = inject("storeApplicationSettings")(observer(PageMacrosSettings)); const MacrosSettings = inject("storeApplicationSettings")(observer(PageMacrosSettings));

View file

@ -32,7 +32,7 @@ const routes = [
component: DocumentInfoController, component: DocumentInfoController,
}, },
{ {
path: '/application-settings', path: '/application-settings/',
component: ApplicationSettingsController component: ApplicationSettingsController
}, },
{ {