Skip to content

Commit

Permalink
SAK-31705 Added 'Search Users' facility to ste-info. (sakaiproject#3240)
Browse files Browse the repository at this point in the history
Added Search input and clear search in the chef_site-siteInfo-list.vm.
If search word is in session state then Participant List is filtered for
the search term in each Participant's displayName and displayId.
Corrected the position of search box in the participant's table.

Have added new variable to STATE_SITE_PARTICIPANT_LIST in SiteAction class
to save the original site members list. Search is case insensitive.
  • Loading branch information
ouit0408 authored and buckett committed Sep 16, 2016
1 parent e16f26d commit f373308
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,7 @@ sitegen.roledescription.TeachingAssistant = Can read, add, and revise most cont
##Additional site info
sitegen.siteinfolist.modify = Modification date
sitegen.siteinfolist.usermodify = Modified by
sitegen.siteinfolist.searchUser=Search

useOfficialDescription=Use Official Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,11 @@ public class SiteAction extends PagedResourceActionII {

private static final String STATE_CM_AUTHORIZER_SECTIONS = "site_cm_authorizer_sections";

//list to store participants for a user search in site_info
private static final String STATE_SITE_PARTICIPANT_LIST = "site_participants";

//for user search in site_info page
private static final String SITE_USER_SEARCH = "search_user";
private String cmSubjectCategory;

private boolean warnedNoSubjectCategory = false;
Expand Down Expand Up @@ -1200,6 +1205,8 @@ private void cleanState(SessionState state) {
// lti tools
state.removeAttribute(STATE_LTITOOL_EXISTING_SELECTED_LIST);
state.removeAttribute(STATE_LTITOOL_SELECTED_LIST);
state.removeAttribute(STATE_SITE_PARTICIPANT_LIST);
state.removeAttribute(SITE_USER_SEARCH);

// bjones86 - SAK-24423 - remove joinable site settings from the state
JoinableSiteSettings.removeJoinableSiteSettingsFromState( state );
Expand Down Expand Up @@ -1960,7 +1967,10 @@ else if (state.getAttribute(STATE_CM_REQUESTED_SECTIONS) != null) {
*/
// put the link for downloading participant
putPrintParticipantLinkIntoContext(context, data, site);

context.put("searchString", state.getAttribute(STATE_SEARCH));
//add user search string
context.put("userSearch", state.getAttribute(SITE_USER_SEARCH));
context.put("form_search", FORM_SEARCH);
context.put("userDirectoryService", UserDirectoryService
.getInstance());
try {
Expand Down Expand Up @@ -4713,6 +4723,19 @@ public void doSite_search_clear(RunData data, Context context) {

} // doSite_search_clear

/**
* Handle a Search Clear request.
*/
public void doUser_search_clear(RunData data, Context context) {
SessionState state = ((JetspeedRunData) data)
.getPortletSessionState(((JetspeedRunData) data).getJs_peid());

// clear the search
state.removeAttribute(SITE_USER_SEARCH);
resetPaging(state);

} // doUser_search_clear

/**
*
* @param state
Expand Down Expand Up @@ -4759,6 +4782,24 @@ private boolean coursesIntoContext(SessionState state, Context context,
return (rv || rv2 || rv3);
}

public void doUser_search(RunData data, Context context) {
SessionState state = ((JetspeedRunData) data)
.getPortletSessionState(((JetspeedRunData) data).getJs_peid());

// read the search form field into the state object
String search = StringUtils.trimToNull(Validator.escapeHtml(data.getParameters().getString(FORM_SEARCH)));

// set the flag to go to the prev page on the next list
if (StringUtils.isNotBlank(search)) {
state.removeAttribute(SITE_USER_SEARCH);
} else {
//search item is present, if the result was paged clear the top position from the state
resetPaging(state);
state.setAttribute(SITE_USER_SEARCH, search);
}

} // doUser_search

/**
*
* @param state
Expand Down Expand Up @@ -8424,6 +8465,8 @@ private void init(VelocityPortlet portlet, RunData data, SessionState state) {
public void doNavigate_to_site(RunData data) {
SessionState state = ((JetspeedRunData) data)
.getPortletSessionState(((JetspeedRunData) data).getJs_peid());
//remove search user attribute from the state
state.removeAttribute(SITE_USER_SEARCH);
String siteId = StringUtils.trimToNull(data.getParameters().getString(
"option"));
if (siteId != null) {
Expand Down Expand Up @@ -8689,7 +8732,15 @@ public void doUpdate_participant(RunData data) {
// init variables useful for actual edits and mainainersAfterProposedChanges check
AuthzGroup realmEdit = authzGroupService.getAuthzGroup(realmId);
String maintainRoleString = realmEdit.getMaintainRole();
List participants = collectionToList((Collection) state.getAttribute(STATE_PARTICIPANT_LIST));
List participants;
//Check for search term
String search = (String)state.getAttribute(SITE_USER_SEARCH);
if(StringUtils.isNotBlank(search)) {
//search is true, get the complete list of participants from the other attribute.
participants = collectionToList((Collection) state.getAttribute(STATE_SITE_PARTICIPANT_LIST));
} else {
participants = collectionToList((Collection) state.getAttribute(STATE_PARTICIPANT_LIST));
}

// SAK 23029 Test proposed removals/updates; reject all where activeMainainer count would = 0 if all proposed changes were made
List<Participant> maintainersAfterProposedChanges = testProposedUpdates(participants, params, maintainRoleString);
Expand Down Expand Up @@ -10820,6 +10871,21 @@ private Collection getParticipantList(SessionState state) {
}

Collection participants = SiteParticipantHelper.prepareParticipants(siteId, providerCourseList);
//check for search user attribute in the state
String search = (String)state.getAttribute(SITE_USER_SEARCH);
if(StringUtils.isNotBlank(search) && (participants.size() > 0)) {
for(Object object : participants){
Participant participant = (Participant)object;
//if search term is in the display name or in display Id, add into the list
if (StringUtils.containsIgnoreCase(participant.getDisplayName(), search) || StringUtils.containsIgnoreCase(participant.getDisplayId(),search)) {
members.add(participant);
}
}
state.setAttribute(STATE_PARTICIPANT_LIST, members);
//STATE_PARTICIPANT_LIST will contain members which satisfy search criteria therefore saving original participants list in new attribute
state.setAttribute(STATE_SITE_PARTICIPANT_LIST, participants);
return members;
}
state.setAttribute(STATE_PARTICIPANT_LIST, participants);

return participants;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,20 @@
utils.resizeFrame();
}
});
//catch enter key press for search box
$('#$form_search').keyup(function(event){
if(event.keyCode === 13){
$("#searchUser").click();
}
});
});

//method called to do search for the participant
function doSearch(url){
var searchText = $('#$form_search' ).val();
location = url + "&search=" + searchText;
return true;
}

</script>

Expand Down Expand Up @@ -555,6 +567,14 @@
#end
#end
</a>
<span class="site-searchbox">
<label for="$form_search" class="skip">$tlang.getString('list.search')</label>
<input size="10" value="$validator.escapeHtml($!userSearch)" name="$form_search" id="$form_search" type="text" class="searchField" />
<input type="button" id="searchUser" value="$tlang.getString('sitegen.siteinfolist.searchUser')" onclick="doSearch('#toolLink($action "doUser_search")');" />
#if (($!userSearch) && (!$userSearch.equals("")))
<input type="button" class="button" value="$tlang.getString("list.cls")" onclick="location = '#toolLink($action "doUser_search_clear")';return false;" />
#end
</span>
</th>
#if ($hasProviderSet)
<th id="coursename" scope="col">
Expand Down

0 comments on commit f373308

Please sign in to comment.