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 .
|
?grant rdfs:label ?grantLabel .
|
||||||
</v:jsonset>
|
</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">
|
<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>
|
</c:set>
|
||||||
|
|
||||||
<v:jsonset var="grantTypeUriJson">${vivoOnt}#Grant</v:jsonset>
|
<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="acUrl" value="/autocomplete?stem=true" />
|
||||||
<c:url var="sparqlQueryUrl" value="/admin/sparqlquery" />
|
<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>
|
<h2>${formHeading}</h2>
|
||||||
|
|
||||||
|
@ -215,4 +208,13 @@ var customFormData = {
|
||||||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var customFormData = {
|
||||||
|
sparqlForAcFilter: '${sparqlForAcFilter}',
|
||||||
|
sparqlQueryUrl: '${sparqlQueryUrl}',
|
||||||
|
acUrl: '${acUrl}',
|
||||||
|
acType: '${vivoCore}Grant'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
<jsp:include page="${postForm}"/>
|
|
@ -52,19 +52,14 @@ core:informationResourceInAuthorship (InformationResource : Authorship) - invers
|
||||||
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
||||||
vreq.setAttribute("subjectUriJson", MiscWebUtils.escape(subjectUri));
|
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()));
|
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
||||||
|
|
||||||
String intDatatypeUri = XSD.xint.toString();
|
String intDatatypeUri = XSD.xint.toString();
|
||||||
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
|
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
|
||||||
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(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="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
||||||
<c:set var="label" value="${rdfs}label" />
|
<c:set var="label" value="${rdfs}label" />
|
||||||
<c:set var="infoResourceClassUri" value="${vivoCore}InformationResource" />
|
<c:set var="infoResourceClassUri" value="${vivoCore}InformationResource" />
|
||||||
|
@ -107,7 +102,7 @@ SPARQL queries for existing values. --%>
|
||||||
?newPub core:informationResourceInAuthorship ?authorshipUri .
|
?newPub core:informationResourceInAuthorship ?authorshipUri .
|
||||||
</v:jsonset>
|
</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">
|
<c:set var="sparqlForAcFilter">
|
||||||
PREFIX core: <${vivoCore}> SELECT ?individual WHERE {<${subjectUri}> core:authorInAuthorship ?authorshipUri .?authorshipUri core:linkedInformationResource ?individual .}
|
PREFIX core: <${vivoCore}> SELECT ?individual WHERE {<${subjectUri}> core:authorInAuthorship ?authorshipUri .?authorshipUri core:linkedInformationResource ?individual .}
|
||||||
</c:set>
|
</c:set>
|
||||||
|
|
|
@ -27,10 +27,12 @@ var customForm = {
|
||||||
|
|
||||||
if (!this.typeSelector) {
|
if (!this.typeSelector) {
|
||||||
this.formSteps = 1;
|
this.formSteps = 1;
|
||||||
|
// there's also going to be a 3-step form
|
||||||
} else {
|
} else {
|
||||||
this.formSteps = 2;
|
this.formSteps = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is the label element for the field with name 'label'
|
// This is the label element for the field with name 'label'
|
||||||
this.labelFieldLabel = $('label[for=' + $('#label').attr('id') + ']');
|
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,
|
// 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();
|
var typeVal = $(this).val();
|
||||||
// Set the type of individual that the autocomplete will search for.
|
// 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.
|
// 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) {
|
if (typeVal.length) {
|
||||||
customForm.labelFieldLabel.html(customForm.getSelectedTypeName() + ' ' + customForm.baseLabelText);
|
customForm.labelFieldLabel.html(customForm.getSelectedTypeName() + ' ' + customForm.baseLabelText);
|
||||||
customForm.initFormFullView();
|
customForm.initFormFullView();
|
||||||
|
@ -116,7 +119,7 @@ var customForm = {
|
||||||
|
|
||||||
this.getAcFilter();
|
this.getAcFilter();
|
||||||
this.acCache = {};
|
this.acCache = {};
|
||||||
this.baseAcUrl = customFormData.acUrl;
|
//this.baseAcUrl = customFormData.acUrl;
|
||||||
|
|
||||||
this.acSelector.autocomplete({
|
this.acSelector.autocomplete({
|
||||||
minLength: 3,
|
minLength: 3,
|
||||||
|
@ -127,11 +130,14 @@ var customForm = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// console.log('not getting term from cache');
|
// console.log('not getting term from cache');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: customForm.acUrl,
|
url: customForm.acUrl,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: request,
|
data: {
|
||||||
|
term: request.term,
|
||||||
|
type: customForm.acType,
|
||||||
|
},
|
||||||
complete: function(xhr, status) {
|
complete: function(xhr, status) {
|
||||||
// Not sure why, but we need an explicit json parse here. jQuery
|
// Not sure why, but we need an explicit json parse here. jQuery
|
||||||
// should parse the response text and return a json object.
|
// should parse the response text and return a json object.
|
||||||
|
@ -152,9 +158,6 @@ var customForm = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getAcFilter: function() {
|
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({
|
$.ajax({
|
||||||
url: customFormData.sparqlQueryUrl,
|
url: customFormData.sparqlQueryUrl,
|
||||||
|
@ -184,13 +187,13 @@ var customForm = {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
$.each(results, function() {
|
$.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);
|
filteredResults.push(this);
|
||||||
}
|
}
|
||||||
// Debugging
|
else {
|
||||||
// else {
|
console.log("filtering out " + this.label);
|
||||||
// console.log("filtering out " + this.label);
|
}
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
return filteredResults;
|
return filteredResults;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue