From 4c10324957ef339f2b256d7be8e8e957ca5f0c96 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 2 Oct 2020 18:33:07 +0300 Subject: [PATCH] [SSE] Select chart data in diagramm mode --- .../main/app/controller/Toolbar.js | 36 ++++++++++++++++++- .../main/app/template/ToolbarAnother.template | 1 + .../main/app/view/Toolbar.js | 14 ++++++-- apps/spreadsheeteditor/main/locale/en.json | 1 + 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index e416582c0..cabb7d14d 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -274,6 +274,7 @@ define([ if (toolbar.cmbNumberFormat.cmpEl) toolbar.cmbNumberFormat.cmpEl.on('click', '#id-toolbar-mnu-item-more-formats a', _.bind(this.onNumberFormatSelect, this)); toolbar.btnEditChart.on('click', _.bind(this.onEditChart, this)); + toolbar.btnEditChartData.on('click', _.bind(this.onEditChartData, this)); } else if ( me.appConfig.isEditMailMerge ) { toolbar.btnUndo.on('click', _.bind(this.onUndo, this)); @@ -968,6 +969,35 @@ define([ } }, + onEditChartData: function(btn) { + if (!this.editMode) return; + + var me = this; + var props; + if (me.api){ + props = me.api.asc_getChartObject(); + if (props) { + me._isEditRanges = true; + props.startEdit(); + var win = new SSE.Views.ChartDataDialog({ + chartSettings: props, + api: me.api, + handler: function(result, value) { + if (result == 'ok') { + props.endEdit(); + me._isEditRanges = false; + } + Common.NotificationCenter.trigger('edit:complete', me); + } + }).on('close', function() { + me._isEditRanges && props.cancelEdit(); + me._isEditRanges = false; + }); + win.show(); + } + } + }, + onSelectChart: function(group, type) { if (!this.editMode) return; var me = this, @@ -1817,7 +1847,7 @@ define([ var toolbar = this.toolbar; if (toolbar.mode.isEditDiagram || toolbar.mode.isEditMailMerge) { is_cell_edited = (state == Asc.c_oAscCellEditorState.editStart); - toolbar.lockToolbar(SSE.enumLock.editCell, state == Asc.c_oAscCellEditorState.editStart, {array: [toolbar.btnDecDecimal,toolbar.btnIncDecimal,toolbar.cmbNumberFormat]}); + toolbar.lockToolbar(SSE.enumLock.editCell, state == Asc.c_oAscCellEditorState.editStart, {array: [toolbar.btnDecDecimal,toolbar.btnIncDecimal,toolbar.cmbNumberFormat, toolbar.btnEditChartData]}); } else if (state == Asc.c_oAscCellEditorState.editStart || state == Asc.c_oAscCellEditorState.editEnd) { toolbar.lockToolbar(SSE.enumLock.editCell, state == Asc.c_oAscCellEditorState.editStart, { @@ -2556,6 +2586,10 @@ define([ if ( _disableEditOptions(selectionType, coauth_disable) ) return; + var need_disable = (selectionType === Asc.c_oAscSelectionType.RangeCells || selectionType === Asc.c_oAscSelectionType.RangeCol || + selectionType === Asc.c_oAscSelectionType.RangeRow || selectionType === Asc.c_oAscSelectionType.RangeMax); + this.toolbar.lockToolbar( SSE.enumLock.selRange, need_disable, {array:[this.toolbar.btnEditChartData]} ); + if (selectionType == Asc.c_oAscSelectionType.RangeChart || selectionType == Asc.c_oAscSelectionType.RangeChartText) return; diff --git a/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template b/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template index 82b536786..611aab6f4 100644 --- a/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template +++ b/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template @@ -30,6 +30,7 @@
+
diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index e65dee66c..fa5315672 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -276,6 +276,14 @@ define([ lock : [_set.lostConnect], style : 'width: 120px;' }); + + me.btnEditChartData = new Common.UI.Button({ + id : 'id-toolbar-rtn-edit-chart-data', + cls : 'btn-toolbar btn-text-value', + caption : me.tipEditChartData, + lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect], + style : 'width: 120px;' + }); } else if ( config.isEditMailMerge ) { me.$layout = $(_.template(simple)(config)); @@ -1629,6 +1637,7 @@ define([ _injectComponent('#slot-btn-inschart', this.btnInsertChart); _injectComponent('#slot-field-styles', this.listStyles); _injectComponent('#slot-btn-chart', this.btnEditChart); + _injectComponent('#slot-btn-chart-data', this.btnEditChartData); _injectComponent('#slot-btn-pageorient', this.btnPageOrient); _injectComponent('#slot-btn-pagemargins', this.btnPageMargins); _injectComponent('#slot-btn-pagesize', this.btnPageSize); @@ -1973,7 +1982,7 @@ define([ if (mode.isDisconnected) { this.lockToolbar( SSE.enumLock.lostConnect, true ); this.lockToolbar( SSE.enumLock.lostConnect, true, - {array:[this.btnEditChart,this.btnUndo,this.btnRedo]} ); + {array:[this.btnEditChart, this.btnEditChartData, this.btnUndo,this.btnRedo]} ); if (!mode.enableDownload) this.lockToolbar(SSE.enumLock.cantPrint, true, {array: [this.btnPrint]}); } else { @@ -2436,6 +2445,7 @@ define([ capBtnInsSlicer: 'Slicer', tipInsertSlicer: 'Insert slicer', textVertical: 'Vertical Text', - textTabView: 'View' + textTabView: 'View', + tipEditChartData: 'Select Data' }, 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 76229fefc..71aaa8a68 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2896,6 +2896,7 @@ "SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells", "SSE.Views.Toolbar.txtYen": "¥ Yen", "SSE.Views.Toolbar.textTabView": "View", + "SSE.Views.Toolbar.tipEditChartData": "Select Data", "SSE.Views.Top10FilterDialog.textType": "Show", "SSE.Views.Top10FilterDialog.txtBottom": "Bottom", "SSE.Views.Top10FilterDialog.txtBy": "by",