[SSE] Added settings for value field.
This commit is contained in:
parent
d80e045181
commit
582df369f2
|
@ -183,6 +183,7 @@ require([
|
|||
'spreadsheeteditor/main/app/view/ShapeSettings',
|
||||
'spreadsheeteditor/main/app/view/TextArtSettings',
|
||||
'spreadsheeteditor/main/app/view/PivotSettings',
|
||||
'spreadsheeteditor/main/app/view/ValueFieldSettingsDialog',
|
||||
'common/main/lib/util/utils',
|
||||
'common/main/lib/util/LocalStorage',
|
||||
'common/main/lib/controller/Fonts',
|
||||
|
|
|
@ -45,7 +45,8 @@ define([
|
|||
'underscore',
|
||||
'backbone',
|
||||
'common/main/lib/component/Button',
|
||||
'common/main/lib/component/ListView'
|
||||
'common/main/lib/component/ListView',
|
||||
'spreadsheeteditor/main/app/view/ValueFieldSettingsDialog'
|
||||
], function (menuTemplate, $, _, Backbone, Sortable) {
|
||||
'use strict';
|
||||
|
||||
|
@ -67,18 +68,8 @@ define([
|
|||
this._initSettings = true;
|
||||
|
||||
this._state = {
|
||||
TableName: '',
|
||||
TemplateName: '',
|
||||
Range: '',
|
||||
CheckHeader: false,
|
||||
CheckTotal: false,
|
||||
CheckBanded: false,
|
||||
CheckFirst: false,
|
||||
CheckLast: false,
|
||||
CheckColBanded: false,
|
||||
CheckFilter: false,
|
||||
DisabledControls: false,
|
||||
TableNameError: false
|
||||
names: [],
|
||||
DisabledControls: false
|
||||
};
|
||||
this.lockedControls = [];
|
||||
this._locked = false;
|
||||
|
@ -292,10 +283,11 @@ define([
|
|||
|
||||
var me = this,
|
||||
cache_names = props.asc_getCacheFields(),
|
||||
pivot_names = props.asc_getPivotFields(),
|
||||
names = [];
|
||||
pivot_names = props.asc_getPivotFields();
|
||||
|
||||
this._state.names = [];
|
||||
pivot_names.forEach(function (item, index) {
|
||||
names[index] = item.asc_getName() || cache_names[index].asc_getName();
|
||||
me._state.names[index] = item.asc_getName() || cache_names[index].asc_getName();
|
||||
});
|
||||
|
||||
var arr = [], isChecked = [],
|
||||
|
@ -303,7 +295,7 @@ define([
|
|||
value && value.forEach(function (item, index) {
|
||||
var pivotIndex = item.asc_getIndex();
|
||||
if (pivotIndex>-1 || pivotIndex == -2) {
|
||||
var name = (pivotIndex>-1) ? names[pivotIndex] : me.textValues;
|
||||
var name = (pivotIndex>-1) ? me._state.names[pivotIndex] : me.textValues;
|
||||
arr.push(new Common.UI.DataViewModel({
|
||||
selected : false,
|
||||
allowSelected : false,
|
||||
|
@ -323,7 +315,7 @@ define([
|
|||
value && value.forEach(function (item, index) {
|
||||
var pivotIndex = item.asc_getIndex();
|
||||
if (pivotIndex>-1 || pivotIndex == -2) {
|
||||
var name = (pivotIndex>-1) ? names[pivotIndex] : me.textValues;
|
||||
var name = (pivotIndex>-1) ? me._state.names[pivotIndex] : me.textValues;
|
||||
arr.push(new Common.UI.DataViewModel({
|
||||
selected : false,
|
||||
allowSelected : false,
|
||||
|
@ -352,7 +344,7 @@ define([
|
|||
value : name,
|
||||
tip : (name.length>10) ? name : ''
|
||||
}));
|
||||
isChecked[names[pivotIndex]] = true;
|
||||
isChecked[me._state.names[pivotIndex]] = true;
|
||||
}
|
||||
});
|
||||
this.valuesList.store.reset(arr);
|
||||
|
@ -363,7 +355,7 @@ define([
|
|||
value && value.forEach(function (item, index) {
|
||||
var pivotIndex = item.asc_getIndex();
|
||||
if (pivotIndex>-1) {
|
||||
var name = names[pivotIndex];
|
||||
var name = me._state.names[pivotIndex];
|
||||
arr.push(new Common.UI.DataViewModel({
|
||||
selected : false,
|
||||
allowSelected : false,
|
||||
|
@ -379,13 +371,13 @@ define([
|
|||
this.filtersList.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true});
|
||||
|
||||
arr = [];
|
||||
names.forEach(function (item, index) {
|
||||
me._state.names.forEach(function (item, index) {
|
||||
arr.push(new Common.UI.DataViewModel({
|
||||
selected : false,
|
||||
allowSelected : false,
|
||||
value : item,
|
||||
index : index,
|
||||
tip : (name.length>25) ? name : '',
|
||||
tip : (item.length>25) ? item : '',
|
||||
check : isChecked[item]
|
||||
}));
|
||||
});
|
||||
|
@ -578,7 +570,7 @@ define([
|
|||
caption : this.txtFieldSettings,
|
||||
checkable : false
|
||||
});
|
||||
this.miFieldSettings.on('click', _.bind(this.onFieldSettings, this, record));
|
||||
this.miFieldSettings.on('click', _.bind(this.onFieldSettings, this, record, type));
|
||||
|
||||
this.fieldsMenu = new Common.UI.Menu({
|
||||
menuAlign: 'tr-br',
|
||||
|
@ -656,17 +648,20 @@ define([
|
|||
this._locked = locked;
|
||||
},
|
||||
|
||||
onFieldSettings: function(e) {
|
||||
onFieldSettings: function(record, type, e) {
|
||||
var me = this;
|
||||
var win;
|
||||
if (me.api && !this._locked){
|
||||
(new SSE.Views.TableSettingsAdvanced(
|
||||
if (type == 2) // value field
|
||||
(new SSE.Views.ValueFieldSettingsDialog(
|
||||
{
|
||||
tableProps: me._originalProps,
|
||||
props: me._originalProps,
|
||||
fieldIndex: record.get('index'),
|
||||
names: me._state.names,
|
||||
api: me.api,
|
||||
handler: function(result, value) {
|
||||
if (result == 'ok' && me.api && value) {
|
||||
me.api.asc_changeFormatTableInfo(me._state.TableName, Asc.c_oAscChangeTableStyleInfo.advancedSettings, value);
|
||||
// me.api.asc_changeFormatTableInfo(me._state.TableName, Asc.c_oAscChangeTableStyleInfo.advancedSettings, value);
|
||||
}
|
||||
|
||||
Common.NotificationCenter.trigger('edit:complete', me);
|
||||
|
|
303
apps/spreadsheeteditor/main/app/view/ValueFieldSettingsDialog.js
Normal file
303
apps/spreadsheeteditor/main/app/view/ValueFieldSettingsDialog.js
Normal file
|
@ -0,0 +1,303 @@
|
|||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* 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 Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* ValueFieldSettingsDialog.js
|
||||
*
|
||||
* Created by Julia Radzhabova on 14.07.2017
|
||||
* Copyright (c) 2017 Ascensio System SIA. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
define([
|
||||
'common/main/lib/util/utils',
|
||||
'common/main/lib/component/MetricSpinner',
|
||||
'common/main/lib/component/ComboBox',
|
||||
'common/main/lib/view/AdvancedSettingsWindow'
|
||||
], function () { 'use strict';
|
||||
|
||||
SSE.Views.ValueFieldSettingsDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({
|
||||
options: {
|
||||
contentWidth: 284,
|
||||
height: 340
|
||||
},
|
||||
|
||||
initialize : function(options) {
|
||||
var me = this;
|
||||
|
||||
_.extend(this.options, {
|
||||
title: this.textTitle,
|
||||
template: [
|
||||
'<div class="box" style="height:' + (me.options.height - 85) + 'px;">',
|
||||
'<div class="content-panel" style="padding: 0 10px;"><div class="inner-content">',
|
||||
'<div class="settings-panel active">',
|
||||
'<table cols="2" style="width: 100%;">',
|
||||
'<tr>',
|
||||
'<td colspan="2" class="padding-small" style="white-space: nowrap;">',
|
||||
'<label class="header" style="vertical-align: middle; margin-right: 4px;">' + me.txtSourceName + '</label>',
|
||||
'<label id="value-field-settings-source" style="vertical-align: middle; max-width: 220px; overflow: hidden; text-overflow: ellipsis;"></label>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td colspan="2" class="padding-large">',
|
||||
'<label class="header">', me.txtCustomName,'</label>',
|
||||
'<div id="value-field-settings-custom" style="width:264px;"></div>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td colspan="2" class="padding-small">',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td colspan="2" class="padding-large">',
|
||||
'<label class="header">', me.txtSummarize,'</label>',
|
||||
'<div id="value-field-settings-summarize" class="input-group-nr" style="width:264px;"></div>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td colspan="2" class="padding-small">',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td colspan="2" class="padding-large">',
|
||||
'<label class="header">', me.txtShowAs,'</label>',
|
||||
'<div id="value-field-settings-showas" class="input-group-nr" style="width:264px;"></div>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr class="format-code">',
|
||||
'<td>',
|
||||
'<label class="header">', me.txtBaseField,'</label>',
|
||||
'<div id="value-field-settings-field" class="input-group-nr" style="width:125px;"></div>',
|
||||
'</td>',
|
||||
'<td>',
|
||||
'<label class="header">', me.txtBaseItem,'</label>',
|
||||
'<div id="value-field-settings-item" class="input-group-nr" style="width:125px;"></div>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'</table>',
|
||||
'</div></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="separator horizontal"/>',
|
||||
'<div class="footer center">',
|
||||
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px; width: 86px;">' + me.textOk + '</button>',
|
||||
'<button class="btn normal dlg-btn" result="cancel" style="width: 86px;">' + me.textCancel + '</button>',
|
||||
'</div>'
|
||||
].join('')
|
||||
}, options);
|
||||
|
||||
this.api = options.api;
|
||||
this.handler = options.handler;
|
||||
this.props = options.props;
|
||||
this.fieldIndex = options.fieldIndex || 0;
|
||||
this.names = options.names || [];
|
||||
|
||||
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
|
||||
var me = this;
|
||||
|
||||
this.inputCustomName = new Common.UI.InputField({
|
||||
el : $('#value-field-settings-custom'),
|
||||
allowBlank : true,
|
||||
validateOnBlur: false,
|
||||
style : 'width: 100%;'
|
||||
});
|
||||
|
||||
this.cmbSummarize = new Common.UI.ComboBox({
|
||||
el: $('#value-field-settings-summarize'),
|
||||
cls: 'input-group-nr',
|
||||
menuStyle: 'min-width: 264px;',
|
||||
editable: false,
|
||||
data: [
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.Sum, displayValue: this.txtSum },
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.Count, displayValue: this.txtCount },
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.Average, displayValue: this.txtAverage },
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.Max, displayValue: this.txtMax },
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.Min, displayValue: this.txtMin },
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.Product, displayValue: this.txtProduct },
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.CountNums,displayValue: this.txtCountNums },
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.StdDev, displayValue: this.txtStdDev },
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.StdDevp, displayValue: this.txtStdDevp },
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.Var, displayValue: this.txtVar },
|
||||
{ value: Asc.c_oAscDataConsolidateFunction.Varp, displayValue: this.txtVarp }
|
||||
]
|
||||
});
|
||||
this.cmbSummarize.setValue(Asc.c_oAscDataConsolidateFunction.Sum);
|
||||
this.cmbSummarize.on('selected', _.bind(this.onSummarizeSelect, this));
|
||||
|
||||
this.cmbShowAs = new Common.UI.ComboBox({
|
||||
el: $('#value-field-settings-showas'),
|
||||
cls: 'input-group-nr',
|
||||
menuStyle: 'min-width: 264px;',
|
||||
editable: false,
|
||||
data: [
|
||||
{ value: Asc.c_oAscShowDataAs.Normal, displayValue: this.txtNormal },
|
||||
{ value: Asc.c_oAscShowDataAs.PercentOfRow, displayValue: this.txtPercentOfRow },
|
||||
{ value: Asc.c_oAscShowDataAs.PercentOfCol, displayValue: this.txtPercentOfCol },
|
||||
{ value: Asc.c_oAscShowDataAs.PercentOfTotal, displayValue: this.txtPercentOfTotal },
|
||||
{ value: Asc.c_oAscShowDataAs.Percent, displayValue: this.txtPercent },
|
||||
{ value: Asc.c_oAscShowDataAs.Difference, displayValue: this.txtDifference },
|
||||
{ value: Asc.c_oAscShowDataAs.PercentDiff, displayValue: this.txtPercentDiff },
|
||||
{ value: Asc.c_oAscShowDataAs.RunTotal, displayValue: this.txtRunTotal },
|
||||
{ value: Asc.c_oAscShowDataAs.Index, displayValue: this.txtIndex }
|
||||
]
|
||||
});
|
||||
this.cmbShowAs.setValue(Asc.c_oAscDataConsolidateFunction.Normal);
|
||||
this.cmbShowAs.on('selected', _.bind(this.onShowAsSelect, this));
|
||||
|
||||
this.cmbBaseField = new Common.UI.ComboBox({
|
||||
el: $('#value-field-settings-field'),
|
||||
cls: 'input-group-nr',
|
||||
menuStyle: 'min-width: 264px;max-height:235px;',
|
||||
editable: false,
|
||||
data: [],
|
||||
scrollAlwaysVisible: true
|
||||
});
|
||||
this.cmbBaseField.on('selected', _.bind(this.onBaseFieldSelect, this));
|
||||
|
||||
this.cmbBaseItem = new Common.UI.ComboBox({
|
||||
el: $('#value-field-settings-item'),
|
||||
cls: 'input-group-nr',
|
||||
menuStyle: 'min-width: 264px;max-height:235px;',
|
||||
editable: false,
|
||||
data: [],
|
||||
scrollAlwaysVisible: true
|
||||
});
|
||||
this.cmbBaseItem.on('selected', _.bind(this.onBaseItemSelect, this));
|
||||
|
||||
this.lblSourceName = this.$window.find('#value-field-settings-source');
|
||||
|
||||
this.afterRender();
|
||||
},
|
||||
|
||||
afterRender: function() {
|
||||
this._setDefaults(this.props);
|
||||
},
|
||||
|
||||
show: function() {
|
||||
Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments);
|
||||
},
|
||||
|
||||
_setDefaults: function (props) {
|
||||
if (props) {
|
||||
var field = props.asc_getDataFields()[this.fieldIndex],
|
||||
cache_names = props.asc_getCacheFields(),
|
||||
show_as = field.asc_getShowDataAs();
|
||||
|
||||
this.lblSourceName.html(Common.Utils.String.htmlEncode(cache_names[field.asc_getIndex()].asc_getName()));
|
||||
this.inputCustomName.setValue(Common.Utils.String.htmlEncode(field.asc_getName()));
|
||||
|
||||
this.cmbSummarize.setValue(field.asc_getSubtotal());
|
||||
this.cmbShowAs.setValue(show_as);
|
||||
|
||||
var data = [];
|
||||
this.names.forEach(function(item){
|
||||
data.push({value: item, displayValue: item});
|
||||
});
|
||||
this.cmbBaseField.setData(data);
|
||||
this.cmbBaseField.setValue(this.names[0]);
|
||||
this.cmbBaseField.setDisabled(show_as != c_oAscShowDataAs.Difference && show_as != c_oAscShowDataAs.Percent &&
|
||||
show_as != c_oAscShowDataAs.PercentDiff && show_as != c_oAscShowDataAs.RunTotal);
|
||||
|
||||
// this.cmbBaseItem.setData(data);
|
||||
this.cmbBaseItem.setDisabled(show_as != c_oAscShowDataAs.Difference && show_as != c_oAscShowDataAs.Percent &&
|
||||
show_as != c_oAscShowDataAs.PercentDiff);
|
||||
}
|
||||
},
|
||||
|
||||
getSettings: function () {
|
||||
return {};
|
||||
},
|
||||
|
||||
onDlgBtnClick: function(event) {
|
||||
var me = this;
|
||||
var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event;
|
||||
if (state == 'ok') {
|
||||
this.handler && this.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined);
|
||||
}
|
||||
|
||||
this.close();
|
||||
},
|
||||
|
||||
onPrimary: function() {
|
||||
this.onDlgBtnClick('ok');
|
||||
return false;
|
||||
},
|
||||
|
||||
onSummarizeSelect: function(combo, record) {
|
||||
},
|
||||
|
||||
onShowAsSelect: function(combo, record) {
|
||||
},
|
||||
|
||||
onBaseFieldSelect: function(combo, record) {
|
||||
},
|
||||
|
||||
onBaseItemSelect: function(combo, record) {
|
||||
},
|
||||
|
||||
textTitle: 'Value Field Settings',
|
||||
textCancel: 'Cancel',
|
||||
textOk: 'OK',
|
||||
txtSourceName: 'Source name: ',
|
||||
txtCustomName: 'Custom name',
|
||||
txtSummarize: 'Summarize value field by',
|
||||
txtShowAs: 'Show values as',
|
||||
txtBaseField: 'Base field',
|
||||
txtBaseItem: 'Base item',
|
||||
txtAverage: 'Average',
|
||||
txtCount: 'Count',
|
||||
txtCountNums: 'Count Numbers',
|
||||
txtMax: 'Max',
|
||||
txtMin: 'Min',
|
||||
txtProduct: 'Product',
|
||||
txtStdDev: 'StdDev',
|
||||
txtStdDevp: 'StdDevp',
|
||||
txtSum: 'Sum',
|
||||
txtVar: 'Var',
|
||||
txtVarp: 'Varp',
|
||||
txtNormal: 'No Calculation',
|
||||
txtDifference: 'The Difference From',
|
||||
txtPercent: 'Percent of',
|
||||
txtPercentDiff: 'Percent Difference From',
|
||||
txtRunTotal: 'Running Total In',
|
||||
txtPercentOfRow: 'Percent of Total',
|
||||
txtPercentOfCol: 'Percent of Column',
|
||||
txtPercentOfTotal: 'Percent of Row',
|
||||
txtIndex: 'Index'
|
||||
|
||||
}, SSE.Views.ValueFieldSettingsDialog || {}))
|
||||
});
|
|
@ -173,6 +173,7 @@ require([
|
|||
'spreadsheeteditor/main/app/view/ShapeSettings',
|
||||
'spreadsheeteditor/main/app/view/TextArtSettings',
|
||||
'spreadsheeteditor/main/app/view/PivotSettings',
|
||||
'spreadsheeteditor/main/app/view/ValueFieldSettingsDialog',
|
||||
'common/main/lib/util/utils',
|
||||
'common/main/lib/util/LocalStorage',
|
||||
'common/main/lib/controller/Fonts',
|
||||
|
|
Loading…
Reference in a new issue