dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29697
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15040: added reverse, and future period filters to js period generator
------------------------------------------------------------
revno: 15040
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-28 12:00:45 +0545
message:
added reverse, and future period filters to js period generator
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js 2014-04-28 05:33:12 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js 2014-04-28 06:15:45 +0000
@@ -100,6 +100,36 @@
this.financialApril = function( offset ) {
return this.get('FinancialApril').generatePeriods(offset);
};
+
+ this.reverse = function( periods ) {
+ return periods.slice(0).reverse();
+ };
+
+ this.filterFuturePeriods = function( periods ) {
+ var array = [];
+ var today = calendar.today();
+
+ $.each(periods, function( idx ) {
+ if( this['_endDate'].compareTo(today) <= 0 ) {
+ array.push(this);
+ }
+ });
+
+ return array;
+ };
+
+ this.filterFuturePeriodsExceptCurrent = function( periods ) {
+ var array = [];
+ var today = calendar.today();
+
+ $.each(periods, function( idx ) {
+ if( this['_startDate'].compareTo(today) <= 0 ) {
+ array.push(this);
+ }
+ });
+
+ return array;
+ }
};
dhis2.period.makeDailyPeriodGenerator = function( cal ) {
@@ -161,6 +191,9 @@
period['id'] = 'Weekly_' + period['startDate'];
period['iso'] = year + 'W' + week;
+ period['_startDate'] = startDate;
+ period['_endDate'] = endDate;
+
periods.push(period);
startDate.add(1, 'w');
@@ -198,6 +231,9 @@
period['id'] = 'Monthly_' + period['startDate'];
period['iso'] = startDate.formatDate("yyyymm");
+ period['_startDate'] = startDate;
+ period['_endDate'] = endDate;
+
periods.push(period);
}
@@ -229,6 +265,9 @@
period['id'] = 'BiMonthly_' + period['startDate'];
period['iso'] = startDate.formatDate("yyyymm") + 'B';
+ period['_startDate'] = startDate;
+ period['_endDate'] = endDate;
+
periods.push(period);
}
@@ -260,6 +299,9 @@
period['id'] = 'Quarterly_' + period['startDate'];
period['iso'] = startDate.formatDate("yyyy") + 'Q' + idx;
+ period['_startDate'] = startDate;
+ period['_endDate'] = endDate;
+
periods.push(period);
}
@@ -291,6 +333,9 @@
period['id'] = 'SixMonthly_' + period['startDate'];
period['iso'] = startDate.formatDate("yyyy") + 'S1';
+ period['_startDate'] = startDate;
+ period['_endDate'] = endDate;
+
periods.push(period);
startDate = cal.newDate(year, 7, 1);
@@ -304,6 +349,9 @@
period['id'] = 'SixMonthly_' + period['startDate'];
period['iso'] = startDate.formatDate("yyyy") + 'S2';
+ period['_startDate'] = startDate;
+ period['_endDate'] = endDate;
+
periods.push(period);
return periods;
@@ -333,6 +381,9 @@
period['id'] = 'SixMonthlyApril_' + period['startDate'];
period['iso'] = startDate.formatDate("yyyy") + 'AprilS1';
+ period['_startDate'] = startDate;
+ period['_endDate'] = endDate;
+
periods.push(period);
startDate = cal.newDate(year, 10, 1);
@@ -346,6 +397,9 @@
period['id'] = 'SixMonthlyApril_' + period['startDate'];
period['iso'] = startDate.formatDate("yyyy") + 'AprilS2';
+ period['_startDate'] = startDate;
+ period['_endDate'] = endDate;
+
periods.push(period);
return periods;
@@ -377,6 +431,9 @@
period['id'] = 'Yearly_' + period['startDate'];
period['iso'] = startDate.formatDate("yyyy");
+ period['_startDate'] = startDate;
+ period['_endDate'] = endDate;
+
periods.push(period);
}