NIHVIVO-725, NIHVIVO-629 Autocomplete fixes
This commit is contained in:
parent
9167b3e84a
commit
8eea64d949
3 changed files with 30 additions and 30 deletions
|
@ -89,9 +89,9 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
|
|||
?grant rdfs:label ?grantLabel .
|
||||
</v:jsonset>
|
||||
|
||||
<%-- Must be all one line for JavaScript. --%>
|
||||
<%-- Must be all one line for JavaScript. Must use ?individual since Javascript will look for that property in the data returned. --%>
|
||||
<c:set var="sparqlForAcFilter">
|
||||
PREFIX core: <${vivoCore}> SELECT ?grantURI WHERE {<${subjectUri}> core:hasPrincipalInvestigatorRole ?grantRole .?grantRole core:relatedRole ?grantURI .}
|
||||
PREFIX core: <${vivoCore}> SELECT ?individual WHERE {<${subjectUri}> core:hasPrincipalInvestigatorRole ?grantRole .?grantRole core:relatedRole ?individual .}
|
||||
</c:set>
|
||||
|
||||
<v:jsonset var="grantTypeUriJson">${vivoOnt}#Grant</v:jsonset>
|
||||
|
@ -189,14 +189,7 @@ PREFIX core: <${vivoCore}> SELECT ?grantURI WHERE {<${subjectUri}> core:hasPrinc
|
|||
|
||||
<c:url var="acUrl" value="/autocomplete?stem=true" />
|
||||
<c:url var="sparqlQueryUrl" value="/admin/sparqlquery" />
|
||||
<script>
|
||||
var customFormData = {
|
||||
sparqlForAcFilter: '${sparqlForAcFilter}',
|
||||
sparqlQueryUrl: '${sparqlQueryUrl}',
|
||||
acUrl: '${acUrl}',
|
||||
acType: 'http://vivo.cornel.jdkjfldk#Grant'
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<h2>${formHeading}</h2>
|
||||
|
||||
|
@ -215,4 +208,13 @@ var customFormData = {
|
|||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var customFormData = {
|
||||
sparqlForAcFilter: '${sparqlForAcFilter}',
|
||||
sparqlQueryUrl: '${sparqlQueryUrl}',
|
||||
acUrl: '${acUrl}',
|
||||
acType: '${vivoCore}Grant'
|
||||
}
|
||||
</script>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
|
@ -52,19 +52,14 @@ core:informationResourceInAuthorship (InformationResource : Authorship) - invers
|
|||
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
||||
vreq.setAttribute("subjectUriJson", MiscWebUtils.escape(subjectUri));
|
||||
|
||||
String vivoOnt = "http://vivoweb.org/ontology";
|
||||
String vivoCore = vivoOnt + "/core#";
|
||||
vreq.setAttribute("vivoOnt", vivoOnt);
|
||||
vreq.setAttribute("vivoCore", vivoCore);
|
||||
vreq.setAttribute("vivoCoreJson", MiscWebUtils.escape(vivoCore));
|
||||
|
||||
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
||||
|
||||
String intDatatypeUri = XSD.xint.toString();
|
||||
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
|
||||
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
|
||||
%>
|
||||
|
||||
<c:set var="vivoOnt" value="http://vivoweb.org/ontology" />
|
||||
<c:set var="vivoCore" value="${vivoOnt}/core#" />
|
||||
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
||||
<c:set var="label" value="${rdfs}label" />
|
||||
<c:set var="infoResourceClassUri" value="${vivoCore}InformationResource" />
|
||||
|
@ -107,7 +102,7 @@ SPARQL queries for existing values. --%>
|
|||
?newPub core:informationResourceInAuthorship ?authorshipUri .
|
||||
</v:jsonset>
|
||||
|
||||
<%-- Must be all one line for JavaScript. --%>
|
||||
<%-- Must be all one line for JavaScript. Must use ?individual since Javascript will look for that property in the data returned. --%>
|
||||
<c:set var="sparqlForAcFilter">
|
||||
PREFIX core: <${vivoCore}> SELECT ?individual WHERE {<${subjectUri}> core:authorInAuthorship ?authorshipUri .?authorshipUri core:linkedInformationResource ?individual .}
|
||||
</c:set>
|
||||
|
|
|
@ -27,10 +27,12 @@ var customForm = {
|
|||
|
||||
if (!this.typeSelector) {
|
||||
this.formSteps = 1;
|
||||
// there's also going to be a 3-step form
|
||||
} else {
|
||||
this.formSteps = 2;
|
||||
}
|
||||
|
||||
|
||||
// This is the label element for the field with name 'label'
|
||||
this.labelFieldLabel = $('label[for=' + $('#label').attr('id') + ']');
|
||||
// Get this on page load, so we can prepend to it. We can't just prepend to the current label text,
|
||||
|
@ -100,7 +102,8 @@ var customForm = {
|
|||
var typeVal = $(this).val();
|
||||
// Set the type of individual that the autocomplete will search for.
|
||||
// We do this even if typeVal is empty, to clear out a previous value.
|
||||
customForm.resetAutocomplete(typeVal);
|
||||
//customForm.resetAutocomplete(typeVal);
|
||||
customForm.acType = typeVal;
|
||||
if (typeVal.length) {
|
||||
customForm.labelFieldLabel.html(customForm.getSelectedTypeName() + ' ' + customForm.baseLabelText);
|
||||
customForm.initFormFullView();
|
||||
|
@ -116,7 +119,7 @@ var customForm = {
|
|||
|
||||
this.getAcFilter();
|
||||
this.acCache = {};
|
||||
this.baseAcUrl = customFormData.acUrl;
|
||||
//this.baseAcUrl = customFormData.acUrl;
|
||||
|
||||
this.acSelector.autocomplete({
|
||||
minLength: 3,
|
||||
|
@ -131,7 +134,10 @@ var customForm = {
|
|||
$.ajax({
|
||||
url: customForm.acUrl,
|
||||
dataType: 'json',
|
||||
data: request,
|
||||
data: {
|
||||
term: request.term,
|
||||
type: customForm.acType,
|
||||
},
|
||||
complete: function(xhr, status) {
|
||||
// Not sure why, but we need an explicit json parse here. jQuery
|
||||
// should parse the response text and return a json object.
|
||||
|
@ -152,9 +158,6 @@ var customForm = {
|
|||
},
|
||||
|
||||
getAcFilter: function() {
|
||||
// RY This gets put on the page for now. May want to put into a js file instead.
|
||||
var url = $('.sparqlQueryUrl').attr('id'),
|
||||
filter;
|
||||
|
||||
$.ajax({
|
||||
url: customFormData.sparqlQueryUrl,
|
||||
|
@ -184,13 +187,13 @@ var customForm = {
|
|||
return results;
|
||||
}
|
||||
$.each(results, function() {
|
||||
if (! $.inArray(this.uri, this.acFilter)) {
|
||||
if ($.inArray(this.uri, customForm.acFilter) == -1) {
|
||||
console.log("adding " + this.label + " to filtered results");
|
||||
filteredResults.push(this);
|
||||
}
|
||||
// Debugging
|
||||
// else {
|
||||
// console.log("filtering out " + this.label);
|
||||
// }
|
||||
else {
|
||||
console.log("filtering out " + this.label);
|
||||
}
|
||||
});
|
||||
return filteredResults;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue