← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3553: fixed select all when saving in datasets. also added indicators to add dataset.

 

------------------------------------------------------------
revno: 3553
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-10 10:42:26 +0200
message:
  fixed select all when saving in datasets. also added indicators to add dataset.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.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-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java	2011-01-25 20:50:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java	2011-05-10 08:42:26 +0000
@@ -29,11 +29,14 @@
 
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Set;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.user.CurrentUserService;
@@ -90,6 +93,13 @@
         this.userService = userService;
     }
 
+    private IndicatorService indicatorService;
+
+    public void setIndicatorService( IndicatorService indicatorService )
+    {
+        this.indicatorService = indicatorService;
+    }
+
     // -------------------------------------------------------------------------
     // Input & output
     // -------------------------------------------------------------------------
@@ -129,6 +139,13 @@
         this.selectedList = selectedList;
     }
 
+    private Collection<String> indicatorSelectedList = new HashSet<String>();
+
+    public void setIndicatorSelectedList( Collection<String> indicatorSelectedList )
+    {
+        this.indicatorSelectedList = indicatorSelectedList;
+    }
+
     private boolean mobile;
 
     public void setMobile( boolean mobile )
@@ -159,18 +176,27 @@
 
         PeriodType periodType = periodService.getPeriodTypeByName( frequencySelect );
 
+        Collection<DataElement> dataElements = new HashSet<DataElement>();
+        
+        for ( String id : selectedList )
+        {
+            dataElements.add( dataElementService.getDataElement( Integer.parseInt( id ) ) );
+        }
+
+        Set<Indicator> indicators = new HashSet<Indicator>();
+
+        for ( String id : indicatorSelectedList )
+        {
+            indicators.add( indicatorService.getIndicator( Integer.parseInt( id ) ) );
+        }
+
         DataSet dataSet = new DataSet( name, shortName, code, periodType );
-
+        
         dataSet.setMobile( mobile );
         dataSet.setVersion( 1 );
+        dataSet.setDataElements( dataElements );
+        dataSet.setIndicators( indicators );
         
-        for ( String id : selectedList )
-        {
-            DataElement dataElement = dataElementService.getDataElement( Integer.parseInt( id ) );
-
-            dataSet.getDataElements().add( dataElement );
-        }
-
         dataSetService.addDataSet( dataSet );
 
         assignDataSetToUserRole( dataSet );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java	2011-05-09 10:42:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java	2011-05-10 08:42:26 +0000
@@ -49,6 +49,42 @@
 public class UpdateDataSetAction
     implements Action
 {
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private DataSetService dataSetService;
+
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private IndicatorService indicatorService;
+
+    public void setIndicatorService( IndicatorService indicatorService )
+    {
+        this.indicatorService = indicatorService;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Input & output
+    // -------------------------------------------------------------------------
+
     private String name;
 
     public void setName( String name )
@@ -99,38 +135,6 @@
     }
 
     // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private DataSetService dataSetService;
-
-    public void setDataSetService( DataSetService dataSetService )
-    {
-        this.dataSetService = dataSetService;
-    }
-
-    private PeriodService periodService;
-
-    public void setPeriodService( PeriodService periodService )
-    {
-        this.periodService = periodService;
-    }
-
-    private DataElementService dataElementService;
-
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
-    private IndicatorService indicatorService;
-
-    public void setIndicatorService( IndicatorService indicatorService )
-    {
-        this.indicatorService = indicatorService;
-    }
-
-    // -------------------------------------------------------------------------
     // Action
     // -------------------------------------------------------------------------
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2011-05-09 10:42:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2011-05-10 08:42:26 +0000
@@ -259,12 +259,15 @@
 		<property name="dataSetService">
 			<ref bean="org.hisp.dhis.dataset.DataSetService"/>
 		</property>
+		<property name="periodService">
+			<ref bean="org.hisp.dhis.period.PeriodService"/>
+		</property>
 		<property name="dataElementService">
 			<ref bean="org.hisp.dhis.dataelement.DataElementService"/>
 		</property>
-		<property name="periodService">
-			<ref bean="org.hisp.dhis.period.PeriodService"/>
-		</property>
+        <property name="indicatorService">
+          <ref bean="org.hisp.dhis.indicator.IndicatorService"/>
+        </property>
 		<property name="userService">
 			<ref bean="org.hisp.dhis.user.UserService"/>
 		</property>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml	2011-05-09 15:20:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml	2011-05-10 08:42:26 +0000
@@ -131,16 +131,28 @@
     
     <action name="addDataSetForm"
       class="org.hisp.dhis.dataset.action.DataElementListFilteredByGroup">
+      <result name="success" type="chain">indicatorListFilteredByGroupChain</result>
+      <param name="requiredAuthorities">F_DATASET_ADD</param>
+    </action>
+
+    <action name="indicatorListFilteredByGroupChain"
+      class="org.hisp.dhis.dataset.action.IndicatorListFilteredByGroup">
       <result name="success" type="chain">dataElementGroupListAddChain</result>
-      <param name="requiredAuthorities">F_DATASET_ADD</param>
+      <param name="requiredAuthorities">F_DATASET_UPDATE</param>
     </action>
-    
+
     <action name="dataElementGroupListAddChain"
       class="org.hisp.dhis.dataset.action.DataElementGroupListAction">
+      <result name="success" type="chain">indicatorGroupListAddChain</result>
+      <param name="requiredAuthorities">F_DATASET_ADD</param>
+    </action>
+
+    <action name="indicatorGroupListAddChain"
+      class="org.hisp.dhis.dataset.action.IndicatorGroupListAction">
       <result name="success" type="chain">periodTypeListAddChain</result>
       <param name="requiredAuthorities">F_DATASET_ADD</param>
     </action>
-    
+
     <action name="periodTypeListAddChain"
       class="org.hisp.dhis.dataset.action.PeriodTypeListAction">
       <result name="success" type="velocity">/main.vm</result>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2011-03-17 12:08:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2011-05-10 08:42:26 +0000
@@ -100,11 +100,70 @@
           </select>
         </td>
       </tr>
+    </tbody>
+  </table>
+
+  <br/>
+
+  <table id="indicatorSelectionArea">
+    <col/> ## Available Indicators
+    <col/> ## Filter
+    <col/> ## Selected Indicators
+    <thead>
+      <tr>
+        <th>$i18n.getString( "available_indicators" )</th>
+		<th>$i18n.getString( "filter" )</th>
+        <th>$i18n.getString( "selected_indicators" )</th>
+      </tr>
+    </thead>
+    <tbody>
+      <tr>
+        <td>
+          <select id="indicatorGroupSelect" name="indicatorGroupSelect" style="min-width:20em"
+              onchange="javascript:filterByIndicatorGroup( this.options[this.selectedIndex].value )">
+            <option value="ALL" selected="selected">$i18n.getString( "all" )</option>
+            #foreach ( $indicatorGroup in $indicatorGroups )
+              <option value="$indicatorGroup.id">$encoder.htmlEncode( $indicatorGroup.name )</option>
+            #end
+          </select>
+        </td>
+        <td>$i18n.getString( "group" )</td>
+        <td></td>
+      </tr>
+
+      <tr>
+        <td><input type="text" id="availableIndicatorsFilter" onkeyup="filterList( this.value, 'indicatorAvailableList' )" style="min-width:20em"></td>
+      	<td>$i18n.getString( "name" )</td>
+      	<td></td>        
+      </tr>
+
+      <tr>
+        <td>
+          <select size="15" id="indicatorAvailableList" name="indicatorAvailableList" multiple="multiple" style="min-width:20em;height:20em" ondblclick="moveSelectedById( 'indicatorAvailableList', 'indicatorSelectedList');">
+              #foreach ( $availableIndicator in $indicators )
+                  <option value="$availableIndicator.id">$encoder.htmlEncode( $availableIndicator.name )</option>
+              #end               
+          </select>
+        </td>
+        <td>
+            <input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="moveSelectedById( 'indicatorAvailableList', 'indicatorSelectedList');"/><br/>
+            <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="moveSelectedById( 'indicatorSelectedList', 'indicatorAvailableList');"/><br/>
+            <input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="moveAllById( 'indicatorAvailableList', 'indicatorSelectedList' );"/><br/>
+            <input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="moveAllById( 'indicatorSelectedList', 'indicatorAvailableList' );"/>
+        </td>
+        <td>
+          <select id="indicatorSelectedList" name="indicatorSelectedList" multiple="multiple" style="min-width:20em;height:20em" ondblclick="moveSelectedById( 'indicatorSelectedList', 'indicatorAvailableList' );">
+              #foreach ( $availableIndicator in $dataSetIndicators )
+                  <option value="$availableIndicator.id">$encoder.htmlEncode( $availableIndicator.name )</option>
+              #end
+          </select>
+        </td>
+      </tr>
 
       <tr>
         <td colspan="3">
-          <input type="submit" value="$i18n.getString( 'save' )" style="width:13em"/><input type="button"
-            onclick="window.location.href='dataSet.action'" value="$i18n.getString( 'cancel' )" style="width:12em"/>
+          <input type="submit" value="$i18n.getString( 'save' )" style="width:13em" />
+          <input type="button" onclick="window.location.href='dataSet.action'" value="$i18n.getString( 'cancel' )" style="width:12em" />
         </td>
       </tr>
       

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2011-05-09 11:05:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2011-05-10 08:42:26 +0000
@@ -159,8 +159,8 @@
 
       <tr>
         <td colspan="3">
-          <input type="submit" value="$i18n.getString( 'save' )" style="width:10em"/><input type="button"
-            onclick="window.location.href='dataSet.action'" value="$i18n.getString( 'cancel' )" style="width:10em"/>
+          <input type="submit" value="$i18n.getString( 'save' )" style="width:10em" />
+          <input type="button" onclick="window.location.href='dataSet.action'" value="$i18n.getString( 'cancel' )" style="width:10em" />
         </td>
       </tr>
       

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js	2011-04-11 11:52:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js	2011-05-10 08:42:26 +0000
@@ -3,7 +3,8 @@
 		form.submit()
 	}, {
 		'beforeValidateHandler' : function() {
-			selectAllById('selectedList')
+			selectAllById('selectedList');
+			selectAllById('indicatorSelectedList');
 		},
 		'rules' : getValidationRules("dataSet")
 	});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js	2011-04-11 11:52:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js	2011-05-10 08:42:26 +0000
@@ -3,7 +3,8 @@
 		form.submit()
 	}, {
 		'beforeValidateHandler' : function() {
-			selectAllById('selectedList')
+			selectAllById('selectedList');
+			selectAllById('indicatorSelectedList');
 		},
 		'rules' : getValidationRules("dataSet")
 	});