← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14653: Fixed bug - Cannot create a new tracked entity attribute.

 

------------------------------------------------------------
revno: 14653
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-04-04 18:49:44 +0700
message:
  Fixed bug - Cannot create a new tracked entity attribute.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.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/webapp/dhis-web-maintenance-program/addAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm	2014-04-03 08:06:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm	2014-04-04 11:49:44 +0000
@@ -4,7 +4,7 @@
 
 #sharingCreateNotification( "trackedEntityAttribute" )
 
-<form id="addAttributeForm" action="addAttribute.action" method="post" class="inputForm">
+<form id="addAttributeForm" name="addAttributeForm" action="addAttribute.action" method="post" class="inputForm">
 
 <table id="attrTable"> 
 	<thead>
@@ -67,35 +67,53 @@
                 <option value="age">$i18n.getString( "age" )</option>
                 <option value="users">$i18n.getString( "users" )</option>
                 <option value="combo">$i18n.getString( "attribute_combo_type" )</option>
+				<option value="localId">$i18n.getString( "local_identifier" )</option>
             </select>
         </td>
         <td></td>
     </tr>  
 	<tr id="optionSetRow" class="hidden"> 
 		<td><label>$i18n.getString( "option_set" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-		<td><select id="optionSetId" name="optionSetId" class="{validate:{required:true}}">
+		<td><select id="optionSetId" name="optionSetId" class="{validate:{required:true}}" disabled>
 				#foreach($optionSet in $optionSets)
 					<option value="$optionSet.id">$optionSet.name</option>
 				#end
 			</select>
 		</td>
 	</tr>
-
+	
 	<tr name='localIdField' style='display:none;'>
-        <th colspan='2'><label for="type">$i18n.getString( "scope" )</label></th>
-    </tr>
+			<th colspan='2'><label for="type">$i18n.getString( "scope" )</label></th>
+		</tr>
 			
-    <tr name='localIdField' style='display:none;'>
-        <td><label for="type">$i18n.getString( "orgunit" )</label></td>
-        <td><input type='checkbox' id="orgunitScope" name="orgunitScope" value='true' ></td>
-        <td></td>
-    </tr>
-		
-    <tr name='localIdField' style='display:none;'>
-        <td><label for="type">$i18n.getString( "program" )</label></td>
-        <td><input type='checkbox' id="programScope" name="programScope" value='true' ></td>
-        <td></td>
-    </tr>
+		<tr name='localIdField' style='display:none;'>
+			<td><label for="type">$i18n.getString( "orgunit" )</label></td>
+			<td>
+				<input type='checkbox' id="orgunitScope" name="orgunitScope" value='true' >
+			</td>
+			<td></td>
+		</tr>
+		
+		<tr name='localIdField' style='display:none;'>
+			<td><label for="type">$i18n.getString( "program" )</label></td>
+			<td>
+				<input type='checkbox' id="programScope" name="programScope" value='true' >
+			</td>
+			<td></td>
+		</tr>
+		
+		<tr name='localIdField' style='display:none;'>
+			<td><label for="type">$i18n.getString( "period_type" )</label></td>
+			<td>
+				<select type='checkbox' id="periodTypeName" name="periodTypeName" >
+					<option value="">[$i18n.getString( "please_select" )]</option>
+					#foreach ( $periodType in $periodTypes )
+					<option value="$periodType.name">$i18n.getString( $periodType.name )</option>
+					#end
+				</select>
+			</td>
+			<td></td>
+		</tr>
 
     </tbody>
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js	2014-04-03 08:06:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js	2014-04-04 11:49:44 +0000
@@ -1,13 +1,9 @@
-$(document).ready(	function(){
+jQuery(document).ready(	function(){
 	validation( 'addAttributeForm', function(form){
 		form.submit();
-	});
+	})
 
 	checkValueIsExist( "name", "validateAttribute.action");
 	checkValueIsExist( "shortName", "validateAttribute.action");
 	checkValueIsExist( "code", "validateAttribute.action");
-
-  $('#unique').on('click', function() {
-    $("[name='localIdField']").toggle();
-  });
-});
+});	
\ 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/attribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js	2014-04-03 08:06:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js	2014-04-04 11:49:44 +0000
@@ -1,3 +1,4 @@
+
 $(function() {
   dhis2.contextmenu.makeContextMenu({
     menuId: 'contextMenu',
@@ -14,59 +15,66 @@
 }
 
 function showAttributeDetails( context ) {
-  jQuery.getJSON('getAttribute.action', { id: context.id },
-      function( json ) {
-        setInnerHTML('nameField', json.attribute.name);
-        setInnerHTML('descriptionField', json.attribute.description);
-        setInnerHTML('optionSetField', json.attribute.optionSet);
-
-        var unique = ( json.attribute.unique == 'true') ? i18n_yes : i18n_no;
-        setInnerHTML('uniqueField', unique);
-
-        var inherit = ( json.attribute.inherit == 'true') ? i18n_yes : i18n_no;
-        setInnerHTML('inheritField', inherit);
-
-        var valueType = json.attribute.valueType;
-        var typeMap = attributeTypeMap();
-        setInnerHTML('valueTypeField', typeMap[valueType]);
-
-        showDetails();
-      });
+	jQuery.getJSON( 'getAttribute.action', { id: context.id },
+		function ( json ) {
+			setInnerHTML( 'nameField', json.attribute.name );	
+			setInnerHTML( 'descriptionField', json.attribute.description );
+			setInnerHTML( 'optionSetField', json.attribute.optionSet );
+			
+			var unique = ( json.attribute.unique == 'true') ? i18n_yes : i18n_no;
+			setInnerHTML( 'uniqueField', unique );
+			
+			var inherit = ( json.attribute.inherit == 'true') ? i18n_yes : i18n_no;
+			setInnerHTML( 'inheritField', inherit );
+			
+			var valueType = json.attribute.valueType;
+			var typeMap = attributeTypeMap();
+			setInnerHTML( 'valueTypeField', typeMap[valueType] );    
+			
+			showDetails();
+	});
 }
 
-function attributeTypeMap() {
-  var typeMap = [];
-  typeMap['number'] = i18n_number;
-  typeMap['string'] = i18n_text;
-  typeMap['bool'] = i18n_yes_no;
-  typeMap['trueOnly'] = i18n_yes_only;
-  typeMap['date'] = i18n_date;
-  typeMap['phoneNumber'] = i18n_phone_number;
-  typeMap['trackerAssociate'] = i18n_tracker_associate;
-  typeMap['combo'] = i18n_attribute_combo_type;
-  return typeMap;
+function attributeTypeMap()
+{
+	var typeMap = [];
+	typeMap['number'] = i18n_number;
+	typeMap['string'] = i18n_text;
+	typeMap['bool'] = i18n_yes_no;
+	typeMap['trueOnly'] = i18n_yes_only;
+	typeMap['date'] = i18n_date;
+	typeMap['phoneNumber'] = i18n_phone_number;
+	typeMap['trackerAssociate'] = i18n_tracker_associate;
+	typeMap['combo'] = i18n_attribute_combo_type;
+	return typeMap;
 }
 
 // -----------------------------------------------------------------------------
 // Remove Attribute
 // -----------------------------------------------------------------------------
 
-function removeAttribute( context ) {
-  removeItem(context.id, context.name, i18n_confirm_delete, 'removeAttribute.action');
+function removeAttribute( context )
+{
+	removeItem( context.id, context.name, i18n_confirm_delete, 'removeAttribute.action' );
 }
 
+
 function typeOnChange() {
-  var type = getFieldValue('valueType');
-  if( type == "combo" ) {
-    showById("optionSetRow");
-    jQuery('[name=localIdField]').hide();
-  }
-  else if( type == 'localId' ) {
-    jQuery('[name=localIdField]').show();
-    hideById("optionSetRow");
-  }
-  else {
-    jQuery('[name=localIdField]').hide();
-    hideById("optionSetRow");
-  }
+	var type = getFieldValue('valueType');
+	if( type=="combo"){
+		showById("optionSetRow");
+		enable("optionSetId");
+		jQuery('[name=localIdField]').hide();
+	}
+	else if( type == 'localId' ) {
+		jQuery('[name=localIdField]').show();
+		hideById("optionSetRow");
+		disable("optionSetId");
+	}
+	else {
+		jQuery('[name=localIdField]').hide();
+		hideById("optionSetRow");
+		disable("optionSetId");
+	}
 }
+

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js	2014-04-03 08:06:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js	2014-04-04 11:49:44 +0000
@@ -1,17 +1,9 @@
-jQuery(document).ready(function() {
-  validation('updateAttributeForm', function( form ) {
-    form.submit();
-  });
-
-  checkValueIsExist("name", "validateAttribute.action", {id: getFieldValue('id')});
-  checkValueIsExist("shortName", "validateAttribute.action", {id: getFieldValue('id')});
-  checkValueIsExist("code", "validateAttribute.action", {id: getFieldValue('id')});
-
-  if( $('#unique').is(':checked') ) {
-    $("[name='localIdField']").show();
-  }
-
-  $('#unique').on('click', function() {
-    $("[name='localIdField']").toggle();
-  });
-});
+jQuery(document).ready(	function(){
+	validation( 'updateAttributeForm', function(form){
+		form.submit();
+	});
+	
+	checkValueIsExist( "name", "validateAttribute.action", {id:getFieldValue('id')});
+	checkValueIsExist( "shortName", "validateAttribute.action", {id:getFieldValue('id')});
+	checkValueIsExist( "code", "validateAttribute.action", {id:getFieldValue('id')});
+});		
\ 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/updateAttibuteForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm	2014-04-03 08:06:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm	2014-04-04 11:49:44 +0000
@@ -63,6 +63,7 @@
 				<option value="age" #if( $attribute.valueType == 'age' ) selected="selected" #end>$i18n.getString( "age" )</option>
 				<option value="users" #if( $attribute.valueType == 'users' ) selected="selected" #end>$i18n.getString( "users" )</option>
 				<option value="combo" #if( $attribute.valueType == 'combo' ) selected="selected" #end>$i18n.getString( "attribute_combo_type" )</option>
+				<option value="localId" #if( $attribute.valueType == 'localId' ) selected="selected" #end>$i18n.getString( "local_identifier" )</option>
             </select>
         </td>
     </tr>
@@ -77,9 +78,6 @@
 		</td>
 	</tr>
 
-programScope: $attribute.programScope
-orgunitScope: $attribute.orgunitScope
-
 	<tr name='localIdField' #if($attribute.valueType!='localId' ) style='display:none;' #end >
 		<th colspan='2'><label for="type">$i18n.getString( "scope" )</label></th>
 	</tr>
@@ -91,7 +89,7 @@
 		</td>
 		<td></td>
 	</tr>
-
+	
 	<tr name='localIdField' #if($attribute.valueType!='localId' ) style='display:none;' #end>
 		<td><label for="type">$i18n.getString( "program" )</label></td>
 		<td>
@@ -99,7 +97,20 @@
 		</td>
 		<td></td>
 	</tr>
-
+	
+	<tr name='localIdField' #if($attribute.valueType!='localId' ) style='display:none;' #end>
+		<td><label for="type">$i18n.getString( "period_type" )</label></td>
+		<td>
+			<select type='checkbox' id="periodTypeName" name="periodTypeName" >
+				<option value="">[$i18n.getString( "please_select" )]</option>
+				#foreach ( $periodType in $periodTypes )
+				<option value="$periodType.name" #if( $attribute.periodType.name==$periodType.name ) selected #end>$i18n.getString( $periodType.name )</option>
+				#end
+			</select>
+		</td>
+		<td></td>
+	</tr>
+		
     </tbody>
 	
 	<tr>