From 5ab470ec5fa32637188ae28fd09bf60541df597e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 22 Mar 2021 22:21:03 +0300 Subject: [PATCH 1/7] [SSE] Add sparklines --- .../main/app/controller/Toolbar.js | 23 ++++++++++ .../main/app/template/Toolbar.template | 1 + .../main/app/view/Toolbar.js | 45 ++++++++++++++++++- apps/spreadsheeteditor/main/locale/en.json | 2 + 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 0b2c0fdd0..8e267602f 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -79,6 +79,7 @@ define([ 'Toolbar': { 'change:compact': this.onClickChangeCompact.bind(me), 'add:chart' : this.onSelectChart, + 'add:spark' : this.onSelectSpark, 'insert:textart': this.onInsertTextart, 'change:scalespn': this.onClickChangeScaleInMenu.bind(me), 'click:customscale': this.onScaleClick.bind(me), @@ -1130,6 +1131,28 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, + onSelectSpark: function(type) { + if (!this.editMode) return; + var me = this, + info = me.api.asc_getCellInfo(), + seltype = info.asc_getSelectionType(); + + if (me.api) { + if (seltype==Asc.c_oAscSelectionType.RangeCells || seltype==Asc.c_oAscSelectionType.RangeCol || + seltype==Asc.c_oAscSelectionType.RangeRow || seltype==Asc.c_oAscSelectionType.RangeMax) { + var sparkLineInfo = info.asc_getSparklineInfo(); + if (!!sparkLineInfo) { + var props = new Asc.sparklineGroup(); + props.asc_setType(type); + this.api.asc_setSparklineGroup(sparkLineInfo.asc_getId(), props); + } else { + // add sparkline + } + } + } + Common.NotificationCenter.trigger('edit:complete', this.toolbar); + }, + onInsertTextart: function (data) { if (this.api) { this.toolbar.fireEvent('inserttextart', this.toolbar); diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template index 1b359be7d..55a1bf9a0 100644 --- a/apps/spreadsheeteditor/main/app/template/Toolbar.template +++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template @@ -130,6 +130,7 @@ +
diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 78b16ee8f..3dd82ee5e 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -722,6 +722,15 @@ define([ menu : true }); + me.btnInsertSparkline = new Common.UI.Button({ + id : 'tlbtn-insertsparkline', + cls : 'btn-toolbar x-huge icon-top', + iconCls : 'toolbar__icon btn-insert-sparkline', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.editPivot], + caption : me.capInsertSpark, + menu : true + }); + me.btnInsertShape = new Common.UI.Button({ id : 'tlbtn-insertshape', cls : 'btn-toolbar x-huge icon-top', @@ -1461,7 +1470,7 @@ define([ me.btnInsertText, me.btnInsertTextArt, me.btnSortUp, me.btnSortDown, me.btnSetAutofilter, me.btnClearAutofilter, me.btnTableTemplate, me.btnPercentStyle, me.btnCurrencyStyle, me.btnDecDecimal, me.btnAddCell, me.btnDeleteCell, me.btnCondFormat, me.cmbNumberFormat, me.btnBorders, me.btnInsertImage, me.btnInsertHyperlink, - me.btnInsertChart, me.btnColorSchemas, + me.btnInsertChart, me.btnColorSchemas, me.btnInsertSparkline, me.btnCopy, me.btnPaste, me.listStyles, me.btnPrint, /*me.btnSave,*/ me.btnClearStyle, me.btnCopyStyle, me.btnPageMargins, me.btnPageSize, me.btnPageOrient, me.btnPrintArea, me.btnPrintTitles, me.btnImgAlign, me.btnImgBackward, me.btnImgForward, me.btnImgGroup, me.btnScale @@ -1661,6 +1670,7 @@ define([ _injectComponent('#slot-btn-colorschemas', this.btnColorSchemas); _injectComponent('#slot-btn-search', this.btnSearch); _injectComponent('#slot-btn-inschart', this.btnInsertChart); + _injectComponent('#slot-btn-inssparkline', this.btnInsertSparkline); _injectComponent('#slot-field-styles', this.listStyles); _injectComponent('#slot-btn-chart', this.btnEditChart); _injectComponent('#slot-btn-chart-data', this.btnEditChartData); @@ -1720,6 +1730,7 @@ define([ _updateHint(this.btnInsertTable, this.tipInsertTable); _updateHint(this.btnInsertImage, this.tipInsertImage); _updateHint(this.btnInsertChart, this.tipInsertChartSpark); + _updateHint(this.btnInsertSparkline, this.tipInsertSpark); _updateHint(this.btnInsertText, this.tipInsertText); _updateHint(this.btnInsertTextArt, this.tipInsertTextart); _updateHint(this.btnInsertHyperlink, this.tipInsertHyperlink + Common.Utils.String.platformKey('Ctrl+K')); @@ -1919,6 +1930,34 @@ define([ this.btnInsertChart.menu.on('show:before', onShowBefore); } + if ( this.btnInsertSparkline ) { + this.btnInsertSparkline.setMenu(new Common.UI.Menu({ + style: 'width: 166px;padding: 5px 0 10px;', + items: [ + { template: _.template('') } + ] + })); + + var onShowBefore = function(menu) { + var picker = new Common.UI.DataView({ + el: $('#id-toolbar-menu-insertspark'), + parentMenu: menu, + showLast: false, + restoreHeight: 50, + // groups: new Common.UI.DataViewGroupStore(Common.define.chartData.getSparkGroupData()), + store: new Common.UI.DataViewStore(Common.define.chartData.getSparkData()), + itemTemplate: _.template('
\">
') + }); + picker.on('item:click', function (picker, item, record, e) { + if (record) + me.fireEvent('add:spark', [record.get('type')]); + if (e.type !== 'click') menu.hide(); + }); + menu.off('show:before', onShowBefore); + }; + this.btnInsertSparkline.menu.on('show:before', onShowBefore); + } + if (this.btnInsertTextArt) { var onShowBeforeTextArt = function (menu) { var collection = SSE.getCollection('Common.Collections.TextArt'); @@ -2648,6 +2687,8 @@ define([ tipEditChartData: 'Select Data', tipEditChartType: 'Change Chart Type', textAutoColor: 'Automatic', - textItems: 'Items' + textItems: 'Items', + tipInsertSpark: 'Insert sparkline', + capInsertSpark: 'Sparkline' }, SSE.Views.Toolbar || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index a22d4868f..e7e814122 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -3257,6 +3257,8 @@ "SSE.Views.Toolbar.txtTime": "Time", "SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells", "SSE.Views.Toolbar.txtYen": "¥ Yen", + "SSE.Views.Toolbar.tipInsertSpark": "Insert sparkline", + "SSE.Views.Toolbar.capInsertSpark": "Sparkline", "SSE.Views.Top10FilterDialog.textType": "Show", "SSE.Views.Top10FilterDialog.txtBottom": "Bottom", "SSE.Views.Top10FilterDialog.txtBy": "by", From 8489136021e334281f6f8e9c209a34d37a2fcc37 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 23 Mar 2021 17:51:50 +0300 Subject: [PATCH 2/7] [SSE] Add sparkline --- .../main/app/controller/Toolbar.js | 86 +++++++++---------- .../main/app/view/Toolbar.js | 2 +- apps/spreadsheeteditor/main/locale/en.json | 2 +- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 8e267602f..9b69fd05d 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -62,7 +62,8 @@ define([ 'spreadsheeteditor/main/app/view/ScaleDialog', 'spreadsheeteditor/main/app/view/FormatRulesManagerDlg', 'spreadsheeteditor/main/app/view/SlicerAddDialog', - 'spreadsheeteditor/main/app/view/AdvancedSeparatorDialog' + 'spreadsheeteditor/main/app/view/AdvancedSeparatorDialog', + 'spreadsheeteditor/main/app/view/CreateSparklineDialog' ], function () { 'use strict'; SSE.Controllers.Toolbar = Backbone.Controller.extend(_.extend({ @@ -1079,52 +1080,39 @@ define([ if (!this.editMode) return; var me = this, info = me.api.asc_getCellInfo(), - seltype = info.asc_getSelectionType(), - isSpark = (group == 'menu-chart-group-sparkcolumn' || group == 'menu-chart-group-sparkline' || group == 'menu-chart-group-sparkwin'); + seltype = info.asc_getSelectionType(); if (me.api) { var win, props; - if (isSpark && (seltype==Asc.c_oAscSelectionType.RangeCells || seltype==Asc.c_oAscSelectionType.RangeCol || - seltype==Asc.c_oAscSelectionType.RangeRow || seltype==Asc.c_oAscSelectionType.RangeMax)) { - var sparkLineInfo = info.asc_getSparklineInfo(); - if (!!sparkLineInfo) { - var props = new Asc.sparklineGroup(); - props.asc_setType(type); - this.api.asc_setSparklineGroup(sparkLineInfo.asc_getId(), props); + var ischartedit = ( seltype == Asc.c_oAscSelectionType.RangeChart || seltype == Asc.c_oAscSelectionType.RangeChartText); + props = me.api.asc_getChartObject(true); // don't lock chart object + if (props) { + (ischartedit) ? props.changeType(type) : props.putType(type); + var range = props.getRange(), + isvalid = (!_.isEmpty(range)) ? me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, range, true, props.getInRows(), props.getType()) : Asc.c_oAscError.ID.No; + if (isvalid == Asc.c_oAscError.ID.No) { + (ischartedit) ? me.api.asc_editChartDrawingObject(props) : me.api.asc_addChartDrawingObject(props); } else { - // add sparkline - } - } else if (!isSpark) { - var ischartedit = ( seltype == Asc.c_oAscSelectionType.RangeChart || seltype == Asc.c_oAscSelectionType.RangeChartText); - props = me.api.asc_getChartObject(true); // don't lock chart object - if (props) { - (ischartedit) ? props.changeType(type) : props.putType(type); - var range = props.getRange(), - isvalid = (!_.isEmpty(range)) ? me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, range, true, props.getInRows(), props.getType()) : Asc.c_oAscError.ID.No; - 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: msg, - callback: function() { - _.defer(function(btn) { - Common.NotificationCenter.trigger('edit:complete', me.toolbar); - }) - } - }); + 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: msg, + callback: function() { + _.defer(function(btn) { + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + }) + } + }); } } } @@ -1146,7 +1134,19 @@ define([ props.asc_setType(type); this.api.asc_setSparklineGroup(sparkLineInfo.asc_getId(), props); } else { - // add sparkline + var me = this; + (new SSE.Views.CreateSparklineDialog( + { + api: me.api, + handler: function(result, settings) { + if (result == 'ok' && settings) { + me.view && me.view.fireEvent('insertspark', me.view); + if (settings.destination) + me.api.asc_addSparklineGroup(type, settings.source, settings.destination); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + })).show(); } } } diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 3dd82ee5e..683b4b0a4 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -2689,6 +2689,6 @@ define([ textAutoColor: 'Automatic', textItems: 'Items', tipInsertSpark: 'Insert sparkline', - capInsertSpark: 'Sparkline' + capInsertSpark: 'Sparklines' }, SSE.Views.Toolbar || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index e7e814122..f73a181f5 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -3258,7 +3258,7 @@ "SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells", "SSE.Views.Toolbar.txtYen": "¥ Yen", "SSE.Views.Toolbar.tipInsertSpark": "Insert sparkline", - "SSE.Views.Toolbar.capInsertSpark": "Sparkline", + "SSE.Views.Toolbar.capInsertSpark": "Sparklines", "SSE.Views.Top10FilterDialog.textType": "Show", "SSE.Views.Top10FilterDialog.txtBottom": "Bottom", "SSE.Views.Top10FilterDialog.txtBy": "by", From 3e5928286d23f07fce59ed4918e254aba7dfc48d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 23 Mar 2021 17:53:56 +0300 Subject: [PATCH 3/7] [SSE] Add sparklines --- .../main/app/view/CreateSparklineDialog.js | 250 ++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 apps/spreadsheeteditor/main/app/view/CreateSparklineDialog.js diff --git a/apps/spreadsheeteditor/main/app/view/CreateSparklineDialog.js b/apps/spreadsheeteditor/main/app/view/CreateSparklineDialog.js new file mode 100644 index 000000000..608d512b8 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/view/CreateSparklineDialog.js @@ -0,0 +1,250 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2021 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +/** + * CreateSparklineDialog.js + * + * Created by Julia Radzhabova on 23.03.2021 + * Copyright (c) 2021 Ascensio System SIA. All rights reserved. + * + */ +define([ + 'common/main/lib/util/utils', + 'common/main/lib/component/InputField', + 'common/main/lib/view/AdvancedSettingsWindow' +], function () { 'use strict'; + + SSE.Views.CreateSparklineDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ + options: { + contentWidth: 310, + height: 200 + }, + + initialize : function(options) { + var me = this; + + _.extend(this.options, { + title: this.textTitle, + template: [ + '
', + '
', + '
', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '
', + '', + '
', + '
', + '
', + '', + '
', + '
', + '
', + '
', + '
', + '
' + ].join('') + }, options); + + this.api = options.api; + this.props = options.props; + + this.options.handler = function(result, value) { + if ( result != 'ok' || this.isRangeValid() ) { + if (options.handler) + options.handler.call(this, result, value); + return; + } + return true; + }; + + this.dataSourceValid = ''; + this.dataDestValid = ''; + + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + }, + + render: function() { + Common.Views.AdvancedSettingsWindow.prototype.render.call(this); + var me = this; + + this.txtSourceRange = new Common.UI.InputFieldBtn({ + el : $('#create-spark-input-source'), + name : 'range', + style : 'width: 100%;', + btnHint : this.textSelectData, + allowBlank : true, + validateOnChange: true + }); + this.txtSourceRange.on('button:click', _.bind(this.onSelectData, this, 'source')); + + this.txtDestRange = new Common.UI.InputFieldBtn({ + el : $('#create-spark-input-dest'), + name : 'range', + style : 'width: 100%;', + btnHint : this.textSelectData, + allowBlank : true, + validateOnChange: true, + validateOnBlur: false + }); + this.txtDestRange.on('button:click', _.bind(this.onSelectData, this, 'dest')); + + this.afterRender(); + }, + + getFocusedComponents: function() { + return [this.txtSourceRange, this.txtDestRange]; + }, + + getDefaultFocusableComponent: function () { + if (this._alreadyRendered) return; // focus only at first show + this._alreadyRendered = true; + return this.txtSourceRange; + }, + + afterRender: function() { + this._setDefaults(this.props); + }, + + _setDefaults: function (props) { + if (props) { + var value = props.asc_getRange(); + this.txtSourceRange.setValue((value) ? value : ''); + this.dataSourceValid = value; + } + var me = this; + this.txtSourceRange.validation = function(value) { + var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false); + return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true; + }; + this.txtDestRange.validation = function(value) { + var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false); + return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true; + }; + }, + + getSettings: function () { + var source = this.txtSourceRange.getValue(), + dest = this.txtDestRange.getValue(); + + return {source: source, destination: dest}; + }, + + isRangeValid: function() { + var isvalid = true, + txtError = ''; + + if (_.isEmpty(this.txtSourceRange.getValue())) { + isvalid = false; + txtError = this.txtEmpty; + } else { + isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, this.txtSourceRange.getValue()); + isvalid = (isvalid == Asc.c_oAscError.ID.No); + !isvalid && (txtError = this.textInvalidRange); + } + if (!isvalid) { + this.txtSourceRange.showError([txtError]); + this.txtSourceRange.cmpEl.find('input').focus(); + return isvalid; + } + + if (_.isEmpty(this.txtDestRange.getValue())) { + isvalid = false; + txtError = this.txtEmpty; + } else { + isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, this.txtDestRange.getValue()); + isvalid = (isvalid == Asc.c_oAscError.ID.No); + !isvalid && (txtError = this.textInvalidRange); + } + if (!isvalid) { + this.txtDestRange.showError([txtError]); + this.txtDestRange.cmpEl.find('input').focus(); + return isvalid; + } + + return isvalid; + }, + + onSelectData: function(type) { + var me = this, + txtRange = (type=='source') ? me.txtSourceRange : me.txtDestRange; + + if (me.api) { + var handlerDlg = function(dlg, result) { + if (result == 'ok') { + var txt = dlg.getSettings(); + (type=='source') ? (me.dataSourceValid = txt) : (me.dataDestValid = txt); + txtRange.setValue(txt); + txtRange.checkValidate(); + } + }; + + var win = new SSE.Views.CellRangeDialog({ + handler: handlerDlg + }).on('close', function() { + me.show(); + _.delay(function(){ + txtRange.focus(); + },1); + }); + + var xy = me.$window.offset(); + me.hide(); + win.show(xy.left + 160, xy.top + 125); + win.setSettings({ + api : me.api, + range : (!_.isEmpty(txtRange.getValue()) && (txtRange.checkValidate()==true)) ? txtRange.getValue() : ((type=='source') ? me.dataSourceValid : me.dataDestValid), + type : Asc.c_oAscSelectionDialogType.Chart + }); + } + }, + + textTitle: 'Create Sparklines', + textDataRange: 'Source data range', + textSelectData: 'Select data', + textDestination: 'Choose, where to place the sparklines', + txtEmpty: 'This field is required', + textInvalidRange: 'Invalid cells range' + }, SSE.Views.CreateSparklineDialog || {})) +}); \ No newline at end of file From 35237831f54cd708155923a649edcc11492bfe1d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 24 Mar 2021 18:39:00 +0300 Subject: [PATCH 4/7] [SSE] Fix ranges for sparklines --- .../main/app/controller/Toolbar.js | 9 ++++- .../main/app/view/CreateSparklineDialog.js | 37 ++++++++++--------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 9b69fd05d..18b979bf4 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -193,7 +193,8 @@ define([ pgmargins: undefined, pgorient: undefined, lock_doc: undefined, - cf_locked: [] + cf_locked: [], + selectedCells: 0 }; this.binding = {}; @@ -418,6 +419,7 @@ define([ this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this)); Common.NotificationCenter.on('storage:image-load', _.bind(this.openImageFromStorage, this)); Common.NotificationCenter.on('storage:image-insert', _.bind(this.insertImageFromStorage, this)); + this.api.asc_registerCallback('asc_onSelectionMathChanged', _.bind(this.onApiMathChanged, this)); } this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this)); @@ -1138,6 +1140,7 @@ define([ (new SSE.Views.CreateSparklineDialog( { api: me.api, + props: {selectedCells: me._state.selectedCells}, handler: function(result, settings) { if (result == 'ok' && settings) { me.view && me.view.fireEvent('insertspark', me.view); @@ -1153,6 +1156,10 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, + onApiMathChanged: function(info) { + this._state.selectedCells = info.asc_getCount(); // not empty cells + }, + onInsertTextart: function (data) { if (this.api) { this.toolbar.fireEvent('inserttextart', this.toolbar); diff --git a/apps/spreadsheeteditor/main/app/view/CreateSparklineDialog.js b/apps/spreadsheeteditor/main/app/view/CreateSparklineDialog.js index 608d512b8..271fe84a4 100644 --- a/apps/spreadsheeteditor/main/app/view/CreateSparklineDialog.js +++ b/apps/spreadsheeteditor/main/app/view/CreateSparklineDialog.js @@ -47,7 +47,7 @@ define([ SSE.Views.CreateSparklineDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ options: { contentWidth: 310, - height: 200 + height: 195 }, initialize : function(options) { @@ -71,7 +71,7 @@ define([ '', '', '', - '', + '', '', '', '', @@ -137,29 +137,30 @@ define([ return [this.txtSourceRange, this.txtDestRange]; }, - getDefaultFocusableComponent: function () { - if (this._alreadyRendered) return; // focus only at first show - this._alreadyRendered = true; - return this.txtSourceRange; - }, - afterRender: function() { this._setDefaults(this.props); }, _setDefaults: function (props) { - if (props) { - var value = props.asc_getRange(); - this.txtSourceRange.setValue((value) ? value : ''); - this.dataSourceValid = value; - } + var cells = props ? props.selectedCells : 0; var me = this; + if (cells>0) { + var range = this.api.asc_getActiveRangeStr(Asc.referenceType.R); + this.txtSourceRange.setValue(range); + this.dataSourceValid = range; + setTimeout(function(){me.txtDestRange.focus();}, 100); + } else { + var range = this.api.asc_getActiveRangeStr(Asc.referenceType.A); + this.txtDestRange.setValue(range); + this.dataDestValid = range; + setTimeout(function(){me.txtSourceRange.focus();}, 100); + } this.txtSourceRange.validation = function(value) { var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false); return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true; }; this.txtDestRange.validation = function(value) { - var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false); + var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.FormatTable, value, false); return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true; }; }, @@ -185,7 +186,7 @@ define([ } if (!isvalid) { this.txtSourceRange.showError([txtError]); - this.txtSourceRange.cmpEl.find('input').focus(); + this.txtSourceRange.focus(); return isvalid; } @@ -193,13 +194,13 @@ define([ isvalid = false; txtError = this.txtEmpty; } else { - isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, this.txtDestRange.getValue()); + isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.FormatTable, this.txtDestRange.getValue()); isvalid = (isvalid == Asc.c_oAscError.ID.No); !isvalid && (txtError = this.textInvalidRange); } if (!isvalid) { this.txtDestRange.showError([txtError]); - this.txtDestRange.cmpEl.find('input').focus(); + this.txtDestRange.focus(); return isvalid; } @@ -235,7 +236,7 @@ define([ win.setSettings({ api : me.api, range : (!_.isEmpty(txtRange.getValue()) && (txtRange.checkValidate()==true)) ? txtRange.getValue() : ((type=='source') ? me.dataSourceValid : me.dataDestValid), - type : Asc.c_oAscSelectionDialogType.Chart + type : (type=='source') ? Asc.c_oAscSelectionDialogType.Chart : Asc.c_oAscSelectionDialogType.FormatTable }); } }, From 21f6a6ae6204697a6351077efb2644383353c6ee Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 29 Mar 2021 18:26:22 +0300 Subject: [PATCH 5/7] [SSE] Add icons --- .../img/toolbar/1.25x/big/btn-sparkline.png | Bin 0 -> 397 bytes .../img/toolbar/1.5x/big/btn-sparkline.png | Bin 0 -> 392 bytes .../img/toolbar/1.75x/big/btn-sparkline.png | Bin 0 -> 436 bytes .../img/toolbar/1x/big/btn-sparkline.png | Bin 0 -> 363 bytes .../img/toolbar/2x/big/btn-sparkline.png | Bin 0 -> 479 bytes 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.25x/big/btn-sparkline.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.5x/big/btn-sparkline.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.75x/big/btn-sparkline.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1x/big/btn-sparkline.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/2x/big/btn-sparkline.png diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/1.25x/big/btn-sparkline.png b/apps/spreadsheeteditor/main/resources/img/toolbar/1.25x/big/btn-sparkline.png new file mode 100644 index 0000000000000000000000000000000000000000..e03dc660afa2b90ce2670f1dc10130612446007b GIT binary patch literal 397 zcmeAS@N?(olHy`uVBq!ia0vp^Za}Qe!3-qjPWHqDDVB6cUq=Rpjs4tz5?O(K#^NA% zCx&(BWL^R}oCO|{#S9GG!XV7ZFl&wkP|zd5C&bmgzz4|u|NlQS3E?7(z}XN6Pyrl3 zM3iK+&jDFtB|(0{3|S5i_Z1Wj4DL4w2sF%}KcOHYzkfn_yXhXFiZz}tjv*e$-(Eh+ z*J8lK9Kf78cf)zM|Noa4zvwu<qz>hFJDZFzA2 z%bI21XC}Nd418f^mhaa&@%*zXGZLF-Fm5Dtu75t0W%V{ zSer~47KF`A^V-YdvXZgklgKl#m72>G=LW5}Z*%I&wOSfCGbn4bZ?7KYYgXW4d%)DX z?ZvY9|F>9gQIVVQWmAsY-~0u2o%Ji2T$K1vJ=|At?`|dAuh=gIN92m1{G1zRe(TPQ zwkIy-iRw{?u~%7dsl;Cuoh3A3WyrLQa|f0c#V=yjp5f)8y~Ue3II^NOZ%1RL*8N4h z-z3aC6}&~j;pn35L(|I)oUNHnUhYb(%w`XsGC^VKM#HMP3w3xb`+G0G{_~YnIPChv z^plt7w9nrXaNK31*sED9Udde+o4@ae`(K7$mwy)WtlWZowi@jRg${$KtDnm{r-UW| DiPW8d literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/1.75x/big/btn-sparkline.png b/apps/spreadsheeteditor/main/resources/img/toolbar/1.75x/big/btn-sparkline.png new file mode 100644 index 0000000000000000000000000000000000000000..8b7a09c05b268d2158d2d4fb5fbd5fdfd2c31a18 GIT binary patch literal 436 zcmeAS@N?(olHy`uVBq!ia0vp^NkDAK!3-qD5_?jC6id3JuOkD)#(wTUiL5|AV{wqX z6T`Z5GB1G~&H|6fVg?3oVGw3ym^DWNC}3I+!ECnO{^G|Zp>GGHS+Q1ZE_i(^Q{;kQ>e3NwkN* z)~ZV#cYM?~?#R`VsXf5Q5TP?|f7;c3v8&{D+-#;sL@VFler(qdriWWvt_w9z?(3K` zm8HB@P>SOfx3ZbQdQQ)tBk!hFoIjD2@@c!v0|vuw>2o_o6pwvdBiz^i`Tp(@Rh!=D z`^#7QmB^<2IUcjh<-YT=`ZG_v3K$GFOcrZfJdyhl^8t^zD2aYIy^aH!`b-*CJJgh( z?&VnUVxd|05zfor8+RM0p2@%Z&hO5~R}3ewO#Z~+dDO`C?YkJA;K%REZY5v1eK)s! i`_;b%hmtn_F_8Z*FRoiFvUeNM%M6~belF{r5}E+g1hMk~ literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/1x/big/btn-sparkline.png b/apps/spreadsheeteditor/main/resources/img/toolbar/1x/big/btn-sparkline.png new file mode 100644 index 0000000000000000000000000000000000000000..25fb558eacc87e15b94710f5267f11ad6bd19fa6 GIT binary patch literal 363 zcmeAS@N?(olHy`uVBq!ia0vp^7CgFya-2?+@W`48hy)B@!vdAc};Se$-)=`>%n z0guZ?Zi!>hZnFRRzrO6C-h`6itwBe1gk>||u&mp2GRoq{rQL7K3(m46oPLrV`kP6H zdjoH3V*0$++%t*}mj%nV&0zj#(OBB-q*2mxwPE(-XPk3ff|;XuBFDibgwb)_*v-o_FakPzTIbvejT#ztN-$JAN%?_&sb;n^Sj-;HQ^o5bqt=a KelF{r5}E+5B9SWq literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/2x/big/btn-sparkline.png b/apps/spreadsheeteditor/main/resources/img/toolbar/2x/big/btn-sparkline.png new file mode 100644 index 0000000000000000000000000000000000000000..9a59a55140b2d3623496376d20bfb890ded77f80 GIT binary patch literal 479 zcmeAS@N?(olHy`uVBq!ia0vp^1wd@U!VDy@A5E+TQY`6?zK#qG8~eHcB(ehejKx9j zP7LeL$-D$|I14-?iy0WiR6&^0Gf3qFP|zU2C&bmgz~}$}|3DrPpfP}42!Klgxeqg! zwgdTmB|(0{4EOIVD3l8b%%7j%5D>87LxwBRS~*V_#}JR>Z?9N$9dZz0d(gVZe+$PA z_9S_gOx+j{?Fy!k9C8PhD_HU$2#V}!XjSL9p||8}(%hM+JU4asd)-lV_4xGhy`P%k zq3P?-dt2+xcxC(eA$LG@m)xc+G%a!+RdS&zbjBYRAxcY!XTx5GpTlVn@>3!>! nzt`{l|Ks#uhA&TF->qWUvM%%24Lw06P Date: Mon, 29 Mar 2021 18:27:26 +0300 Subject: [PATCH 6/7] [SSE] Add icons --- apps/spreadsheeteditor/main/app/view/Toolbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 683b4b0a4..1b30f9005 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -725,7 +725,7 @@ define([ me.btnInsertSparkline = new Common.UI.Button({ id : 'tlbtn-insertsparkline', cls : 'btn-toolbar x-huge icon-top', - iconCls : 'toolbar__icon btn-insert-sparkline', + iconCls : 'toolbar__icon btn-sparkline', lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.editPivot], caption : me.capInsertSpark, menu : true From 06e44a34b6844cd2e9f53e7d8ad0e0c2ab4b3d55 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 1 Apr 2021 13:41:23 +0300 Subject: [PATCH 7/7] [SSE] Add translation --- apps/spreadsheeteditor/main/locale/en.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index f73a181f5..f56d19f6a 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1637,6 +1637,12 @@ "SSE.Views.CreatePivotDialog.textSelectData": "Select data", "SSE.Views.CreatePivotDialog.textTitle": "Create Pivot Table", "SSE.Views.CreatePivotDialog.txtEmpty": "This field is required", + "SSE.Views.CreateSparklineDialog.textTitle": "Create Sparklines", + "SSE.Views.CreateSparklineDialog.textDataRange": "Source data range", + "SSE.Views.CreateSparklineDialog.textSelectData": "Select data", + "SSE.Views.CreateSparklineDialog.textDestination": "Choose, where to place the sparklines", + "SSE.Views.CreateSparklineDialog.txtEmpty": "This field is required", + "SSE.Views.CreateSparklineDialog.textInvalidRange": "Invalid cells range", "SSE.Views.DataTab.capBtnGroup": "Group", "SSE.Views.DataTab.capBtnTextCustomSort": "Custom Sort", "SSE.Views.DataTab.capBtnTextDataValidation": "Data Validation",