← Back to team overview

dhis2-devs team mailing list archive

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

 

------------------------------------------------------------
revno: 16830
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-09-26 18:31:48 +0700
message:
  use new available/selected plugin in teag mgmt
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/AddAttributeGroupAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/UpdateAttributeGroupAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeGroupForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeGroupForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeGroupForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteGroupForm.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-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/AddAttributeGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/AddAttributeGroupAction.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/AddAttributeGroupAction.java	2014-09-26 11:31:48 +0000
@@ -28,15 +28,14 @@
  * 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.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
 
-import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author Chau Thu Tran
@@ -71,8 +70,6 @@
 
     private String description;
 
-    private String[] selectedAttributes;
-
     // -------------------------------------------------------------------------
     // Getters && Setters
     // -------------------------------------------------------------------------
@@ -87,9 +84,11 @@
         this.name = name;
     }
 
-    public void setSelectedAttributes( String[] selectedAttributes )
+    private List<String> teaSelected = new ArrayList<>();
+
+    public void setTeaSelected( List<String> teaSelected )
     {
-        this.selectedAttributes = selectedAttributes;
+        this.teaSelected = teaSelected;
     }
 
     // -------------------------------------------------------------------------
@@ -105,12 +104,12 @@
         attributeGroup.setDescription( description );
 
         List<TrackedEntityAttribute> attributes = new ArrayList<>();
-        for ( String attributeId : selectedAttributes )
+
+        for ( String attributeId : teaSelected )
         {
-            TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( Integer
-                .parseInt( attributeId ) );
-            attributes.add( attribute );
+            attributes.add( attributeService.getTrackedEntityAttribute( attributeId ) );
         }
+
         attributeGroup.setAttributes( attributes );
 
         attributeGroupService.addTrackedEntityAttributeGroup( attributeGroup );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/UpdateAttributeGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/UpdateAttributeGroupAction.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/UpdateAttributeGroupAction.java	2014-09-26 11:31:48 +0000
@@ -28,15 +28,14 @@
  * 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.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
 
-import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author Chau Thu Tran
@@ -73,8 +72,6 @@
 
     private String description;
 
-    private String[] selectedAttributes;
-
     // -------------------------------------------------------------------------
     // Getters && Setters
     // -------------------------------------------------------------------------
@@ -94,9 +91,11 @@
         this.description = description;
     }
 
-    public void setSelectedAttributes( String[] selectedAttributes )
+    private List<String> teaSelected = new ArrayList<>();
+
+    public void setTeaSelected( List<String> teaSelected )
     {
-        this.selectedAttributes = selectedAttributes;
+        this.teaSelected = teaSelected;
     }
 
     // -------------------------------------------------------------------------
@@ -112,14 +111,12 @@
         attributeGroup.setDescription( description );
 
         List<TrackedEntityAttribute> attributes = new ArrayList<>();
-        
-        for ( String attributeId : selectedAttributes )
+
+        for ( String attributeId : teaSelected )
         {
-            TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( Integer
-                .parseInt( attributeId ) );
-            attributes.add( attribute );
+            attributes.add( attributeService.getTrackedEntityAttribute( attributeId ) );
         }
-        
+
         attributeGroup.setAttributes( attributes );
 
         attributeGroupService.updateTrackedEntityAttributeGroup( attributeGroup );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeGroupForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeGroupForm.vm	2014-08-06 15:20:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeGroupForm.vm	2014-09-26 11:31:48 +0000
@@ -21,6 +21,12 @@
 	</tr>
 </table>
 
+#jqSelected({
+  "prefix": "tea",
+  "i18n_available": "availableAttribute",
+  "i18n_selected": "selectedAttribute"
+})
+
 <table>
 	<colgroup>
 		<col style='width:500px'/>
@@ -28,31 +34,6 @@
 		<col style='width:500px'/>
 	</colgroup>
 	<tr>
-		<th>$i18n.getString( "availableAttribute" )</th>
-		<th>$i18n.getString( "filter" )</th>
-		<td class='class-th'>$i18n.getString( "selectedAttribute" )<input type="hidden" id="attributeList" name="attributeList" />
-		</td>
-	</tr>
-	
-	<tr>
-		<td>
-			<select style="height: 200px; width: 100%;" multiple="multiple" id="availableAttributes" name="availableAttributes" ></select>
-		</td>
-		<td>
-			<input type="button" value="&gt;" title="$i18n.getString('move_selected')" onclick="dhisAjaxSelect_moveAllSelected( 'availableAttributes', 'selectedAttributes' )" class='filterButton'/><br/>
-			<input type="button" value="&lt;" title="$i18n.getString('remove_selected')" onclick="dhisAjaxSelect_moveAllSelected( 'selectedAttributes', 'availableAttributes' )" class='filterButton'/><br/>
-			<input type="button" value="&gt;&gt;" onclick="moveAllById( 'availableAttributes', 'selectedAttributes' )" class='filterButton' /><br/>
-			<input type="button" value="&lt;&lt;" onclick="moveAllById( 'selectedAttributes', 'availableAttributes' )" class='filterButton' />
-		</td>
-		<td>
-			<select style="height: 200px; width: 100%; margin-top: 22px;" multiple="multiple" id="selectedAttributes" name="selectedAttributes" ></select>
-		</td>
-		<td>
-			<a href="javascript:moveUpSelectedOption( 'selectedAttributes')" title="$i18n.getString( 'move_up' )"><img src="../images/move_up.png" alt="$i18n.getString( 'move_up' )"/></a><br/><br/>
-			<a href="javascript:moveDownSelectedOption( 'selectedAttributes' )" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" alt="$i18n.getString( 'move_up' )"/></a>
-		</td>
-	</tr>  
-	<tr>
 		<td colspan='2'>
 			<input type="submit" value="$i18n.getString( 'add' )" style="width:10em" />
 			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='attributeGroup.action'" style="width:10em" />

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeGroupForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeGroupForm.js	2014-08-06 15:20:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeGroupForm.js	2014-09-26 11:31:48 +0000
@@ -1,33 +1,25 @@
-jQuery(document).ready(	function(){
-		
-		jQuery('name').focus();
-		
-		validation2( 'addAttributeGroupForm', function( form )
-		{
-			form.submit();
-		},{
-			'beforeValidateHandler' : function()
-			{
-				selectAllById('selectedAttributes');
-				if(jQuery("#selectedAttributes option").length > 0 ){
-					setFieldValue('attributeList', 'true');
-				}
-			},
-			'rules' : getValidationRules( "trackedEntityAttributeGroup" )
-		});
-		
-		jQuery("#availableAttributes").dhisAjaxSelect({
-			source: 'getAttributeWithoutGroup.action',
-			iterator: 'attributes',
-			connectedTo: 'selectedAttributes',
-			handler: function(item){
-				var option = jQuery( "<option/>" );
-				option.attr( "value", item.id );
-				option.text( item.name );
-				
-				return option;
-			}
-		});
-		
-		checkValueIsExist( "name", "validateAttributeGroup.action" );
-	});		
\ No newline at end of file
+jQuery(document).ready(function() {
+
+    jQuery('name').focus();
+
+    validation2('addAttributeGroupForm', function( form ) {
+        form.submit();
+    }, {
+        'beforeValidateHandler': function() {
+            $("#teaSelected").find("option").attr("selected", "selected");
+            if( jQuery("#teaSelected option").length > 0 ) {
+                setFieldValue('attributeList', 'true');
+            }
+        },
+        'rules': getValidationRules("trackedEntityAttributeGroup")
+    });
+
+    $('#teaAvailable').selected({
+        url: '../api/trackedEntityAttributes.json?filter=trackedEntityAttributeGroup:null',
+        target: $('#teaSelected'),
+        search: $('#teaAvailableSearch'),
+        iterator: 'trackedEntityAttributes'
+    });
+
+    checkValueIsExist("name", "validateAttributeGroup.action");
+});
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeGroupForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeGroupForm.js	2014-08-06 15:20:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeGroupForm.js	2014-09-26 11:31:48 +0000
@@ -1,33 +1,24 @@
-jQuery(document).ready(	function() {
-	
-	jQuery('name').focus();
-
-	validation2( 'updateAttributeGroupForm', function( form )
-		{
-			form.submit();
-		},{
-			'beforeValidateHandler' : function()
-			{
-				selectAllById('selectedAttributes');
-				if(jQuery("#selectedAttributes option").length > 0 ){
-					setFieldValue('attributeList', 'true');
-				}
-			},
-			'rules' : getValidationRules( "trackedEntityAttributeGroup" )
-		});
-		
-	checkValueIsExist( "name", "validateAttributeGroup.action", {id:getFieldValue('id')});
-	
-	jQuery("#availableAttributes").dhisAjaxSelect({
-		source: 'getAttributeWithoutGroup.action',
-		iterator: 'attributes',
-		connectedTo: 'selectedAttributes',
-		handler: function(item){
-			var option = jQuery( "<option/>" );
-			option.attr( "value", item.id );
-			option.text( item.name );
-			
-			return option;
-		}
-	});
-});		
\ No newline at end of file
+jQuery(document).ready(function() {
+    jQuery('name').focus();
+
+    validation2('updateAttributeGroupForm', function( form ) {
+        form.submit();
+    }, {
+        'beforeValidateHandler': function() {
+            $("#teaSelected").find("option").attr("selected", "selected");
+            if( jQuery("#teaSelected option").length > 0 ) {
+                setFieldValue('attributeList', 'true');
+            }
+        },
+        'rules': getValidationRules("trackedEntityAttributeGroup")
+    });
+
+    checkValueIsExist("name", "validateAttributeGroup.action", {id: getFieldValue('id')});
+
+    $('#teaAvailable').selected({
+        url: '../api/trackedEntityAttributes.json?filter=trackedEntityAttributeGroup:null',
+        target: $('#teaSelected'),
+        search: $('#teaAvailableSearch'),
+        iterator: 'trackedEntityAttributes'
+    });
+});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteGroupForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteGroupForm.vm	2014-08-06 15:20:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteGroupForm.vm	2014-09-26 11:31:48 +0000
@@ -24,6 +24,13 @@
 	</tr>
 </table>
 
+#jqSelected({
+  "prefix": "tea",
+  "i18n_available": "availableAttribute",
+  "i18n_selected": "selectedAttribute",
+  "objects": $attributeGroup.attributes
+})
+
 <table>
 	<colgroup>
 		<col style='width:500px'/>
@@ -31,44 +38,11 @@
 		<col style='width:500px'/>
 	</colgroup>
 	<tr>
-		<th>$i18n.getString( "availableAttribute" )</th>
-		<th>$i18n.getString( "filter" )</th>
-		<td class='class-th'>$i18n.getString( "selectedAttribute" )
-			<input type='hidden' id='attributeList' name='attributeList' >
-		</td>
-	</tr>
-	
-	<tr>
-		<td>
-			<select style="height: 200px; width: 100%;" multiple id="availableAttributes" name="availableAttributes" size="15"></select>
-		</td>
-		<td>
-			<input type="button" value="&gt;" title="$i18n.getString('move_selected')" onclick="dhisAjaxSelect_moveAllSelected( 'availableAttributes', 'selectedAttributes' )" class='filterButton'/><br/>
-			<input type="button" value="&lt;" title="$i18n.getString('remove_selected')" onclick="dhisAjaxSelect_moveAllSelected( 'selectedAttributes', 'availableAttributes' )" class='filterButton'/><br/>
-			<input type="button" value="&gt;&gt;" onclick="moveAllById( 'availableAttributes', 'selectedAttributes' )" class='filterButton' /><br/>
-			<input type="button" value="&lt;&lt;" onclick="moveAllById( 'selectedAttributes', 'availableAttributes' )" class='filterButton' />
-		</td>
-		<td>
-			<select style="height: 200px; width: 100%; margin-top: 22px;" multiple id="selectedAttributes" name="selectedAttributes" size="15">
-			#foreach($attribute in $attributeGroup.attributes)
-			#if($!attribute)
-				<option value='$attribute.id'>$attribute.name</option>
-			#end
-			#end
-			</select>
-		</td>
-		<td>
-			<a href="javascript:moveUpSelectedOption( 'selectedAttributes')" title="$i18n.getString( 'move_up' )"><img src="../images/move_up.png" alt="$i18n.getString( 'move_up' )"/></a><br/><br/>
-			<a href="javascript:moveDownSelectedOption( 'selectedAttributes' )" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" alt="$i18n.getString( 'move_up' )"/></a>
-		</td>
-	</tr>  
-
-	<tr>
 		<td colspan='2'>
 			<input type="submit" value="$i18n.getString( 'update' )" style="width:10em" />
 			<input type="button" value="$i18n.getString( 'cancel' )" style="width:10em" onclick="window.location.href='attributeGroup.action'" />
 		</td>
 	</tr>
-</table> 
+</table>
 
 </form>