From e7ad410744839ad41f5b536eb7cda575c0d3733e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 29 Sep 2016 12:38:39 +0300 Subject: [PATCH] [SSE] Select data range for charts from the right panel. --- .../main/app/template/ChartSettings.template | 18 +++++-- .../main/app/view/CellRangeDialog.js | 11 ++-- .../main/app/view/ChartSettings.js | 53 ++++++++++++++++++- apps/spreadsheeteditor/main/locale/en.json | 6 ++- 4 files changed, 77 insertions(+), 11 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/template/ChartSettings.template b/apps/spreadsheeteditor/main/app/template/ChartSettings.template index 80fabdf56d..a9021ac86e 100644 --- a/apps/spreadsheeteditor/main/app/template/ChartSettings.template +++ b/apps/spreadsheeteditor/main/app/template/ChartSettings.template @@ -24,16 +24,13 @@
- - - - - +
+
@@ -42,6 +39,17 @@
+ + + + + + + + +
+ + diff --git a/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js b/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js index 232df0660c..86686c7893 100644 --- a/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js +++ b/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js @@ -119,8 +119,12 @@ define([ } me.inputRange.validation = function(value) { - var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false); - return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.txtInvalidRange : true; + if (me.options.validation) { + return me.options.validation.call(me, value); + } else { + var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false); + return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.txtInvalidRange : true; + } }; }, @@ -173,6 +177,7 @@ define([ textCancel : 'Cancel', txtEmpty : 'This field is required', txtInvalidRange: 'ERROR! Invalid cells range', - errorMaxRows: 'ERROR! The maximum number of data series per chart is 255.' + errorMaxRows: 'ERROR! The maximum number of data series per chart is 255.', + 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.' }, SSE.Views.CellRangeDialog || {})) }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/ChartSettings.js b/apps/spreadsheeteditor/main/app/view/ChartSettings.js index 0789acb65a..532d385dc5 100644 --- a/apps/spreadsheeteditor/main/app/view/ChartSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ChartSettings.js @@ -303,6 +303,12 @@ define([ } }, this)); + this.btnSelectData = new Common.UI.Button({ + el: $('#chart-btn-select-data') + }); + this.btnSelectData.on('click', _.bind(this.onSelectData, this)); + this.lockedControls.push(this.btnSelectData); + this.linkAdvanced = $('#chart-advanced-link'); $(this.el).on('click', '#chart-advanced-link', _.bind(this.openAdvancedSettings, this)); }, @@ -381,6 +387,48 @@ define([ } }, + onSelectData: function() { + var me = this; + if (me.api) { + var props = me.api.asc_getChartObject(), + handlerDlg = function(dlg, result) { + if (result == 'ok') { + props.putRange(dlg.getSettings()); + me.api.asc_setSelectionDialogMode(Asc.c_oAscSelectionDialogType.None); + me.api.asc_editChartDrawingObject(props); + } + + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + }, + validation = function(value) { + var isvalid; + if (!_.isEmpty(value)) { + isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, true, !props.getInColumns(), me._state.ChartType); + if (isvalid == Asc.c_oAscError.ID.No) + return true; + } else return ''; + + if (isvalid == Asc.c_oAscError.ID.StockChartError) { + return this.errorStockChart; + } else if (isvalid == Asc.c_oAscError.ID.MaxDataSeriesError) { + return this.errorMaxRows; + } + return this.txtInvalidRange; + }; + + var win = new SSE.Views.CellRangeDialog({ + handler: handlerDlg, + validation: validation + }); + + win.show(); + win.setSettings({ + api : me.api, + range : props.getRange() + }); + } + }, + onSelectType: function(btn, picker, itemView, record) { if (this._noApply) return; @@ -537,7 +585,10 @@ define([ textPoint: 'XY (Scatter) Chart', textStock: 'Stock Chart', textStyle: 'Style', - textAdvanced: 'Show advanced settings' + textAdvanced: 'Show advanced settings', + textType: 'Type', + textSelectData: 'Select Data', + textRanges: 'Data Range' }, SSE.Views.ChartSettings || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 51cc67dd2c..9bde2e4470 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -130,8 +130,6 @@ "SSE.Controllers.Main.confirmMoveCellRange": "The destination cell range can contain data. Continue the operation?", "SSE.Controllers.Main.confirmPutMergeRange": "The source data contained merged cells.
They had been unmerged before they were pasted into the table.", "del_SSE.Controllers.Main.convertationErrorText": "Conversion failed.", - "SSE.Controllers.Main.openErrorText": "An error has occurred while opening the file", - "SSE.Controllers.Main.saveErrorText": "An error has occurred while saving the file", "SSE.Controllers.Main.convertationTimeoutText": "Conversion timeout exceeded.", "SSE.Controllers.Main.criticalErrorExtText": "Press \"OK\" to return to document list.", "SSE.Controllers.Main.criticalErrorTitle": "Error", @@ -299,6 +297,7 @@ "SSE.Views.CellEditor.textManager": "Name Manager", "SSE.Views.CellEditor.tipFormula": "Insert Function", "SSE.Views.CellRangeDialog.errorMaxRows": "ERROR! The maximum number of data series per chart is 255", + "SSE.Views.CellRangeDialog.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.", "SSE.Views.CellRangeDialog.textCancel": "Cancel", "SSE.Views.CellRangeDialog.txtEmpty": "This field is required", "SSE.Views.CellRangeDialog.txtInvalidRange": "ERROR! Invalid cells range", @@ -318,6 +317,9 @@ "SSE.Views.ChartSettings.textStock": "Stock Chart", "SSE.Views.ChartSettings.textStyle": "Style", "SSE.Views.ChartSettings.textWidth": "Width", + "SSE.Views.ChartSettings.textType": "Type", + "SSE.Views.ChartSettings.textSelectData": "Select Data", + "SSE.Views.ChartSettings.textRanges": "Data Range", "SSE.Views.ChartSettingsDlg.cancelButtonText": "Cancel", "SSE.Views.ChartSettingsDlg.errorMaxRows": "ERROR! The maximum number of data series per chart is 255", "SSE.Views.ChartSettingsDlg.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.",