← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16808: use new available/selected plugin in category mgmt

 

------------------------------------------------------------
revno: 16808
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-09-25 11:06:55 +0700
message:
  use new available/selected plugin in category mgmt
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.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-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryAction.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryAction.java	2014-09-25 04:06:55 +0000
@@ -28,14 +28,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.List;
-
+import com.opensymphony.xwork2.Action;
 import org.hisp.dhis.dataelement.DataElementCategory;
 import org.hisp.dhis.dataelement.DataElementCategoryOption;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 
-import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author Selamawit
@@ -65,7 +64,7 @@
     {
         this.name = name;
     }
-    
+
     private boolean dataDimension;
 
     public void setDataDimension( boolean dataDimension )
@@ -80,11 +79,11 @@
         this.dimensionType = dimensionType;
     }
 
-    private List<String> selectedList = new ArrayList<>();
+    private List<String> coSelected = new ArrayList<>();
 
-    public void setSelectedList( List<String> selectedList )
+    public void setCoSelected( List<String> coSelected )
     {
-        this.selectedList = selectedList;
+        this.coSelected = coSelected;
     }
 
     // -------------------------------------------------------------------------
@@ -100,10 +99,9 @@
 
         List<DataElementCategoryOption> options = new ArrayList<>();
 
-        for ( String id : selectedList )
+        for ( String id : coSelected )
         {
-            DataElementCategoryOption categoryOption = dataElementCategoryService.getDataElementCategoryOption( Integer.parseInt( id ) );
-            options.add( categoryOption );
+            options.add( dataElementCategoryService.getDataElementCategoryOption( id ) );
         }
 
         dataElementCategory.setCategoryOptions( options );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryAction.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryAction.java	2014-09-25 04:06:55 +0000
@@ -28,14 +28,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.List;
-
+import com.opensymphony.xwork2.Action;
 import org.hisp.dhis.dataelement.DataElementCategory;
 import org.hisp.dhis.dataelement.DataElementCategoryOption;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 
-import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author Abyot Asalefew
@@ -80,11 +79,11 @@
         this.dataDimension = dataDimension;
     }
 
-    private List<String> selectedList = new ArrayList<>();
+    private List<String> coSelected = new ArrayList<>();
 
-    public void setSelectedList( List<String> selectedList )
+    public void setCoSelected( List<String> coSelected )
     {
-        this.selectedList = selectedList;
+        this.coSelected = coSelected;
     }
 
     // -------------------------------------------------------------------------
@@ -99,9 +98,9 @@
 
         List<DataElementCategoryOption> options = new ArrayList<>();
 
-        for ( String id : selectedList )
+        for ( String id : coSelected )
         {
-            options.add( dataElementCategoryService.getDataElementCategoryOption( Integer.parseInt( id ) ) );
+            options.add( dataElementCategoryService.getDataElementCategoryOption( id ) );
         }
 
         dataElementCategory.setCategoryOptions( options );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm	2014-02-12 16:09:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm	2014-09-25 04:06:55 +0000
@@ -1,23 +1,16 @@
 <script type="text/javascript">
 	jQuery(document).ready(	function() {
-	   jQuery("#availableList").dhisAjaxSelect({
-            source: "../dhis-web-commons-ajax-json/getDataElementCategoryOptions.action",
-            iterator: 'dataElementCategoryOptions',
-            sortSelected: false,
-            connectedTo: 'selectedList',
-            handler: function(item) {
-                var option = jQuery("<option />");
-                option.text( item.name );
-                option.attr( "value", item.id );
-
-                return option;
-            }
+        $('#coAvailable').selected({
+          url: '../api/categoryOptions.json',
+          target: $('#coSelected'),
+          search: $('#coAvailableSearch'),
+          iterator: 'categoryOptions'
         });
 	
 		validation2( 'addDataElementCategoryForm', function( form ){ form.submit() }, {
 			'beforeValidateHandler': function() { 
-			    jQuery("#selectedList option").each(function() { jQuery(this).attr("selected", "true"); });
-			    listValidator( 'memberValidator', 'categoryOptionNames' ); 
+                $("#coSelected").find("option").attr("selected", "selected");
+			    listValidator( 'coValidator', 'coSelected' );
 			},
 			'rules': getValidationRules("dateElementCategory")
 		});
@@ -58,49 +51,13 @@
       <td colspan="2" style="height:15px"></td>
     </tr>
   </table>  
-  
-  <table id="dataElementCategoryOptionSelectionArea">
-    <colgroup>
-      <col style="width: 500px;"/>
-      <col/>
-      <col style="width: 500px;"/>
-      <col/>
-    </colgroup>
-
-    <thead>
-      <tr>        
-        <th>$i18n.getString( "available_category_options" )</th>
-        <th></th>
-        <th>$i18n.getString( "selected_category_options" )</th>
-      </tr>
-    </thead>
-
-    <tbody>
-      <tr>
-        <td>
-            <select id="availableList" name="availableList" multiple="multiple" style="height: 200px; width: 100%;"></select>
-        </td>
-
-        <td style="text-align:center">
-            <input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableList' );"/><br/>
-            <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'selectedList' );"/><br/>
-            <input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableList' );"/><br/>
-            <input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'selectedList' );"/>
-        </td>
-
-        <td>
-            <select id="selectedList" name="selectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 22px;"></select>
-        </td>
-
-        <td>
-          <a onclick="moveUpSelectedOption('selectedList')" title="$i18n.getString( 'move_up' )"><img src="../images/move_up.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_up' )"/></a><br/><br/>
-          <a onclick="moveDownSelectedOption('selectedList')" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_down' )"/></a>
-        </td>
-      </tr>
-
-    </tbody>
-  </table>
-  
+
+#jqSelected({
+   "prefix": "co",
+   "i18n_available": "available_category_options",
+   "i18n_selected": "selected_category_options"
+ })
+
   <p>
   	<input type="submit" value="$i18n.getString( 'add' )" style="width:100px">
     <input type="button" onclick="dhis2.commons.redirectCurrentPage( 'category.action' )" value="$i18n.getString( 'cancel' )" style="width:100px"/>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm	2014-02-12 16:09:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm	2014-09-25 04:06:55 +0000
@@ -1,24 +1,17 @@
 <script type="text/javascript">
 	jQuery(document).ready(	function() {
-	    jQuery("#availableList").dhisAjaxSelect({
-            source: "../dhis-web-commons-ajax-json/getDataElementCategoryOptions.action",
-            iterator: 'dataElementCategoryOptions',
-            sortSelected: false,
-            connectedTo: 'selectedList',
-            handler: function(item) {
-                var option = jQuery("<option />");
-                option.text( item.name );
-                option.attr( "value", item.id );
-
-                return option;
-            }
+        $('#coAvailable').selected({
+          url: '../api/categoryOptions.json',
+          target: $('#coSelected'),
+          search: $('#coAvailableSearch'),
+          iterator: 'categoryOptions'
         });
-	
+
 		validation2( 'editDataElementCategoryForm', function( form ){ form.submit()}, 
 		{
 			'beforeValidateHandler': function() { 
-			    jQuery("#selectedList option").each(function() { jQuery(this).attr("selected", "true"); });
-			    listValidator( 'memberValidator', 'categoryOptions' ); 
+                $("#coSelected").find("option").attr("selected", "selected");
+			    listValidator( 'coValidator', 'coSelected' );
 			},
 			'rules': getValidationRules("dateElementCategory")
 		}); 
@@ -63,56 +56,14 @@
       <td colspan="2" style="height:15px"></td>
     </tr>
   </table>
-  
-  
-  <table id="dataElementCategoryOptionSelectionArea">
-     <colgroup>
-       <col style="width: 500px;"/>
-       <col/>
-       <col style="width: 500px;"/>
-       <col/>
-     </colgroup>
-
-    <thead>
-        <tr>        
-        <th>$i18n.getString( "available_category_options" )</th>
-        <th></th>        
-        <th>$i18n.getString( "selected_category_options" )</th>
-      </tr>
-    </thead>
-  
-    <tbody>
-      <tr>       
-        <td>
-          <select id="availableList" name="availableList" multiple="multiple" style="height: 200px; width: 100%;"></select>
-        </td>
-       </td>
-
-        <td style="text-align:center">
-            <input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableList' );"/><br/>
-            <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'selectedList' );"/><br/>
-            <input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableList' );"/><br/>
-            <input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'selectedList' );"/>
-        </td>
-
-        <td>
-          <select id="selectedList" name="selectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 22px;">
-            #foreach ( $categoryOption in $dataElementCategory.categoryOptions )
-              <option value="$categoryOption.id">$encoder.htmlEncode( $categoryOption.name )</option>
-            #end
-          </select>
-        </td>
-        
-        <td>
-          <a onclick="moveUpSelectedOption('selectedList')" title="$i18n.getString( 'move_up' )"><img src="../images/move_up.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_up' )"/></a><br/><br/>
-          <a onclick="moveDownSelectedOption('selectedList')" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_down' )"/></a>        
-        </td> 
-            
-      </tr>
-
-    </tbody>
-  </table>
-  
+
+#jqSelected({
+   "prefix": "co",
+   "i18n_available": "available_category_options",
+   "i18n_selected": "selected_category_options",
+   "objects": $dataElementCategory.categoryOptions
+ })
+
   <p>
     <input type="submit" value="$i18n.getString( 'save' )" style="width:100px"/>
     <input type="button" onclick="dhis2.commons.redirectCurrentPage( 'category.action' )" value="$i18n.getString( 'cancel' )" style="width:100px"/></p>