[SSE] Add processing of some pivot settings
This commit is contained in:
parent
cc05a8ae5b
commit
7d4cdabdb3
|
@ -136,11 +136,32 @@ define([
|
|||
Common.NotificationCenter.trigger('edit:complete', this);
|
||||
},
|
||||
|
||||
createSheetName: function() {
|
||||
var items = [], wc = this.api.asc_getWorksheetsCount();
|
||||
while (wc--) {
|
||||
items.push(this.api.asc_getWorksheetName(wc).toLowerCase());
|
||||
}
|
||||
|
||||
var index = 0, name;
|
||||
while(++index < 1000) {
|
||||
name = this.strSheet + index;
|
||||
if (items.indexOf(name.toLowerCase()) < 0) break;
|
||||
}
|
||||
|
||||
return name;
|
||||
},
|
||||
|
||||
onCreateClick: function(btn, opts){
|
||||
if (this.api) {
|
||||
this.api.asc_insertPivot("Sheet1!B2:H13", this.createSheetName());
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', this);
|
||||
},
|
||||
|
||||
onRefreshClick: function(btn, opts){
|
||||
if (this.api) {
|
||||
this._originalProps.asc_refresh(this.api);
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', this);
|
||||
},
|
||||
|
||||
|
@ -160,29 +181,37 @@ define([
|
|||
|
||||
onPivotBlankRows: function(type){
|
||||
if (this.api) {
|
||||
if (type === 'insert'){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
var props = new Asc.CT_pivotTableDefinition();
|
||||
props.asc_setInsertBlankRow(type === 'insert');
|
||||
this._originalProps.asc_set(this.api, props);
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', this);
|
||||
},
|
||||
|
||||
onPivotLayout: function(type){
|
||||
if (this.api) {
|
||||
var props = new Asc.CT_pivotTableDefinition();
|
||||
switch (type){
|
||||
case 0:
|
||||
props.asc_setCompact(true);
|
||||
props.asc_setOutline(true);
|
||||
break;
|
||||
case 1:
|
||||
props.asc_setCompact(false);
|
||||
props.asc_setOutline(true);
|
||||
break;
|
||||
case 2:
|
||||
props.asc_setCompact(false);
|
||||
props.asc_setOutline(false);
|
||||
break;
|
||||
case 3:
|
||||
props.asc_setFillDownLabelsDefault(true);
|
||||
break;
|
||||
case 4:
|
||||
props.asc_setFillDownLabelsDefault(false);
|
||||
break;
|
||||
}
|
||||
this._originalProps.asc_set(this.api, props);
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', this);
|
||||
},
|
||||
|
@ -199,14 +228,21 @@ define([
|
|||
|
||||
onPivotSubtotals: function(type){
|
||||
if (this.api) {
|
||||
var props = new Asc.CT_pivotTableDefinition();
|
||||
switch (type){
|
||||
case 0:
|
||||
props.asc_setDefaultSubtotal(false);
|
||||
break;
|
||||
case 1:
|
||||
props.asc_setDefaultSubtotal(true);
|
||||
props.asc_setSubtotalTop(false);
|
||||
break;
|
||||
case 2:
|
||||
props.asc_setDefaultSubtotal(true);
|
||||
props.asc_setSubtotalTop(true);
|
||||
break;
|
||||
}
|
||||
this._originalProps.asc_set(this.api, props);
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', this);
|
||||
},
|
||||
|
@ -348,7 +384,9 @@ define([
|
|||
resolve();
|
||||
})).then(function () {
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
strSheet : 'Sheet'
|
||||
|
||||
}, SSE.Controllers.PivotTable || {}));
|
||||
});
|
|
@ -227,14 +227,22 @@ define([ 'text!spreadsheeteditor/main/app/template/FieldSettingsDialog.templa
|
|||
_setDefaults: function (props) {
|
||||
if (props) {
|
||||
var me = this,
|
||||
cache_names = props.asc_getCacheFields(),
|
||||
field = props.asc_getPivotFields()[this.fieldIndex];
|
||||
|
||||
this.lblSourceName.html(Common.Utils.String.htmlEncode(cache_names[this.fieldIndex].asc_getName()));
|
||||
this.inputCustomName.setValue(Common.Utils.String.htmlEncode((field || cache_names[this.fieldIndex]).asc_getName()));
|
||||
this.lblSourceName.html(Common.Utils.String.htmlEncode(props.getCacheFieldName(this.fieldIndex)));
|
||||
this.inputCustomName.setValue(Common.Utils.String.htmlEncode(props.getPivotFieldName(this.fieldIndex)));
|
||||
|
||||
(field.asc_getOutline()) ? this.radioOutline.setValue(true) : this.radioTabular.setValue(true);
|
||||
this.chCompact.setValue(field.asc_getOutline() && field.asc_getCompact());
|
||||
|
||||
this.chRepeat.setValue(field.asc_getFillDownLabelsDefault());
|
||||
this.chBlank.setValue(field.asc_getInsertBlankRow());
|
||||
|
||||
this.chSubtotals.setValue(field.asc_getDefaultSubtotal());
|
||||
(field.asc_getSubtotalTop()) ? this.radioTop.setValue(true) : this.radioBottom.setValue(true);
|
||||
|
||||
this.chEmpty.setValue(field.asc_getShowAll());
|
||||
if (field.asc_getDefaultSubtotal()) {
|
||||
var arr = field.asc_getSubtotals();
|
||||
if (arr) {
|
||||
_.each(arr, function(item) {
|
||||
|
@ -276,10 +284,62 @@ define([ 'text!spreadsheeteditor/main/app/template/FieldSettingsDialog.templa
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getSettings: function () {
|
||||
return {};
|
||||
var field = new Asc.CT_PivotField();
|
||||
field.asc_setName(this.inputCustomName.getValue());
|
||||
|
||||
field.asc_setOutline(this.radioOutline.getValue());
|
||||
field.asc_setCompact(this.radioOutline.getValue() && this.chCompact.getValue() == 'checked');
|
||||
|
||||
field.asc_setFillDownLabelsDefault(this.chRepeat.getValue() == 'checked');
|
||||
field.asc_setInsertBlankRow(this.chBlank.getValue() == 'checked');
|
||||
|
||||
field.asc_setDefaultSubtotal(this.chSubtotals.getValue() == 'checked');
|
||||
field.asc_setSubtotalTop(this.radioTop.getValue());
|
||||
|
||||
field.asc_setShowAll(this.chEmpty.getValue() == 'checked');
|
||||
if (field.asc_getDefaultSubtotal()) {
|
||||
var arr = [];
|
||||
if (this.chSum.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.Sum);
|
||||
}
|
||||
if (this.chCount.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.Count);
|
||||
}
|
||||
if (this.chAve.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.Avg);
|
||||
}
|
||||
if (this.chMax.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.Max);
|
||||
}
|
||||
if (this.chMin.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.Min);
|
||||
}
|
||||
if (this.chProduct.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.Product);
|
||||
}
|
||||
if (this.chNum.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.CountA);
|
||||
}
|
||||
if (this.chDev.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.StdDev);
|
||||
}
|
||||
if (this.chDevp.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.StdDevP);
|
||||
}
|
||||
if (this.chVar.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.Var);
|
||||
}
|
||||
if (this.chVarp.getValue() == 'checked') {
|
||||
arr.push(Asc.c_oAscItemType.VarP);
|
||||
}
|
||||
field.asc_setSubtotals(arr);
|
||||
}
|
||||
|
||||
return field;
|
||||
},
|
||||
|
||||
onDlgBtnClick: function(event) {
|
||||
|
|
|
@ -344,17 +344,17 @@ define([
|
|||
caption : this.txtAddRow,
|
||||
checkable : false
|
||||
});
|
||||
// this.miAddRow.on('click', _.bind(this.onAddRow, this));
|
||||
this.miAddRow.on('click', _.bind(this.onAddRow, this));
|
||||
this.miAddColumn = new Common.UI.MenuItem({
|
||||
caption : this.txtAddColumn,
|
||||
checkable : false
|
||||
});
|
||||
// this.miAddColumn.on('click', _.bind(this.onAddColumn, this));
|
||||
this.miAddColumn.on('click', _.bind(this.onAddColumn, this));
|
||||
this.miAddValues = new Common.UI.MenuItem({
|
||||
caption : this.txtAddValues,
|
||||
checkable : false
|
||||
});
|
||||
// this.miAddValues.on('click', _.bind(this.onAddValues, this));
|
||||
this.miAddValues.on('click', _.bind(this.onAddValues, this));
|
||||
|
||||
this.pivotFieldsMenu = new Common.UI.Menu({
|
||||
menuAlign: 'tr-br',
|
||||
|
@ -435,6 +435,13 @@ define([
|
|||
listView.isSuspendEvents = true;
|
||||
|
||||
record.set('check', !record.get('check'));
|
||||
if (this.api && !this._locked){
|
||||
if (record.get('check')) {
|
||||
this._originalProps.asc_addField(this.api, record.get('index'));
|
||||
} else {
|
||||
this._originalProps.asc_removeField(this.api, record.get('index'));
|
||||
}
|
||||
}
|
||||
|
||||
listView.isSuspendEvents = false;
|
||||
listView.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true});
|
||||
|
@ -602,6 +609,7 @@ define([
|
|||
}
|
||||
})).show();
|
||||
} else {
|
||||
var pivotField = me._originalProps.asc_getPivotFields()[me._state.field.record.get('pivotIndex')];
|
||||
(new SSE.Views.FieldSettingsDialog(
|
||||
{
|
||||
props: me._originalProps,
|
||||
|
@ -611,7 +619,7 @@ define([
|
|||
type: me._state.field.type,
|
||||
handler: function(result, value) {
|
||||
if (result == 'ok' && me.api && value) {
|
||||
// me.api.asc_changeFormatTableInfo(me._state.TableName, Asc.c_oAscChangeTableStyleInfo.advancedSettings, value);
|
||||
pivotField.asc_set(me.api, me._originalProps, value);
|
||||
}
|
||||
|
||||
Common.NotificationCenter.trigger('edit:complete', me);
|
||||
|
@ -627,6 +635,24 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onAddRow: function() {
|
||||
if (this.api && !this._locked && this._state.field){
|
||||
this._originalProps.asc_addRowField(this.api, this._state.field.record.get('index'));
|
||||
}
|
||||
},
|
||||
|
||||
onAddColumn: function() {
|
||||
if (this.api && !this._locked && this._state.field){
|
||||
this._originalProps.asc_addColField(this.api, this._state.field.record.get('index'));
|
||||
}
|
||||
},
|
||||
|
||||
onAddValues: function() {
|
||||
if (this.api && !this._locked && this._state.field){
|
||||
this._originalProps.asc_addDataField(this.api, this._state.field.record.get('index'));
|
||||
}
|
||||
},
|
||||
|
||||
onRemove: function() {
|
||||
if (this.api && !this._locked && this._state.field){
|
||||
this._originalProps.asc_removeField(this.api, this._state.field.record.get('pivotIndex'));
|
||||
|
|
|
@ -217,8 +217,12 @@ define([ 'text!spreadsheeteditor/main/app/template/PivotSettingsAdvanced.temp
|
|||
|
||||
getSettings: function () {
|
||||
var props = new Asc.CT_pivotTableDefinition();
|
||||
props.asc_setName(this.inputName.getValue());
|
||||
props.asc_setRowGrandTotals(this.chCols.getValue() == 'checked');
|
||||
props.asc_setColGrandTotals(this.chRows.getValue() == 'checked');
|
||||
props.asc_setPageOverThenDown(this.radioOver.getValue());
|
||||
props.asc_setPageWrap(this.numWrap.getNumberValue());
|
||||
props.asc_setShowHeaders(this.chHeaders.getValue() == 'checked');
|
||||
|
||||
return props;
|
||||
},
|
||||
|
|
|
@ -52,21 +52,21 @@ define([
|
|||
SSE.Views.PivotTable = Common.UI.BaseView.extend(_.extend((function(){
|
||||
var template =
|
||||
'<section id="pivot-table-panel" class="panel" data-tab="pivot">' +
|
||||
// '<div class="group">' +
|
||||
// '<span id="slot-btn-add-pivot" class="btn-slot text x-huge"></span>' +
|
||||
// '</div>' +
|
||||
// '<div class="separator long"/>' +
|
||||
// '<div class="group">' +
|
||||
// '<span id="slot-btn-pivot-report-layout" class="btn-slot text x-huge"></span>' +
|
||||
// '<span id="slot-btn-pivot-blank-rows" class="btn-slot text x-huge"></span>' +
|
||||
// '<span id="slot-btn-pivot-subtotals" class="btn-slot text x-huge"></span>' +
|
||||
// '<span id="slot-btn-pivot-grand-totals" class="btn-slot text x-huge"></span>' +
|
||||
// '</div>' +
|
||||
// '<div class="separator long"/>' +
|
||||
// '<div class="group">' +
|
||||
// '<span id="slot-btn-refresh-pivot" class="btn-slot text x-huge"></span>' +
|
||||
// '</div>' +
|
||||
// '<div class="separator long"/>' +
|
||||
'<div class="group">' +
|
||||
'<span id="slot-btn-add-pivot" class="btn-slot text x-huge"></span>' +
|
||||
'</div>' +
|
||||
'<div class="separator long"/>' +
|
||||
'<div class="group">' +
|
||||
'<span id="slot-btn-pivot-report-layout" class="btn-slot text x-huge"></span>' +
|
||||
'<span id="slot-btn-pivot-blank-rows" class="btn-slot text x-huge"></span>' +
|
||||
'<span id="slot-btn-pivot-subtotals" class="btn-slot text x-huge"></span>' +
|
||||
'<span id="slot-btn-pivot-grand-totals" class="btn-slot text x-huge"></span>' +
|
||||
'</div>' +
|
||||
'<div class="separator long"/>' +
|
||||
'<div class="group">' +
|
||||
'<span id="slot-btn-refresh-pivot" class="btn-slot text x-huge"></span>' +
|
||||
'</div>' +
|
||||
'<div class="separator long"/>' +
|
||||
'<div class="group">' +
|
||||
'<span id="slot-btn-select-pivot" class="btn-slot text x-huge"></span>' +
|
||||
'</div>' +
|
||||
|
@ -176,7 +176,7 @@ define([
|
|||
cls: 'btn-toolbar x-huge icon-top',
|
||||
iconCls: 'btn-add-pivot',
|
||||
caption: this.txtCreate,
|
||||
disabled : true
|
||||
disabled : false
|
||||
});
|
||||
// this.lockedControls.push(this.btnAddPivot);
|
||||
|
||||
|
@ -196,7 +196,7 @@ define([
|
|||
]
|
||||
})
|
||||
});
|
||||
// this.lockedControls.push(this.btnPivotLayout); // remove commentings after enabled option
|
||||
this.lockedControls.push(this.btnPivotLayout);
|
||||
|
||||
this.btnPivotBlankRows = new Common.UI.Button({
|
||||
cls : 'btn-toolbar x-huge icon-top',
|
||||
|
@ -210,7 +210,7 @@ define([
|
|||
]
|
||||
})
|
||||
});
|
||||
// this.lockedControls.push(this.btnPivotBlankRows); // remove commentings after enabled option
|
||||
this.lockedControls.push(this.btnPivotBlankRows);
|
||||
|
||||
this.btnPivotSubtotals = new Common.UI.Button({
|
||||
cls : 'btn-toolbar x-huge icon-top',
|
||||
|
@ -225,7 +225,7 @@ define([
|
|||
]
|
||||
})
|
||||
});
|
||||
// this.lockedControls.push(this.btnPivotSubtotals); // remove commentings after enabled option
|
||||
this.lockedControls.push(this.btnPivotSubtotals);
|
||||
|
||||
this.btnPivotGrandTotals = new Common.UI.Button({
|
||||
cls : 'btn-toolbar x-huge icon-top',
|
||||
|
@ -241,7 +241,7 @@ define([
|
|||
]
|
||||
})
|
||||
});
|
||||
// this.lockedControls.push(this.btnPivotGrandTotals); // remove commentings after enabled option
|
||||
this.lockedControls.push(this.btnPivotGrandTotals);
|
||||
|
||||
this.btnRefreshPivot = new Common.UI.Button({
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
|
@ -249,7 +249,7 @@ define([
|
|||
caption: this.txtRefresh,
|
||||
disabled : true
|
||||
});
|
||||
// this.lockedControls.push(this.btnRefreshPivot);
|
||||
this.lockedControls.push(this.btnRefreshPivot);
|
||||
|
||||
this.btnSelectPivot = new Common.UI.Button({
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
|
|
Loading…
Reference in a new issue