From edd4ed6629590dbb958a343922e79611e5289750 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Fri, 28 May 2021 15:12:21 +0300 Subject: [PATCH] [SSE mobile] Bug 48058 --- apps/spreadsheeteditor/mobile/locale/en.json | 2 ++ .../mobile/src/controller/add/AddChart.jsx | 27 +++++++++++++++---- .../mobile/src/view/add/Add.jsx | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index 49889fc50..c2662e79b 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -222,6 +222,8 @@ "txtNotUrl": "This field should be a URL in the format \"http://www.example.com\"", "textEmptyImgUrl": "You need to specify image URL.", "notcriticalErrorTitle": "Warning", + "errorStockChart": "Incorrect row order. To build a stock chart place the data on the sheet in the following order:
opening price, max price, min price, closing price.", + "errorMaxRows": "ERROR! The maximum number of data series per chart is 255.", "textLink": "Link", "textAddLink": "Add Link", "textLinkType": "Link Type", diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddChart.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddChart.jsx index 55d1b8e3a..b560d9519 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddChart.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddChart.jsx @@ -1,6 +1,7 @@ import React, {Component} from 'react'; import { f7 } from 'framework7-react'; import {Device} from '../../../../../common/mobile/utils/device'; +import { withTranslation } from 'react-i18next'; import AddChart from '../../view/add/AddChart'; @@ -20,10 +21,24 @@ class AddChartController extends Component { onInsertChart (type) { const api = Common.EditorApi.get(); - const settings = api.asc_getChartObject(); - settings.changeType(type); - api.asc_addChartDrawingObject(settings); - this.closeModal(); + const { t } = this.props; + const _t = t('View.Add', {returnObjects: true}); + const settings = api.asc_getChartObject(true); + const info = api.asc_getCellInfo(); + const selType = info.asc_getSelectionType(); + const isChartEdit = (selType == Asc.c_oAscSelectionType.RangeChart || selType == Asc.c_oAscSelectionType.RangeChartText); + + if (settings) { + isChartEdit ? settings.changeType(type) : settings.putType(type); + let range = settings.getRange(), + isValid = !!range ? api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, range, true, !settings.getInColumns(), settings.getType()) : Asc.c_oAscError.ID.No; + if (isValid == Asc.c_oAscError.ID.No) { + isChartEdit ? api.asc_editChartDrawingObject(settings) : api.asc_addChartDrawingObject(settings); + this.closeModal(); + } else { + f7.dialog.alert((isValid == Asc.c_oAscError.ID.StockChartError) ? _t.errorStockChart : ((isValid == Asc.c_oAscError.ID.MaxDataSeriesError) ? _t.errorMaxRows : _t.txtInvalidRange), _t.notcriticalErrorTitle); + } + } } render () { @@ -34,4 +49,6 @@ class AddChartController extends Component { } } -export default AddChartController; \ No newline at end of file +const AddChartControllerTranslated = withTranslation()(AddChartController); + +export {AddChartControllerTranslated as AddChartController}; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx b/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx index 3fd709181..b98e305ce 100644 --- a/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/add/Add.jsx @@ -5,7 +5,7 @@ import {f7} from 'framework7-react'; import { observer, inject } from "mobx-react"; import {Device} from '../../../../../common/mobile/utils/device'; -import AddChartController from "../../controller/add/AddChart"; +import {AddChartController} from "../../controller/add/AddChart"; import {AddFunctionController} from "../../controller/add/AddFunction"; import {PageFunctionGroup, PageFunctionInfo} from "./AddFunction"; import AddShapeController from "../../controller/add/AddShape";