From 77b5e90c4ba4c9b8eac602298d806e00742f7050 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 1 Oct 2020 20:37:18 +0300 Subject: [PATCH] [mobile-react] Fix store focus objects --- .../mobile/src/components/edit/Edit.jsx | 2 +- .../mobile/src/store/focusObjects.js | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/apps/documenteditor/mobile/src/components/edit/Edit.jsx b/apps/documenteditor/mobile/src/components/edit/Edit.jsx index 9a7c95de2..2641c2ac4 100644 --- a/apps/documenteditor/mobile/src/components/edit/Edit.jsx +++ b/apps/documenteditor/mobile/src/components/edit/Edit.jsx @@ -59,7 +59,7 @@ const EditLayoutContent = ({ editors }) => { const EditSheet = props => { const { t } = useTranslation(); - const settings = props.storeFocusObjects.focusObjects; + const settings = props.storeFocusObjects.settings; const headerType = props.storeFocusObjects.headerType; let editors = []; if (settings.length < 1) { diff --git a/apps/documenteditor/mobile/src/store/focusObjects.js b/apps/documenteditor/mobile/src/store/focusObjects.js index 1cb46738d..fc6836f6e 100644 --- a/apps/documenteditor/mobile/src/store/focusObjects.js +++ b/apps/documenteditor/mobile/src/store/focusObjects.js @@ -1,14 +1,17 @@ import {action, observable, computed} from 'mobx'; export class storeFocusObjects { - @observable focusObjects = []; - @observable headerType = 1; + @observable _focusObjects = []; + @observable _headerType = 1; @action resetFocusObjects (objects) { - this.focusObjects = objects; + this._focusObjects = objects; + } + + @computed get settings() { let _settings = []; - for (let object of objects) { - var type = object.get_ObjectType(); + for (let object of this._focusObjects) { + let type = object.get_ObjectType(); if (Asc.c_oAscTypeSelectElement.Paragraph === type) { _settings.push('text', 'paragraph'); } else if (Asc.c_oAscTypeSelectElement.Table === type) { @@ -25,13 +28,21 @@ export class storeFocusObjects { _settings.push('hyperlink'); } else if (Asc.c_oAscTypeSelectElement.Header === type) { _settings.push('header'); - this.headerType = object.get_ObjectValue().get_Type(); } } // Exclude shapes if chart exist if (_settings.indexOf('chart') > -1) { _settings = _settings.filter((value) => value !== 'shape'); } - this.focusObjects = _settings.filter((value, index, self) => self.indexOf(value) === index); + return _settings.filter((value, index, self) => self.indexOf(value) === index); + } + @computed get headerType() { + for (let object of this._focusObjects) { + let type = object.get_ObjectType(); + if (Asc.c_oAscTypeSelectElement.Header === type) { + return object.get_ObjectValue().get_Type(); + } + } + return this._headerType; } } \ No newline at end of file