[SSE mobile] Corrected stores according to mobx v. 6

This commit is contained in:
SergeyEzhin 2021-03-15 16:39:45 +03:00
parent a556f4e196
commit 0fa56cd60b
13 changed files with 245 additions and 128 deletions

View file

@ -74,7 +74,7 @@ class SearchSettingsView extends Component {
} }
} }
@observer // @observer
class SearchView extends Component { class SearchView extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -304,4 +304,6 @@ class SearchView extends Component {
} }
} }
export {SearchView, SearchSettingsView}; const SearchViewWithObserver = observer(SearchView);
export {SearchViewWithObserver as SearchView, SearchSettingsView};

View file

@ -1,8 +1,16 @@
import {action, observable} from 'mobx'; import {action, observable, makeObservable} from 'mobx';
export class storeAppOptions { export class storeAppOptions {
constructor() {
makeObservable(this, {
setConfigOptions: action,
setPermissionOptions: action
});
}
config = {}; config = {};
@action setConfigOptions (config) {
setConfigOptions (config) {
this.config = config; this.config = config;
this.user = Common.Utils.fillUserInfo(config.user, config.lang, "Local.User"/*me.textAnonymous*/); this.user = Common.Utils.fillUserInfo(config.user, config.lang, "Local.User"/*me.textAnonymous*/);
this.isDesktopApp = config.targetApp == 'desktop'; this.isDesktopApp = config.targetApp == 'desktop';
@ -27,7 +35,8 @@ export class storeAppOptions {
this.canBack = this.canBackToFolder === true; this.canBack = this.canBackToFolder === true;
this.canPlugins = false; this.canPlugins = false;
} }
@action setPermissionOptions (document, licType, params, permissions) {
setPermissionOptions (document, licType, params, permissions) {
permissions.edit = params.asc_getRights() !== Asc.c_oRights.Edit ? false : true; permissions.edit = params.asc_getRights() !== Asc.c_oRights.Edit ? false : true;
this.canAutosave = true; this.canAutosave = true;
this.canAnalytics = params.asc_getIsAnalyticsEnable(); this.canAnalytics = params.asc_getIsAnalyticsEnable();

View file

@ -3,27 +3,26 @@ import {makeObservable, action, observable} from 'mobx';
export class storeApplicationSettings { export class storeApplicationSettings {
constructor() { constructor() {
makeObservable(this, { makeObservable(this, {
unitMeasurement: observable unitMeasurement: observable,
, macrosMode: observable macrosMode: observable,
, formulaLang: observable formulaLang: observable,
, regCode: observable regCode: observable,
, regExample: observable regExample: observable,
, regData: observable regData: observable,
, isRefStyle: observable isRefStyle: observable,
, isComments: observable isComments: observable,
, isResolvedComments: observable isResolvedComments: observable,
, initRegData: action initRegData: action,
, getRegCode: action getRegCode: action,
, changeRegCode: action changeRegCode: action,
, setRegExample: action setRegExample: action,
, changeUnitMeasurement: action changeUnitMeasurement: action,
, changeMacrosSettings: action changeMacrosSettings: action,
, changeDisplayComments: action changeDisplayComments: action,
, changeDisplayResolved: action changeDisplayResolved: action,
, changeRefStyle: action changeRefStyle: action,
, changeFormulaLang: action changeFormulaLang: action
});
})
} }
unitMeasurement = Common.Utils.Metric.getCurrentMetric(); unitMeasurement = Common.Utils.Metric.getCurrentMetric();

View file

@ -3,35 +3,35 @@ import {makeObservable, action, observable, computed} from 'mobx';
export class storeCellSettings { export class storeCellSettings {
constructor() { constructor() {
makeObservable(this, { makeObservable(this, {
styleSize: observable styleSize: observable,
, borderInfo: observable borderInfo: observable,
, borderStyle: observable borderStyle: observable,
, cellStyles: observable cellStyles: observable,
, fontsArray: observable fontsArray: observable,
, fontInfo: observable fontInfo: observable,
, fillColor: observable fillColor: observable,
, fontColor: observable fontColor: observable,
, styleName: observable styleName: observable,
, isBold: observable isBold: observable,
, isItalic: observable isItalic: observable,
, isUnderline: observable isUnderline: observable,
, hAlignStr: observable hAlignStr: observable,
, vAlignStr: observable vAlignStr: observable,
, isWrapText: observable isWrapText: observable,
, orientationStr: observable orientationStr: observable,
, initCellSettings: action initCellSettings: action,
, initTextFormat: action initTextFormat: action,
, initTextOrientation: action initTextOrientation: action,
, initFontSettings: action initFontSettings: action,
, initEditorFonts: action initEditorFonts: action,
, initCellStyles: action initCellStyles: action,
, initFontInfo: action initFontInfo: action,
, changeFontColor: action changeFontColor: action,
, changeFillColor: action changeFillColor: action,
, changeBorderColor: action changeBorderColor: action,
, changeBorderSize: action changeBorderSize: action,
, changeBorderStyle: action changeBorderStyle: action
}) });
} }
styleSize = { styleSize = {

View file

@ -1,25 +1,40 @@
import {action, observable, computed} from 'mobx'; import {action, observable, computed, makeObservable} from 'mobx';
export class storeChartSettings { export class storeChartSettings {
constructor() {
@observable borderColor = undefined; makeObservable(this, {
borderColor: observable,
fillColor: observable,
chartStyles: observable,
setBorderColor: action,
initBorderColor: action,
setFillColor: action,
getFillColor: action,
clearChartStyles: action,
updateChartStyles: action,
styles: computed,
types: computed,
});
}
borderColor = undefined;
setBorderColor (color) { setBorderColor (color) {
this.borderColor = color; this.borderColor = color;
} }
@action initBorderColor(shapeProperties) { initBorderColor(shapeProperties) {
let stroke = shapeProperties.get_stroke(); let stroke = shapeProperties.get_stroke();
this.borderColor = (stroke && stroke.get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) ? this.resetColor(stroke.get_color()) : 'transparent'; this.borderColor = (stroke && stroke.get_type() == Asc.c_oAscStrokeType.STROKE_COLOR) ? this.resetColor(stroke.get_color()) : 'transparent';
} }
@observable fillColor = undefined; fillColor = undefined;
setFillColor (color) { setFillColor (color) {
this.fillColor = color; this.fillColor = color;
} }
@action getFillColor (shapeProperties) { getFillColor (shapeProperties) {
const fill = shapeProperties.asc_getFill(); const fill = shapeProperties.asc_getFill();
const fillType = fill.asc_getType(); const fillType = fill.asc_getType();
@ -30,17 +45,17 @@ export class storeChartSettings {
return this.fillColor; return this.fillColor;
} }
@observable chartStyles = null; chartStyles = null;
@action clearChartStyles () { clearChartStyles () {
this.chartStyles = null; this.chartStyles = null;
} }
@action updateChartStyles (styles) { updateChartStyles (styles) {
this.chartStyles = styles; this.chartStyles = styles;
} }
@computed get styles () { get styles () {
if (!this.chartStyles) return null; if (!this.chartStyles) return null;
const widthContainer = document.querySelector(".page-content").clientWidth; const widthContainer = document.querySelector(".page-content").clientWidth;
const columns = parseInt(widthContainer / 70); // magic const columns = parseInt(widthContainer / 70); // magic
@ -58,7 +73,7 @@ export class storeChartSettings {
return styles; return styles;
} }
@computed get types () { get types () {
const _types = [ const _types = [
{ type: Asc.c_oAscChartTypeSettings.barNormal, thumb: 'bar-normal'}, { type: Asc.c_oAscChartTypeSettings.barNormal, thumb: 'bar-normal'},
{ type: Asc.c_oAscChartTypeSettings.barStacked, thumb: 'bar-stacked'}, { type: Asc.c_oAscChartTypeSettings.barStacked, thumb: 'bar-stacked'},

View file

@ -1,16 +1,30 @@
import {action, observable, computed} from 'mobx'; import {action, observable, computed, makeObservable} from 'mobx';
export class storeFocusObjects { export class storeFocusObjects {
@observable focusOn = undefined; constructor() {
makeObservable(this, {
focusOn: observable,
_focusObjects: observable,
_cellInfo: observable,
resetFocusObjects: action,
objects: computed,
resetCellInfo: action,
selections: computed,
shapeObject: computed,
imageObject: computed,
chartObject: computed
});
}
@observable _focusObjects = []; focusOn = undefined;
_focusObjects = [];
@action resetFocusObjects(objects) { resetFocusObjects(objects) {
this.focusOn = 'obj'; this.focusOn = 'obj';
this._focusObjects = objects; this._focusObjects = objects;
} }
@computed get objects() { get objects() {
const _objects = []; const _objects = [];
for (let object of this._focusObjects) { for (let object of this._focusObjects) {
const type = object.get_ObjectType(); const type = object.get_ObjectType();
@ -39,14 +53,14 @@ export class storeFocusObjects {
return resultArr; return resultArr;
} }
@observable _cellInfo; _cellInfo;
@action resetCellInfo (cellInfo) { resetCellInfo (cellInfo) {
this.focusOn = 'cell'; this.focusOn = 'cell';
this._cellInfo = cellInfo; this._cellInfo = cellInfo;
} }
@computed get selections () { get selections () {
const _selections = []; const _selections = [];
let isCell, isRow, isCol, isAll, isChart, isImage, isTextShape, isShape, isTextChart, let isCell, isRow, isCol, isAll, isChart, isImage, isTextShape, isShape, isTextChart,
@ -134,7 +148,7 @@ export class storeFocusObjects {
return _selections; return _selections;
} }
@computed get shapeObject() { get shapeObject() {
const shapes = []; const shapes = [];
for (let object of this._focusObjects) { for (let object of this._focusObjects) {
if (object.get_ObjectType() === Asc.c_oAscTypeSelectElement.Image) { if (object.get_ObjectType() === Asc.c_oAscTypeSelectElement.Image) {
@ -151,7 +165,7 @@ export class storeFocusObjects {
} }
} }
@computed get imageObject() { get imageObject() {
const images = []; const images = [];
for (let object of this._focusObjects) { for (let object of this._focusObjects) {
if (object.get_ObjectType() === Asc.c_oAscTypeSelectElement.Image) { if (object.get_ObjectType() === Asc.c_oAscTypeSelectElement.Image) {
@ -166,7 +180,7 @@ export class storeFocusObjects {
} }
} }
@computed get chartObject() { get chartObject() {
const charts = []; const charts = [];
for (let object of this._focusObjects) { for (let object of this._focusObjects) {
if (object.get_ObjectType() === Asc.c_oAscTypeSelectElement.Image) { if (object.get_ObjectType() === Asc.c_oAscTypeSelectElement.Image) {

View file

@ -1,11 +1,19 @@
import {action, computed} from 'mobx'; import {action, computed, makeObservable} from 'mobx';
export class storeFunctions { export class storeFunctions {
@action initFunctions (groups, data) { constructor() {
makeObservable(this, {
initFunctions: action,
functions: computed
});
}
initFunctions (groups, data) {
this.groups = groups; this.groups = groups;
this.data = data; this.data = data;
} }
@computed get functions () {
get functions () {
const groups = this.groups; const groups = this.groups;
const data = this.data; const data = this.data;
const functions = {}; const functions = {};

View file

@ -1,9 +1,16 @@
import {action, observable} from 'mobx'; import {action, makeObservable, observable} from 'mobx';
export class storePalette { export class storePalette {
@observable customColors = []; constructor() {
makeObservable(this, {
customColors: observable,
changeCustomColors: action
});
}
customColors = [];
@action changeCustomColors (colors) { changeCustomColors (colors) {
this.customColors = colors; this.customColors = colors;
} }
} }

View file

@ -1,6 +1,16 @@
import {action, observable, computed} from 'mobx'; import {action, observable, computed, makeObservable} from 'mobx';
export class storeShapeSettings { export class storeShapeSettings {
constructor() {
makeObservable(this, {
fillColor: observable,
borderColorView: observable,
setFillColor: action,
getFillColor: action,
setBorderColor: action,
initBorderColorView: action
});
}
getStyleGroups () { getStyleGroups () {
const styles = [ const styles = [
@ -125,8 +135,10 @@ export class storeShapeSettings {
type: 'cloudCallout' type: 'cloudCallout'
} }
]; ];
const groups = []; const groups = [];
let i = 0; let i = 0;
for (let row=0; row<Math.floor(styles.length/4); row++) { for (let row=0; row<Math.floor(styles.length/4); row++) {
const group = []; const group = [];
for (let cell=0; cell<4; cell++) { for (let cell=0; cell<4; cell++) {
@ -135,12 +147,13 @@ export class storeShapeSettings {
} }
groups.push(group); groups.push(group);
} }
return groups; return groups;
} }
// Fill Color // Fill Color
@observable fillColor = undefined; fillColor = undefined;
setFillColor (color) { setFillColor (color) {
this.fillColor = color; this.fillColor = color;
@ -169,7 +182,7 @@ export class storeShapeSettings {
// Border size and color // Border size and color
@observable borderColorView; borderColorView;
setBorderColor (color) { setBorderColor (color) {
this.borderColorView = color; this.borderColorView = color;
@ -220,5 +233,4 @@ export class storeShapeSettings {
} }
} }
} }
} }

View file

@ -1,8 +1,8 @@
import {observable, action} from 'mobx'; import {observable, action, makeObservable} from 'mobx';
class Worksheet { class Worksheet {
@observable sheet = { sheet = {
index : -1, index : -1,
active : false, active : false,
name : '', name : '',
@ -12,22 +12,30 @@ class Worksheet {
}; };
constructor(data = {}) { constructor(data = {}) {
makeObservable(this, {
sheet: observable
});
this.sheet.merge(data); this.sheet.merge(data);
} }
} }
export class storeWorksheets { export class storeWorksheets {
@observable sheets; sheets;
constructor() { constructor() {
makeObservable(this, {
sheets: observable,
reset: action,
setActiveWorksheet: action
});
this.sheets = []; this.sheets = [];
} }
@action reset(sheets) { reset(sheets) {
this.sheets = Object.values(sheets) this.sheets = Object.values(sheets)
} }
@action setActiveWorksheet(i) { setActiveWorksheet(i) {
if ( !this.sheets[i].active ) { if ( !this.sheets[i].active ) {
this.sheets.forEach(model => { this.sheets.forEach(model => {
if ( model.active ) if ( model.active )

View file

@ -1,10 +1,16 @@
import {action, observable, computed} from 'mobx'; import {action, observable, makeObservable} from 'mobx';
export class storeSpreadsheetInfo { export class storeSpreadsheetInfo {
constructor() {
@observable dataDoc; makeObservable(this, {
dataDoc: observable,
setDataDoc: action
})
}
dataDoc;
@action setDataDoc(obj) { setDataDoc(obj) {
this.dataDoc = obj; this.dataDoc = obj;
} }
} }

View file

@ -1,19 +1,35 @@
import {action, observable, computed} from 'mobx'; import {action, observable, computed, makeObservable} from 'mobx';
export class storeSpreadsheetSettings { export class storeSpreadsheetSettings {
constructor() {
makeObservable(this, {
isPortrait: observable,
widthDocument: observable,
heightDocument: observable,
allSchemes: observable,
isHideHeadings: observable,
isHideGridlines: observable,
resetPortrait: action,
changeDocSize: action,
pageSizesIndex: computed,
addSchemes: action,
changeHideHeadings: action,
changeHideGridlines: action
})
}
@observable isPortrait = true; isPortrait = true;
@action resetPortrait (isPortrait) { resetPortrait (isPortrait) {
this.isPortrait = isPortrait === true; this.isPortrait = isPortrait === true;
} }
// Spreadsheet Formats // Spreadsheet Formats
@observable widthDocument; widthDocument;
@observable heightDocument; heightDocument;
@action changeDocSize (width, height) { changeDocSize (width, height) {
this.widthDocument = width; this.widthDocument = width;
this.heightDocument = height; this.heightDocument = height;
} }
@ -43,7 +59,7 @@ export class storeSpreadsheetSettings {
return pageSizes; return pageSizes;
} }
@computed get pageSizesIndex () { get pageSizesIndex () {
let w = this.widthDocument; let w = this.widthDocument;
let h = this.heightDocument; let h = this.heightDocument;
let ind; let ind;
@ -60,20 +76,20 @@ export class storeSpreadsheetSettings {
// Color Schemes // Color Schemes
@observable allSchemes; allSchemes;
@action addSchemes(arr) { addSchemes(arr) {
this.allSchemes = arr; this.allSchemes = arr;
} }
@observable isHideHeadings; isHideHeadings;
@observable isHideGridlines; isHideGridlines;
@action changeHideHeadings(value) { changeHideHeadings(value) {
this.isHideHeadings = value; this.isHideHeadings = value;
} }
@action changeHideGridlines(value) { changeHideGridlines(value) {
this.isHideGridlines = value; this.isHideGridlines = value;
} }

View file

@ -1,21 +1,42 @@
import {action, observable, computed} from 'mobx'; import {action, observable, makeObservable, computed} from 'mobx';
export class storeTextSettings { export class storeTextSettings {
constructor() {
makeObservable(this, {
fontsArray: observable,
fontInfo: observable,
fontName: observable,
fontSize: observable,
isBold: observable,
isItalic: observable,
isUnderline: observable,
textColor: observable,
customTextColors: observable,
paragraphAlign: observable,
paragraphValign: observable,
textIn: observable,
initTextSettings: action,
initEditorFonts: action,
initFontInfo: action,
changeTextColor: action,
changeCustomTextColors: action
});
}
fontsArray = [];
fontInfo = {};
fontName = '';
fontSize = undefined;
isBold = false;
isItalic = false;
isUnderline = false;
textColor = undefined;
customTextColors = [];
paragraphAlign = undefined;
paragraphValign = undefined;
textIn = undefined;
@observable fontsArray = []; initTextSettings(cellInfo) {
@observable fontInfo = {};
@observable fontName = '';
@observable fontSize = undefined;
@observable isBold = false;
@observable isItalic = false;
@observable isUnderline = false;
@observable textColor = undefined;
@observable customTextColors = [];
@observable paragraphAlign = undefined;
@observable paragraphValign = undefined;
@observable textIn = undefined;
@action initTextSettings(cellInfo) {
let xfs = cellInfo.asc_getXfs(); let xfs = cellInfo.asc_getXfs();
let selectType = cellInfo.asc_getSelectionType(); let selectType = cellInfo.asc_getSelectionType();
@ -40,7 +61,7 @@ export class storeTextSettings {
this.paragraphValign = xfs.asc_getVertAlign(); this.paragraphValign = xfs.asc_getVertAlign();
} }
@action initEditorFonts (fonts, select) { initEditorFonts (fonts, select) {
let array = []; let array = [];
for (let font of fonts) { for (let font of fonts) {
let fontId = font.asc_getFontId(); let fontId = font.asc_getFontId();
@ -56,11 +77,11 @@ export class storeTextSettings {
this.fontsArray = array; this.fontsArray = array;
} }
@action initFontInfo(fontObj) { initFontInfo(fontObj) {
this.fontInfo = fontObj; this.fontInfo = fontObj;
} }
@action changeTextColor(value) { changeTextColor(value) {
this.textColor = value; this.textColor = value;
} }
@ -85,7 +106,7 @@ export class storeTextSettings {
return value; return value;
} }
@action changeCustomTextColors (colors) { changeCustomTextColors (colors) {
this.customTextColors = colors; this.customTextColors = colors;
} }
} }