dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19597
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8615: mobile: implemented support for future periods in datasets, also enable/disable next/prev period ...
------------------------------------------------------------
revno: 8615
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-10-22 00:00:21 +0200
message:
mobile: implemented support for future periods in datasets, also enable/disable next/prev period buttons correctly
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/FormUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/form/Form.java
dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm
dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/data-entry.vm
--
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-api/src/main/java/org/hisp/dhis/api/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/FormUtils.java 2012-10-11 14:35:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/FormUtils.java 2012-10-21 22:00:21 +0000
@@ -49,6 +49,7 @@
Form form = new Form();
form.setLabel( dataSet.getName() );
form.setPeriodType( dataSet.getPeriodType().getName() );
+ form.setAllowFuturePeriods( dataSet.isAllowFuturePeriods() );
if ( dataSet.getSections().size() > 0 )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/form/Form.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/form/Form.java 2012-10-15 10:20:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/form/Form.java 2012-10-21 22:00:21 +0000
@@ -43,6 +43,8 @@
private List<Group> groups = new ArrayList<Group>();
+ private boolean allowFuturePeriods;
+
public Form()
{
}
@@ -80,6 +82,17 @@
this.groups = groups;
}
+ @JsonProperty
+ public boolean isAllowFuturePeriods()
+ {
+ return allowFuturePeriods;
+ }
+
+ public void setAllowFuturePeriods( boolean allowFuturePeriods )
+ {
+ this.allowFuturePeriods = allowFuturePeriods;
+ }
+
@Override
public String toString()
{
@@ -87,6 +100,7 @@
"label='" + label + '\'' +
", periodType='" + periodType + '\'' +
", groups=" + groups +
+ ", allowFuturePeriods=" + allowFuturePeriods +
'}';
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm 2012-10-21 15:54:35 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm 2012-10-21 22:00:21 +0000
@@ -1,6 +1,7 @@
<!DOCTYPE html>
-<html manifest="../dhis-web-mobile-resources/manifest.appcache">
-<!-- <html> -->
+<!-- <html manifest="../dhis-web-mobile-resources/manifest.appcache"> -->
+<html>
+
<head>
<title>DHIS2</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/data-entry.vm'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/data-entry.vm 2012-10-21 17:43:34 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/data-entry.vm 2012-10-21 22:00:21 +0000
@@ -9,6 +9,7 @@
var periodTypeFactory = new PeriodType();
var periodType;
var periodOffset = 0;
+ var allowFuturePeriods = false;
function selectOrganisationUnit( e ) {
var $this = $(this);
@@ -67,27 +68,48 @@
var tmpl = $('#period-template').html();
var periods = periodTypeFactory.get( periodType ).generatePeriods( periodOffset );
- periods = periodTypeFactory.filterFuturePeriodsExceptCurrent( periods );
+
+ if( !allowFuturePeriods ) {
+ periods = periodTypeFactory.filterFuturePeriods( periods );
+ $('#next_year').button('disable');
+ }
+
periods = periodTypeFactory.reverse( periods );
- $('#period-page section[data-role="content"]').html(
- _.template(tmpl, { 'periods' : periods })
+ $( '#period-page section[data-role="content"]' ).html(
+ _.template(tmpl, { 'periods' : periods })
);
- $('#period-page').trigger( 'pagecreate' );
- $('#period-list').listview( 'refresh' );
-
- $('#previous_year').bind( 'click', function() {
+ $( '#period-page' ).trigger( 'pagecreate' );
+ $( '#period-list' ).listview( 'refresh' );
+
+ if( !allowFuturePeriods ) {
+ $('#next_year').button('disable');
+ }
+
+ $( '#previous_year' ).bind( 'click', function() {
periodOffset--;
refreshPeriods();
+
+ if( periodOffset < 0) {
+ $('#next_year').button('enable');
+ } else {
+ $('#next_year').button('disable');
+ }
});
- $('#next_year').bind( 'click', function() {
+ $( '#next_year' ).bind( 'click', function() {
periodOffset++;
refreshPeriods();
+
+ if( !allowFuturePeriods && periodOffset == 0) {
+ $('#next_year').button('disable');
+ } else {
+ $('#next_year').button('enable');
+ }
});
- $('#period-list li a').bind( 'click', selectPeriod );
+ $( '#period-list li a' ).bind( 'click', selectPeriod );
}
function loadPeriodPage() {
@@ -106,6 +128,7 @@
var form = fm.form( Selected.dataSet );
periodType = form.periodType;
+ allowFuturePeriods = form.allowFuturePeriods;
refreshPeriods();
$.mobile.hidePageLoadingMsg();