Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f9e94c3c1cf7
Choose a base ref
...
head repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fa44f20d43a1
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Apr 17, 2013

  1. Copy the full SHA
    62cfdd2 View commit details

Commits on May 1, 2013

  1. Merge pull request #277 from bhashitha/TRUNK-3943

    TRUNK-3943: Add support for back button in concept search page
    dkayiwa committed May 1, 2013

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fa44f20 View commit details
Showing with 41 additions and 1 deletion.
  1. +25 −1 webapp/src/main/webapp/WEB-INF/view/dictionary/index.jsp
  2. +16 −0 webapp/src/main/webapp/WEB-INF/view/scripts/jquery-ui/js/openmrsSearch.js
26 changes: 25 additions & 1 deletion webapp/src/main/webapp/WEB-INF/view/dictionary/index.jsp
Original file line number Diff line number Diff line change
@@ -14,6 +14,12 @@

<script type="text/javascript">
var lastSearch;
// Get relevant parameter value, in current URL
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20')) || null;
}
$j(document).ready(function() {
new OpenmrsSearch("findConcept", true, doConceptSearch, doSelectionHandler,
[{fieldName:"name", header:" "}, {fieldName:"preferredName", header:" "}],
@@ -25,11 +31,29 @@
searchPhrase:'<request:parameter name="phrase"/>',
showIncludeVerbose: true,
verboseHandler: doGetVerbose,
showSearchButton: true
showSearchButton: true,
lastSearchParams : getURLParameter('lastSearchText')
? {
'lastSearchText' : getURLParameter('lastSearchText'),
'includeVoided' : getURLParameter('includeVoided'),
'includeVerbose' : getURLParameter('includeVerbose')
}
: null
});
});
function doSelectionHandler(index, data) {
// Check the browser compatibility and, add an entry to history
if (window.history.pushState) {
window.history.pushState(
{}, "",
document.location.pathname + "?lastSearchText=" + document.getElementById('inputNode').value
+ "&includeVoided=" + ($j('#includeVoided').is(':checked') ? 1 : 0)
+ "&includeVerbose=" + ($j('#includeVerbose').is(':checked') ? 1 : 0)
);
}
document.location = "concept.htm?conceptId=" + data.conceptId;
}
Original file line number Diff line number Diff line change
@@ -104,6 +104,7 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler,
* 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
* lastSearchParams: An object with last search parameters, to support preserve data for browser back button
*
* The styling on this table works like this:
* <pre>
@@ -194,6 +195,7 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler,
notification = div.find("#searchWidgetNotification");
loadingMsgObj = div.find("#loadingMsg");
showSearchButton = o.showSearchButton ? true : false;
lastSearchParams = (o.lastSearchParams !== null) ? o.lastSearchParams : null;

this._div = div;

@@ -546,6 +548,20 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler,
}
});

// Browser back button support, for preserve data
if (lastSearchParams !== null) {
$j('#inputNode').val(lastSearchParams.lastSearchText);
if (lastSearchParams.includeVoided == 1) {
$j('#includeVoided').attr('checked','checked');
}
if (lastSearchParams.includeVerbose == 1) {
$j('#includeVerbose').attr('checked','checked');
}
var keyEvent = jQuery.Event("keyup");
keyEvent.keyCode = 13;
$j("#inputNode").trigger(keyEvent);
}

//register an onchange event handler for the length dropdown so that we don't lose
//the row highlight when the user makes changes to the length
var selectElement = document.getElementById('openmrsSearchTable_length').getElementsByTagName('select')[0];