dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08615
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2102: Retaining current period selection if valid
------------------------------------------------------------
revno: 2102
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2010-11-18 11:07:31 +0100
message:
Retaining current period selection if valid
added:
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java 2010-11-17 18:26:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java 2010-11-18 10:07:31 +0000
@@ -75,6 +75,13 @@
{
return periods;
}
+
+ private boolean selectionValid;
+
+ public boolean isSelectionValid()
+ {
+ return selectionValid;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -82,11 +89,15 @@
public String execute()
{
- DataSet dataSet = dataSetService.getDataSet( dataSetId );
+ DataSet selectedDataSet = dataSetService.getDataSet( dataSetId );
- if ( dataSet != null )
+ if ( selectedDataSet != null )
{
- selectedStateManager.setSelectedDataSet( dataSet );
+ DataSet previousDataSet = selectedStateManager.getSelectedDataSet();
+
+ selectionValid = previousDataSet != null && previousDataSet.getPeriodType().equals( selectedDataSet.getPeriodType() );
+
+ selectedStateManager.setSelectedDataSet( selectedDataSet );
if ( next )
{
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2010-11-18 08:13:18 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2010-11-18 10:07:31 +0000
@@ -28,7 +28,7 @@
</action>
<action name="loadPeriods" class="org.hisp.dhis.de.action.LoadPeriodsAction">
- <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonPeriods.vm</result>
+ <result name="success" type="velocity-json">/dhis-web-dataentry/responsePeriods.vm</result>
</action>
<action name="loadDisplayModes" class="org.hisp.dhis.de.action.LoadDisplayModesAction">
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2010-11-18 09:42:34 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2010-11-18 10:07:31 +0000
@@ -34,7 +34,7 @@
function organisationUnitSelected( orgUnits )
{
- var selectedDataSetId = $( '#selectedDataSetId' ).val();
+ var dataSetId = $( '#selectedDataSetId' ).val();
var url = 'loadDataSets.action';
@@ -51,8 +51,8 @@
addOptionToList( list, json.dataSets[i].id, json.dataSets[i].name );
}
- if ( json.selectionValid && selectedDataSetId != null ) {
- $( '#selectedDataSetId' ).val( selectedDataSetId );
+ if ( json.selectionValid && dataSetId != null ) {
+ $( '#selectedDataSetId' ).val( dataSetId );
}
} );
}
@@ -78,6 +78,8 @@
{
var dataSetId = $( '#selectedDataSetId' ).val();
+ var periodIndex = $('#selectedPeriodIndex').val();
+
if ( dataSetId && dataSetId != -1 )
{
var url = 'loadPeriods.action?dataSetId=' + dataSetId + '&next=' + next + '&previous=' + previous;
@@ -91,6 +93,10 @@
for ( i in json.periods ) {
addOptionToList( list, i, json.periods[i].name );
}
+
+ if ( json.selectionValid && periodIndex != null ) {
+ $('#selectedPeriodIndex').val( periodIndex );
+ }
} );
}
}
=== added file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm 2010-11-18 10:07:31 +0000
@@ -0,0 +1,13 @@
+#set( $size = $periods.size() )
+{ "periods": [
+#foreach( $period in $periods )
+ {
+ "id": $!{period.id},
+ "startDate": "$!format.formatDate( ${period.startDate} )",
+ "endDate": "$!format.formatDate( ${period.endDate} )",
+ "name": "$!format.formatPeriod( ${period} )",
+ "externalId": "$!{period.externalId}"
+ }#if( $velocityCount < $size ),#end
+#end ],
+ "selectionValid": ${selectionValid}
+}