Skip to content

Commit

Permalink
Show currentyear + 3 past years of quarters when periods are quarters
Browse files Browse the repository at this point in the history
  • Loading branch information
Markionium committed Mar 16, 2015
1 parent 778e55a commit 6a75c32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/manifest.webapp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"0.2.6","name":"Data Approval","description":"Approvals app for PEPFAR","icons":{"48":"img/icons/dataapproval.png"},"developer":{"url":"http://www.dhis2.org","name":"Mark Polak","company":"DHIS2 Core Team","email":"[email protected]"},"launch_path":"index.html","default_locale":"en","activities":{"dhis":{"href":"*"}}}
{"version":"0.2.7","name":"Data Approval","description":"Approvals app for PEPFAR","icons":{"48":"img/icons/dataapproval.png"},"developer":{"url":"http://www.dhis2.org","name":"Mark Polak","company":"DHIS2 Core Team","email":"[email protected]"},"launch_path":"index.html","default_locale":"en","activities":{"dhis":{"href":"*"}}}
13 changes: 10 additions & 3 deletions src/main/period/period-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,17 @@ function periodService(d2Api) {
}

//Show this years and last years quarters
if (/^Quarterly|SixMonthly/.test(currentPeriodType)) {
if (/^Quarterly$/.test(currentPeriodType)) {
var thisYear = dhis2.period.generator.generateReversedPeriods(currentPeriodType, 0);
var lastYear = dhis2.period.generator.generateReversedPeriods(currentPeriodType, -1);
generatedPeriods = thisYear.concat(lastYear);

var currentQuarter = dhis2.period.generator.filterFuturePeriodsExceptCurrent(thisYear);
thisYear = thisYear.slice((3 - currentQuarter.length >= 0) ? 3 - currentQuarter.length : 0);

var oneYearAgo = dhis2.period.generator.generateReversedPeriods(currentPeriodType, -1);
var twoYearsAgo = dhis2.period.generator.generateReversedPeriods(currentPeriodType, -2);
var threeYearsAgo = dhis2.period.generator.generateReversedPeriods(currentPeriodType, -3);

generatedPeriods = thisYear.concat(oneYearAgo).concat(twoYearsAgo).concat(threeYearsAgo);
return;
}

Expand Down

0 comments on commit 6a75c32

Please sign in to comment.