[SSE] Add dialog for creating pivot table
This commit is contained in:
parent
18ab148633
commit
4e45c72734
|
@ -40,7 +40,8 @@
|
|||
|
||||
define([
|
||||
'core',
|
||||
'spreadsheeteditor/main/app/view/PivotTable'
|
||||
'spreadsheeteditor/main/app/view/PivotTable',
|
||||
'spreadsheeteditor/main/app/view/CreatePivotDialog'
|
||||
], function () {
|
||||
'use strict';
|
||||
|
||||
|
@ -155,8 +156,21 @@ define([
|
|||
if (this.api) {
|
||||
var options = this.api.asc_getAddPivotTableOptions();
|
||||
if (options) {
|
||||
this.api.asc_insertPivotNewWorksheet(options.asc_getRange(), this.createSheetName());
|
||||
// this.api.asc_insertPivotExistingWorksheet(options.asc_getRange(), "Sheet1!B17:B17");
|
||||
var me = this;
|
||||
(new SSE.Views.CreatePivotDialog(
|
||||
{
|
||||
props: options,
|
||||
api: me.api,
|
||||
handler: function(result, settings) {
|
||||
if (result == 'ok' && settings) {
|
||||
if (settings.destination)
|
||||
me.api.asc_insertPivotExistingWorksheet(settings.source, settings.destination);
|
||||
else
|
||||
me.api.asc_insertPivotNewWorksheet(settings.source, me.createSheetName());
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', me);
|
||||
}
|
||||
})).show();
|
||||
}
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', this);
|
||||
|
|
|
@ -72,9 +72,17 @@ define([ 'text!spreadsheeteditor/main/app/template/PivotSettingsAdvanced.temp
|
|||
}, options);
|
||||
|
||||
this.api = options.api;
|
||||
this.handler = options.handler;
|
||||
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;
|
||||
};
|
||||
|
||||
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
||||
},
|
||||
|
||||
|
@ -227,36 +235,25 @@ define([ 'text!spreadsheeteditor/main/app/template/PivotSettingsAdvanced.temp
|
|||
return props;
|
||||
},
|
||||
|
||||
onDlgBtnClick: function(event) {
|
||||
var me = this;
|
||||
var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event;
|
||||
if (state == 'ok' && this.isRangeValid()) {
|
||||
this.handler && this.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined);
|
||||
}
|
||||
|
||||
this.close();
|
||||
},
|
||||
|
||||
onPrimary: function() {
|
||||
this.onDlgBtnClick('ok');
|
||||
return false;
|
||||
},
|
||||
|
||||
isRangeValid: function() {
|
||||
if (this.isChart) {
|
||||
var isvalid;
|
||||
if (!_.isEmpty(this.txtDataRange.getValue())) {
|
||||
isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Pivot, this.txtDataRange.getValue());
|
||||
if (isvalid == Asc.c_oAscError.ID.No)
|
||||
return true;
|
||||
} else
|
||||
this.txtDataRange.showError([this.txtEmpty]);
|
||||
var isvalid = true,
|
||||
txtError = '';
|
||||
|
||||
if (_.isEmpty(this.txtDataRange.getValue())) {
|
||||
isvalid = false;
|
||||
txtError = this.txtEmpty;
|
||||
} else {
|
||||
// isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Pivot, this.txtDataRange.getValue());
|
||||
// isvalid = (isvalid == Asc.c_oAscError.ID.No);
|
||||
!isvalid && (txtError = this.textInvalidRange);
|
||||
}
|
||||
if (!isvalid) {
|
||||
this.setActiveCategory(1);
|
||||
this.txtDataRange.showError([txtError]);
|
||||
this.txtDataRange.cmpEl.find('input').focus();
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
return isvalid;
|
||||
}
|
||||
return isvalid;
|
||||
},
|
||||
|
||||
onSelectData: function() {
|
||||
|
|
|
@ -1341,6 +1341,14 @@
|
|||
"SSE.Views.ChartSettingsDlg.textYAxisTitle": "Y Axis Title",
|
||||
"SSE.Views.ChartSettingsDlg.textZero": "Zero",
|
||||
"SSE.Views.ChartSettingsDlg.txtEmpty": "This field is required",
|
||||
"SSE.Views.CreatePivotDialog.textTitle": "Create Table",
|
||||
"SSE.Views.CreatePivotDialog.textDataRange": "Source data range",
|
||||
"SSE.Views.CreatePivotDialog.textSelectData": "Select",
|
||||
"SSE.Views.CreatePivotDialog.textDestination": "Choose, where to place the table",
|
||||
"SSE.Views.CreatePivotDialog.textNew": "New worksheet",
|
||||
"SSE.Views.CreatePivotDialog.textExist": "Existing worksheet",
|
||||
"SSE.Views.CreatePivotDialog.txtEmpty": "This field is required",
|
||||
"SSE.Views.CreatePivotDialog.textInvalidRange": "Invalid cells range",
|
||||
"SSE.Views.DataTab.capBtnGroup": "Group",
|
||||
"SSE.Views.DataTab.capBtnTextToCol": "Text to Columns",
|
||||
"SSE.Views.DataTab.capBtnUngroup": "Ungroup",
|
||||
|
|
Loading…
Reference in a new issue