committing beginnings of autocomplete form and changes
This commit is contained in:
parent
d1b17c75d1
commit
48c8a73613
2 changed files with 109 additions and 86 deletions
|
@ -45,6 +45,8 @@ public class AutocompleteController extends VitroAjaxController {
|
|||
|
||||
private static final String PARAM_QUERY = "term";
|
||||
private static final String PARAM_RDFTYPE = "type";
|
||||
private static final String PARAM_MULTIPLE_RDFTYPE = "multipleTypes";
|
||||
|
||||
|
||||
String NORESULT_MSG = "";
|
||||
private static final int DEFAULT_MAX_HIT_COUNT = 1000;
|
||||
|
@ -156,8 +158,9 @@ public class AutocompleteController extends VitroAjaxController {
|
|||
|
||||
// Filter by type
|
||||
String typeParam = (String) vreq.getParameter(PARAM_RDFTYPE);
|
||||
String multipleTypesParam = (String) vreq.getParameter(PARAM_MULTIPLE_RDFTYPE);
|
||||
if (typeParam != null) {
|
||||
query.addFilterQuery(VitroSearchTermNames.RDFTYPE + ":\"" + typeParam + "\"");
|
||||
addFilterQuery(query, typeParam, multipleTypesParam);
|
||||
}
|
||||
|
||||
query.setFields(VitroSearchTermNames.NAME_RAW, VitroSearchTermNames.URI); // fields to retrieve
|
||||
|
@ -168,7 +171,28 @@ public class AutocompleteController extends VitroAjaxController {
|
|||
return query;
|
||||
}
|
||||
|
||||
private void setNameQuery(SolrQuery query, String queryStr, HttpServletRequest request) {
|
||||
private void addFilterQuery(SolrQuery query, String typeParam, String multipleTypesParam) {
|
||||
if(multipleTypesParam == null || multipleTypesParam.equals("null") || multipleTypesParam.isEmpty()) {
|
||||
//Single type parameter, process as usual
|
||||
query.addFilterQuery(VitroSearchTermNames.RDFTYPE + ":\"" + typeParam + "\"");
|
||||
} else {
|
||||
//Types should be comma separated
|
||||
String[] typeParams = typeParam.split(",");
|
||||
int len = typeParams.length;
|
||||
int i;
|
||||
List<String> filterQueries = new ArrayList<String>();
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
filterQueries.add(VitroSearchTermNames.RDFTYPE + ":\"" + typeParams[i] + "\" ");
|
||||
}
|
||||
String filterQuery = StringUtils.join(filterQueries, " OR ");
|
||||
query.addFilterQuery(filterQuery);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void setNameQuery(SolrQuery query, String queryStr, HttpServletRequest request) {
|
||||
|
||||
if (StringUtils.isBlank(queryStr)) {
|
||||
log.error("No query string");
|
||||
|
|
|
@ -1,92 +1,91 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- autocomplete template for object properties -->
|
||||
<#--Assign variables from editConfig-->
|
||||
<#assign rangeOptions = editConfiguration.pageData.objectVar />
|
||||
<#assign rangeOptionsExist = false />
|
||||
<#if (rangeOptions?keys?size > 0)>
|
||||
<#assign rangeOptionsExist = true/>
|
||||
</#if>
|
||||
|
||||
<#-- NOTE the jsp contained the following which has not been converted
|
||||
<h2>${editConfiguration.formTitle}</h2>
|
||||
|
||||
<jsp:include page="${preForm}">
|
||||
<jsp:param name="useTinyMCE" value="false"/>
|
||||
<jsp:param name="useAutoComplete" value="true"/>
|
||||
</jsp:include>
|
||||
<#if editConfiguration.propertySelectFromExisting = true>
|
||||
<#if rangeOptionsExist = true >
|
||||
<#assign rangeOptionKeys = rangeOptions?keys />
|
||||
<form class="editForm" action = "${submitUrl}">
|
||||
<input type="hidden" name="editKey" id="editKey" value="${editKey}" role="input" />
|
||||
<#if editConfiguration.propertyPublicDescription?has_content>
|
||||
<p>${editConfiguration.propertyPublicDescription}</p>
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
<#---This section should become autocomplete instead-->
|
||||
<p>
|
||||
<label for="relatedIndLabel">Concept <span class='requiredHint'> *</span></label>
|
||||
<input class="acSelector" size="50" type="text" id="relatedIndLabel" name="objectLabel" value="" />
|
||||
</p>
|
||||
|
||||
<div class="acSelection">
|
||||
<p class="inline">
|
||||
<label>Selected:</label>
|
||||
<span class="acSelectionInfo"></span>
|
||||
<a href="/vivo/individual?uri="
|
||||
class="verifyMatch">(Verify this match)</a>
|
||||
</p> <input class="acUriReceiver" type="hidden" id="objectVar" name="objectVar" value="" />
|
||||
</div>
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
$(this).load($(this).parent().children('a').attr('src')+" .editForm");
|
||||
|
||||
$(document).ready(function() {
|
||||
var key = $("input[name='editKey']").attr("value");
|
||||
$.getJSON("<c:url value="/dataservice"/>", {getN3EditOptionList:"1", field: "${objectVar}", editKey: key}, function(json){
|
||||
|
||||
$("select#${objectVar}").replaceWith("<input type='hidden' id='${objectVar}' name='${objectVar}' /><input type='text' id='${objectVar}-entry' name='${objectVar}-entry' />");
|
||||
|
||||
$("#${objectVar}-entry").autocomplete(json, {
|
||||
minChars: 1,
|
||||
width: 320,
|
||||
matchContains: true,
|
||||
mustMatch: 1,
|
||||
autoFill: true,
|
||||
// formatItem: function(row, i, max) {
|
||||
// return row[0];
|
||||
// },
|
||||
// formatMatch: function(row, i, max) {
|
||||
// return row[0];
|
||||
// },
|
||||
// formatResult: function(row) {
|
||||
// return row[0];
|
||||
// }
|
||||
|
||||
}).result(function(event, data, formatted) {
|
||||
$("input#${objectVar}-entry").attr("value", data[0]); // dump the string into the text box
|
||||
$("input#${objectVar}").attr("value", data[1]); // dump the uri into the hidden form input
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
</script>
|
||||
|
||||
<h2>${formTitle}</h2>
|
||||
|
||||
<form id="autoCompleteDatapropForm" class="editForm" action="${submitUrl}" role="autocomplete">
|
||||
|
||||
<#if predicate.offerCreateNewOption >
|
||||
<#assign var="createNewUrl = "/editRequestDispatch?subjectUri=${param.subjectUri}&predicateUri=${param.predicateUri}&clearEditConfig=true&cmd=create >
|
||||
</#if>
|
||||
|
||||
<#if predicate.publicDescription?has_content >
|
||||
<p class="propEntryHelpText">${predicate.publicDescription}</p>
|
||||
</#if>
|
||||
<p>
|
||||
<select id="objectVar" name="objectVar">
|
||||
<#list objectVar as key>
|
||||
<opton value="${key}"
|
||||
<#if editConfiguration.objectUri?has_contant && editConfiguration.object.Uri = key>selected</#if>
|
||||
</#list>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p class="submit">
|
||||
<input type="submit" id="submit" value="editConfiguration.submitLabel"/>
|
||||
<span class="or"> or <a class="cancel" href="${editConfiguration.cancelUrl}" title="cancel">Cancel</a>
|
||||
</p>
|
||||
|
||||
<#if predicate.offerCreateNewOption>
|
||||
<p>If you don't find the appropriate entry on the selection list,
|
||||
<button type="button" onclick="javascript:document.location.href='${createNewUrl}'">Add a new item to this list</button>
|
||||
</p>
|
||||
</#if>
|
||||
|
||||
</form>
|
||||
|
||||
<#if ! param.objectUri?has_content >
|
||||
<form class="deleteForm" action="${???}" method="get">
|
||||
<label for="delete"><h3>Delete this entry?</h3></label>
|
||||
<input type="hidden" name="subjectUri" value="${param.subjectUri}"/>
|
||||
<input type="hidden" name="predicateUri" value="${param.predicateUri}"/>
|
||||
<input type="hidden" name="objectUri" value="${param.objectUri}"/>
|
||||
<input type="hidden" name="cmd" value="delete"/>
|
||||
<input type="submit" id="delete" value="Delete"/>
|
||||
|
||||
<#--The above section should be autocomplete-->
|
||||
|
||||
|
||||
<p>
|
||||
<input type="submit" id="submit" value="${editConfiguration.submitLabel}" role="button "/>
|
||||
<span class="or"> or </span>
|
||||
<a title="Cancel" class="cancel" href="${cancelUrl}">Cancel</a>
|
||||
</p>
|
||||
</form>
|
||||
<#else>
|
||||
<p> There are no entries in the system from which to select. </p>
|
||||
</#if>
|
||||
</#if>
|
||||
|
||||
<#if editConfiguration.propertyOfferCreateNewOption = true>
|
||||
<#include "defaultOfferCreateNewOptionForm.ftl">
|
||||
|
||||
</#if>
|
||||
|
||||
<#if editConfiguration.propertySelectFromExisting = false && editConfiguration.propertyOfferCreateNewOption = false>
|
||||
<p>This property is currently configured to prohibit editing. </p>
|
||||
</#if>
|
||||
|
||||
|
||||
<#if editConfiguration.includeDeletionForm = true>
|
||||
<#include "defaultDeletePropertyForm.ftl">
|
||||
</#if>
|
||||
|
||||
|
||||
<#assign sparqlQueryUrl = "${urls.base}/ajax/sparqlQuery" >
|
||||
|
||||
<script type="text/javascript">
|
||||
var customFormData = {
|
||||
acUrl: '${urls.base}/autocomplete?tokenize=true',
|
||||
acType: 'http://vivoweb.org/ontology/core#FacultyMember,http://vivoweb.org/ontology/core#Librarian',
|
||||
acMultipleTypes: 'true',
|
||||
submitButtonTextType: 'simple',
|
||||
editMode: 'add',
|
||||
defaultTypeName: 'thing' // used in repair mode to generate button text
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
|
||||
|
||||
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
|
||||
|
|
Loading…
Add table
Reference in a new issue