← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6701: Fixed incorrect sorting in section list

 

------------------------------------------------------------
revno: 6701
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-04-23 13:43:13 +0200
message:
  Fixed incorrect sorting in section list
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/comparator/SectionOrderComparator.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SectionListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/section.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionList.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-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2012-04-20 18:31:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2012-04-23 11:43:13 +0000
@@ -38,7 +38,6 @@
 import org.hisp.dhis.common.BaseNameableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
 import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.common.annotation.Scanned;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.dataset.DataSet;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/comparator/SectionOrderComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/comparator/SectionOrderComparator.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/comparator/SectionOrderComparator.java	2012-04-23 11:43:13 +0000
@@ -36,6 +36,16 @@
 {
     public int compare( Section o1, Section o2 )
     {
+        if ( o1.getDataSet() != null && o2.getDataSet() != null )
+        {
+            int dataSet = o1.getDataSet().getName().compareTo( o2.getDataSet().getName() );
+            
+            if ( dataSet != 0 )
+            {
+                return dataSet;
+            }
+        }
+        
         return o1.getSortOrder() - o2.getSortOrder();
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SectionListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SectionListAction.java	2012-01-25 17:11:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SectionListAction.java	2012-04-23 11:43:13 +0000
@@ -134,29 +134,23 @@
 
         Collections.sort( datasets, IdentifiableObjectNameComparator.INSTANCE );
 
-        Collection<Section> temp = sectionService.getAllSections();
-
-        if ( dataSetId == null )
-        {
-            sections = new ArrayList<Section>( temp );
-        }
-        else
-        {
-            sections = new ArrayList<Section>();
-
+        if ( dataSetId != null && dataSetId != -1 )
+        {
             DataSet dataSet = dataSetService.getDataSet( dataSetId );
-            Set<Section> dataSetSections = dataSet.getSections();
-            sections = new ArrayList<Section>( dataSetSections );
-
-            dataSet = dataSetService.getDataSet( dataSetId.intValue() );
+            
+            sections = new ArrayList<Section>( dataSet.getSections() );
 
             for ( DataElement de : dataSet.getDataElements() )
             {
                 categoryCombos.add( de.getCategoryCombo() );
-            }
-
-            Collections.sort( sections, new SectionOrderComparator() );
-        }
+            }            
+        }
+        else
+        {
+            sections = new ArrayList<Section>( sectionService.getAllSections() );
+        }
+        
+        Collections.sort( sections, new SectionOrderComparator() );
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2012-02-24 05:14:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2012-04-23 11:43:13 +0000
@@ -65,7 +65,7 @@
 datasets=DataSets
 data=Data
 pivot=Pivot
-please_select_dataset_or_categorycombo=Please select a dataset/category combo
+please_select_dataset_or_categorycombo=Please select data set and category combination
 indicator_already_inserted=Indicator already inserted
 no_indicator_was_selected=No indicator was selected
 dataelement_already_inserted=Data element already inserted

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/section.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/section.js	2012-03-04 13:46:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/section.js	2012-04-23 11:43:13 +0000
@@ -11,44 +11,45 @@
 		setInnerHTML( 'dataElementCountField', json.section.dataElementCount );  
 		
 		showDetails();
-	});
+	} );
 }
 
 function sortOrderSubmit() 
 {
-	var datasetId = document.getElementById('dataSetId').value;
+	var dataSetId = $( "#dataSetId" ).val();
 
-	if ( datasetId == "null" ) 
+	if ( dataSetId && dataSetId != -1 ) 
+	{
+		window.location.href = "showSortSectionForm.action?dataSetId=" + dataSetId;
+	} 
+	else 
 	{
 		window.alert( i18n_please_select_dataset );
-	} else 
-	{
-		window.location.href = "showSortSectionForm.action?dataSetId=" + datasetId;
 	}
 }
 
-function getSectionByDataSet(dataSetId) 
+function getSectionByDataSet( dataSetId ) 
 {
 	window.location.href = "section.action?dataSetId=" + dataSetId;
 }
 
 function removeSection(sectionId, sectionName) 
 {
-	removeItem(sectionId, sectionName, i18n_confirm_delete,	"removeSection.action");
+	removeItem( sectionId, sectionName, i18n_confirm_delete, "removeSection.action" );
 }
 
 function addSectionSubmit() 
 {
-	var dataSetId = document.getElementById('dataSetId').value;
-	var categoryComboId = document.getElementById('categoryComboId').value;
+	var dataSetId = $( '#dataSetId' ).val();
+	var categoryComboId = $( '#categoryComboId' ).val();
 
-	if ( dataSetId == "null" || dataSetId == "" || categoryComboId == "null" || categoryComboId == "" ) 
-	{
-		showWarningMessage( i18n_please_select_dataset_categorycombo );
-	} 
-	else 
+	if ( dataSetId && dataSetId != "-1" && categoryComboId && categoryComboId != "-1" ) 
 	{
 		window.location.href = "getSectionOptions.action?dataSetId=" + dataSetId + "&categoryComboId=" + categoryComboId;
+	} 
+	else 
+	{
+		showWarningMessage( i18n_please_select_dataset_categorycombo );		
 	}
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionList.vm	2012-04-16 13:41:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionList.vm	2012-04-23 11:43:13 +0000
@@ -13,7 +13,7 @@
 			<tr>
 				<td><label>$i18n.getString( "select_dataset" )</label><br/>
 					<select id="dataSetId" name="dataSetId" style="min-width:20em" onchange="javascript:getSectionByDataSet(this.options[this.selectedIndex].value)">
-						<option value=null selected="selected" >[ $i18n.getString( "all" ) ]</option>
+						<option value="-1">[ $i18n.getString( "all" ) ]</option>
 						#foreach ( $dataset in $datasets )
 						  <option value="$dataset.id" #if($dataSetId==$dataset.id) selected="selected" #end>$dataset.name</option>
 						#end
@@ -22,7 +22,7 @@
 				<td>	
 					<label>$i18n.getString( "select_categorycombo" )</label><br/>			  
 					<select id="categoryComboId" name="categoryComboId" style="min-width:20em">
-						<option value=null selected="selected" >[ $i18n.getString( "all" ) ]</option>
+						<option value="-1">[ $i18n.getString( "all" ) ]</option>
 						#foreach ( $categoryCombo in $categoryCombos )
 							<option value="$categoryCombo.id" #if($categoryComboId==$categoryCombo.id) selected="selected" #end>$categoryCombo.name</option>
 						#end