Skip to content

Commit

Permalink
Add search button to Concept search -TRUNK-3836
Browse files Browse the repository at this point in the history
TRUNK-3836: Improvements on first fix

TRUNK-3836: Further improvement on fix

TRUNK-3836: Avoid double search
  • Loading branch information
bhashitha authored and wluyima committed Mar 21, 2013
1 parent a9586d5 commit e60d95e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
3 changes: 2 additions & 1 deletion webapp/src/main/webapp/WEB-INF/view/dictionary/index.jsp
Expand Up @@ -24,7 +24,8 @@
columnVisibility: [true, false],
searchPhrase:'<request:parameter name="phrase"/>',
showIncludeVerbose: true,
verboseHandler: doGetVerbose
verboseHandler: doGetVerbose,
showSearchButton: true
});
});
Expand Down
Expand Up @@ -103,6 +103,7 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler,
* doSearchWhenEmpty: If it is set to true, it lists all items initially and filters them with the given search phrase. (default:false)
* verboseHandler: function to be called to return the text to display as verbose output
* attributes: Array of names for attributes types to display in the list of results
* showSearchButton: Boolean, indicating whether to use search button for immediate search
*
* The styling on this table works like this:
* <pre>
Expand Down Expand Up @@ -192,6 +193,7 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler,
minCharErrorObj.html(omsgs.minCharRequired.replace("_REQUIRED_NUMBER_", o.minLength));
notification = div.find("#searchWidgetNotification");
loadingMsgObj = div.find("#loadingMsg");
showSearchButton = o.showSearchButton ? true : false;

this._div = div;

Expand All @@ -201,6 +203,21 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler,
if(o.displayLength < 3)
o.displayLength = 3;

// If need search button
if (showSearchButton) {
input.after("<input type='button' id='searchButton' name='searchButton' value='" + omsgs.searchLabel + "' />");
$j('#searchButton').click(function() {
if ($j.trim(input.val()) != '' || self.options.doSearchWhenEmpty) {
//if there is any delay in progress, cancel it
if(self._searchDelayTimer != null) {
window.clearTimeout(self._searchDelayTimer);
}
self._doSearch($j.trim(input.val()));
input.focus();
}
});
}

if(o.showIncludeVoided) {
var tmp = div.find("#includeVoided");
tmp.after("<label for='includeVoided'>" + o.includeVoidedLabel + "</label>");
Expand Down Expand Up @@ -250,11 +267,17 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler,
//LEFT(37), UP(38), RIGHT(39), DOWN(40), ENTER(13), HOME(36), END(35), PAGE UP(33), PAGE DOWN(34)
var kc = event.keyCode;
if(((kc >= 33) && (kc <= 40)) || (kc == 13)) {
if(!(self._div.find(".openmrsSearchDiv").css("display") != 'none')) {
if(!(self._div.find(".openmrsSearchDiv").css("display") != 'none') && ($j.trim(input.val()) == '')) {
return true;
}
if(kc == 13)
if(kc == 13) {
//if there is any delay in progress, cancel it
if(self._searchDelayTimer != null) {
window.clearTimeout(self._searchDelayTimer);
}
self._doKeyEnter();
}

//kill the event
event.stopPropagation();

Expand Down Expand Up @@ -885,15 +908,22 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler,
},

_doKeyEnter: function() {

var selectedRowIndex = null;
if(this.hoverRowSelection != null) {
selectedRowIndex = this.hoverRowSelection;
}else if(this.curRowSelection != null){
selectedRowIndex = this.curRowSelection;
}

if(selectedRowIndex != null)
if(selectedRowIndex != null) {
this._doSelected(selectedRowIndex, this._results[selectedRowIndex]);
} else if (showSearchButton) {
if (($j.trim($j('#inputNode').val()) != '') || self.options.doSearchWhenEmpty) {
this._doSearch($j.trim($j('#inputNode').val()));
}
}

},

_doSelected: function(position, rowData) {
Expand Down
Expand Up @@ -21,6 +21,7 @@ omsgs.gender="<openmrs:message code="Person.gender" javaScriptEscape="true"/>";
omsgs.genderRequired="<openmrs:message code='Person.gender.required'/>";
omsgs.givenName="<openmrs:message code="PersonName.givenName" javaScriptEscape="true"/>";
omsgs.identifier="<openmrs:message code="Patient.identifier" javaScriptEscape="true"/>";
omsgs.searchLabel="<openmrs:message code="general.search" javaScriptEscape="true"/>";
omsgs.includeDisabled="<openmrs:message code="SearchResults.includeDisabled" javaScriptEscape="true"/>";
omsgs.includeRetired="<openmrs:message code="SearchResults.includeRetired" javaScriptEscape="true"/>";
omsgs.includeVoided="<openmrs:message code="SearchResults.includeVoided" javaScriptEscape="true"/>";
Expand Down

0 comments on commit e60d95e

Please sign in to comment.