From ca01b519f95beb89d42e2b819daf60fb47a7a70f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 8 Dec 2020 11:48:28 +0300 Subject: [PATCH] [SSE] Show errors when set combo chart type --- .../main/app/controller/Main.js | 9 ++++++++- .../main/app/controller/Toolbar.js | 11 +++++----- .../main/app/view/ChartSettings.js | 17 +++++++++------- .../main/app/controller/Main.js | 8 +++++++- .../main/app/controller/Toolbar.js | 12 ++++++----- .../main/app/view/ChartSettings.js | 20 ++++++++++++------- .../main/app/controller/Toolbar.js | 17 ++++++++++++++-- .../main/app/view/ChartTypeDialog.js | 17 +++++++++++----- 8 files changed, 78 insertions(+), 33 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 67e9c141d..239a0a671 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -204,6 +204,8 @@ define([ Common.NotificationCenter.on('goback', _.bind(this.goBack, this)); Common.NotificationCenter.on('download:advanced', _.bind(this.onAdvancedOptions, this)); Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this)); + Common.NotificationCenter.on('showerror', _.bind(this.onError, this)); + this.isShowOpenDialog = false; @@ -1601,6 +1603,10 @@ define([ config.msg = this.errorCompare; break; + case Asc.c_oAscError.ID.ComboSeriesError: + config.msg = this.errorComboSeries; + break; + default: config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id); break; @@ -2712,7 +2718,8 @@ define([ textRemember: 'Remember my choice', warnLicenseLimitedRenewed: 'License needs to be renewed.
You have a limited access to document editing functionality.
Please contact your administrator to get full access', warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.', - saveErrorTextDesktop: 'This file cannot be saved or created.
Possible reasons are:
1. The file is read-only.
2. The file is being edited by other users.
3. The disk is full or corrupted.' + saveErrorTextDesktop: 'This file cannot be saved or created.
Possible reasons are:
1. The file is read-only.
2. The file is being edited by other users.
3. The disk is full or corrupted.', + errorComboSeries: 'To create a combination chart, select at least two series of data.' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index fa9a5baa5..75a0df6ee 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -2050,11 +2050,12 @@ define([ } if (chart) { - var props = new Asc.asc_CImgProperty(); - chart.changeType(type); - props.put_ChartProperties(chart); - this.api.ImgApply(props); - + var isCombo = (type==Asc.c_oAscChartTypeSettings.comboBarLine || type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary || + type==Asc.c_oAscChartTypeSettings.comboAreaBar || type==Asc.c_oAscChartTypeSettings.comboCustom); + if (isCombo && chart.getSeries().length<2) { + Common.NotificationCenter.trigger('showerror', Asc.c_oAscError.ID.ComboSeriesError, Asc.c_oAscError.Level.NoCritical); + } else + chart.changeType(type); Common.NotificationCenter.trigger('edit:complete', this.toolbar); } else { if (!this.diagramEditor) diff --git a/apps/documenteditor/main/app/view/ChartSettings.js b/apps/documenteditor/main/app/view/ChartSettings.js index 3fa55df2e..011a52bd1 100644 --- a/apps/documenteditor/main/app/view/ChartSettings.js +++ b/apps/documenteditor/main/app/view/ChartSettings.js @@ -386,14 +386,17 @@ define([ rawData = record; } - this.btnChartType.setIconCls('svgicon ' + 'chart-' + rawData.iconCls); - this._state.ChartType = -1; - if (this.api && !this._noApply && this.chartProps) { - var props = new Asc.asc_CImgProperty(); - this.chartProps.changeType(rawData.type); - props.put_ChartProperties(this.chartProps); - this.api.ImgApply(props); + var isCombo = (rawData.type==Asc.c_oAscChartTypeSettings.comboBarLine || rawData.type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary || + rawData.type==Asc.c_oAscChartTypeSettings.comboAreaBar || rawData.type==Asc.c_oAscChartTypeSettings.comboCustom); + if (isCombo && this.chartProps.getSeries().length<2) { + Common.NotificationCenter.trigger('showerror', Asc.c_oAscError.ID.ComboSeriesError, Asc.c_oAscError.Level.NoCritical); + this.mnuChartTypePicker.selectRecord(this.mnuChartTypePicker.store.findWhere({type: this.chartProps.getType()}), true); + } else { + this.btnChartType.setIconCls('svgicon ' + 'chart-' + rawData.iconCls); + this._state.ChartType = -1; + this.chartProps.changeType(rawData.type); + } } this.fireEvent('editcomplete', this); }, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index af7ee014f..9c8106fb1 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -184,6 +184,7 @@ define([ Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('goback', _.bind(this.goBack, this)); Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this)); + Common.NotificationCenter.on('showerror', _.bind(this.onError, this)); this.isShowOpenDialog = false; @@ -1273,6 +1274,10 @@ define([ config.maxwidth = 600; break; + case Asc.c_oAscError.ID.ComboSeriesError: + config.msg = this.errorComboSeries; + break; + default: config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id); break; @@ -2355,7 +2360,8 @@ define([ textRemember: 'Remember my choice', warnLicenseLimitedRenewed: 'License needs to be renewed.
You have a limited access to document editing functionality.
Please contact your administrator to get full access', warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.', - saveErrorTextDesktop: 'This file cannot be saved or created.
Possible reasons are:
1. The file is read-only.
2. The file is being edited by other users.
3. The disk is full or corrupted.' + saveErrorTextDesktop: 'This file cannot be saved or created.
Possible reasons are:
1. The file is read-only.
2. The file is being edited by other users.
3. The disk is full or corrupted.', + errorComboSeries: 'To create a combination chart, select at least two series of data.' } })(), PE.Controllers.Main || {})) }); diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 727b6165f..726edf11f 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -1687,17 +1687,19 @@ define([ if (selectedElements && _.isArray(selectedElements)) { for (var i = 0; i< selectedElements.length; i++) { if (Asc.c_oAscTypeSelectElement.Chart == selectedElements[i].get_ObjectType()) { - chart = true; + chart = selectedElements[i].get_ObjectValue(); break; } } } if (chart) { - var props = new Asc.CAscChartProp(); - props.changeType(type); - this.api.ChartApply(props); - + var isCombo = (type==Asc.c_oAscChartTypeSettings.comboBarLine || type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary || + type==Asc.c_oAscChartTypeSettings.comboAreaBar || type==Asc.c_oAscChartTypeSettings.comboCustom); + if (isCombo && chart.get_ChartProperties() && chart.get_ChartProperties().getSeries().length<2) { + Common.NotificationCenter.trigger('showerror', Asc.c_oAscError.ID.ComboSeriesError, Asc.c_oAscError.Level.NoCritical); + } else + chart.changeType(type); Common.NotificationCenter.trigger('edit:complete', this.toolbar); } else { if (!this.diagramEditor) diff --git a/apps/presentationeditor/main/app/view/ChartSettings.js b/apps/presentationeditor/main/app/view/ChartSettings.js index 7fceffff2..f48a79233 100644 --- a/apps/presentationeditor/main/app/view/ChartSettings.js +++ b/apps/presentationeditor/main/app/view/ChartSettings.js @@ -108,8 +108,9 @@ define([ this.disableControls(this._locked); if (props){ - this._originalProps = new Asc.CAscChartProp(props); + this._originalProps = props; this._noApply = true; + this.chartProps = props.get_ChartProperties(); var value = props.get_SeveralCharts() || this._locked; if (this._state.SeveralCharts!==value) { @@ -320,13 +321,18 @@ define([ rawData = record; } - this.btnChartType.setIconCls('svgicon ' + 'chart-' + rawData.iconCls); - this._state.ChartType = -1; - if (this.api && !this._noApply) { - var props = new Asc.CAscChartProp(); - props.changeType(rawData.type); - this.api.ChartApply(props); + var isCombo = (rawData.type==Asc.c_oAscChartTypeSettings.comboBarLine || rawData.type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary || + rawData.type==Asc.c_oAscChartTypeSettings.comboAreaBar || rawData.type==Asc.c_oAscChartTypeSettings.comboCustom); + + if (isCombo && this.chartProps.getSeries().length<2) { + Common.NotificationCenter.trigger('showerror', Asc.c_oAscError.ID.ComboSeriesError, Asc.c_oAscError.Level.NoCritical); + this.mnuChartTypePicker.selectRecord(this.mnuChartTypePicker.store.findWhere({type: this._originalProps.getType()}), true); + } else { + this.btnChartType.setIconCls('svgicon ' + 'chart-' + rawData.iconCls); + this._state.ChartType = -1; + this._originalProps.changeType(rawData.type); + } } this.fireEvent('editcomplete', this); }, diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index e28e93882..dd07bf069 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -1028,8 +1028,20 @@ define([ if (isvalid == Asc.c_oAscError.ID.No) { (ischartedit) ? me.api.asc_editChartDrawingObject(props) : me.api.asc_addChartDrawingObject(props); } else { + var msg = me.txtInvalidRange; + switch (isvalid) { + case isvalid == Asc.c_oAscError.ID.StockChartError: + msg = me.errorStockChart; + break; + case isvalid == Asc.c_oAscError.ID.MaxDataSeriesError: + msg = me.errorMaxRows; + break; + case isvalid == Asc.c_oAscError.ID.ComboSeriesError: + msg = me.errorComboSeries; + break; + } Common.UI.warning({ - msg: (isvalid == Asc.c_oAscError.ID.StockChartError) ? me.errorStockChart : ((isvalid == Asc.c_oAscError.ID.MaxDataSeriesError) ? me.errorMaxRows : me.txtInvalidRange), + msg: msg, callback: function() { _.defer(function(btn) { Common.NotificationCenter.trigger('edit:complete', me.toolbar); @@ -4012,7 +4024,8 @@ define([ txtTable_TableStyleLight: 'Table Style Light', textInsert: 'Insert', txtInsertCells: 'Insert Cells', - txtDeleteCells: 'Delete Cells' + txtDeleteCells: 'Delete Cells', + errorComboSeries: 'To create a combination chart, select at least two series of data.' }, SSE.Controllers.Toolbar || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/ChartTypeDialog.js b/apps/spreadsheeteditor/main/app/view/ChartTypeDialog.js index 31a5c0252..4b3af205a 100644 --- a/apps/spreadsheeteditor/main/app/view/ChartTypeDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ChartTypeDialog.js @@ -278,15 +278,21 @@ define([ } else { rawData = record; } + var isCombo = rawData.type==Asc.c_oAscChartTypeSettings.comboBarLine || rawData.type==Asc.c_oAscChartTypeSettings.comboBarLineSecondary || + rawData.type==Asc.c_oAscChartTypeSettings.comboAreaBar || rawData.type==Asc.c_oAscChartTypeSettings.comboCustom, + series = isCombo ? this.chartSettings.getSeries() : []; + if (isCombo && series.length<2) { + Common.UI.warning({msg: this.errorComboSeries, maxwidth: 600}); + return; + } this.btnChartType.setIconCls('svgicon ' + 'chart-' + rawData.iconCls); this.currentChartType = rawData.type; this.chartSettings.changeType(this.currentChartType); this.ShowHideSettings(this.currentChartType); - if (this.currentChartType==Asc.c_oAscChartTypeSettings.comboBarLine || this.currentChartType==Asc.c_oAscChartTypeSettings.comboBarLineSecondary || - this.currentChartType==Asc.c_oAscChartTypeSettings.comboAreaBar || this.currentChartType==Asc.c_oAscChartTypeSettings.comboCustom) { - this.updateSeriesList(this.chartSettings.getSeries()); - } else + if (isCombo) + this.updateSeriesList(series); + else this.updateChartStyles(this.api.asc_getChartPreviews(this.currentChartType)); }, @@ -437,7 +443,8 @@ define([ textStyle: 'Style', textSeries: 'Series', textSecondary: 'Secondary Axis', - errorSecondaryAxis: 'The selected chart type requires the secondary axis that an existing chart is using. Select another chart type.' + errorSecondaryAxis: 'The selected chart type requires the secondary axis that an existing chart is using. Select another chart type.', + errorComboSeries: 'To create a combination chart, select at least two series of data.' }, SSE.Views.ChartTypeDialog || {})) });