[SSE mobile] fix according to mobx v. 6

This commit is contained in:
Maxim Kadushkin 2021-03-08 00:28:37 +03:00
parent 56c323c0e1
commit 4c38321d72
2 changed files with 110 additions and 57 deletions

View file

@ -1,15 +1,40 @@
import {action, observable} from 'mobx';
import {makeObservable, 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 regCode = undefined;
@observable regExample = '';
@observable regData = [];
@observable isRefStyle = false;
@observable isComments = true;
@observable isResolvedComments = true;
constructor() {
makeObservable(this, {
unitMeasurement: observable
, macrosMode: observable
, formulaLang: observable
, regCode: observable
, regExample: observable
, regData: observable
, isRefStyle: observable
, isComments: observable
, isResolvedComments: observable
, initRegData: action
, getRegCode: action
, changeRegCode: action
, setRegExample: action
, changeUnitMeasurement: action
, changeMacrosSettings: action
, changeDisplayComments: action
, changeDisplayResolved: action
, changeRefStyle: action
, changeFormulaLang: action
})
}
unitMeasurement = Common.Utils.Metric.getCurrentMetric();
macrosMode = 0;
formulaLang = Common.Locale.currentLang || dataLang[0].value;
regCode = undefined;
regExample = '';
regData = [];
isRefStyle = false;
isComments = true;
isResolvedComments = true;
getFormulaLanguages() {
const dataLang = [
@ -35,7 +60,7 @@ export class storeApplicationSettings {
return regDataCode;
}
@action initRegData() {
initRegData() {
const regDataCodes = this.getRegDataCodes();
regDataCodes.forEach(item => {
@ -44,7 +69,7 @@ export class storeApplicationSettings {
})
}
@action getRegCode() {
getRegCode() {
const regData = this.regData;
let value = Number(Common.localStorage.getItem('sse-settings-regional'));
@ -59,36 +84,36 @@ export class storeApplicationSettings {
}
}
@action changeRegCode(value) {
changeRegCode(value) {
this.regCode = value;
}
@action setRegExample(value) {
setRegExample(value) {
this.regExample = value;
}
@action changeUnitMeasurement(value) {
changeUnitMeasurement(value) {
this.unitMeasurement = +value;
}
@action changeMacrosSettings(value) {
changeMacrosSettings(value) {
this.macrosMode = +value;
}
@action changeDisplayComments(value) {
changeDisplayComments(value) {
this.isComments = value;
if (!value) this.changeDisplayResolved(value);
}
@action changeDisplayResolved(value) {
changeDisplayResolved(value) {
this.isResolvedComments = value;
}
@action changeRefStyle(value) {
changeRefStyle(value) {
this.isRefStyle = value;
}
@action changeFormulaLang(value) {
changeFormulaLang(value) {
this.formulaLang = value;
}
}

View file

@ -1,47 +1,78 @@
import {action, observable, computed} from 'mobx';
import {makeObservable, action, observable, computed} from 'mobx';
export class storeCellSettings {
constructor() {
makeObservable(this, {
styleSize: observable
, borderInfo: observable
, borderStyle: observable
, cellStyles: observable
, fontsArray: observable
, fontInfo: observable
, fillColor: observable
, fontColor: observable
, styleName: observable
, isBold: observable
, isItalic: observable
, isUnderline: observable
, hAlignStr: observable
, vAlignStr: observable
, isWrapText: observable
, orientationStr: observable
, initCellSettings: action
, initTextFormat: action
, initTextOrientation: action
, initFontSettings: action
, initEditorFonts: action
, initCellStyles: action
, initFontInfo: action
, changeFontColor: action
, changeFillColor: action
, changeBorderColor: action
, changeBorderSize: action
, changeBorderStyle: action
})
}
@observable styleSize = {
styleSize = {
width: 100,
height: 50
};
@observable borderInfo = {
borderInfo = {
color: '000000',
width: Asc.c_oAscBorderStyles.Medium
width: 12 // Asc.c_oAscBorderStyles.Medium
};
@observable borderStyle = 'none';
borderStyle = 'none';
@observable cellStyles = [];
@observable fontsArray = [];
@observable fontInfo = {};
cellStyles = [];
fontsArray = [];
fontInfo = {};
@observable fillColor = undefined;
@observable fontColor = undefined;
@observable styleName = undefined;
fillColor = undefined;
fontColor = undefined;
styleName = undefined;
@observable isBold = false;
@observable isItalic = false;
@observable isUnderline = false;
isBold = false;
isItalic = false;
isUnderline = false;
@observable hAlignStr = 'left';
@observable vAlignStr = 'bottom';
@observable isWrapText;
hAlignStr = 'left';
vAlignStr = 'bottom';
isWrapText;
@observable orientationStr = 'horizontal';
orientationStr = 'horizontal';
@action initCellSettings(cellInfo) {
initCellSettings(cellInfo) {
let xfs = cellInfo.asc_getXfs();
this.initFontSettings(xfs);
let color = xfs.asc_getFillColor();
// console.log(color);
let clr = color.get_auto() ? 'transparent' : this.resetColor(color);
const clr = color.get_auto() ? 'transparent' : this.resetColor(color);
this.fillColor = clr;
this.styleName = cellInfo.asc_getStyleName();
@ -51,7 +82,7 @@ export class storeCellSettings {
}
@action initTextFormat(xfs) {
initTextFormat(xfs) {
let hAlign = xfs.asc_getHorAlign();
let vAlign = xfs.asc_getVertAlign();
let isWrapText = xfs.asc_getWrapText();
@ -73,10 +104,8 @@ export class storeCellSettings {
this.isWrapText = isWrapText;
}
@action initTextOrientation(xfs) {
let textAngle = xfs.asc_getAngle();
switch(textAngle) {
initTextOrientation(xfs) {
switch( xfs.asc_getAngle() ) {
case 45: this.orientationStr = 'anglecount'; break;
case -45: this.orientationStr = 'angleclock'; break;
case 255: this.orientationStr = 'vertical'; break;
@ -86,8 +115,7 @@ export class storeCellSettings {
}
}
@action initFontSettings(xfs) {
initFontSettings(xfs) {
this.fontInfo.name = xfs.asc_getFontName();
this.fontInfo.size = xfs.asc_getFontSize();
@ -100,7 +128,7 @@ export class storeCellSettings {
this.isUnderline = xfs.asc_getFontUnderline();
}
@action initEditorFonts(fonts, select) {
initEditorFonts(fonts, select) {
let array = [];
for (let font of fonts) {
@ -117,31 +145,31 @@ export class storeCellSettings {
this.fontsArray = array;
}
@action initCellStyles(styles) {
initCellStyles(styles) {
this.cellStyles = styles;
}
@action initFontInfo(fontObj) {
initFontInfo(fontObj) {
this.fontInfo = fontObj;
}
@action changeFontColor(color) {
changeFontColor(color) {
this.fontColor = color;
}
@action changeFillColor(color) {
changeFillColor(color) {
this.fillColor = color;
}
@action changeBorderColor(color) {
changeBorderColor(color) {
this.borderInfo.color = color;
}
@action changeBorderSize(size) {
changeBorderSize(size) {
this.borderInfo.width = size;
}
@action changeBorderStyle(type) {
changeBorderStyle(type) {
this.borderStyle = type;
}