← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8964: Change ui of search function in patient module.

 

------------------------------------------------------------
revno: 8964
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-11-09 21:20:40 +0700
message:
  Change ui of search function in patient module.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.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-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2012-11-09 06:08:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm	2012-11-09 14:20:40 +0000
@@ -69,19 +69,30 @@
 			<col/>
 			<col/>
 			<col width="180"/>
+			<tr class="hidden">
+				<td id='searchingAttributeIdTD'>
+					<select id="searchObjectId" name="searchObjectId" onchange='dataElementOnChange(this);'></select>
+				</td>
+			</tr>
 			<tbody id='advancedSearchTB'>
+				<tr><td></td></tr>
+				<tr>
+					<td></td>
+					<td></td>
+					<td rowspan='30' valign='bottom'>
+						<input type="button" class='large-button' id='addSearchOptionBtn' name='addSearchOptionBtn' value="$i18n.getString('add')" onclick='addAttributeOption()'>
+					</td>
+					<td rowspan='30' valign='bottom' align='right'>
+						<input type="button" class='large-button' id='addSearchOptionBtn' name='addSearchOptionBtn' value="$i18n.getString('clear_all')" onclick='removeAllOption()'>
+					</td>
+				</tr>
 				<tr id='advSearchBox0'>	
-					<td id='searchingAttributeIdTD'>
+					<td>
 						<select id="searchObjectId" name="searchObjectId" onchange='dataElementOnChange(this);'></select>
 					</td>		
-					<td style="padding-right:5px;">
+					<td>
 						<input type="text" id="searchText" name="searchText" value="$!searchText">
-					</td>
-					<td rowspan='30' valign='bottom' style="padding-bottom:5px">
-						<input type="button" class='tiny-button' id='addSearchOptionBtn' name='addSearchOptionBtn' value="+" onclick='addAttributeOption()'>
-					</td>
-					<td rowspan='30' valign='bottom' align='right' style="padding-bottom:5px">
-						<input type="button" class='large-button' id='addSearchOptionBtn' name='addSearchOptionBtn' value="$i18n.getString('clear_all')" onclick='removeAllOption()'>
+						<input type="button" class='large-button' name="clearSearchBtn" value='$i18n.getString( "clear" )' onclick="removeAttributeOption('advSearchBox0');" disabled>
 					</td>
 				</tr>
 			</tbody>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2012-11-09 06:08:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2012-11-09 14:20:40 +0000
@@ -4,10 +4,12 @@
 	hideById('dataEntryInfor');
 	hideById('listDiv');
 	showById('mainLinkLbl');
+	setFieldValue("filter", false);
 	jQuery.getJSON( "anonymousPrograms.action",{}, 
 		function( json )
 		{   
-			clearListById('searchObjectId');
+			jQuery('#searchingAttributeIdTD [id=searchObjectId] option').remove();
+			jQuery('#advancedSearchTB [id=searchObjectId] option').remove();
 			clearListById('displayInReports');
 			clearListById('programId');
 			
@@ -53,7 +55,8 @@
 {
 	hideById('dataEntryInfor');
 	hideById('listDiv');
-	clearListById('searchObjectId');
+	jQuery('#searchingAttributeIdTD [id=searchObjectId] option').remove();
+	jQuery('#advancedSearchTB [id=searchObjectId] option').remove();
 	programStageId = jQuery('#programId option:selected').attr('psid');
 	setFieldValue('programStageId', programStageId );
 	setInnerHTML('reportDateDescriptionField', jQuery('#programId option:selected').attr('reportDateDes'));
@@ -83,7 +86,7 @@
 			
 			jQuery( '#searchObjectId').append( '<option value="" >[' + i18n_please_select + ']</option>' );
 			for ( i in json.programStageDataElements ) {
-				jQuery( '#searchObjectId').append( '<option value="' + json.programStageDataElements[i].id + '" type="' + json.programStageDataElements[i].type +'">' + json.programStageDataElements[i].name + '</option>' );
+				jQuery( '[id=searchObjectId]').append( '<option value="' + json.programStageDataElements[i].id + '" type="' + json.programStageDataElements[i].type +'">' + json.programStageDataElements[i].name + '</option>' );
 				
 				if( json.programStageDataElements[i].displayInReports=='true' ){
 					jQuery( '#displayInReports').append( '<option value="' + json.programStageDataElements[i].id + '"></option>');
@@ -256,7 +259,13 @@
 			
 			var searchInfor = (listAll) ? i18n_list_all_events : i18n_search_events_by_dataelements;
 			setInnerHTML( 'searchInforTD', searchInfor);
-			
+	
+			if(getFieldValue('filter')=='true')
+			{
+				showById('minimized-advanced-search');
+				hideById('advanced-search');
+			}
+	
 			showById('listDiv');
 			hideById('loaderDiv');
 		}
@@ -265,11 +274,6 @@
 
 function updateEvents()
 {
-	if(getFieldValue('filter')=='true')
-	{
-		showById('minimized-advanced-search');
-		hideById('advanced-search');
-	}
 	validateSearchEvents( false );
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-10-31 04:09:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-11-09 14:20:40 +0000
@@ -64,10 +64,11 @@
 
 function addAttributeOption()
 {
+	jQuery('#advancedSearchTB [name=clearSearchBtn]').attr('disabled', false);
 	var rowId = 'advSearchBox' + jQuery('#advancedSearchTB select[name=searchObjectId]').length + 1;
 	var contend  = '<td>' + getInnerHTML('searchingAttributeIdTD') + '</td>';
 		contend += '<td>' + searchTextBox ;
-		contend += '&nbsp;<input type="button" class="tiny-button" value="-" onclick="removeAttributeOption(' + "'" + rowId + "'" + ');"></td>';
+		contend += '&nbsp;<input type="button" name="clearSearchBtn" class="large-button" value="' + i18n_clear + '" onclick="removeAttributeOption(' + "'" + rowId + "'" + ');"></td>';
 		contend = '<tr id="' + rowId + '">' + contend + '</tr>';
 
 	jQuery('#advancedSearchTB').append( contend );
@@ -76,6 +77,9 @@
 function removeAttributeOption( rowId )
 {
 	jQuery( '#' + rowId ).remove();
+	if( jQuery( '#advancedSearchTB tr' ).length == 3 ){
+		jQuery('#advancedSearchTB [name=clearSearchBtn]').attr('disabled', true);
+	}	
 }	
 
 //------------------------------------------------------------------------------
@@ -184,7 +188,7 @@
 	
 	if (getFieldValue('searchByProgramStage') == "false" 
 		|| ( getFieldValue('searchByProgramStage') == "true"  
-			&& jQuery( '#advancedSearchTB tr' ).length > 1) ){
+			&& jQuery( '#advancedSearchTB tr' ).length > 2) ){
 		jQuery("#searchDiv :input").each( function( i, item )
 		{
 			var elementName = $(this).attr('name');
@@ -223,34 +227,36 @@
 		var dateOperator = "";
 		var p = "";
 		jQuery( this ).find(':input').each( function( idx, item ){
-			if( idx == 0){
-				p = "&searchTexts=" + item.value;
-				if(item.value=='prg'){
-					programIds += '&programIds=';
-					flag = true;
-				}
-			}
-			else if( item.name == 'dateOperator'){
-				dateOperator = item.value;
-			}
-			else if( item.name == 'searchText'){
-				if( item.value!='')
-				{
-					p += "_";
-					if ( dateOperator.length >0 ) {
-						p += dateOperator + "'" +  item.value.toLowerCase() + "'";
-					}
-					else{
-						p += htmlEncode( item.value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, "") );
-					}
-					
-					if( flag ){
-						programIds += item.value;
-						flag = false;
-					}
-				}
-				else {
-					p = "";
+			if(item.type!="button"){
+				if( idx == 0){
+					p = "&searchTexts=" + item.value;
+					if(item.value=='prg'){
+						programIds += '&programIds=';
+						flag = true;
+					}
+				}
+				else if( item.name == 'dateOperator'){
+					dateOperator = item.value;
+				}
+				else if( item.name == 'searchText'){
+					if( item.value!='')
+					{
+						p += "_";
+						if ( dateOperator.length >0 ) {
+							p += dateOperator + "'" +  item.value.toLowerCase() + "'";
+						}
+						else{
+							p += htmlEncode( item.value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, "") );
+						}
+						
+						if( flag ){
+							programIds += item.value;
+							flag = false;
+						}
+					}
+					else {
+						p = "";
+					}
 				}
 			}
 		});

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2012-11-09 06:08:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2012-11-09 14:20:40 +0000
@@ -61,9 +61,38 @@
 		#else
 			<input type='checkbox' class='hidden' id='searchInAllFacility' name='searchInAllFacility' />
 		#end
+		<tr>
+			<td id='searchingAttributeIdTD' class="hidden">
+			  <select class='search-field' id="searchObjectId" name="searchObjectId" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end onchange="searchObjectOnChange(this)">
+				<option value="iden">$i18n.getString( "search_by_name_identifier" )</option>
+				<option value="prg">$i18n.getString( "search_by_program" )</option>
+				<option value="fixedAttr_birthDate">$i18n.getString( "date_of_birth" )</option>
+				<option value="fixedAttr_age">$i18n.getString( "age_year" )</option>
+				<option value="fixedAttr_gender">$i18n.getString( "gender" )</option>
+				<option value="fixedAttr_phoneNumber">$i18n.getString( "phone_number" )</option>
+				#foreach( $attribute in $patientAttributes )
+					<option value="attr_$attribute.id" valueType='$attribute.valueType'>$encoder.htmlEncode( $attribute.name )</option>
+				#end
+			  </select>
+			  <em title="$i18n.getString( 'required' )" class="required">*</em></label>
+			</td>
+		</tr>
 		<tbody id='advancedSearchTB'>
+			<tr>
+				<td></td>
+				<td></td>
+				<td rowspan='30' valign='bottom'>
+					<input type="button" class='large-button' value='$i18n.getString( "add" )' onclick='addAttributeOption();'>
+				</td>
+				<td rowspan='30' valign='bottom' align="right" >
+					<input type="button" class='large-button' value='$i18n.getString( "search" )' onclick='validateAdvancedSearch();' id='searchPatientBtn'>
+				</td>
+				<td rowspan='30' valign='bottom' align="right" >
+					<input type="button" class='large-button hidden' id='sendSmsToListBtn' value="$i18n.getString('send_message')" onclick="setFieldValue('sendToList', true);showSendSmsForm();" >
+				</td>
+			</tr>
 			<tr id='advSearchBox0'>	       
-				<td id='searchingAttributeIdTD'>
+				<td>
 				  <select class='search-field' id="searchObjectId" name="searchObjectId" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end onchange="searchObjectOnChange(this)">
 					<option value="iden">$i18n.getString( "search_by_name_identifier" )</option>
 					<option value="prg">$i18n.getString( "search_by_program" )</option>
@@ -78,18 +107,14 @@
 				  <em title="$i18n.getString( 'required' )" class="required">*</em></label>
 				</td>		
 				<td>
-					<input type="text" id="searchText" name="searchText" value="$!searchText" onkeyup='searchPatientsOnKeyUp( event );' style='margin-right:25px;'>
-				</td>	
-				<td></td>
-				<td rowspan='30' valign='bottom' style="padding-bottom:5px">
-					<input type="button" class='tiny-button' value='+' onclick='addAttributeOption();'>
-				</td>
-				<td rowspan='30' valign='bottom' style="padding-bottom:5px">
-					<input type="button" class='large-button' value='$i18n.getString( "search" )' onclick='validateAdvancedSearch();' id='searchPatientBtn'>
-				</td rowspan='30' valign='bottom' style="padding-bottom:5px">
-				<td rowspan='30' valign='bottom' style="padding-bottom:5px" style="padding-bottom:5px">
-					<input type="button" class='large-button hidden' id='sendSmsToListBtn' value="$i18n.getString('send_message')" onclick="setFieldValue('sendToList', true);showSendSmsForm();" >
-				</td>
+					<input type="text" id="searchText" name="searchText" value="$!searchText" onkeyup='searchPatientsOnKeyUp( event );'>
+					<input type="button" class='large-button' name="clearSearchBtn" value='$i18n.getString( "clear" )' onclick="removeAttributeOption('advSearchBox0');" disabled>
+				</td>
+			</tr>
+			<tr>
+				<td></td>
+				<td></td>
+				
 			</tr>
 		</tbody>
 	</table>