Commit 5e46983d authored by GoshaZotov's avatar GoshaZotov Committed by Alexander.Trofimov

functions for DynamicFilter

parent 9cd91100
......@@ -147,6 +147,44 @@ var c_oAscCustomAutoFilter = {
doesNotContain: 12
};
/** @enum */
var c_oAscDynamicAutoFilter = {
aboveAverage: 1,
belowAverage: 2,
lastMonth: 3,
lastQuarter: 4,
lastWeek: 5,
lastYear: 6,
m1: 7,
m10: 8,
m11: 9,
m12: 10,
m2: 11,
m3: 12,
m4: 13,
m5: 14,
m6: 15,
m7: 16,
m8: 17,
m9: 18,
nextMonth: 19,
nextQuarter: 20,
nextWeek: 21,
nextYear: 22,
q1: 23,
q2: 24,
q3: 25,
q4: 26,
thisMonth: 27,
thisQuarter: 28,
thisWeek: 29,
thisYear: 30,
today: 31,
tomorrow: 32,
yearToDate: 33,
yesterday: 34
};
var c_oAscChangeFilterOptions = {
filter: 1,
style: 2
......@@ -376,6 +414,10 @@ var c_oAscPopUpSelectorType = {
prot['doesNotEndWith'] = prot.doesNotEndWith;
prot['contains'] = prot.contains;
prot['doesNotContain'] = prot.doesNotContain;
window['Asc']['c_oAscDynamicAutoFilter'] = window['Asc'].c_oAscDynamicAutoFilter = c_oAscDynamicAutoFilter;
prot = c_oAscDynamicAutoFilter;
prot['aboveAverage'] = prot.aboveAverage;
prot['belowAverage'] = prot.belowAverage;
window['Asc']['c_oAscChangeFilterOptions'] = window['Asc'].c_oAscChangeFilterOptions = c_oAscChangeFilterOptions;
prot = c_oAscChangeFilterOptions;
prot['filter'] = prot.filter;
......
......@@ -5320,11 +5320,21 @@ FilterColumn.prototype.isHideValue = function(val, isDateTimeFormat, top10Length
res = this.Filters.isHideValue(val.toLowerCase(), isDateTimeFormat);
}
else if(this.CustomFiltersObj)
{
res = this.CustomFiltersObj.isHideValue(val);
}
else if(this.Top10)
{
res = this.Top10.isHideValue(val, top10Length);
}
else if(this.ColorFilter)
{
res = this.ColorFilter.isHideValue(cell);
}
else if(this.DynamicFilter)
{
res = this.DynamicFilter.isHideValue(val);
}
return res;
};
......@@ -5354,6 +5364,7 @@ FilterColumn.prototype.createFilter = function(obj) {
}
case c_oAscAutoFilterTypes.DynamicFilter:
{
this.DynamicFilter = obj.filter.filter.clone();
break;
}
case c_oAscAutoFilterTypes.Top10:
......@@ -5380,6 +5391,19 @@ FilterColumn.prototype.isApplyAutoFilter = function() {
return res;
};
FilterColumn.prototype.init = function(range) {
//добавляем данные, которые не передаются из меню при примененни а/ф(в данном случае только DynamicFilter)
if(null !== this.DynamicFilter)
{
var res = null;
this.DynamicFilter.init(range);
}
};
/** @constructor */
function Filters() {
this.Values = {};
......@@ -5894,6 +5918,56 @@ DynamicFilter.prototype.clone = function() {
return res;
};
DynamicFilter.prototype.init = function(range) {
var res = null;
switch(this.Type)
{
case Asc.c_oAscDynamicAutoFilter.aboveAverage:
case Asc.c_oAscDynamicAutoFilter.belowAverage:
{
var summ = 0;
var counter = 0;
range_forEachCell(function(cell){
var val = parseFloat(cell.getValue());
if(!isNaN(val))
{
summ += parseFloat(val);
counter++;
}
});
res = summ / counter;
break;
}
}
this.Val = res;
};
DynamicFilter.prototype.isHideValue = function(val) {
var res = false;
switch(this.Type)
{
case Asc.c_oAscDynamicAutoFilter.aboveAverage:
{
res = val > this.Val ? false : true;
break;
}
case Asc.c_oAscDynamicAutoFilter.belowAverage:
{
res = val < this.Val ? false : true;
break;
}
}
return res;
};
DynamicFilter.prototype.asc_getType = function () { return this.Type; };
DynamicFilter.prototype.asc_getVal = function () { return this.Val; };
DynamicFilter.prototype.asc_getMaxVal = function () { return this.MaxVal; };
......
......@@ -516,8 +516,11 @@
{
newFilterColumn = autoFilter.addFilterColumn();
newFilterColumn.ColId = filterObj.ColId;
}
}
var allFilterOpenElements = newFilterColumn.createFilter(autoFiltersObject);
newFilterColumn.init(worksheet.getRange3(autoFilter.Ref.r1 + 1, filterObj.ColId + autoFilter.Ref.c1, autoFilter.Ref.r2, filterObj.ColId + autoFilter.Ref.c1));
if(allFilterOpenElements && autoFilter.FilterColumns[filterObj.index])
{
if(autoFilter.FilterColumns[filterObj.index].ShowButton !== false)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment