[SSE] Group/ungroup pivot table
This commit is contained in:
parent
b0fedaa13f
commit
274f56291a
|
@ -72,7 +72,8 @@ define([
|
||||||
'spreadsheeteditor/main/app/view/SetValueDialog',
|
'spreadsheeteditor/main/app/view/SetValueDialog',
|
||||||
'spreadsheeteditor/main/app/view/AutoFilterDialog',
|
'spreadsheeteditor/main/app/view/AutoFilterDialog',
|
||||||
'spreadsheeteditor/main/app/view/SpecialPasteDialog',
|
'spreadsheeteditor/main/app/view/SpecialPasteDialog',
|
||||||
'spreadsheeteditor/main/app/view/SlicerSettingsAdvanced'
|
'spreadsheeteditor/main/app/view/SlicerSettingsAdvanced',
|
||||||
|
'spreadsheeteditor/main/app/view/PivotGroupDialog'
|
||||||
], function () {
|
], function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -196,6 +197,8 @@ define([
|
||||||
view.pmiSortCells.menu.on('item:click', _.bind(me.onSortCells, me));
|
view.pmiSortCells.menu.on('item:click', _.bind(me.onSortCells, me));
|
||||||
view.pmiFilterCells.menu.on('item:click', _.bind(me.onFilterCells, me));
|
view.pmiFilterCells.menu.on('item:click', _.bind(me.onFilterCells, me));
|
||||||
view.pmiReapply.on('click', _.bind(me.onReapply, me));
|
view.pmiReapply.on('click', _.bind(me.onReapply, me));
|
||||||
|
view.mnuGroupPivot.on('click', _.bind(me.onGroupPivot, me));
|
||||||
|
view.mnuUnGroupPivot.on('click', _.bind(me.onGroupPivot, me));
|
||||||
view.pmiClear.menu.on('item:click', _.bind(me.onClear, me));
|
view.pmiClear.menu.on('item:click', _.bind(me.onClear, me));
|
||||||
view.pmiSelectTable.menu.on('item:click', _.bind(me.onSelectTable, me));
|
view.pmiSelectTable.menu.on('item:click', _.bind(me.onSelectTable, me));
|
||||||
view.pmiInsertTable.menu.on('item:click', _.bind(me.onInsertTable, me));
|
view.pmiInsertTable.menu.on('item:click', _.bind(me.onInsertTable, me));
|
||||||
|
@ -323,6 +326,7 @@ define([
|
||||||
this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this.onChangeCropState, this));
|
this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this.onChangeCropState, this));
|
||||||
this.api.asc_registerCallback('asc_onInputMessage', _.bind(this.onInputMessage, this));
|
this.api.asc_registerCallback('asc_onInputMessage', _.bind(this.onInputMessage, this));
|
||||||
this.api.asc_registerCallback('asc_onTableTotalMenu', _.bind(this.onTableTotalMenu, this));
|
this.api.asc_registerCallback('asc_onTableTotalMenu', _.bind(this.onTableTotalMenu, this));
|
||||||
|
this.api.asc_registerCallback('asc_onShowPivotGroupDialog', _.bind(this.onShowPivotGroupDialog, this));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -474,6 +478,27 @@ define([
|
||||||
this.api.asc_reapplyAutoFilter(this.documentHolder.ssMenu.formatTableName);
|
this.api.asc_reapplyAutoFilter(this.documentHolder.ssMenu.formatTableName);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onGroupPivot: function(item) {
|
||||||
|
item.value=='grouping' ? this.api.asc_groupPivot() : this.api.asc_ungroupPivot();
|
||||||
|
},
|
||||||
|
|
||||||
|
onShowPivotGroupDialog: function(rangePr, dateTypes) {
|
||||||
|
var win, props,
|
||||||
|
me = this;
|
||||||
|
win = new SSE.Views.PivotGroupDialog({
|
||||||
|
date: !!dateTypes,
|
||||||
|
handler: function(dlg, result) {
|
||||||
|
if (result == 'ok') {
|
||||||
|
props = dlg.getSettings();
|
||||||
|
me.api.asc_groupPivot(props[0], props[1]);
|
||||||
|
Common.NotificationCenter.trigger('edit:complete', me.documentHolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
win.show();
|
||||||
|
win.setSettings(rangePr, dateTypes, me.permissions.lang);
|
||||||
|
},
|
||||||
|
|
||||||
onClear: function(menu, item) {
|
onClear: function(menu, item) {
|
||||||
if (this.api) {
|
if (this.api) {
|
||||||
this.api.asc_emptyCells(item.value);
|
this.api.asc_emptyCells(item.value);
|
||||||
|
@ -1657,6 +1682,7 @@ define([
|
||||||
seltype = cellinfo.asc_getSelectionType(),
|
seltype = cellinfo.asc_getSelectionType(),
|
||||||
isCellLocked = cellinfo.asc_getLocked(),
|
isCellLocked = cellinfo.asc_getLocked(),
|
||||||
isTableLocked = cellinfo.asc_getLockedTable()===true,
|
isTableLocked = cellinfo.asc_getLockedTable()===true,
|
||||||
|
isPivotLocked = cellinfo.asc_getLockedPivotTable()===true,
|
||||||
isObjLocked = false,
|
isObjLocked = false,
|
||||||
commentsController = this.getApplication().getController('Common.Controllers.Comments'),
|
commentsController = this.getApplication().getController('Common.Controllers.Comments'),
|
||||||
internaleditor = this.permissions.isEditMailMerge || this.permissions.isEditDiagram,
|
internaleditor = this.permissions.isEditMailMerge || this.permissions.isEditDiagram,
|
||||||
|
@ -1861,7 +1887,8 @@ define([
|
||||||
formatTableInfo = cellinfo.asc_getFormatTableInfo(),
|
formatTableInfo = cellinfo.asc_getFormatTableInfo(),
|
||||||
isinsparkline = (cellinfo.asc_getSparklineInfo()!==null),
|
isinsparkline = (cellinfo.asc_getSparklineInfo()!==null),
|
||||||
isintable = (formatTableInfo !== null),
|
isintable = (formatTableInfo !== null),
|
||||||
ismultiselect = cellinfo.asc_getMultiselect();
|
ismultiselect = cellinfo.asc_getMultiselect(),
|
||||||
|
inPivot = !!cellinfo.asc_getPivotTableInfo();
|
||||||
documentHolder.ssMenu.formatTableName = (isintable) ? formatTableInfo.asc_getTableName() : null;
|
documentHolder.ssMenu.formatTableName = (isintable) ? formatTableInfo.asc_getTableName() : null;
|
||||||
documentHolder.ssMenu.cellColor = xfs.asc_getFillColor();
|
documentHolder.ssMenu.cellColor = xfs.asc_getFillColor();
|
||||||
documentHolder.ssMenu.fontColor = xfs.asc_getFontColor();
|
documentHolder.ssMenu.fontColor = xfs.asc_getFontColor();
|
||||||
|
@ -1869,20 +1896,22 @@ define([
|
||||||
documentHolder.pmiInsertEntire.setVisible(isrowmenu||iscolmenu);
|
documentHolder.pmiInsertEntire.setVisible(isrowmenu||iscolmenu);
|
||||||
documentHolder.pmiInsertEntire.setCaption((isrowmenu) ? this.textInsertTop : this.textInsertLeft);
|
documentHolder.pmiInsertEntire.setCaption((isrowmenu) ? this.textInsertTop : this.textInsertLeft);
|
||||||
documentHolder.pmiDeleteEntire.setVisible(isrowmenu||iscolmenu);
|
documentHolder.pmiDeleteEntire.setVisible(isrowmenu||iscolmenu);
|
||||||
documentHolder.pmiInsertCells.setVisible(iscellmenu && !iscelledit && !isintable);
|
documentHolder.pmiInsertCells.setVisible(iscellmenu && !iscelledit && !isintable && !inPivot);
|
||||||
documentHolder.pmiDeleteCells.setVisible(iscellmenu && !iscelledit && !isintable);
|
documentHolder.pmiDeleteCells.setVisible(iscellmenu && !iscelledit && !isintable && !inPivot);
|
||||||
documentHolder.pmiSelectTable.setVisible(iscellmenu && !iscelledit && isintable);
|
documentHolder.pmiSelectTable.setVisible(iscellmenu && !iscelledit && isintable);
|
||||||
documentHolder.pmiInsertTable.setVisible(iscellmenu && !iscelledit && isintable);
|
documentHolder.pmiInsertTable.setVisible(iscellmenu && !iscelledit && isintable);
|
||||||
documentHolder.pmiDeleteTable.setVisible(iscellmenu && !iscelledit && isintable);
|
documentHolder.pmiDeleteTable.setVisible(iscellmenu && !iscelledit && isintable);
|
||||||
documentHolder.pmiSparklines.setVisible(isinsparkline);
|
documentHolder.pmiSparklines.setVisible(isinsparkline);
|
||||||
documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu) && !iscelledit);
|
documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu) && !iscelledit && !inPivot);
|
||||||
documentHolder.pmiSortCells.menu.items[2].setVisible(!internaleditor);
|
documentHolder.pmiSortCells.menu.items[2].setVisible(!internaleditor);
|
||||||
documentHolder.pmiSortCells.menu.items[3].setVisible(!internaleditor);
|
documentHolder.pmiSortCells.menu.items[3].setVisible(!internaleditor);
|
||||||
documentHolder.pmiSortCells.menu.items[4].setVisible(!internaleditor);
|
documentHolder.pmiSortCells.menu.items[4].setVisible(!internaleditor);
|
||||||
documentHolder.pmiFilterCells.setVisible(iscellmenu && !iscelledit && !internaleditor);
|
documentHolder.pmiFilterCells.setVisible(iscellmenu && !iscelledit && !internaleditor && !inPivot);
|
||||||
documentHolder.pmiReapply.setVisible((iscellmenu||isallmenu) && !iscelledit && !internaleditor);
|
documentHolder.pmiReapply.setVisible((iscellmenu||isallmenu) && !iscelledit && !internaleditor && !inPivot);
|
||||||
|
documentHolder.mnuGroupPivot.setVisible(iscellmenu && !iscelledit && !internaleditor && inPivot);
|
||||||
|
documentHolder.mnuUnGroupPivot.setVisible(iscellmenu && !iscelledit && !internaleditor && inPivot);
|
||||||
documentHolder.ssMenu.items[12].setVisible((iscellmenu||isallmenu||isinsparkline) && !iscelledit);
|
documentHolder.ssMenu.items[12].setVisible((iscellmenu||isallmenu||isinsparkline) && !iscelledit);
|
||||||
documentHolder.pmiInsFunction.setVisible(iscellmenu && !iscelledit);
|
documentHolder.pmiInsFunction.setVisible(iscellmenu && !iscelledit && !inPivot);
|
||||||
documentHolder.pmiAddNamedRange.setVisible(iscellmenu && !iscelledit && !internaleditor);
|
documentHolder.pmiAddNamedRange.setVisible(iscellmenu && !iscelledit && !internaleditor);
|
||||||
|
|
||||||
if (isintable) {
|
if (isintable) {
|
||||||
|
@ -1898,8 +1927,8 @@ define([
|
||||||
}
|
}
|
||||||
|
|
||||||
var hyperinfo = cellinfo.asc_getHyperlink();
|
var hyperinfo = cellinfo.asc_getHyperlink();
|
||||||
documentHolder.menuHyperlink.setVisible(iscellmenu && hyperinfo && !iscelledit && !ismultiselect && !internaleditor);
|
documentHolder.menuHyperlink.setVisible(iscellmenu && hyperinfo && !iscelledit && !ismultiselect && !internaleditor && !inPivot);
|
||||||
documentHolder.menuAddHyperlink.setVisible(iscellmenu && !hyperinfo && !iscelledit && !ismultiselect && !internaleditor);
|
documentHolder.menuAddHyperlink.setVisible(iscellmenu && !hyperinfo && !iscelledit && !ismultiselect && !internaleditor && !inPivot);
|
||||||
|
|
||||||
documentHolder.pmiRowHeight.setVisible(isrowmenu||isallmenu);
|
documentHolder.pmiRowHeight.setVisible(isrowmenu||isallmenu);
|
||||||
documentHolder.pmiColumnWidth.setVisible(iscolmenu||isallmenu);
|
documentHolder.pmiColumnWidth.setVisible(iscolmenu||isallmenu);
|
||||||
|
@ -1910,7 +1939,7 @@ define([
|
||||||
|
|
||||||
/** coauthoring begin **/
|
/** coauthoring begin **/
|
||||||
var count = cellinfo.asc_getComments().length;
|
var count = cellinfo.asc_getComments().length;
|
||||||
documentHolder.ssMenu.items[17].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && count < 1);
|
documentHolder.ssMenu.items[19].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && count < 1);
|
||||||
documentHolder.pmiAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && count < 1);
|
documentHolder.pmiAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && count < 1);
|
||||||
/** coauthoring end **/
|
/** coauthoring end **/
|
||||||
documentHolder.pmiCellMenuSeparator.setVisible(iscellmenu && !iscelledit || isrowmenu || iscolmenu || isallmenu);
|
documentHolder.pmiCellMenuSeparator.setVisible(iscellmenu && !iscelledit || isrowmenu || iscolmenu || isallmenu);
|
||||||
|
@ -1936,8 +1965,6 @@ define([
|
||||||
documentHolder.pmiInsertCells.menu.items[1].setDisabled(isApplyAutoFilter);
|
documentHolder.pmiInsertCells.menu.items[1].setDisabled(isApplyAutoFilter);
|
||||||
documentHolder.pmiDeleteCells.menu.items[1].setDisabled(isApplyAutoFilter);
|
documentHolder.pmiDeleteCells.menu.items[1].setDisabled(isApplyAutoFilter);
|
||||||
|
|
||||||
var inPivot = !!cellinfo.asc_getPivotTableInfo();
|
|
||||||
|
|
||||||
documentHolder.pmiEntriesList.setVisible(!iscelledit && !inPivot);
|
documentHolder.pmiEntriesList.setVisible(!iscelledit && !inPivot);
|
||||||
|
|
||||||
documentHolder.pmiNumFormat.setVisible(!iscelledit);
|
documentHolder.pmiNumFormat.setVisible(!iscelledit);
|
||||||
|
@ -1965,6 +1992,12 @@ define([
|
||||||
documentHolder.pmiInsFunction.setDisabled(isCellLocked || inPivot);
|
documentHolder.pmiInsFunction.setDisabled(isCellLocked || inPivot);
|
||||||
documentHolder.pmiFreezePanes.setDisabled(this.api.asc_isWorksheetLockedOrDeleted(this.api.asc_getActiveWorksheetIndex()));
|
documentHolder.pmiFreezePanes.setDisabled(this.api.asc_isWorksheetLockedOrDeleted(this.api.asc_getActiveWorksheetIndex()));
|
||||||
|
|
||||||
|
if (inPivot) {
|
||||||
|
var canGroup = this.api.asc_canGroupPivot();
|
||||||
|
documentHolder.mnuGroupPivot.setDisabled(isPivotLocked || !canGroup);
|
||||||
|
documentHolder.mnuUnGroupPivot.setDisabled(isPivotLocked || !canGroup);
|
||||||
|
}
|
||||||
|
|
||||||
if (showMenu) this.showPopupMenu(documentHolder.ssMenu, {}, event);
|
if (showMenu) this.showPopupMenu(documentHolder.ssMenu, {}, event);
|
||||||
} else if (this.permissions.isEditDiagram && seltype == Asc.c_oAscSelectionType.RangeChartText) {
|
} else if (this.permissions.isEditDiagram && seltype == Asc.c_oAscSelectionType.RangeChartText) {
|
||||||
if (!showMenu && !documentHolder.textInShapeMenu.isVisible()) return;
|
if (!showMenu && !documentHolder.textInShapeMenu.isVisible()) return;
|
||||||
|
|
|
@ -338,6 +338,16 @@ define([
|
||||||
caption : me.txtReapply
|
caption : me.txtReapply
|
||||||
});
|
});
|
||||||
|
|
||||||
|
me.mnuGroupPivot = new Common.UI.MenuItem({
|
||||||
|
caption : this.txtGroup,
|
||||||
|
value : 'grouping'
|
||||||
|
});
|
||||||
|
|
||||||
|
me.mnuUnGroupPivot = new Common.UI.MenuItem({
|
||||||
|
caption : this.txtUngroup,
|
||||||
|
value : 'ungrouping'
|
||||||
|
});
|
||||||
|
|
||||||
me.pmiInsFunction = new Common.UI.MenuItem({
|
me.pmiInsFunction = new Common.UI.MenuItem({
|
||||||
iconCls: 'menu__icon btn-function',
|
iconCls: 'menu__icon btn-function',
|
||||||
caption : me.txtFormula
|
caption : me.txtFormula
|
||||||
|
@ -560,6 +570,8 @@ define([
|
||||||
me.pmiSortCells,
|
me.pmiSortCells,
|
||||||
me.pmiFilterCells,
|
me.pmiFilterCells,
|
||||||
me.pmiReapply,
|
me.pmiReapply,
|
||||||
|
me.mnuGroupPivot,
|
||||||
|
me.mnuUnGroupPivot,
|
||||||
{caption: '--'},
|
{caption: '--'},
|
||||||
me.pmiAddComment,
|
me.pmiAddComment,
|
||||||
me.pmiCellMenuSeparator,
|
me.pmiCellMenuSeparator,
|
||||||
|
|
364
apps/spreadsheeteditor/main/app/view/PivotGroupDialog.js
Normal file
364
apps/spreadsheeteditor/main/app/view/PivotGroupDialog.js
Normal file
|
@ -0,0 +1,364 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* (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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* PivotGroupDialog.js
|
||||||
|
*
|
||||||
|
* Created by Julia Radzhabova 04.03.2021
|
||||||
|
* Copyright (c) 2021 Ascensio System SIA. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
define([
|
||||||
|
'common/main/lib/component/Window'
|
||||||
|
], function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
SSE.Views.PivotGroupDialog = Common.UI.Window.extend(_.extend({
|
||||||
|
options: {
|
||||||
|
width: 250,
|
||||||
|
header: true,
|
||||||
|
cls: 'modal-dlg',
|
||||||
|
buttons: ['ok', 'cancel']
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize : function (options) {
|
||||||
|
var t = this,
|
||||||
|
height = options.date ? 335 : 195;
|
||||||
|
|
||||||
|
_.extend(this.options, {
|
||||||
|
title: this.txtTitle
|
||||||
|
}, options || {});
|
||||||
|
|
||||||
|
this.template = options.template || [
|
||||||
|
'<div class="box" style="height:' + (height - 85) + 'px;">',
|
||||||
|
'<table cols="2" style="width: 100%;">',
|
||||||
|
'<tr>',
|
||||||
|
'<td colspan="2" style="padding-bottom: 4px;">',
|
||||||
|
'<label style="font-weight: bold;">' + this.textAuto + '</label>',
|
||||||
|
'</td>',
|
||||||
|
'</tr>',
|
||||||
|
'<tr>',
|
||||||
|
'<td style="padding-right: 10px;padding-bottom: 8px;width: 100%;">',
|
||||||
|
'<div id="pivot-group-dlg-chk-start" style="margin-top: 2px;"></div>',
|
||||||
|
'</td>',
|
||||||
|
'<td style="padding-bottom: 8px;">',
|
||||||
|
'<div id="pivot-group-dlg-txt-start"></div>',
|
||||||
|
'</td>',
|
||||||
|
'</tr>',
|
||||||
|
'<tr>',
|
||||||
|
'<td style="padding-right: 10px;padding-bottom: 8px;width: 100%;">',
|
||||||
|
'<div id="pivot-group-dlg-chk-end" style="margin-top: 2px;"></div>',
|
||||||
|
'</td>',
|
||||||
|
'<td style="padding-bottom: 8px;">',
|
||||||
|
'<div id="pivot-group-dlg-txt-end"></div>',
|
||||||
|
'</td>',
|
||||||
|
'</tr>',
|
||||||
|
'<tr class="group-number">',
|
||||||
|
'<td style="padding-right: 10px;padding-bottom: 8px;width: 100%;">',
|
||||||
|
'<label style="margin-left:22px;margin-top:2px;">' + t.textBy + '</label>',
|
||||||
|
'</td>',
|
||||||
|
'<td style="padding-bottom: 8px;">',
|
||||||
|
'<div id="pivot-group-dlg-txt-by"></div>',
|
||||||
|
'</td>',
|
||||||
|
'</tr>',
|
||||||
|
'<tr class="group-date">',
|
||||||
|
'<td colspan="2" style="padding-bottom: 4px;">',
|
||||||
|
'<label style="font-weight: bold;">' + this.textBy + '</label>',
|
||||||
|
'</td>',
|
||||||
|
'</tr>',
|
||||||
|
'<tr class="group-date">',
|
||||||
|
'<td colspan="2" style="padding-bottom: 8px;">',
|
||||||
|
'<div id="pivot-group-dlg-list" style="height:116px;"></div>',
|
||||||
|
'</td>',
|
||||||
|
'</tr>',
|
||||||
|
'<tr class="group-date">',
|
||||||
|
'<td style="padding-right: 10px;width: 100%;">',
|
||||||
|
'<label style="margin-top:2px;">' + t.textNumDays + '</label>',
|
||||||
|
'</td>',
|
||||||
|
'<td>',
|
||||||
|
'<div id="pivot-group-dlg-spn-days"></div>',
|
||||||
|
'</td>',
|
||||||
|
'</tr>',
|
||||||
|
'</table>',
|
||||||
|
'</div>'
|
||||||
|
].join('');
|
||||||
|
|
||||||
|
this.api = options.api;
|
||||||
|
this.handler = options.handler;
|
||||||
|
|
||||||
|
this.options.tpl = _.template(this.template)(this.options);
|
||||||
|
Common.UI.Window.prototype.initialize.call(this, this.options);
|
||||||
|
},
|
||||||
|
render: function () {
|
||||||
|
Common.UI.Window.prototype.render.call(this);
|
||||||
|
|
||||||
|
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
||||||
|
|
||||||
|
var me = this;
|
||||||
|
|
||||||
|
this.chStart = new Common.UI.CheckBox({
|
||||||
|
el: $('#pivot-group-dlg-chk-start', this.$window),
|
||||||
|
labelText: this.textStart
|
||||||
|
});
|
||||||
|
this.chStart.on('change', function (field, newValue, oldValue, eOpts) {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
this.chEnd = new Common.UI.CheckBox({
|
||||||
|
el: $('#pivot-group-dlg-chk-end', this.$window),
|
||||||
|
labelText: this.textEnd
|
||||||
|
});
|
||||||
|
this.chEnd.on('change', function (field, newValue, oldValue, eOpts) {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
this.inputStart = new Common.UI.InputField({
|
||||||
|
el : $('#pivot-group-dlg-txt-start', this.$window),
|
||||||
|
style : 'width: 100px;',
|
||||||
|
allowBlank : true,
|
||||||
|
validateOnChange : true,
|
||||||
|
validation : function () { return true; }
|
||||||
|
}).on ('changing', function (input, value) {
|
||||||
|
me.chStart.setValue(false, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.inputEnd = new Common.UI.InputField({
|
||||||
|
el : $('#pivot-group-dlg-txt-end', this.$window),
|
||||||
|
style : 'width: 100px;',
|
||||||
|
allowBlank : true,
|
||||||
|
validateOnChange : true,
|
||||||
|
validation : function () { return true; }
|
||||||
|
}).on ('changing', function (input, value) {
|
||||||
|
me.chEnd.setValue(false, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.inputBy = new Common.UI.InputField({
|
||||||
|
el : $('#pivot-group-dlg-txt-by', this.$window),
|
||||||
|
style : 'width: 100px;',
|
||||||
|
allowBlank : true,
|
||||||
|
validateOnChange : true,
|
||||||
|
validation : function () { return true; }
|
||||||
|
}).on ('changing', function (input, value) {
|
||||||
|
if (value.length) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.spnDays = new Common.UI.MetricSpinner({
|
||||||
|
el: $('#pivot-group-dlg-spn-days', this.$window),
|
||||||
|
step: 1,
|
||||||
|
width: 100,
|
||||||
|
defaultUnit : "",
|
||||||
|
value: '1',
|
||||||
|
maxValue: 32767,
|
||||||
|
minValue: 1
|
||||||
|
});
|
||||||
|
this.spnDays.on('change', _.bind(function(field, newValue, oldValue, eOpts){
|
||||||
|
}, this));
|
||||||
|
|
||||||
|
var arr = [
|
||||||
|
{ value: this.textSec, type: Asc.c_oAscGroupBy.Seconds},
|
||||||
|
{ value: this.textMin, type: Asc.c_oAscGroupBy.Minutes},
|
||||||
|
{ value: this.textHour, type: Asc.c_oAscGroupBy.Hours},
|
||||||
|
{ value: this.textDays, type: Asc.c_oAscGroupBy.Days},
|
||||||
|
{ value: this.textMonth, type: Asc.c_oAscGroupBy.Months},
|
||||||
|
{ value: this.textQuart, type: Asc.c_oAscGroupBy.Quarters},
|
||||||
|
{ value: this.textYear, type: Asc.c_oAscGroupBy.Years}
|
||||||
|
];
|
||||||
|
this.listDate = new Common.UI.ListView({
|
||||||
|
el: $('#pivot-group-dlg-list', this.$window),
|
||||||
|
store: new Common.UI.DataViewStore(arr),
|
||||||
|
multiSelect: true,
|
||||||
|
tabindex: 1,
|
||||||
|
itemTemplate: _.template('<div id="<%= id %>" class="list-item" style="pointer-events:none;"><%= value %></div>')
|
||||||
|
});
|
||||||
|
|
||||||
|
this.listDate.on('item:select', _.bind(this.onSelectDate, this));
|
||||||
|
this.listDate.on('item:deselect', _.bind(this.onSelectDate, this));
|
||||||
|
this.listDate.on('entervalue', _.bind(this.onPrimary, this));
|
||||||
|
|
||||||
|
this.btnOk = new Common.UI.Button({
|
||||||
|
el: $('.dlg-btn.primary', this.$window)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getFocusedComponents: function() {
|
||||||
|
return [this.inputStart, this.inputEnd, this.inputBy, {cmp: this.listDate, selector: '.listview'}, this.spnDays];
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultFocusableComponent: function () {
|
||||||
|
return this.inputStart;
|
||||||
|
},
|
||||||
|
|
||||||
|
onBtnClick: function (event) {
|
||||||
|
this._handleInput(event.currentTarget.attributes['result'].value);
|
||||||
|
},
|
||||||
|
|
||||||
|
onSelectDate: function (listView, itemView, record) {
|
||||||
|
if (!record || record.length<1) return;
|
||||||
|
if (record.get('type')==Asc.c_oAscGroupBy.Days)
|
||||||
|
this.isDays = record.get('selected');
|
||||||
|
var selected = this.listDate.getSelectedRec().length;
|
||||||
|
this.spnDays.setDisabled(!this.isDays || selected>1);
|
||||||
|
this.btnOk.setDisabled(selected<1);
|
||||||
|
},
|
||||||
|
|
||||||
|
setSettings: function (rangePr, dateTypes, lang) {
|
||||||
|
this.$window.find('.group-number').toggleClass('hidden', !!dateTypes);
|
||||||
|
this.$window.find('.group-date').toggleClass('hidden', !dateTypes);
|
||||||
|
if (rangePr) {
|
||||||
|
this.chStart.setValue(rangePr.asc_getAutoStart(), true);
|
||||||
|
this.chEnd.setValue(rangePr.asc_getAutoEnd(), true);
|
||||||
|
this.inputStart.setValue((dateTypes ? new Date(rangePr.asc_getStartDate()).toLocaleDateString(lang) : rangePr.asc_getStartNum()) || '');
|
||||||
|
this.inputEnd.setValue((dateTypes ? new Date(rangePr.asc_getEndDate()).toLocaleDateString(lang) : rangePr.asc_getEndNum()) || '');
|
||||||
|
!dateTypes && this.inputBy.setValue(rangePr.asc_getGroupInterval() || '');
|
||||||
|
this.rangePr = rangePr;
|
||||||
|
}
|
||||||
|
if (dateTypes) {
|
||||||
|
var me = this,
|
||||||
|
isDays;
|
||||||
|
_.each(dateTypes, function(item) {
|
||||||
|
var rec = me.listDate.store.findWhere({type: item});
|
||||||
|
rec && me.listDate.selectRecord(rec);
|
||||||
|
if (item == Asc.c_oAscGroupBy.Days)
|
||||||
|
isDays = true;
|
||||||
|
});
|
||||||
|
this.spnDays.setValue(rangePr.asc_getGroupInterval() || '');
|
||||||
|
this.spnDays.setDisabled(!isDays || dateTypes.length>1);
|
||||||
|
this.btnOk.setDisabled(dateTypes.length<1);
|
||||||
|
this.dateTypes = dateTypes;
|
||||||
|
this.isDays = isDays;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getSettings: function() {
|
||||||
|
if (this.rangePr) {
|
||||||
|
this.rangePr.asc_setAutoStart(this.chStart.getValue()=='checked');
|
||||||
|
this.rangePr.asc_setAutoEnd(this.chEnd.getValue()=='checked');
|
||||||
|
if (this.dateTypes) {
|
||||||
|
this.dateTypes = this.listDate.getSelectedRec().map(function(item){return item.get('type');});
|
||||||
|
this.rangePr.asc_setGroupInterval(this.spnDays.getNumberValue());
|
||||||
|
this.rangePr.asc_setStartDate(new Date(this.inputStart.getValue()).getTime());
|
||||||
|
this.rangePr.asc_setEndDate(new Date(this.inputEnd.getValue()).getTime());
|
||||||
|
} else {
|
||||||
|
this.rangePr.asc_setStartNum(parseFloat(this.inputStart.getValue()));
|
||||||
|
this.rangePr.asc_setEndNum(parseFloat(this.inputEnd.getValue()));
|
||||||
|
this.rangePr.asc_setGroupInterval(parseFloat(this.inputBy.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [this.rangePr, this.dateTypes];
|
||||||
|
},
|
||||||
|
|
||||||
|
isRangeValid: function() {
|
||||||
|
if (this.dateTypes) {
|
||||||
|
var res1 = new Date(this.inputStart.getValue()).getTime();
|
||||||
|
if (isNaN(res1)) {
|
||||||
|
this.inputStart.showError([this.textError]);
|
||||||
|
this.inputStart.focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var res2 = new Date(this.inputEnd.getValue()).getTime();
|
||||||
|
if (isNaN(res2)) {
|
||||||
|
this.inputEnd.showError([this.textError]);
|
||||||
|
this.inputEnd.focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (res2<res1) {
|
||||||
|
Common.UI.warning({msg: this.textGreaterError, maxwidth: 600});
|
||||||
|
this.inputEnd.focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var regstr = new RegExp('^\s*[0-9]+[,.]?[0-9]*\s*$');
|
||||||
|
var res1 = this.inputStart.getValue();
|
||||||
|
if (!regstr.test(res1)) {
|
||||||
|
this.inputStart.showError([this.textError]);
|
||||||
|
this.inputStart.focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var res2 = this.inputEnd.getValue();
|
||||||
|
if (!regstr.test(res2)) {
|
||||||
|
this.inputEnd.showError([this.textError]);
|
||||||
|
this.inputEnd.focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (parseFloat(res2)<parseFloat(res1)) {
|
||||||
|
Common.UI.warning({msg: this.textGreaterError, maxwidth: 600});
|
||||||
|
this.inputEnd.focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!regstr.test(this.inputBy.getValue())) {
|
||||||
|
this.inputBy.showError([this.textError]);
|
||||||
|
this.inputBy.focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
onPrimary: function(list, record, event) {
|
||||||
|
this._handleInput('ok');
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
_handleInput: function(state) {
|
||||||
|
if (this.options.handler) {
|
||||||
|
if (state == 'ok') {
|
||||||
|
if (this.btnOk.isDisabled() || !this.isRangeValid()) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.options.handler.call(this, this, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.close();
|
||||||
|
},
|
||||||
|
|
||||||
|
txtTitle: 'Grouping',
|
||||||
|
textAuto: 'Auto',
|
||||||
|
textBy: 'By',
|
||||||
|
textStart: 'Starting at',
|
||||||
|
textEnd: 'Ending at',
|
||||||
|
textNumDays: 'Number of days',
|
||||||
|
textSec: 'Seconds',
|
||||||
|
textMin: 'Minutes',
|
||||||
|
textHour: 'Hours',
|
||||||
|
textDays: 'Days',
|
||||||
|
textMonth: 'Months',
|
||||||
|
textQuart: 'Quarters',
|
||||||
|
textYear: 'Years',
|
||||||
|
textError: 'This field must be a numeric value',
|
||||||
|
textGreaterError: 'The end number must be greater than the start number'
|
||||||
|
|
||||||
|
}, SSE.Views.PivotGroupDialog || {}));
|
||||||
|
});
|
|
@ -2252,6 +2252,21 @@
|
||||||
"SSE.Views.PivotDigitalFilterDialog.txtAnd": "and",
|
"SSE.Views.PivotDigitalFilterDialog.txtAnd": "and",
|
||||||
"SSE.Views.PivotDigitalFilterDialog.txtTitleLabel": "Label Filter",
|
"SSE.Views.PivotDigitalFilterDialog.txtTitleLabel": "Label Filter",
|
||||||
"SSE.Views.PivotDigitalFilterDialog.txtTitleValue": "Value Filter",
|
"SSE.Views.PivotDigitalFilterDialog.txtTitleValue": "Value Filter",
|
||||||
|
"SSE.Views.PivotGroupDialog.txtTitle": "Grouping",
|
||||||
|
"SSE.Views.PivotGroupDialog.textAuto": "Auto",
|
||||||
|
"SSE.Views.PivotGroupDialog.textBy": "By",
|
||||||
|
"SSE.Views.PivotGroupDialog.textStart": "Starting at",
|
||||||
|
"SSE.Views.PivotGroupDialog.textEnd": "Ending at",
|
||||||
|
"SSE.Views.PivotGroupDialog.textNumDays": "Number of days",
|
||||||
|
"SSE.Views.PivotGroupDialog.textSec": "Seconds",
|
||||||
|
"SSE.Views.PivotGroupDialog.textMin": "Minutes",
|
||||||
|
"SSE.Views.PivotGroupDialog.textHour": "Hours",
|
||||||
|
"SSE.Views.PivotGroupDialog.textDays": "Days",
|
||||||
|
"SSE.Views.PivotGroupDialog.textMonth": "Months",
|
||||||
|
"SSE.Views.PivotGroupDialog.textQuart": "Quarters",
|
||||||
|
"SSE.Views.PivotGroupDialog.textYear": "Years",
|
||||||
|
"SSE.Views.PivotGroupDialog.textError": "This field must be a numeric value",
|
||||||
|
"SSE.Views.PivotGroupDialog.textGreaterError": "The end number must be greater than the start number",
|
||||||
"SSE.Views.PivotSettings.textAdvanced": "Show advanced settings",
|
"SSE.Views.PivotSettings.textAdvanced": "Show advanced settings",
|
||||||
"SSE.Views.PivotSettings.textColumns": "Columns",
|
"SSE.Views.PivotSettings.textColumns": "Columns",
|
||||||
"SSE.Views.PivotSettings.textFields": "Select Fields",
|
"SSE.Views.PivotSettings.textFields": "Select Fields",
|
||||||
|
|
Loading…
Reference in a new issue