Commit 8b5e51c3 authored by Alexander.Trofimov's avatar Alexander.Trofimov

support timePeriod in conditional formatting

parent 18becc3a
...@@ -76,6 +76,68 @@ ...@@ -76,6 +76,68 @@
res.aRuleElements.push(this.aRuleElements[i].clone()); res.aRuleElements.push(this.aRuleElements[i].clone());
return res; return res;
}; };
CConditionalFormattingRule.prototype.getTimePeriod = function() {
var start, end;
var now = new Date();
switch (this.timePeriod) {
case AscCommonExcel.ST_TimePeriod.last7Days:
end = now.getExcelDate();
now.setDate(now.getDate() - 7);
start = now.getExcelDate();
break;
case AscCommonExcel.ST_TimePeriod.lastMonth:
end = now.getExcelDate();
now.setMonth(now.getMonth() - 1);
start = now.getExcelDate();
break;
case AscCommonExcel.ST_TimePeriod.thisMonth:
start = now.getExcelDate();
now.setMonth(now.getMonth() + 1);
end = now.getExcelDate();
break;
case AscCommonExcel.ST_TimePeriod.nextMonth:
now.setMonth(now.getMonth() + 1);
start = now.getExcelDate();
now.setMonth(now.getMonth() + 1);
end = now.getExcelDate();
break;
case AscCommonExcel.ST_TimePeriod.lastWeek:
now.setDate(now.getDate() - now.getDay());
end = now.getExcelDate();
now.setDate(now.getDate() - 7);
start = now.getExcelDate();
break;
case AscCommonExcel.ST_TimePeriod.thisWeek:
now.setDate(now.getDate() - now.getDay());
start = now.getExcelDate();
now.setDate(now.getDate() + 7);
end = now.getExcelDate();
break;
case AscCommonExcel.ST_TimePeriod.nextWeek:
now.setDate(now.getDate() - now.getDay() + 7);
start = now.getExcelDate();
now.setDate(now.getDate() + 7);
end = now.getExcelDate();
break;
case AscCommonExcel.ST_TimePeriod.yesterday:
end = now.getExcelDate();
now.setDate(now.getDate() - 1);
start = now.getExcelDate();
break;
case AscCommonExcel.ST_TimePeriod.today:
start = now.getExcelDate();
now.setDate(now.getDate() + 1);
end = now.getExcelDate();
break;
case AscCommonExcel.ST_TimePeriod.tomorrow:
now.setDate(now.getDate() + 1);
start = now.getExcelDate();
now.setDate(now.getDate() + 1);
end = now.getExcelDate();
break;
}
return {start: start, end: end};
};
function CColorScale () { function CColorScale () {
this.aCFVOs = []; this.aCFVOs = [];
......
...@@ -8102,6 +8102,7 @@ ...@@ -8102,6 +8102,7 @@
window["Asc"].EIconSetType = EIconSetType; window["Asc"].EIconSetType = EIconSetType;
window["Asc"].ECfType = ECfType; window["Asc"].ECfType = ECfType;
window["AscCommonExcel"].ECfvoType = ECfvoType; window["AscCommonExcel"].ECfvoType = ECfvoType;
window["AscCommonExcel"].ST_TimePeriod = ST_TimePeriod;
window["Asc"].ESparklineType = ESparklineType; window["Asc"].ESparklineType = ESparklineType;
window["Asc"].EDispBlanksAs = EDispBlanksAs; window["Asc"].EDispBlanksAs = EDispBlanksAs;
window["Asc"].SparklineAxisMinMax = SparklineAxisMinMax; window["Asc"].SparklineAxisMinMax = SparklineAxisMinMax;
......
...@@ -3511,8 +3511,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3511,8 +3511,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
oRule = aRules[j]; oRule = aRules[j];
// ToDo aboveAverage, cellIs, // ToDo aboveAverage, cellIs,
// ToDo dataBar, expression, iconSet, // ToDo dataBar, expression, iconSet (page 2679)
// ToDo timePeriod (page 2679)
if (Asc.ECfType.colorScale === oRule.type) { if (Asc.ECfType.colorScale === oRule.type) {
if (1 !== oRule.aRuleElements.length) { if (1 !== oRule.aRuleElements.length) {
break; break;
...@@ -3658,6 +3657,18 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3658,6 +3657,18 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
return !c.isEmptyTextString(); return !c.isEmptyTextString();
}; };
break; break;
case Asc.ECfType.timePeriod:
if (oRule.timePeriod) {
compareFunction = (function(rule, period) {
return function(val, c) {
var n = parseFloat(val);
return period.start <= n && n <= period.end;
};
})(oRule, oRule.getTimePeriod());
} else {
continue;
}
break;
default: default:
continue; continue;
break; break;
......
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