← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15539: Fixed bug - Display value-field according to the value type of attribute selected in Add/Update V...

 

------------------------------------------------------------
revno: 15539
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-06-03 20:16:32 +0800
message:
  Fixed bug - Display value-field according to the value type of attribute selected in Add/Update Validation Criteria.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addValidationCriteria.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateValidationCriteria.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/validationcriteria.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateValidationCriteria.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/addValidationCriteria.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addValidationCriteria.vm	2014-05-30 08:04:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addValidationCriteria.vm	2014-06-03 12:16:32 +0000
@@ -1,7 +1,4 @@
 <script type="text/javascript" src="javascript/addValidationCriteria.js"></script>																
-<script type="text/javascript">
-	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_tracked_entity_attribute" ) , "'" )';
-</script>
 
 <h3>$i18n.getString( "create_validation_criteria" ) #openHelp( "validation_criteria" )</h3>
 <h5>$program.displayName</h5>
@@ -31,7 +28,7 @@
 							#foreach($option in $programAttribute.attribute.optionSet.options)
 								#set($opt=$opt + ';' + $option )
 							#end 
-						<option value="$programAttribute.attribute.uid" opt="$opt">$programAttribute.attribute.displayName</option>
+							<option valuetype='$programAttribute.attribute.valueType' value="$programAttribute.attribute.uid" opt="$opt">$programAttribute.attribute.displayName</option>
 						#end
 					</select>
 				</td>
@@ -59,3 +56,8 @@
   </table>
 </form>
 
+<script type="text/javascript">
+	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_tracked_entity_attribute" ) , "'" )';
+	var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'" )';
+	var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'" )';
+</script>
\ 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/updateValidationCriteria.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateValidationCriteria.js	2012-03-19 09:35:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateValidationCriteria.js	2014-06-03 12:16:32 +0000
@@ -1,9 +1,7 @@
-jQuery(document).ready(
-	function()
-		{
-			validation( 'validationCriteriaForm', function( form ){			
-				form.submit();
-			});
-	
-		checkValueIsExist( "name", "validateValidationCriteria.action", {id:getFieldValue('id')});
+jQuery(document).ready(function(){
+	validation( 'validationCriteriaForm', function( form ){			
+		form.submit();
+	});
+
+	checkValueIsExist( "name", "validateValidationCriteria.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/javascript/validationcriteria.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/validationcriteria.js	2014-02-28 10:09:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/validationcriteria.js	2014-06-03 12:16:32 +0000
@@ -49,23 +49,52 @@
 // ----------------------------------------------------------------------------------------
 
 function showDivValue() {
-  var value = getFieldValue('value');
-  var property = jQuery('#property option:selected');
-  var propertyName = property.val();
-  if( propertyName != '' && property.attr('opt')!='') {
-	var opts = property.attr('opt').split(";");
-	var selectField = "<select id='value' name='value' class=\"{validate:{required:true}}\" style=\"width:200px;\">";
-	for(var i=1;i<opts.length;i++){
-		selectField += "<option value=\"" + opts[i] + "\" >" + opts[i] + "</option>";
-	}
-	selectField += "</select>";
-	setInnerHTML('valueTD', selectField);
-  }
-  else
-  {
-	var inputField = "<input id='value' name='value' class=\"{validate:{required:true}}\" style=\"width:200px;\"/>";
-  }
-  setFieldValue('value', value);
+	var value = getFieldValue('value');
+	var property = jQuery('#property option:selected');
+	var type = property.attr('valueType');
+	var propertyName = property.val();
+	
+	var valueField = "";
+	 if(type=='bool') {
+		valueField = "<select id='value' name='value' class=\"{validate:{required:true}}\" style=\"width:140px;\">";
+		valueField += "<option value='true' >" + i18n_yes + "</option>";
+		valueField += "<option value='false' >" + i18n_no + "</option>";
+		valueField += "</select>";
+	}
+	else if(type == "trueOnly" ){
+		valueField = "<select id='value' name='value' class=\"{validate:{required:true}}\" style=\"width:140px;\">";
+		valueField += "<option value='true' >" + i18n_yes + "</option>";
+		valueField += "</select>";
+	}
+	else if(type=='date') {
+		valueField = "<input id='value' name='value' class=\"{validate:{required:true}}\" style=\"width:140px;\"/>";
+	}
+	else if(type=='optionSet') {
+		var opts = property.attr('opt').split(";");
+		valueField = "<select id='value' name='value' class=\"{validate:{required:true}}\" style=\"width:140px;\">";
+		for(var i=1;i<opts.length;i++){
+			valueField += "<option value=\"" + opts[i] + "\" >" + opts[i] + "</option>";
+		}
+		valueField += "</select>";
+	}
+	else if( type == "phoneNumber" ){
+		valueField = "<select id='value' name='value' class=\"{validate:{phone:true,required:true}}\" style=\"width:140px;\">";
+	}
+	else if( type == "age" || type == "number" ){
+		valueField = "<input id='value' name='value' class=\"{validate:{number:true,required:true}}\" style=\"width:140px;\"/>";
+	}
+	else if( type == "letter" ){
+		valueField = "<select id='value' name='value' class=\"{validate:{letterswithbasicpunc:true,required:true}}\" style=\"width:140px;\">";
+	}
+	else{
+		valueField = "<input id='value' name='value' class=\"{validate:{required:true}}\" style=\"width:140px;\"/>";
+	}
+	
+	setInnerHTML('valueTD', valueField);
+	setFieldValue('value', value);
+	if(type=='date') {
+		datePickerValid( 'value', false, false );
+	}
 }
 
 function fillValue( value ) {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateValidationCriteria.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateValidationCriteria.vm	2014-05-30 08:04:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateValidationCriteria.vm	2014-06-03 12:16:32 +0000
@@ -32,7 +32,7 @@
 									#foreach($option in $programAttribute.attribute.optionSet.options)
 										#set($opt=$opt + ';' + $option )
 									#end 
-									<option value="$programAttribute.attribute.uid" opt="$opt" #if($validationCriteria.property==$$programAttribute.attribute.uid) #set($attribute = $$programAttribute.attribute) selected #end>$programAttribute.attribute.displayName</option>
+									<option valuetype='$programAttribute.attribute.valueType' value="$programAttribute.attribute.uid" opt="$opt" #if($validationCriteria.property==$$programAttribute.attribute.uid) #set($attribute = $$programAttribute.attribute) selected #end>$programAttribute.attribute.displayName</option>
 								#end
 							</select>
 						</td>
@@ -44,15 +44,7 @@
 							</select>
 						</td>
 						<td id='valueTD'>
-							#if($attribute.optionSet.options)
-								<select id='value' name='value' class="{validate:{required:true}}" style="width:130px">
-									#foreach($option in $attribute.optionSet.options)
-									<option value="$option" #if($validationCriteria.value==$option.name) selected #end>$option</option>
-									#end
-								</select>
-							#else
-								<input type='text' id='value' name='value' class="{validate:{required:true}}" style="width:200px;" value='$validationCriteria.value' />
-							#end
+							<input type='text' id='value' name='value' class="{validate:{required:true}}" style="width:140px;" value='$validationCriteria.value' />
 						</td>
 					</tr>
 				</table>
@@ -67,3 +59,7 @@
 		</tr>
 	</table>
 </form>
+
+<script>
+	showDivValue();
+</script>
\ No newline at end of file