[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();
// let state = value === '1' ? true : false;
// 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);
}
@ -57,6 +55,11 @@ class ApplicationSettingsController extends Component {
// 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() {
return (
<ApplicationSettings
@ -65,7 +68,8 @@ class ApplicationSettingsController extends Component {
switchNoCharacters={this.switchNoCharacters}
switchShowTableEmptyLine={this.switchShowTableEmptyLine}
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 isResolvedComments = true;
@action changeUnitMeasurement(value) {
value = (value !== null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric();
console.log(value);
@observable isDisabledAllMacros = false;
@observable isShowNotification = true;
@observable isEnabledAllMacros = false;
@action changeUnitMeasurement(value) {
value = (value !== null) ? +value : Common.Utils.Metric.getDefaultMetric();
if(value === Common.Utils.Metric.c_MetricUnits.inch) {
this.isActiveUnitCentimeter = false;
this.isActiveUnitPoint = false;
@ -36,27 +39,40 @@ export class storeApplicationSettings {
@action changeSpellCheck(value) {
this.isSpellChecking = value;
console.log(this.isSpellChecking);
}
@action changeNoCharacters(value) {
this.isNonprintingCharacters = value;
console.log(this.isNonprintingCharacters);
}
@action changeShowTableEmptyLine(value) {
this.isHiddenTableBorders = value;
console.log(this.isHiddenTableBorders);
}
@action changeDisplayComments(value) {
this.isComments = value;
if (!value) this.changeDisplayResolved(value);
console.log(this.isComments);
}
@action changeDisplayResolved(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 { Page, Navbar, List, ListItem, BlockTitle, Toggle } from "framework7-react";
import { useTranslation } from "react-i18next";
const PageApplicationSettings = (props) => {
const PageApplicationSettings = props => {
const { t } = useTranslation();
const _t = t("Settings", { returnObjects: true });
const store = props.storeApplicationSettings;
@ -16,19 +16,22 @@ const PageApplicationSettings = (props) => {
const isComments = store.isComments;
const isResolvedComments = store.isResolvedComments;
const changeMeasure = (e) => {
store.changeUnitMeasurement(e.target.value);
props.setUnitMeasurement(e.target.value);
}
const changeMeasureSettings = value => {
store.changeUnitMeasurement(value);
props.setUnitMeasurement(value);
};
return (
<Page>
<Navbar title={_t.textApplicationSettings} backLink={_t.textBack} />
<BlockTitle>{_t.textUnitOfMeasurement}</BlockTitle>
<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.textPoint} value="1" name="unit-of-measurement" checked={isActiveUnitPoint} onChange={changeMeasure}></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.textCentimeter} value="0" name="unit-of-measurement" checked={isActiveUnitCentimeter}
onChange={e => changeMeasureSettings(e.target.value)}></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>
<ListItem>
@ -69,7 +72,7 @@ const PageApplicationSettings = (props) => {
onChange={() => {
store.changeDisplayComments(!isComments);
props.switchDisplayComments(!isComments);
}}
}}
/>
</ListItem>
<ListItem>
@ -83,27 +86,41 @@ const PageApplicationSettings = (props) => {
</ListItem>
</List>
<List mediaList>
<ListItem title={_t.textMacrosSettings} link="/macros-settings/"></ListItem>
<ListItem title={_t.textMacrosSettings} link="/macros-settings/" routeProps={{
setMacrosSettings: props.setMacrosSettings
}}></ListItem>
</List>
</Page>
);
};
const PageMacrosSettings = () => {
const PageMacrosSettings = props => {
const { t } = useTranslation();
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 (
<Page>
<Navbar title={_t.textMacrosSettings} backLink={_t.textBack} />
<List mediaList>
<ListItem radio name="demo-media-radio" value="1" title={_t.textDisableAll} text={_t.textDisableAllMacrosWithoutNotification}></ListItem>
<ListItem radio defaultChecked name="demo-media-radio" value="2" title={_t.textShowNotification} text={_t.textDisableAllMacrosWithNotification}></ListItem>
<ListItem radio name="demo-media-radio" value="3" title={_t.textEnableAll} text={_t.textEnableAllMacrosWithoutNotification}></ListItem>
<ListItem radio name="macros-settings" value="2" title={_t.textDisableAll} text={_t.textDisableAllMacrosWithoutNotification}
checked={isDisabledAllMacros} onChange={e => changeMacros(e.target.value)}></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>
</Page>
)
}
);
};
const ApplicationSettings = inject("storeApplicationSettings")(observer(PageApplicationSettings));
const MacrosSettings = inject("storeApplicationSettings")(observer(PageMacrosSettings));

View file

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