Commit 390b9b64 authored by Maxym Borodenko's avatar Maxym Borodenko

Autocomplete for "Add multiple accessions" fields

parent e6fdbad7
......@@ -34,10 +34,12 @@ import org.genesys2.server.model.json.UserAccessionList;
import org.genesys2.server.service.AccessionListService;
import org.genesys2.server.service.DownloadService;
import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GenesysFilterService;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.impl.FilterHandler;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilter;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilters;
import org.genesys2.server.service.impl.GenesysFilterServiceImpl.LabelValue;
import org.genesys2.server.service.impl.NonUniqueAccessionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
......@@ -79,6 +81,9 @@ public class SelectionController extends BaseController {
@Autowired
private PermissionEvaluator permissionEvaluator;
@Autowired
private GenesysFilterService filterService;
@RequestMapping(value = "/")
public String view(ModelMap model, @RequestParam(value = "page", required = false, defaultValue = "1") int page) {
......@@ -366,4 +371,10 @@ public class SelectionController extends BaseController {
return "redirect:/sel/";
}
@RequestMapping(value = "/autocomplete", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public List<LabelValue<String>> autocomplete(@RequestParam(value = "term", required = true) String ac) {
return filterService.autocomplete(FilterConstants.INSTCODE, ac, new AppliedFilters());
}
}
......@@ -156,7 +156,7 @@
<div class="form-group">
<label for="accessionIds" class="control-label"><spring:message code="selection.add-many.instCode" /></label>
<div class="controls">
<input class="form-control" placeholder="XXX000" name="instCode" />
<input class="form-control autocomplete-input" placeholder="XXX000" name="instCode" />
</div>
</div>
<div class="form-group transparent">
......@@ -251,7 +251,9 @@
}
});
$('body').on('input', '#accessionListTitle', function () {
var body = $('body');
body.on('input', '#accessionListTitle', function () {
var showError = false;
var title = $(this).val();
<c:forEach items="${userAccessionLists}" var="userList">
......@@ -277,6 +279,30 @@
}
}
});
body.on('input', '.autocomplete-input', function () {
var t = $(this);
t.autocomplete({
delay : 2,
minLength : 3,
messages : {
noResults : '',
results : function() {
}
},
source : function(request, response) {
$.get('/sel/autocomplete', {
term : request.term
}, function(data) {
$.each(data, function (i, elem) {
var index = elem.label.indexOf('(');
elem.label = elem.label.substring(0, index);
});
response(data);
});
}
});
});
});
</script>
</content>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment