|
|
|
@ -83,7 +83,7 @@ define([
|
|
|
|
|
'</div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'<div class="separator horizontal" style="width:100%"></div>',
|
|
|
|
|
'<div class="footer right" style="margin-left:-15px;">',
|
|
|
|
|
'<div class="footer center">',
|
|
|
|
|
'<button class="btn normal dlg-btn primary" result="ok">', t.okButtonText, '</button>',
|
|
|
|
|
'<button class="btn normal dlg-btn" result="cancel">', t.cancelButtonText, '</button>',
|
|
|
|
|
'</div>'
|
|
|
|
@ -303,8 +303,10 @@ define([
|
|
|
|
|
initialize: function (options) {
|
|
|
|
|
var t = this, _options = {};
|
|
|
|
|
|
|
|
|
|
this.type = options.type;
|
|
|
|
|
|
|
|
|
|
_.extend(_options, {
|
|
|
|
|
width : 318,
|
|
|
|
|
width : (this.type=='value') ? 450 : 318,
|
|
|
|
|
height : 160,
|
|
|
|
|
contentWidth : 180,
|
|
|
|
|
header : true,
|
|
|
|
@ -318,17 +320,13 @@ define([
|
|
|
|
|
this.template = options.template || [
|
|
|
|
|
'<div class="box" style="height:' + (_options.height - 85) + 'px;">',
|
|
|
|
|
'<div class="content-panel" >',
|
|
|
|
|
'<div style="margin-right:15px; display: inline-block; vertical-align: middle;">',
|
|
|
|
|
'<label class="input-label">', t.textType, '</label>',
|
|
|
|
|
'<div id="id-top10-type-combo" style=""></div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'<div style="margin-right:15px; display: inline-block; vertical-align: middle;">',
|
|
|
|
|
'<label class="input-label"></label>',
|
|
|
|
|
'<div id="id-top10-count-spin" class="input-group-nr" style=""></div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'<div style="display: inline-block; vertical-align: middle;">',
|
|
|
|
|
'<label class="input-label"></label>',
|
|
|
|
|
'<div id="id-top10-item-combo" class="input-group-nr" style=""></div>',
|
|
|
|
|
'<label>', t.textType, '</label>',
|
|
|
|
|
'<div>',
|
|
|
|
|
'<div id="id-top10-type-combo" style="margin-right:10px; display: inline-block; vertical-align: middle;"></div>',
|
|
|
|
|
'<div id="id-top10-count-spin" class="input-group-nr" style="margin-right:10px; display: inline-block; vertical-align: middle;"></div>',
|
|
|
|
|
'<div id="id-top10-item-combo" class="input-group-nr" style="display: inline-block; vertical-align: middle;"></div>',
|
|
|
|
|
'<label id="id-top10-lblby" class="input-group-nr" style="min-width: 40px; text-align: center; display: inline-block; vertical-align: middle;">'+ t.txtBy +'</label>',
|
|
|
|
|
'<div id="id-top10-fields-combo" class="input-group-nr" style="width:100px;display: inline-block; vertical-align: middle;"></div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'</div>',
|
|
|
|
@ -358,15 +356,18 @@ define([
|
|
|
|
|
});
|
|
|
|
|
this.cmbType.setValue(true);
|
|
|
|
|
|
|
|
|
|
var data = [
|
|
|
|
|
{ value: false, displayValue: this.txtItems },
|
|
|
|
|
{ value: true, displayValue: this.txtPercent }
|
|
|
|
|
];
|
|
|
|
|
(this.type=='value') && data.push({ value: 0, displayValue: this.txtSum });
|
|
|
|
|
|
|
|
|
|
this.cmbItem = new Common.UI.ComboBox({
|
|
|
|
|
el : $('#id-top10-item-combo', this.$window),
|
|
|
|
|
style : 'width: 85px;',
|
|
|
|
|
menuStyle : 'min-width: 85px;',
|
|
|
|
|
cls : 'input-group-nr',
|
|
|
|
|
data : [
|
|
|
|
|
{ value: false, displayValue: this.txtItems },
|
|
|
|
|
{ value: true, displayValue: this.txtPercent }
|
|
|
|
|
],
|
|
|
|
|
data : data,
|
|
|
|
|
editable : false
|
|
|
|
|
});
|
|
|
|
|
this.cmbItem.setValue(false);
|
|
|
|
@ -384,6 +385,18 @@ define([
|
|
|
|
|
minValue: 1
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.cmbFields = new Common.UI.ComboBox({
|
|
|
|
|
el : $('#id-top10-fields-combo', this.$window),
|
|
|
|
|
menuStyle : 'min-width: 100%;max-height: 135px;',
|
|
|
|
|
style : 'width:100%;',
|
|
|
|
|
cls : 'input-group-nr',
|
|
|
|
|
data : [],
|
|
|
|
|
scrollAlwaysVisible: true,
|
|
|
|
|
editable : false
|
|
|
|
|
});
|
|
|
|
|
this.cmbFields.setVisible(this.type=='value');
|
|
|
|
|
(this.type!=='value') && this.$window.find('#id-top10-lblby').addClass('hidden');
|
|
|
|
|
|
|
|
|
|
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
|
|
|
|
|
|
|
|
|
this.loadDefaults();
|
|
|
|
@ -422,6 +435,23 @@ define([
|
|
|
|
|
|
|
|
|
|
loadDefaults: function () {
|
|
|
|
|
if (this.properties) {
|
|
|
|
|
var isTop10Sum = false;
|
|
|
|
|
if (this.type == 'value') {
|
|
|
|
|
var pivotObj = this.properties.asc_getPivotObj(),
|
|
|
|
|
idx = pivotObj.asc_getDataFieldIndexFilter(),
|
|
|
|
|
fields = pivotObj.asc_getDataFields();
|
|
|
|
|
isTop10Sum = pivotObj.asc_getIsTop10Sum();
|
|
|
|
|
|
|
|
|
|
this.setTitle(this.txtValueTitle + ' (' + fields[0] + ')');
|
|
|
|
|
fields.shift();
|
|
|
|
|
var arr = [];
|
|
|
|
|
fields && fields.forEach(function (item, index) {
|
|
|
|
|
item && arr.push({value: index, displayValue: item});
|
|
|
|
|
});
|
|
|
|
|
this.cmbFields.setData(arr);
|
|
|
|
|
this.cmbFields.setValue((idx!==0) ? idx-1 : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var filterObj = this.properties.asc_getFilterObj();
|
|
|
|
|
if (filterObj.asc_getType() == Asc.c_oAscAutoFilterTypes.Top10) {
|
|
|
|
|
var top10Filter = filterObj.asc_getFilter(),
|
|
|
|
@ -429,8 +459,8 @@ define([
|
|
|
|
|
percent = top10Filter.asc_getPercent();
|
|
|
|
|
|
|
|
|
|
this.cmbType.setValue(type || type===null);
|
|
|
|
|
this.cmbItem.setValue(percent || percent===null);
|
|
|
|
|
this.spnCount.setDefaultUnit((percent || percent===null) ? '%' : '');
|
|
|
|
|
this.cmbItem.setValue(isTop10Sum ? 0 : (percent || percent===null));
|
|
|
|
|
this.spnCount.setDefaultUnit((percent || percent===null) && !isTop10Sum ? '%' : '');
|
|
|
|
|
this.spnCount.setValue(top10Filter.asc_getVal());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -444,9 +474,15 @@ define([
|
|
|
|
|
|
|
|
|
|
var top10Filter = filterObj.asc_getFilter();
|
|
|
|
|
top10Filter.asc_setTop(this.cmbType.getValue());
|
|
|
|
|
top10Filter.asc_setPercent(this.cmbItem.getValue());
|
|
|
|
|
top10Filter.asc_setPercent(this.cmbItem.getValue()===true);
|
|
|
|
|
top10Filter.asc_setVal(this.spnCount.getNumberValue());
|
|
|
|
|
|
|
|
|
|
if (this.type == 'value') {
|
|
|
|
|
var pivotObj = this.properties.asc_getPivotObj();
|
|
|
|
|
pivotObj.asc_setIsTop10Sum(this.cmbItem.getValue()===0);
|
|
|
|
|
pivotObj.asc_setDataFieldIndexFilter((this.type == 'value') ? this.cmbFields.getValue()+1 : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.api.asc_applyAutoFilter(this.properties);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
@ -462,14 +498,449 @@ define([
|
|
|
|
|
txtTop : 'Top',
|
|
|
|
|
txtBottom : 'Bottom',
|
|
|
|
|
txtItems : 'Item',
|
|
|
|
|
txtPercent : 'Percent'
|
|
|
|
|
txtPercent : 'Percent',
|
|
|
|
|
txtValueTitle: 'Top 10 Filter',
|
|
|
|
|
txtSum: 'Sum',
|
|
|
|
|
txtBy: 'by'
|
|
|
|
|
|
|
|
|
|
}, SSE.Views.Top10FilterDialog || {}));
|
|
|
|
|
|
|
|
|
|
SSE.Views.PivotDigitalFilterDialog = Common.UI.Window.extend(_.extend({
|
|
|
|
|
|
|
|
|
|
initialize: function (options) {
|
|
|
|
|
var t = this, _options = {};
|
|
|
|
|
|
|
|
|
|
_.extend(_options, {
|
|
|
|
|
width : 501,
|
|
|
|
|
height : 210,
|
|
|
|
|
contentWidth : 180,
|
|
|
|
|
header : true,
|
|
|
|
|
cls : 'filter-dlg',
|
|
|
|
|
contentTemplate : '',
|
|
|
|
|
title : (options.type=='label') ? t.txtTitleLabel : t.txtTitleValue,
|
|
|
|
|
items : []
|
|
|
|
|
}, options);
|
|
|
|
|
|
|
|
|
|
this.api = options.api;
|
|
|
|
|
this.handler = options.handler;
|
|
|
|
|
this.type = options.type || 'value';
|
|
|
|
|
|
|
|
|
|
this.template = options.template || [
|
|
|
|
|
'<div class="box" style="height:' + (_options.height - 85) + 'px;">',
|
|
|
|
|
'<div class="content-panel" >',
|
|
|
|
|
'<label class="header">', ((t.type=='label') ? t.textShowLabel : t.textShowValue), '</label>',
|
|
|
|
|
'<div style="margin-top:15px;">',
|
|
|
|
|
'<div id="id-field-digital-combo" class="input-group-nr" style="vertical-align:middle;width:110px;display:inline-block;margin-right:10px;"></div>',
|
|
|
|
|
'<div id="id-cond-digital-combo" class="input-group-nr" style="vertical-align:middle;width:' + ((t.type=='label') ? 225 : 110) + 'px;display:inline-block;margin-right:10px;"></div>',
|
|
|
|
|
'<div id="id-input-digital-value1" class="" style="vertical-align: middle; width:225px;display:inline-block;"></div>',
|
|
|
|
|
'<label id="id-label-digital-and" style="vertical-align: middle;margin-left: 5px;">'+ this.txtAnd +'</label>',
|
|
|
|
|
'<div id="id-input-digital-value2" class="" style="vertical-align: middle; width:100px;display:inline-block;margin-left: 5px;"></div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'<div style="margin-top:10px;">',
|
|
|
|
|
'<label style="display:block;">' + t.textUse1 + '</label>',
|
|
|
|
|
'<label style="display:block;">' + t.textUse2 + '</label>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'<div class="separator horizontal" style="width:100%"></div>',
|
|
|
|
|
'<div class="footer center">',
|
|
|
|
|
'<button class="btn normal dlg-btn primary" result="ok">', t.okButtonText, '</button>',
|
|
|
|
|
'<button class="btn normal dlg-btn" result="cancel">', t.cancelButtonText, '</button>',
|
|
|
|
|
'</div>'
|
|
|
|
|
].join('');
|
|
|
|
|
|
|
|
|
|
_options.tpl = _.template(this.template)(_options);
|
|
|
|
|
|
|
|
|
|
Common.UI.Window.prototype.initialize.call(this, _options);
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
Common.UI.Window.prototype.render.call(this);
|
|
|
|
|
|
|
|
|
|
this.conditions = [
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.equals, displayValue: this.capCondition1},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.doesNotEqual, displayValue: this.capCondition2},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isGreaterThan, displayValue: this.capCondition3},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo, displayValue: this.capCondition4},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isLessThan, displayValue: this.capCondition5},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo, displayValue: this.capCondition6},
|
|
|
|
|
{value: -2, displayValue: this.capCondition13},
|
|
|
|
|
{value: -3, displayValue: this.capCondition14}
|
|
|
|
|
];
|
|
|
|
|
if (this.type=='label') this.conditions = this.conditions.concat([
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.beginsWith, displayValue: this.capCondition7},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.doesNotBeginWith, displayValue: this.capCondition8},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.endsWith, displayValue: this.capCondition9},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.doesNotEndWith, displayValue: this.capCondition10},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.contains, displayValue: this.capCondition11},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.doesNotContain, displayValue: this.capCondition12}
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
this.cmbCondition1 = new Common.UI.ComboBox({
|
|
|
|
|
el : $('#id-cond-digital-combo', this.$window),
|
|
|
|
|
menuStyle : 'min-width: 100%;max-height: 135px;',
|
|
|
|
|
style : 'width:100%;',
|
|
|
|
|
cls : 'input-group-nr',
|
|
|
|
|
data : this.conditions,
|
|
|
|
|
scrollAlwaysVisible: true,
|
|
|
|
|
editable : false
|
|
|
|
|
});
|
|
|
|
|
this.cmbCondition1.setValue(Asc.c_oAscCustomAutoFilter.equals);
|
|
|
|
|
this.cmbCondition1.on('selected', _.bind(function(combo, record) {
|
|
|
|
|
var isBetween = record.value == -2 || record.value == -3;
|
|
|
|
|
this.inputValue2.setVisible(isBetween);
|
|
|
|
|
this.lblAnd.toggleClass('hidden', !isBetween);
|
|
|
|
|
this.inputValue.$el.width(isBetween ? 100 : 225);
|
|
|
|
|
var me = this;
|
|
|
|
|
_.defer(function () {
|
|
|
|
|
if (me.inputValue) {
|
|
|
|
|
me.inputValue._input.focus();
|
|
|
|
|
}
|
|
|
|
|
}, 10);
|
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
|
|
this.cmbFields = new Common.UI.ComboBox({
|
|
|
|
|
el : $('#id-field-digital-combo', this.$window),
|
|
|
|
|
menuStyle : 'min-width: 100%;max-height: 135px;',
|
|
|
|
|
style : 'width:100%;',
|
|
|
|
|
cls : 'input-group-nr',
|
|
|
|
|
data : [],
|
|
|
|
|
scrollAlwaysVisible: true,
|
|
|
|
|
editable : false
|
|
|
|
|
});
|
|
|
|
|
this.cmbFields.setVisible(this.type=='value');
|
|
|
|
|
this.cmbFields.on('selected', _.bind(function(combo, record) {
|
|
|
|
|
var me = this;
|
|
|
|
|
_.defer(function () {
|
|
|
|
|
if (me.inputValue) {
|
|
|
|
|
me.inputValue._input.focus();
|
|
|
|
|
}
|
|
|
|
|
}, 10);
|
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
|
|
this.inputValue = new Common.UI.InputField({
|
|
|
|
|
el : $('#id-input-digital-value1'),
|
|
|
|
|
allowBlank : false,
|
|
|
|
|
style : 'width: 100%;',
|
|
|
|
|
validateOnBlur: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.inputValue2 = new Common.UI.InputField({
|
|
|
|
|
el : $('#id-input-digital-value2'),
|
|
|
|
|
allowBlank : false,
|
|
|
|
|
style : 'width: 100%;',
|
|
|
|
|
validateOnBlur: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.lblAnd = this.$window.find('#id-label-digital-and');
|
|
|
|
|
|
|
|
|
|
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
|
|
|
|
|
|
|
|
|
this.loadDefaults();
|
|
|
|
|
},
|
|
|
|
|
show: function () {
|
|
|
|
|
Common.UI.Window.prototype.show.call(this);
|
|
|
|
|
|
|
|
|
|
var me = this;
|
|
|
|
|
_.defer(function () {
|
|
|
|
|
if (me.inputValue) {
|
|
|
|
|
me.inputValue._input.focus();
|
|
|
|
|
}
|
|
|
|
|
}, 500);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
close: function () {
|
|
|
|
|
if (this.api) {
|
|
|
|
|
this.api.asc_enableKeyEvents(true);
|
|
|
|
|
}
|
|
|
|
|
Common.UI.Window.prototype.close.call(this);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onBtnClick: function (event) {
|
|
|
|
|
if (event.currentTarget.attributes && event.currentTarget.attributes.result) {
|
|
|
|
|
if ('ok' === event.currentTarget.attributes.result.value) {
|
|
|
|
|
this.save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setSettings: function (properties) {
|
|
|
|
|
this.properties = properties;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
loadDefaults: function () {
|
|
|
|
|
if (this.properties && this.cmbCondition1 && this.cmbFields && this.inputValue) {
|
|
|
|
|
|
|
|
|
|
var pivotObj = this.properties.asc_getPivotObj(),
|
|
|
|
|
idx = pivotObj.asc_getDataFieldIndexFilter(),
|
|
|
|
|
fields = pivotObj.asc_getDataFields();
|
|
|
|
|
|
|
|
|
|
this.setTitle(this.options.title + ' (' + fields[0] + ')');
|
|
|
|
|
if (this.type == 'value') {
|
|
|
|
|
fields.shift();
|
|
|
|
|
var arr = [];
|
|
|
|
|
fields && fields.forEach(function (item, index) {
|
|
|
|
|
item && arr.push({value: index, displayValue: item});
|
|
|
|
|
});
|
|
|
|
|
this.cmbFields.setData(arr);
|
|
|
|
|
this.cmbFields.setValue((idx!==0) ? idx-1 : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var filterObj = this.properties.asc_getFilterObj();
|
|
|
|
|
if (filterObj.asc_getType() == Asc.c_oAscAutoFilterTypes.CustomFilters) {
|
|
|
|
|
var customFilter = filterObj.asc_getFilter(),
|
|
|
|
|
customFilters = customFilter.asc_getCustomFilters(),
|
|
|
|
|
value = customFilters[0].asc_getOperator();
|
|
|
|
|
|
|
|
|
|
if ((customFilters.length>1)) {
|
|
|
|
|
var isAnd = customFilter.asc_getAnd();
|
|
|
|
|
var isBetween = (customFilters[0].asc_getOperator() == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo && customFilters[1].asc_getOperator() == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo),
|
|
|
|
|
isNotBetween = (customFilters[0].asc_getOperator() == Asc.c_oAscCustomAutoFilter.isLessThan && customFilters[1].asc_getOperator() == Asc.c_oAscCustomAutoFilter.isGreaterThan);
|
|
|
|
|
|
|
|
|
|
if (isAnd && isBetween)
|
|
|
|
|
value = -2;
|
|
|
|
|
else if (!isAnd && isNotBetween)
|
|
|
|
|
value = -3;
|
|
|
|
|
}
|
|
|
|
|
this.cmbCondition1.setValue(value || Asc.c_oAscCustomAutoFilter.equals);
|
|
|
|
|
this.inputValue.setValue(null === customFilters[0].asc_getVal() ? '' : customFilters[0].asc_getVal());
|
|
|
|
|
this.inputValue.$el.width((value==-2 || value==-3) ? 100 : 225);
|
|
|
|
|
|
|
|
|
|
this.lblAnd.toggleClass('hidden', !(value==-2 || value==-3));
|
|
|
|
|
this.inputValue2.setVisible(value==-2 || value==-3);
|
|
|
|
|
this.inputValue2.setValue((customFilters.length>1) ? (null === customFilters[1].asc_getVal() ? '' : customFilters[1].asc_getVal()) : '');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
save: function () {
|
|
|
|
|
if (this.api && this.properties && this.cmbCondition1 && this.cmbFields && this.inputValue) {
|
|
|
|
|
|
|
|
|
|
var filterObj = this.properties.asc_getFilterObj();
|
|
|
|
|
filterObj.asc_setFilter(new Asc.CustomFilters());
|
|
|
|
|
filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.CustomFilters);
|
|
|
|
|
|
|
|
|
|
var customFilter = filterObj.asc_getFilter(),
|
|
|
|
|
type = this.cmbCondition1.getValue();
|
|
|
|
|
if (type==-2) {
|
|
|
|
|
customFilter.asc_setCustomFilters([new Asc.CustomFilter(), new Asc.CustomFilter()]);
|
|
|
|
|
customFilter.asc_setAnd(true);
|
|
|
|
|
var customFilters = customFilter.asc_getCustomFilters();
|
|
|
|
|
customFilters[0].asc_setOperator(Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo);
|
|
|
|
|
customFilters[0].asc_setVal(this.inputValue.getValue());
|
|
|
|
|
customFilters[1].asc_setOperator(Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo);
|
|
|
|
|
customFilters[1].asc_setVal(this.inputValue2.getValue());
|
|
|
|
|
} else if (type==-3) {
|
|
|
|
|
customFilter.asc_setCustomFilters([new Asc.CustomFilter(), new Asc.CustomFilter()]);
|
|
|
|
|
customFilter.asc_setAnd(false);
|
|
|
|
|
var customFilters = customFilter.asc_getCustomFilters();
|
|
|
|
|
customFilters[0].asc_setOperator(Asc.c_oAscCustomAutoFilter.isLessThan);
|
|
|
|
|
customFilters[0].asc_setVal(this.inputValue.getValue());
|
|
|
|
|
customFilters[1].asc_setOperator(Asc.c_oAscCustomAutoFilter.isGreaterThan);
|
|
|
|
|
customFilters[1].asc_setVal(this.inputValue2.getValue());
|
|
|
|
|
} else {
|
|
|
|
|
customFilter.asc_setCustomFilters([new Asc.CustomFilter()]);
|
|
|
|
|
customFilter.asc_setAnd(true);
|
|
|
|
|
var customFilters = customFilter.asc_getCustomFilters();
|
|
|
|
|
customFilters[0].asc_setOperator(this.cmbCondition1.getValue());
|
|
|
|
|
customFilters[0].asc_setVal(this.inputValue.getValue());
|
|
|
|
|
}
|
|
|
|
|
var pivotObj = this.properties.asc_getPivotObj();
|
|
|
|
|
pivotObj.asc_setDataFieldIndexFilter((this.type == 'value') ? this.cmbFields.getValue()+1 : 0);
|
|
|
|
|
|
|
|
|
|
this.api.asc_applyAutoFilter(this.properties);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onPrimary: function() {
|
|
|
|
|
this.save();
|
|
|
|
|
this.close();
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
capCondition1 : "equals",
|
|
|
|
|
capCondition10 : "does not end with",
|
|
|
|
|
capCondition11 : "contains",
|
|
|
|
|
capCondition12 : "does not contain",
|
|
|
|
|
capCondition2 : "does not equal",
|
|
|
|
|
capCondition3 : "is greater than",
|
|
|
|
|
capCondition4 : "is greater than or equal to",
|
|
|
|
|
capCondition5 : "is less than",
|
|
|
|
|
capCondition6 : "is less than or equal to",
|
|
|
|
|
capCondition7 : "begins with",
|
|
|
|
|
capCondition8 : "does not begin with",
|
|
|
|
|
capCondition9 : "ends with",
|
|
|
|
|
textShowLabel : "Show items for which the label:",
|
|
|
|
|
textShowValue : "Show items for which:",
|
|
|
|
|
textUse1 : "Use ? to present any single character",
|
|
|
|
|
textUse2 : "Use * to present any series of character",
|
|
|
|
|
txtTitleValue: 'Value Filter',
|
|
|
|
|
txtTitleLabel: 'Label Filter',
|
|
|
|
|
capCondition13: 'between',
|
|
|
|
|
capCondition14: 'not between',
|
|
|
|
|
txtAnd: 'and'
|
|
|
|
|
|
|
|
|
|
}, SSE.Views.PivotDigitalFilterDialog || {}));
|
|
|
|
|
|
|
|
|
|
SSE.Views.SortFilterDialog = Common.UI.Window.extend(_.extend({
|
|
|
|
|
|
|
|
|
|
initialize: function (options) {
|
|
|
|
|
var t = this, _options = {};
|
|
|
|
|
|
|
|
|
|
this.type = options.type;
|
|
|
|
|
|
|
|
|
|
_.extend(_options, {
|
|
|
|
|
width : 215,
|
|
|
|
|
height : 215,
|
|
|
|
|
contentWidth : 180,
|
|
|
|
|
header : true,
|
|
|
|
|
cls : 'filter-dlg',
|
|
|
|
|
contentTemplate : '',
|
|
|
|
|
title : t.txtTitle,
|
|
|
|
|
items : [],
|
|
|
|
|
buttons: ['ok', 'cancel']
|
|
|
|
|
}, options);
|
|
|
|
|
|
|
|
|
|
this.template = options.template || [
|
|
|
|
|
'<div class="box" style="height:' + (_options.height - 85) + 'px;">',
|
|
|
|
|
'<div class="content-panel" >',
|
|
|
|
|
'<div id="id-sort-filter-radio-asc" style="margin-bottom: 4px;"></div>',
|
|
|
|
|
'<div id="id-sort-filter-fields-asc" class="input-group-nr" style="width:150px;margin-bottom: 10px;margin-left: 22px;"></div>',
|
|
|
|
|
'<div id="id-sort-filter-radio-desc" style="margin-bottom: 4px;"></div>',
|
|
|
|
|
'<div id="id-sort-filter-fields-desc" class="input-group-nr" style="width:150px;margin-left: 22px;"></div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'<div class="separator horizontal" style="width:100%"></div>'
|
|
|
|
|
].join('');
|
|
|
|
|
|
|
|
|
|
this.api = options.api;
|
|
|
|
|
this.handler = options.handler;
|
|
|
|
|
|
|
|
|
|
_options.tpl = _.template(this.template)(_options);
|
|
|
|
|
|
|
|
|
|
Common.UI.Window.prototype.initialize.call(this, _options);
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
Common.UI.Window.prototype.render.call(this);
|
|
|
|
|
|
|
|
|
|
this.radioAsc = new Common.UI.RadioBox({
|
|
|
|
|
el: $('#id-sort-filter-radio-asc'),
|
|
|
|
|
labelText: this.textAsc,
|
|
|
|
|
name: 'asc-radio-sort',
|
|
|
|
|
checked: true
|
|
|
|
|
});
|
|
|
|
|
this.radioAsc.on('change', _.bind(function(field, newValue) {
|
|
|
|
|
newValue && this.cmbFieldsAsc.setDisabled(false);
|
|
|
|
|
newValue && this.cmbFieldsDesc.setDisabled(true);
|
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
|
|
this.radioDesc = new Common.UI.RadioBox({
|
|
|
|
|
el: $('#id-sort-filter-radio-desc'),
|
|
|
|
|
labelText: this.textDesc,
|
|
|
|
|
name: 'asc-radio-sort'
|
|
|
|
|
});
|
|
|
|
|
this.radioDesc.on('change', _.bind(function(field, newValue) {
|
|
|
|
|
newValue && this.cmbFieldsAsc.setDisabled(true);
|
|
|
|
|
newValue && this.cmbFieldsDesc.setDisabled(false);
|
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
|
|
this.cmbFieldsAsc = new Common.UI.ComboBox({
|
|
|
|
|
el : $('#id-sort-filter-fields-asc', this.$window),
|
|
|
|
|
menuStyle : 'min-width: 100%;max-height: 135px;',
|
|
|
|
|
style : 'width:100%;',
|
|
|
|
|
cls : 'input-group-nr',
|
|
|
|
|
data : [],
|
|
|
|
|
scrollAlwaysVisible: true,
|
|
|
|
|
editable : false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.cmbFieldsDesc = new Common.UI.ComboBox({
|
|
|
|
|
el : $('#id-sort-filter-fields-desc', this.$window),
|
|
|
|
|
menuStyle : 'min-width: 100%;max-height: 135px;',
|
|
|
|
|
style : 'width:100%;',
|
|
|
|
|
cls : 'input-group-nr',
|
|
|
|
|
data : [],
|
|
|
|
|
scrollAlwaysVisible: true,
|
|
|
|
|
editable : false,
|
|
|
|
|
disabled: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
|
|
|
|
|
|
|
|
|
this.loadDefaults();
|
|
|
|
|
},
|
|
|
|
|
show: function () {
|
|
|
|
|
Common.UI.Window.prototype.show.call(this);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
close: function () {
|
|
|
|
|
if (this.api) {
|
|
|
|
|
this.api.asc_enableKeyEvents(true);
|
|
|
|
|
}
|
|
|
|
|
Common.UI.Window.prototype.close.call(this);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onBtnClick: function (event) {
|
|
|
|
|
if (event.currentTarget.attributes && event.currentTarget.attributes.result) {
|
|
|
|
|
if ('ok' === event.currentTarget.attributes.result.value) {
|
|
|
|
|
this.save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setSettings: function (properties) {
|
|
|
|
|
this.properties = properties;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
loadDefaults: function () {
|
|
|
|
|
if (this.properties) {
|
|
|
|
|
var pivotObj = this.properties.asc_getPivotObj(),
|
|
|
|
|
idx = pivotObj.asc_getDataFieldIndexSorting(),
|
|
|
|
|
fields = pivotObj.asc_getDataFields(),
|
|
|
|
|
sort = this.properties.asc_getSortState();
|
|
|
|
|
|
|
|
|
|
this.setTitle(this.txtTitle + ' (' + fields[0] + ')');
|
|
|
|
|
var arr = [];
|
|
|
|
|
fields && fields.forEach(function (item, index) {
|
|
|
|
|
item && arr.push({value: index, displayValue: item});
|
|
|
|
|
});
|
|
|
|
|
this.cmbFieldsAsc.setData(arr);
|
|
|
|
|
this.cmbFieldsAsc.setValue((idx>=0) ? idx : 0);
|
|
|
|
|
this.cmbFieldsDesc.setData(arr);
|
|
|
|
|
this.cmbFieldsDesc.setValue((idx>=0) ? idx : 0);
|
|
|
|
|
|
|
|
|
|
this.radioDesc.setValue(sort == Asc.c_oAscSortOptions.Descending, true);
|
|
|
|
|
this.cmbFieldsDesc.setDisabled(sort !== Asc.c_oAscSortOptions.Descending);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
save: function () {
|
|
|
|
|
if (this.api && this.properties) {
|
|
|
|
|
var combo = this.radioAsc.getValue() ? this.cmbFieldsAsc : this.cmbFieldsDesc;
|
|
|
|
|
var pivotObj = this.properties.asc_getPivotObj();
|
|
|
|
|
pivotObj.asc_setDataFieldIndexSorting(combo.getValue());
|
|
|
|
|
this.properties.asc_setSortState(this.radioAsc.getValue() ? Asc.c_oAscSortOptions.Ascending : Asc.c_oAscSortOptions.Descending);
|
|
|
|
|
this.api.asc_applyAutoFilter(this.properties);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onPrimary: function() {
|
|
|
|
|
this.save();
|
|
|
|
|
this.close();
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
txtTitle: "Sort",
|
|
|
|
|
textAsc: 'Ascenging (A to Z) by',
|
|
|
|
|
textDesc: 'Descending (Z to A) by'
|
|
|
|
|
|
|
|
|
|
}, SSE.Views.SortFilterDialog || {}));
|
|
|
|
|
|
|
|
|
|
SSE.Views.AutoFilterDialog = Common.UI.Window.extend(_.extend({
|
|
|
|
|
|
|
|
|
|
initialize: function (options) {
|
|
|
|
|
var t = this, _options = {}, width = undefined, height = undefined;
|
|
|
|
|
var t = this, _options = {}, width = 450, height = undefined;
|
|
|
|
|
if (Common.Utils.InternalSettings.get('sse-settings-size-filter-window')) {
|
|
|
|
|
width = Common.Utils.InternalSettings.get('sse-settings-size-filter-window')[0];
|
|
|
|
|
height = Common.Utils.InternalSettings.get('sse-settings-size-filter-window')[1];
|
|
|
|
@ -505,7 +976,7 @@ define([
|
|
|
|
|
'<button class="btn normal dlg-btn" result="cancel">', t.cancelButtonText, '</button>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'<div class="menu-panel" style="width: 195px; float: right;">',
|
|
|
|
|
'<div class="menu-panel" style="float: right;">',
|
|
|
|
|
'<div id="menu-container-filters" style=""><div class="dropdown-toggle" data-toggle="dropdown"></div></div>',
|
|
|
|
|
'</div>',
|
|
|
|
|
'</div>'
|
|
|
|
@ -567,6 +1038,11 @@ define([
|
|
|
|
|
});
|
|
|
|
|
this.miSortHigh2Low.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending));
|
|
|
|
|
|
|
|
|
|
this.miSortOptions = new Common.UI.MenuItem({
|
|
|
|
|
caption : this.txtSortOption
|
|
|
|
|
});
|
|
|
|
|
this.miSortOptions.on('click', _.bind(this.onSortOptions, this));
|
|
|
|
|
|
|
|
|
|
this.miSortCellColor = new Common.UI.MenuItem({
|
|
|
|
|
caption : this.txtSortCellColor,
|
|
|
|
|
toggleGroup : 'menufiltersort',
|
|
|
|
@ -685,19 +1161,75 @@ define([
|
|
|
|
|
});
|
|
|
|
|
this.miReapply.on('click', _.bind(this.onReapply, this));
|
|
|
|
|
|
|
|
|
|
this.miReapplySeparator = new Common.UI.MenuItem({ caption: '--' });
|
|
|
|
|
|
|
|
|
|
// pivot
|
|
|
|
|
this.miValueFilter = new Common.UI.MenuItem({
|
|
|
|
|
caption : this.txtValueFilter,
|
|
|
|
|
toggleGroup : 'menufilterfilter',
|
|
|
|
|
checkable : true,
|
|
|
|
|
checked : false,
|
|
|
|
|
menu : new Common.UI.Menu({
|
|
|
|
|
menuAlign: 'tl-tr',
|
|
|
|
|
items: [
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.equals, caption: this.txtEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'value'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.doesNotEqual, caption: this.txtNotEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'value'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isGreaterThan, caption: this.txtGreater, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'value'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo, caption: this.txtGreaterEquals,checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'value'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isLessThan, caption: this.txtLess, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'value'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo, caption: this.txtLessEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'value'},
|
|
|
|
|
{value: -2, caption: this.txtBetween, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'value'},
|
|
|
|
|
{value: -3, caption: this.txtNotBetween, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'value'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.top10, caption: this.txtTop10, checkable: true, type: Asc.c_oAscAutoFilterTypes.Top10, pivottype: 'value'}
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
this.miValueFilter.menu.on('item:click', _.bind(this.onValueFilterMenuClick, this));
|
|
|
|
|
|
|
|
|
|
this.miLabelFilter = new Common.UI.MenuItem({
|
|
|
|
|
caption : this.txtLabelFilter,
|
|
|
|
|
toggleGroup : 'menufilterfilter',
|
|
|
|
|
checkable : true,
|
|
|
|
|
checked : false,
|
|
|
|
|
menu : new Common.UI.Menu({
|
|
|
|
|
menuAlign: 'tl-tr',
|
|
|
|
|
items: [
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.equals, caption: this.txtEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.doesNotEqual, caption: this.txtNotEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.beginsWith, caption: this.txtBegins, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.doesNotBeginWith, caption: this.txtNotBegins, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.endsWith, caption: this.txtEnds, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.doesNotEndWith, caption: this.txtNotEnds, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.contains, caption: this.txtContains, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.doesNotContain, caption: this.txtNotContains, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{caption: '--'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isGreaterThan, caption: this.txtGreater, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo, caption: this.txtGreaterEquals,checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isLessThan, caption: this.txtLess, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo, caption: this.txtLessEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: -2, caption: this.txtBetween, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'},
|
|
|
|
|
{value: -3, caption: this.txtNotBetween, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters, pivottype: 'label'}
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
this.miLabelFilter.menu.on('item:click', _.bind(this.onLabelFilterMenuClick, this));
|
|
|
|
|
|
|
|
|
|
this.filtersMenu = new Common.UI.Menu({
|
|
|
|
|
items: [
|
|
|
|
|
this.miSortLow2High,
|
|
|
|
|
this.miSortHigh2Low,
|
|
|
|
|
this.miSortOptions,
|
|
|
|
|
this.miSortCellColor,
|
|
|
|
|
this.miSortFontColor,
|
|
|
|
|
{caption : '--'},
|
|
|
|
|
this.miLabelFilter,
|
|
|
|
|
this.miValueFilter,
|
|
|
|
|
this.miNumFilter,
|
|
|
|
|
this.miTextFilter,
|
|
|
|
|
this.miFilterCellColor,
|
|
|
|
|
this.miFilterFontColor,
|
|
|
|
|
this.miClear,
|
|
|
|
|
{caption : '--'},
|
|
|
|
|
this.miReapplySeparator,
|
|
|
|
|
this.miReapply
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
@ -847,6 +1379,19 @@ define([
|
|
|
|
|
this.close();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onSortOptions: function () {
|
|
|
|
|
var me = this,
|
|
|
|
|
dlgSort = new SSE.Views.SortFilterDialog({api:this.api}).on({
|
|
|
|
|
'close': function() {
|
|
|
|
|
me.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.close();
|
|
|
|
|
|
|
|
|
|
dlgSort.setSettings(this.configTo);
|
|
|
|
|
dlgSort.show();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onNumCustomFilterItemClick: function(item) {
|
|
|
|
|
var filterObj = this.configTo.asc_getFilterObj(),
|
|
|
|
|
value1 = '', value2 = '',
|
|
|
|
@ -866,10 +1411,10 @@ define([
|
|
|
|
|
|
|
|
|
|
if (item.value!==-1) {
|
|
|
|
|
var newCustomFilter = new Asc.CustomFilters();
|
|
|
|
|
newCustomFilter.asc_setCustomFilters((item.value == -2) ? [new Asc.CustomFilter(), new Asc.CustomFilter()]: [new Asc.CustomFilter()]);
|
|
|
|
|
newCustomFilter.asc_setCustomFilters((item.value == -2 || item.value == -3) ? [new Asc.CustomFilter(), new Asc.CustomFilter()]: [new Asc.CustomFilter()]);
|
|
|
|
|
|
|
|
|
|
var newCustomFilters = newCustomFilter.asc_getCustomFilters();
|
|
|
|
|
newCustomFilters[0].asc_setOperator((item.value == -2) ? Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo : item.value);
|
|
|
|
|
newCustomFilters[0].asc_setOperator((item.value == -2) ? Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo : ((item.value == -3) ? Asc.c_oAscCustomAutoFilter.isLessThan : item.value));
|
|
|
|
|
|
|
|
|
|
if (item.value == -2) {
|
|
|
|
|
var isBetween = (cond1 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo);
|
|
|
|
@ -877,6 +1422,12 @@ define([
|
|
|
|
|
newCustomFilters[0].asc_setVal(isBetween ? value1 : '');
|
|
|
|
|
newCustomFilters[1].asc_setOperator(Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo);
|
|
|
|
|
newCustomFilters[1].asc_setVal(isBetween ? value2 : '');
|
|
|
|
|
} else if (item.value == -3) {
|
|
|
|
|
var isNotBetween = (cond1 == Asc.c_oAscCustomAutoFilter.isLessThan && cond2 == Asc.c_oAscCustomAutoFilter.isGreaterThan);
|
|
|
|
|
newCustomFilter.asc_setAnd(isNotBetween ? isAnd : false);
|
|
|
|
|
newCustomFilters[0].asc_setVal(isNotBetween ? value1 : '');
|
|
|
|
|
newCustomFilters[1].asc_setOperator(Asc.c_oAscCustomAutoFilter.isGreaterThan);
|
|
|
|
|
newCustomFilters[1].asc_setVal(isNotBetween ? value2 : '');
|
|
|
|
|
} else {
|
|
|
|
|
newCustomFilter.asc_setAnd(true);
|
|
|
|
|
newCustomFilters[0].asc_setVal((item.value == cond1) ? value1 : '');
|
|
|
|
@ -887,6 +1438,14 @@ define([
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var me = this,
|
|
|
|
|
dlgDigitalFilter;
|
|
|
|
|
if (item.options.pivottype == 'label' || item.options.pivottype == 'value')
|
|
|
|
|
dlgDigitalFilter = new SSE.Views.PivotDigitalFilterDialog({api:this.api, type: item.options.pivottype}).on({
|
|
|
|
|
'close': function() {
|
|
|
|
|
me.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
else
|
|
|
|
|
dlgDigitalFilter = new SSE.Views.DigitalFilterDialog({api:this.api, type: 'number'}).on({
|
|
|
|
|
'close': function() {
|
|
|
|
|
me.close();
|
|
|
|
@ -930,12 +1489,19 @@ define([
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var me = this,
|
|
|
|
|
dlgDigitalFilter;
|
|
|
|
|
if (item.options.pivottype == 'label' || item.options.pivottype == 'value')
|
|
|
|
|
dlgDigitalFilter = new SSE.Views.PivotDigitalFilterDialog({api:this.api, type: item.options.pivottype}).on({
|
|
|
|
|
'close': function() {
|
|
|
|
|
me.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
else
|
|
|
|
|
dlgDigitalFilter = new SSE.Views.DigitalFilterDialog({api:this.api, type: 'text'}).on({
|
|
|
|
|
'close': function() {
|
|
|
|
|
me.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.close();
|
|
|
|
|
|
|
|
|
|
dlgDigitalFilter.setSettings(this.configTo);
|
|
|
|
@ -956,9 +1522,9 @@ define([
|
|
|
|
|
this.close();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onTop10FilterItemClick: function(menu, item) {
|
|
|
|
|
onTop10FilterItemClick: function(item) {
|
|
|
|
|
var me = this,
|
|
|
|
|
dlgTop10Filter = new SSE.Views.Top10FilterDialog({api:this.api}).on({
|
|
|
|
|
dlgTop10Filter = new SSE.Views.Top10FilterDialog({api:this.api, type: item.options.pivottype}).on({
|
|
|
|
|
'close': function() {
|
|
|
|
|
me.close();
|
|
|
|
|
}
|
|
|
|
@ -969,6 +1535,35 @@ define([
|
|
|
|
|
dlgTop10Filter.show();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onLabelFilterMenuClick: function(menu, item) {
|
|
|
|
|
if (item.value == Asc.c_oAscCustomAutoFilter.isGreaterThan || item.value == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo || item.value == Asc.c_oAscCustomAutoFilter.isLessThan ||
|
|
|
|
|
item.value == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo || item.value == -2 || item.value == -3)
|
|
|
|
|
this.onNumCustomFilterItemClick(item);
|
|
|
|
|
else
|
|
|
|
|
this.onTextFilterMenuClick(menu, item);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onValueFilterMenuClick: function(menu, item) {
|
|
|
|
|
var me = this;
|
|
|
|
|
var pivotObj = this.configTo.asc_getPivotObj(),
|
|
|
|
|
fields = pivotObj.asc_getDataFields();
|
|
|
|
|
if (fields.length<2) {
|
|
|
|
|
Common.UI.warning({title: this.textWarning,
|
|
|
|
|
msg: this.warnFilterError,
|
|
|
|
|
callback: function() {
|
|
|
|
|
_.delay(function () {
|
|
|
|
|
me.close();
|
|
|
|
|
}, 10);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
if (item.options.type == Asc.c_oAscAutoFilterTypes.CustomFilters)
|
|
|
|
|
this.onNumCustomFilterItemClick(item);
|
|
|
|
|
else
|
|
|
|
|
this.onTop10FilterItemClick(item);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onFilterColorSelect: function(isCellColor, picker, color) {
|
|
|
|
|
var filterObj = this.configTo.asc_getFilterObj();
|
|
|
|
|
if (filterObj.asc_getType() !== Asc.c_oAscAutoFilterTypes.ColorFilter) {
|
|
|
|
@ -1098,6 +1693,34 @@ define([
|
|
|
|
|
|
|
|
|
|
_setDefaults: function() {
|
|
|
|
|
this.initialFilterType = this.configTo.asc_getFilterObj().asc_getType();
|
|
|
|
|
var menuPanel = this.$window.find('.menu-panel');
|
|
|
|
|
this.menuPanelWidth = menuPanel.innerWidth();
|
|
|
|
|
var width = this.getWidth();
|
|
|
|
|
if (Common.Utils.InternalSettings.get('sse-settings-size-filter-window')) {
|
|
|
|
|
width = Common.Utils.InternalSettings.get('sse-settings-size-filter-window')[0] + this.menuPanelWidth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var pivotObj = this.configTo.asc_getPivotObj(),
|
|
|
|
|
isPivot = !!pivotObj,
|
|
|
|
|
isValueFilter = false;
|
|
|
|
|
|
|
|
|
|
this.miValueFilter.setVisible(isPivot);
|
|
|
|
|
this.miLabelFilter.setVisible(isPivot);
|
|
|
|
|
this.miSortOptions.setVisible(isPivot);
|
|
|
|
|
|
|
|
|
|
if (isPivot) {
|
|
|
|
|
if (pivotObj.asc_getIsPageFilter()) {
|
|
|
|
|
this.setResizable(true, [this.initConfig.minwidth - this.menuPanelWidth, this.initConfig.minheight]);
|
|
|
|
|
menuPanel.addClass('hidden');
|
|
|
|
|
width -= this.menuPanelWidth;
|
|
|
|
|
this.menuPanelWidth = 0;
|
|
|
|
|
}
|
|
|
|
|
this.miReapplySeparator.setVisible(false);
|
|
|
|
|
this.miReapply.setVisible(false);
|
|
|
|
|
|
|
|
|
|
isValueFilter = (pivotObj.asc_getDataFieldIndexFilter()!==0);
|
|
|
|
|
}
|
|
|
|
|
this.setSize(width, this.getHeight());
|
|
|
|
|
|
|
|
|
|
var filterObj = this.configTo.asc_getFilterObj(),
|
|
|
|
|
isCustomFilter = (this.initialFilterType === Asc.c_oAscAutoFilterTypes.CustomFilters),
|
|
|
|
@ -1111,17 +1734,20 @@ define([
|
|
|
|
|
|
|
|
|
|
if (sortColor) sortColor = Common.Utils.ThemeColor.getHexColor(sortColor.get_r(), sortColor.get_g(), sortColor.get_b()).toLocaleUpperCase();
|
|
|
|
|
|
|
|
|
|
this.miTextFilter.setVisible(isTextFilter);
|
|
|
|
|
this.miNumFilter.setVisible(!isTextFilter);
|
|
|
|
|
this.miTextFilter.setVisible(!isPivot && isTextFilter);
|
|
|
|
|
this.miNumFilter.setVisible(!isPivot && !isTextFilter);
|
|
|
|
|
this.miTextFilter.setChecked(isCustomFilter && isTextFilter, true);
|
|
|
|
|
this.miNumFilter.setChecked((isCustomFilter || isDynamicFilter || isTop10) && !isTextFilter, true);
|
|
|
|
|
|
|
|
|
|
this.miValueFilter.setChecked(isPivot && isValueFilter, true);
|
|
|
|
|
this.miLabelFilter.setChecked(isPivot && !isValueFilter && (isCustomFilter || isTop10), true);
|
|
|
|
|
|
|
|
|
|
this.miSortLow2High.setChecked(sort == Asc.c_oAscSortOptions.Ascending, true);
|
|
|
|
|
this.miSortHigh2Low.setChecked(sort == Asc.c_oAscSortOptions.Descending, true);
|
|
|
|
|
|
|
|
|
|
var hasColors = (colorsFont && colorsFont.length>0);
|
|
|
|
|
this.miSortFontColor.setVisible(hasColors);
|
|
|
|
|
this.miFilterFontColor.setVisible(hasColors);
|
|
|
|
|
this.miFilterFontColor.setVisible(!isPivot && hasColors);
|
|
|
|
|
if (hasColors) {
|
|
|
|
|
var colors = [];
|
|
|
|
|
colorsFont.forEach(function(item, index) {
|
|
|
|
@ -1141,7 +1767,7 @@ define([
|
|
|
|
|
|
|
|
|
|
hasColors = (colorsFill && colorsFill.length>0);
|
|
|
|
|
this.miSortCellColor.setVisible(hasColors);
|
|
|
|
|
this.miFilterCellColor.setVisible(hasColors);
|
|
|
|
|
this.miFilterCellColor.setVisible(!isPivot && hasColors);
|
|
|
|
|
if (hasColors) {
|
|
|
|
|
var colors = [];
|
|
|
|
|
colorsFill.forEach(function(item, index) {
|
|
|
|
@ -1165,7 +1791,7 @@ define([
|
|
|
|
|
isAnd = (customFilter.asc_getAnd()),
|
|
|
|
|
cond1 = customFilters[0].asc_getOperator(),
|
|
|
|
|
cond2 = ((customFilters.length>1) ? (customFilters[1].asc_getOperator() || 0) : 0),
|
|
|
|
|
items = (isTextFilter) ? this.miTextFilter.menu.items : this.miNumFilter.menu.items,
|
|
|
|
|
items = isPivot ? (isValueFilter ? this.miValueFilter.menu.items : this.miLabelFilter.menu.items) : ((isTextFilter) ? this.miTextFilter.menu.items : this.miNumFilter.menu.items),
|
|
|
|
|
isCustomConditions = true;
|
|
|
|
|
|
|
|
|
|
if (customFilters.length==1)
|
|
|
|
@ -1174,7 +1800,7 @@ define([
|
|
|
|
|
item.setChecked(checked, true);
|
|
|
|
|
if (checked) isCustomConditions = false;
|
|
|
|
|
});
|
|
|
|
|
else if (!isTextFilter && (cond1 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo ||
|
|
|
|
|
else if ((isPivot || !isTextFilter) && (cond1 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo ||
|
|
|
|
|
cond1 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo)){
|
|
|
|
|
items[6].setChecked(true, true); // between filter
|
|
|
|
|
isCustomConditions = false;
|
|
|
|
@ -1195,7 +1821,7 @@ define([
|
|
|
|
|
}
|
|
|
|
|
} else if (isDynamicFilter || isTop10) {
|
|
|
|
|
var dynType = (isDynamicFilter) ? filterObj.asc_getFilter().asc_getType() : null,
|
|
|
|
|
items = this.miNumFilter.menu.items;
|
|
|
|
|
items = isPivot ? this.miValueFilter.menu.items : this.miNumFilter.menu.items;
|
|
|
|
|
items.forEach(function(item){
|
|
|
|
|
item.setChecked(isDynamicFilter && (item.options.type == Asc.c_oAscAutoFilterTypes.DynamicFilter) && (item.value == dynType) ||
|
|
|
|
|
isTop10 && (item.options.type == Asc.c_oAscAutoFilterTypes.Top10), true);
|
|
|
|
@ -1360,6 +1986,9 @@ define([
|
|
|
|
|
isValid = true;
|
|
|
|
|
}
|
|
|
|
|
if (isValid) {
|
|
|
|
|
var pivotObj = this.configTo.asc_getPivotObj();
|
|
|
|
|
if (pivotObj && pivotObj.asc_getIsPageFilter())
|
|
|
|
|
pivotObj.asc_setIsMultipleItemSelectionAllowed(true);
|
|
|
|
|
this.configTo.asc_getFilterObj().asc_setType(Asc.c_oAscAutoFilterTypes.Filters);
|
|
|
|
|
this.api.asc_applyAutoFilter(this.configTo);
|
|
|
|
|
}
|
|
|
|
@ -1394,6 +2023,7 @@ define([
|
|
|
|
|
this.$window.find('.combo-values').css({'height': size[1] - 100 + 'px'});
|
|
|
|
|
this.curSize.height = size[1];
|
|
|
|
|
}
|
|
|
|
|
size[0] -= this.menuPanelWidth;
|
|
|
|
|
Common.Utils.InternalSettings.set('sse-settings-size-filter-window', size);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
@ -1438,7 +2068,12 @@ define([
|
|
|
|
|
txtContains : "Contains...",
|
|
|
|
|
txtNotContains : "Does not contain...",
|
|
|
|
|
textSelectAllResults: 'Select All Search Results',
|
|
|
|
|
textAddSelection : 'Add current selection to filter'
|
|
|
|
|
textAddSelection : 'Add current selection to filter',
|
|
|
|
|
txtValueFilter: 'Value filter',
|
|
|
|
|
txtLabelFilter: 'Label filter',
|
|
|
|
|
warnFilterError: 'You need at least one field in the Values area in order to apply a value filter.',
|
|
|
|
|
txtNotBetween: 'Not between...',
|
|
|
|
|
txtSortOption: 'More sort options...'
|
|
|
|
|
|
|
|
|
|
}, SSE.Views.AutoFilterDialog || {}));
|
|
|
|
|
});
|