[SSE] Add pivot table button to the Insert tab.

This commit is contained in:
Julia Radzhabova 2020-09-23 21:15:45 +03:00
parent 1f056b16a5
commit 2493571d17
6 changed files with 30 additions and 25 deletions

View file

@ -1149,7 +1149,7 @@ define([
} }
if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && me.appOptions.canFeaturePivot) if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && me.appOptions.canFeaturePivot)
application.getController('PivotTable').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); application.getController('PivotTable').setMode(me.appOptions);
var viewport = this.getApplication().getController('Viewport').getView('Viewport'); var viewport = this.getApplication().getController('Viewport').getView('Viewport');
viewport.applyEditorMode(); viewport.applyEditorMode();

View file

@ -89,12 +89,10 @@ define([
Common.NotificationCenter.on('api:disconnect', _.bind(this.SetDisabled, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.SetDisabled, this));
}, },
setConfig: function (data, api) { setConfig: function (config) {
this.view = this.createView('PivotTable'); this.view = this.createView('PivotTable', {
this.setApi(api); toolbar: config.toolbar.toolbar
if (data) { });
this.sdkViewName = data['sdkviewname'] || this.sdkViewName;
}
}, },
setApi: function (api) { setApi: function (api) {
@ -106,6 +104,7 @@ define([
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this));
Common.NotificationCenter.on('cells:range', _.bind(this.onCellsRange, this)); Common.NotificationCenter.on('cells:range', _.bind(this.onCellsRange, this));
} }
return this;
}, },
setMode: function(mode) { setMode: function(mode) {
@ -400,7 +399,7 @@ define([
Common.Utils.lockControls(SSE.enumLock.noPivot, !pivotInfo, {array: this.view.lockedControls}); Common.Utils.lockControls(SSE.enumLock.noPivot, !pivotInfo, {array: this.view.lockedControls});
Common.Utils.lockControls(SSE.enumLock.pivotLock, pivotInfo && (info.asc_getLockedPivotTable()===true), {array: this.view.lockedControls}); Common.Utils.lockControls(SSE.enumLock.pivotLock, pivotInfo && (info.asc_getLockedPivotTable()===true), {array: this.view.lockedControls});
Common.Utils.lockControls(SSE.enumLock.editPivot, !!pivotInfo, {array: [this.view.btnAddPivot]}); Common.Utils.lockControls(SSE.enumLock.editPivot, !!pivotInfo, {array: this.view.btnsAddPivot});
if (pivotInfo) if (pivotInfo)
this.ChangeSettings(pivotInfo); this.ChangeSettings(pivotInfo);

View file

@ -3314,6 +3314,7 @@ define([
if ( config.canFeaturePivot ) { if ( config.canFeaturePivot ) {
tab = {action: 'pivot', caption: me.textPivot}; tab = {action: 'pivot', caption: me.textPivot};
var pivottab = me.getApplication().getController('PivotTable'); var pivottab = me.getApplication().getController('PivotTable');
pivottab.setApi(me.api).setConfig({toolbar: me});
$panel = pivottab.createToolbarPanel(); $panel = pivottab.createToolbarPanel();
if ($panel) { if ($panel) {
me.toolbar.addTab(tab, $panel, 5); me.toolbar.addTab(tab, $panel, 5);

View file

@ -120,6 +120,7 @@
</section> </section>
<section class="panel" data-tab="ins"> <section class="panel" data-tab="ins">
<div class="group"> <div class="group">
<span class="btn-slot text x-huge slot-add-pivot"></span>
<span class="btn-slot text x-huge" id="slot-btn-instable"></span> <span class="btn-slot text x-huge" id="slot-btn-instable"></span>
</div> </div>
<div class="separator long"></div> <div class="separator long"></div>

View file

@ -53,7 +53,7 @@ define([
var template = var template =
'<section id="pivot-table-panel" class="panel" data-tab="pivot">' + '<section id="pivot-table-panel" class="panel" data-tab="pivot">' +
'<div class="group">' + '<div class="group">' +
'<span id="slot-btn-add-pivot" class="btn-slot text x-huge"></span>' + '<span class="btn-slot text x-huge slot-add-pivot"></span>' +
'</div>' + '</div>' +
'<div class="separator long"></div>' + '<div class="separator long"></div>' +
'<div class="group">' + '<div class="group">' +
@ -94,8 +94,10 @@ define([
function setEvents() { function setEvents() {
var me = this; var me = this;
this.btnAddPivot.on('click', function (e) { this.btnsAddPivot.forEach(function(button) {
me.fireEvent('pivottable:create'); button.on('click', function (b, e) {
me.fireEvent('pivottable:create');
});
}); });
this.btnPivotLayout.menu.on('item:click', function (menu, item, e) { this.btnPivotLayout.menu.on('item:click', function (menu, item, e) {
@ -149,11 +151,14 @@ define([
initialize: function (options) { initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options); Common.UI.BaseView.prototype.initialize.call(this, options);
this.appConfig = options.mode; this.toolbar = options.toolbar;
this.lockedControls = []; this.lockedControls = [];
var _set = SSE.enumLock; var _set = SSE.enumLock;
this.btnsAddPivot = Common.Utils.injectButtons(this.toolbar.$el.find('.btn-slot.slot-add-pivot'), '', 'toolbar__icon btn-pivot-sum', this.txtPivotTable,
[_set.lostConnect, _set.coAuth, _set.editPivot, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.editCell]);
this.chRowHeader = new Common.UI.CheckBox({ this.chRowHeader = new Common.UI.CheckBox({
labelText: this.textRowHeader, labelText: this.textRowHeader,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock] lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock]
@ -178,14 +183,6 @@ define([
}); });
this.lockedControls.push(this.chColBanded); this.lockedControls.push(this.chColBanded);
this.btnAddPivot = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-pivot-sum',
caption: this.txtCreate,
disabled : false,
lock : [_set.lostConnect, _set.coAuth, _set.editPivot, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.editCell]
});
this.btnPivotLayout = new Common.UI.Button({ this.btnPivotLayout = new Common.UI.Button({
cls : 'btn-toolbar x-huge icon-top', cls : 'btn-toolbar x-huge icon-top',
iconCls : 'toolbar__icon btn-pivot-layout', iconCls : 'toolbar__icon btn-pivot-layout',
@ -276,7 +273,9 @@ define([
(new Promise(function (accept, reject) { (new Promise(function (accept, reject) {
accept(); accept();
})).then(function(){ })).then(function(){
me.btnAddPivot.updateHint(me.tipCreatePivot); me.btnsAddPivot.forEach( function(btn) {
btn.updateHint(me.tipCreatePivot);
});
me.btnRefreshPivot.updateHint(me.tipRefresh); me.btnRefreshPivot.updateHint(me.tipRefresh);
me.btnSelectPivot.updateHint(me.tipSelect); me.btnSelectPivot.updateHint(me.tipSelect);
me.btnPivotLayout.updateHint(me.capLayout); me.btnPivotLayout.updateHint(me.capLayout);
@ -325,12 +324,15 @@ define([
getPanel: function () { getPanel: function () {
this.$el = $(_.template(template)( {} )); this.$el = $(_.template(template)( {} ));
var _set = SSE.enumLock;
this.btnsAddPivot = this.btnsAddPivot.concat(Common.Utils.injectButtons(this.$el.find('.btn-slot.slot-add-pivot'), '', 'toolbar__icon btn-pivot-sum', this.txtCreate,
[_set.lostConnect, _set.coAuth, _set.editPivot, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.editCell]));
this.chRowHeader.render(this.$el.find('#slot-chk-header-row')); this.chRowHeader.render(this.$el.find('#slot-chk-header-row'));
this.chColHeader.render(this.$el.find('#slot-chk-header-column')); this.chColHeader.render(this.$el.find('#slot-chk-header-column'));
this.chRowBanded.render(this.$el.find('#slot-chk-banded-row')); this.chRowBanded.render(this.$el.find('#slot-chk-banded-row'));
this.chColBanded.render(this.$el.find('#slot-chk-banded-column')); this.chColBanded.render(this.$el.find('#slot-chk-banded-column'));
this.btnAddPivot.render(this.$el.find('#slot-btn-add-pivot'));
this.btnRefreshPivot.render(this.$el.find('#slot-btn-refresh-pivot')); this.btnRefreshPivot.render(this.$el.find('#slot-btn-refresh-pivot'));
this.btnSelectPivot.render(this.$el.find('#slot-btn-select-pivot')); this.btnSelectPivot.render(this.$el.find('#slot-btn-select-pivot'));
this.btnPivotLayout.render(this.$el.find('#slot-btn-pivot-report-layout')); this.btnPivotLayout.render(this.$el.find('#slot-btn-pivot-report-layout'));
@ -352,11 +354,11 @@ define([
}, },
getButtons: function(type) { getButtons: function(type) {
return this.lockedControls.concat(this.btnAddPivot); return this.btnsAddPivot.concat(this.lockedControls);
}, },
SetDisabled: function (state) { SetDisabled: function (state) {
this.lockedControls.concat(this.btnAddPivot).forEach(function(button) { this.btnsAddPivot.concat(this.lockedControls).forEach(function(button) {
if ( button ) { if ( button ) {
button.setDisabled(state); button.setDisabled(state);
} }
@ -392,7 +394,8 @@ define([
tipGrandTotals: 'Show or hide grand totals', tipGrandTotals: 'Show or hide grand totals',
tipSubtotals: 'Show or hide subtotals', tipSubtotals: 'Show or hide subtotals',
txtSelect: 'Select', txtSelect: 'Select',
tipSelect: 'Select entire pivot table' tipSelect: 'Select entire pivot table',
txtPivotTable: 'Pivot Table'
} }
}()), SSE.Views.PivotTable || {})); }()), SSE.Views.PivotTable || {}));
}); });

View file

@ -2183,6 +2183,7 @@
"SSE.Views.PivotTable.txtCreate": "Insert Table", "SSE.Views.PivotTable.txtCreate": "Insert Table",
"SSE.Views.PivotTable.txtRefresh": "Refresh", "SSE.Views.PivotTable.txtRefresh": "Refresh",
"SSE.Views.PivotTable.txtSelect": "Select", "SSE.Views.PivotTable.txtSelect": "Select",
"SSE.Views.PivotTable.txtPivotTable": "Pivot Table",
"SSE.Views.PrintSettings.btnDownload": "Save & Download", "SSE.Views.PrintSettings.btnDownload": "Save & Download",
"SSE.Views.PrintSettings.btnPrint": "Save & Print", "SSE.Views.PrintSettings.btnPrint": "Save & Print",
"SSE.Views.PrintSettings.strBottom": "Bottom", "SSE.Views.PrintSettings.strBottom": "Bottom",