VIVO 888, and just a change to an if statement in the menumanagement file

This commit is contained in:
hudajkhan 2014-10-24 12:37:43 -04:00
parent ea98c15092
commit 456f8beb41
3 changed files with 65 additions and 29 deletions

View file

@ -84,6 +84,10 @@ public class AutocompleteController extends VitroAjaxController {
hasMultipleTypes = true;
}
}
} else {
//if the type parameter is null, no range is specified and individuals of any class might be returned
//in this case, it would be useful to show the most specific type of the individual
hasMultipleTypes = true;
}
SearchQuery query = getQuery(qtxt, vreq);

View file

@ -3,7 +3,9 @@
var customForm = {
/* *** Initial page setup *** */
//Setting the default Concept class here
//This would need to change if we update the ontology, etc.
conceptClassURI: "http://www.w3.org/2004/02/skos/core#Concept",
onLoad: function() {
if (this.disableFormInUnsupportedBrowsers()) {
@ -323,8 +325,11 @@ var customForm = {
// Not sure why, but we need an explicit json parse here.
var results = $.parseJSON(xhr.responseText);
var filteredResults = customForm.filterAcResults(results);
if ( customForm.acTypes[$(selectedObj).attr('acGroupName')] == "http://www.w3.org/2004/02/skos/core#Concept" ) {
/*
if ( customForm.acTypes[$(selectedObj).attr('acGroupName')] == customForm.conceptClassURI ) {
filteredResults = customForm.removeConceptSubclasses(filteredResults);
}*/
if(customForm.doRemoveConceptSubclasses()) {
filteredResults = customForm.removeConceptSubclasses(filteredResults);
}
@ -342,6 +347,15 @@ var customForm = {
});
},
//Method to check whether we need to filter to individuals with a most specific type = Concept or other allowed subclasses
doRemoveConceptSubclasses:function() {
//if this array of allowable subclasses was declared annd there is at least one element in it
if(customForm.limitToConceptClasses && customForm.limitToConceptClasses.length) {
return true;
}
return false;
},
// Store original or base text with elements that will have text substitutions.
// Generally the substitution cannot be made on the current value, since that value
// may have changed from the original. So we store the original text with the element to
@ -427,20 +441,23 @@ var customForm = {
},
//Updating this code to utilize an array to
removeConceptSubclasses: function(array) {
$(array).each(function(i) {
var allMsTypes = this["allMsTypes"];
//Using map because the resulting array might be different from the original
array = jQuery.map(array, function(arrayValue, i) {
var allMsTypes = arrayValue["allMsTypes"];
var removeElement = false;
if(allMsTypes.length == 1 && this["msType"] != "http://www.w3.org/2004/02/skos/core#Concept") {
if(allMsTypes.length == 1 && !customForm.isAllowedConceptSubclass(arrayValue["msType"])) {
//Remove from array
removeElement = true;
} else if(allMsTypes.length > 1) {
//If there are multiple most specific types returned, check if none of them equals concept
removeElement = true;
var j;
for(j = 0; j < allMsTypes.length; j++) {
//this refers to the element itself
if(allMsTypes[j] == "http://www.w3.org/2004/02/skos/core#Concept") {
if(customForm.isAllowedConceptSubclass(allMsTypes[j])) {
//don't remove this element if one of the most specific types is a concept
removeElement = false;
break;
@ -448,12 +465,27 @@ var customForm = {
}
}
if(removeElement) {
array.splice(i, 1);
}
if(removeElement)
return null;
else
return arrayValue;
});
return array;
},
isAllowedConceptSubclass:function(classURI) {
if(customForm.limitToConceptClasses && customForm.limitToConceptClasses.length) {
var len = customForm.limitToConceptClasses.length;
var i;
for(i = 0; i < len; i++) {
if(classURI == customForm.limitToConceptClasses[i]) {
return true;
}
}
}
return false;
},
showAutocompleteSelection: function(label, uri, selectedObj) {
// hide the acSelector field and set it's value to the selected ac item

View file

@ -57,7 +57,7 @@
<select name="selectClassGroup" id="selectClassGroup" role="combobox">
<option value="-1" role="option">${i18n().select_one}</option>
<#list classGroups as aClassGroup>
<option value="${aClassGroup.URI}" <#if aClassGroup.URI = associatedPageURI!"">selected</#if> role="option">${aClassGroup.publicName}</option>
<option value="${aClassGroup.URI}" <#if aClassGroup.URI = associatedPageURI>selected</#if> role="option">${aClassGroup.publicName}</option>
</#list>
</select>
</section>