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; 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); SearchQuery query = getQuery(qtxt, vreq);

View file

@ -3,7 +3,9 @@
var customForm = { var customForm = {
/* *** Initial page setup *** */ /* *** 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() { onLoad: function() {
if (this.disableFormInUnsupportedBrowsers()) { if (this.disableFormInUnsupportedBrowsers()) {
@ -323,9 +325,12 @@ var customForm = {
// Not sure why, but we need an explicit json parse here. // Not sure why, but we need an explicit json parse here.
var results = $.parseJSON(xhr.responseText); var results = $.parseJSON(xhr.responseText);
var filteredResults = customForm.filterAcResults(results); 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); filteredResults = customForm.removeConceptSubclasses(filteredResults);
}*/
if(customForm.doRemoveConceptSubclasses()) {
filteredResults = customForm.removeConceptSubclasses(filteredResults);
} }
customForm.acCache[request.term] = filteredResults; customForm.acCache[request.term] = 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. // 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 // 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 // may have changed from the original. So we store the original text with the element to
@ -426,34 +440,52 @@ var customForm = {
customForm.acFilter = customForm.acFilter.concat(this.acFilterForIndividuals); customForm.acFilter = customForm.acFilter.concat(this.acFilterForIndividuals);
}, },
//Updating this code to utilize an array to
removeConceptSubclasses: function(array) { removeConceptSubclasses: function(array) {
$(array).each(function(i) { //Using map because the resulting array might be different from the original
var allMsTypes = this["allMsTypes"]; array = jQuery.map(array, function(arrayValue, i) {
var removeElement = false; var allMsTypes = arrayValue["allMsTypes"];
if(allMsTypes.length == 1 && this["msType"] != "http://www.w3.org/2004/02/skos/core#Concept") { var removeElement = false;
//Remove from array if(allMsTypes.length == 1 && !customForm.isAllowedConceptSubclass(arrayValue["msType"])) {
removeElement = true; //Remove from array
} else if(allMsTypes.length > 1) { removeElement = true;
//If there are multiple most specific types returned, check if none of them equals concept } else if(allMsTypes.length > 1) {
removeElement = true; //If there are multiple most specific types returned, check if none of them equals concept
var j; removeElement = true;
for(j = 0; j < allMsTypes.length; j++) { var j;
//this refers to the element itself
if(allMsTypes[j] == "http://www.w3.org/2004/02/skos/core#Concept") { for(j = 0; j < allMsTypes.length; j++) {
//don't remove this element if one of the most specific types is a concept //this refers to the element itself
removeElement = false; if(customForm.isAllowedConceptSubclass(allMsTypes[j])) {
break; //don't remove this element if one of the most specific types is a concept
} removeElement = false;
} break;
} }
}
if(removeElement) { }
array.splice(i, 1);
} if(removeElement)
}); return null;
else
return arrayValue;
});
return array; 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) { showAutocompleteSelection: function(label, uri, selectedObj) {
// hide the acSelector field and set it's value to the selected ac item // 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"> <select name="selectClassGroup" id="selectClassGroup" role="combobox">
<option value="-1" role="option">${i18n().select_one}</option> <option value="-1" role="option">${i18n().select_one}</option>
<#list classGroups as aClassGroup> <#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> </#list>
</select> </select>
</section> </section>