NIHVIVO-1995 Removed individual counts from classes and added logic that attempts to identify super class
This commit is contained in:
parent
c324ab3151
commit
0db60ac7d8
3 changed files with 60 additions and 42 deletions
|
@ -59,11 +59,18 @@ ul#browse-classgroups .count-classes {
|
||||||
/* BROWSE CLASSES IN CLASS GROUP ------> */
|
/* BROWSE CLASSES IN CLASS GROUP ------> */
|
||||||
#browse-classes {
|
#browse-classes {
|
||||||
float: left;
|
float: left;
|
||||||
|
position: relative;
|
||||||
width: 610px;
|
width: 610px;
|
||||||
border: 1px solid #dde6e5;
|
border: 1px solid #dde6e5;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
min-height: 230px;
|
min-height: 230px;
|
||||||
}
|
}
|
||||||
|
a.browse-superclass {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.3em;
|
||||||
|
right: 0.5em;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
ul#classes-in-classgroup {
|
ul#classes-in-classgroup {
|
||||||
float: left;
|
float: left;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
|
|
|
@ -17,6 +17,7 @@ var browseClassGroups = {
|
||||||
initObjects: function() {
|
initObjects: function() {
|
||||||
this.vClassesInClassGroup = $('ul#classes-in-classgroup');
|
this.vClassesInClassGroup = $('ul#classes-in-classgroup');
|
||||||
this.browseClassGroupLinks = $('#browse-classgroups li a');
|
this.browseClassGroupLinks = $('#browse-classgroups li a');
|
||||||
|
this.browseClasses = $('#browse-classes');
|
||||||
},
|
},
|
||||||
|
|
||||||
// Event listeners. Called on page load
|
// Event listeners. Called on page load
|
||||||
|
@ -24,7 +25,8 @@ var browseClassGroups = {
|
||||||
// Listener for classGroup switching
|
// Listener for classGroup switching
|
||||||
this.browseClassGroupLinks.click(function() {
|
this.browseClassGroupLinks.click(function() {
|
||||||
uri = $(this).attr("data-uri");
|
uri = $(this).attr("data-uri");
|
||||||
browseClassGroups.getVClasses(uri);
|
individualCount = $(this).attr("data-count");
|
||||||
|
browseClassGroups.getVClasses(uri, individualCount);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -51,25 +53,28 @@ var browseClassGroups = {
|
||||||
// Load classes and chart for default class group as defined by template
|
// Load classes and chart for default class group as defined by template
|
||||||
defaultClassGroup: function() {
|
defaultClassGroup: function() {
|
||||||
if ( this.defaultBrowseClassGroupURI != "false" ) {
|
if ( this.defaultBrowseClassGroupURI != "false" ) {
|
||||||
this.getVClasses(this.defaultBrowseClassGroupUri);
|
this.getVClasses(this.defaultBrowseClassGroupUri, this.defaultBrowseClassGroupCount);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Where all the magic happens -- gonna fetch me some classes
|
// Where all the magic happens -- gonna fetch me some classes
|
||||||
getVClasses: function(classgroupUri, alpha) {
|
getVClasses: function(classgroupUri, classGroupIndivCount) {
|
||||||
url = this.dataServiceUrl + encodeURIComponent(classgroupUri);
|
url = this.dataServiceUrl + encodeURIComponent(classgroupUri);
|
||||||
if ( alpha && alpha != "all") {
|
|
||||||
url = url + '&alpha=' + alpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
// First wipe currently displayed classes
|
// First wipe currently displayed classes, browse all link, and bar chart
|
||||||
this.vClassesInClassGroup.empty();
|
this.vClassesInClassGroup.empty();
|
||||||
|
$('a.browse-superclass').remove();
|
||||||
|
$('#visual-graph').empty();
|
||||||
|
|
||||||
var values = [],
|
var values = [],
|
||||||
labels = [],
|
labels = [],
|
||||||
uris = [];
|
uris = [],
|
||||||
|
classList = [],
|
||||||
|
populatedClasses = 0;
|
||||||
|
potentialSuperClasses = [];
|
||||||
|
|
||||||
$.getJSON(url, function(results) {
|
$.getJSON(url, function(results) {
|
||||||
|
|
||||||
$.each(results.classes, function(i, item) {
|
$.each(results.classes, function(i, item) {
|
||||||
name = results.classes[i].name;
|
name = results.classes[i].name;
|
||||||
uri = results.classes[i].URI;
|
uri = results.classes[i].URI;
|
||||||
|
@ -77,18 +82,49 @@ var browseClassGroups = {
|
||||||
indexUrl = browseClassGroups.baseUrl +'/individuallist?vclassId='+ encodeURIComponent(uri);
|
indexUrl = browseClassGroups.baseUrl +'/individuallist?vclassId='+ encodeURIComponent(uri);
|
||||||
// Only add to the arrays and render classes when they aren't empty
|
// Only add to the arrays and render classes when they aren't empty
|
||||||
if ( indivCount > 0 ) {
|
if ( indivCount > 0 ) {
|
||||||
|
// if the class individual count is equal to the class group individual count, this could be a super class
|
||||||
|
if ( indivCount == classGroupIndivCount ) {
|
||||||
|
potentialSuperClasses.push(populatedClasses);
|
||||||
|
}
|
||||||
|
|
||||||
values.push(parseInt(indivCount, 10));
|
values.push(parseInt(indivCount, 10));
|
||||||
labels.push(name + ' (' + parseInt(indivCount, 10) +')');
|
labels.push(name);
|
||||||
uris.push(uri);
|
uris.push(uri);
|
||||||
|
|
||||||
// Build the content of each list item, piecing together each component
|
// Build the content of each list item, piecing together each component
|
||||||
listItem = '<li role="listitem">';
|
listItem = '<li role="listitem">';
|
||||||
listItem += '<a href="'+ indexUrl +'" title="Browse all '+ name +' content">'+ name;
|
listItem += '<a href="'+ indexUrl +'" title="Browse all '+ name +' content">'+ name;
|
||||||
listItem += ' <span class="count-individuals">('+ indivCount +')</span></a>';
|
listItem += ' <span>('+ indivCount +')</span>';
|
||||||
listItem += '</li>';
|
listItem += '</li>';
|
||||||
browseClassGroups.vClassesInClassGroup.append(listItem);
|
|
||||||
|
// Add the list item to the array of classes
|
||||||
|
classList.push(listItem);
|
||||||
|
|
||||||
|
populatedClasses++;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Test for number of potential super classes. If only 1, then remove it from all arrays
|
||||||
|
// But only do so if there are at least 2 classes in the list to begin with
|
||||||
|
if ( classList.length > 1 && potentialSuperClasses.length == 1 ){
|
||||||
|
// Grab the URI of the super class before splicing
|
||||||
|
superClassUri = uris[potentialSuperClasses];
|
||||||
|
|
||||||
|
values.splice(potentialSuperClasses, 1);
|
||||||
|
labels.splice(potentialSuperClasses, 1);
|
||||||
|
uris.splice(potentialSuperClasses, 1);
|
||||||
|
classList.splice(potentialSuperClasses, 1);
|
||||||
|
|
||||||
|
browseAllUrl = browseClassGroups.baseUrl +'/individuallist?vclassId='+ encodeURIComponent(superClassUri);
|
||||||
|
browseAllLink = '<a class="browse-superclass" href="'+ browseAllUrl +'" title="Browse all '+ results.classGroupName +'">Browse all »</a>';
|
||||||
|
browseClassGroups.browseClasses.prepend(browseAllLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the classes to the DOM
|
||||||
|
$.each(classList, function(i, listItem) {
|
||||||
|
browseClassGroups.vClassesInClassGroup.append(listItem);
|
||||||
|
})
|
||||||
|
|
||||||
// Set selected class group
|
// Set selected class group
|
||||||
browseClassGroups.selectedClassGroup(results.classGroupUri);
|
browseClassGroups.selectedClassGroup(results.classGroupUri);
|
||||||
|
|
||||||
|
@ -113,9 +149,6 @@ var browseClassGroups = {
|
||||||
var graphClassGroups = {
|
var graphClassGroups = {
|
||||||
// Build the bar chart using gRaphael
|
// Build the bar chart using gRaphael
|
||||||
barchart: function(values, labels, uris) {
|
barchart: function(values, labels, uris) {
|
||||||
// Clear the existing bar chart
|
|
||||||
$('#visual-graph').empty();
|
|
||||||
|
|
||||||
var height = values.length * 37;
|
var height = values.length * 37;
|
||||||
|
|
||||||
// Create the canvas
|
// Create the canvas
|
||||||
|
@ -144,9 +177,7 @@ var graphClassGroups = {
|
||||||
$('rect').each(function() {
|
$('rect').each(function() {
|
||||||
var index = $('rect').index(this);
|
var index = $('rect').index(this);
|
||||||
var label = labels[index];
|
var label = labels[index];
|
||||||
var countStart = label.lastIndexOf(' (');
|
var title = 'Browse all '+ label +' content';
|
||||||
var label = label.substring(0, countStart);
|
|
||||||
var title = 'View all '+ label +' content';
|
|
||||||
|
|
||||||
// Add a title attribute
|
// Add a title attribute
|
||||||
$(this).attr('title', title);
|
$(this).attr('title', title);
|
||||||
|
|
|
@ -28,7 +28,7 @@ ${stylesheets.add("/css/browseClassGroups.css")}
|
||||||
<#elseif classGroup.uri == group.uri>
|
<#elseif classGroup.uri == group.uri>
|
||||||
<#assign activeGroup = selected />
|
<#assign activeGroup = selected />
|
||||||
</#if>
|
</#if>
|
||||||
<li role="listitem"><a data-uri="${group.uri}" ${activeGroup}href="${urls.base}/${currentPage}?classgroupUri=${group.uri?url}#browse" title="Browse ${group.publicName?capitalize}">${group.publicName?capitalize} <span class="count-classes">(${group.individualCount})</span></a></li>
|
<li role="listitem"><a ${activeGroup}href="${urls.base}/${currentPage}?classgroupUri=${group.uri?url}#browse" title="Browse ${group.publicName?capitalize}" data-uri="${group.uri}" data-count="${group.individualCount}">${group.publicName?capitalize} <span class="count-classes">(${group.individualCount})</span></a></li>
|
||||||
</#if>
|
</#if>
|
||||||
</#list>
|
</#list>
|
||||||
</#assign>
|
</#assign>
|
||||||
|
@ -79,7 +79,8 @@ ${stylesheets.add("/css/browseClassGroups.css")}
|
||||||
var browseData = {
|
var browseData = {
|
||||||
baseUrl: '${domainName + urls.base}',
|
baseUrl: '${domainName + urls.base}',
|
||||||
dataServiceUrl: '${domainName + urls.base}/dataservice?getVClassesForVClassGroup=1&classgroupUri=',
|
dataServiceUrl: '${domainName + urls.base}/dataservice?getVClassesForVClassGroup=1&classgroupUri=',
|
||||||
defaultBrowseClassGroupUri: '${firstPopulatedClassGroup.uri!}'
|
defaultBrowseClassGroupUri: '${firstPopulatedClassGroup.uri!}',
|
||||||
|
defaultBrowseClassGroupCount: '${firstPopulatedClassGroup.individualCount!}'
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -105,27 +106,6 @@ ${stylesheets.add("/css/browseClassGroups.css")}
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
|
|
||||||
<#macro pieChart classes=classes classGroup=classGroup>
|
|
||||||
<section id="visual-graph" role="region">
|
|
||||||
<table class="graph-data">
|
|
||||||
<#list classes?sort_by("individualCount") as class>
|
|
||||||
<#assign countPercentage = (class.individualCount / classGroup.individualCount) * 100 />
|
|
||||||
<#if (class.individualCount > 0 && countPercentage?round > 0)>
|
|
||||||
<tr>
|
|
||||||
<th>${class.name}</th>
|
|
||||||
<td>${countPercentage?round}%</td>
|
|
||||||
</tr>
|
|
||||||
</#if>
|
|
||||||
</#list>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<section id="pieViz" role="region"></section>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
${scripts.add("/themes/wilma/js/jquery_plugins/raphael/raphael.js", "/themes/wilma/js/jquery_plugins/raphael/pie.js")}
|
|
||||||
</#macro>
|
|
||||||
|
|
||||||
|
|
||||||
<#macro visualGraph classes=classes classGroup=classGroup>
|
<#macro visualGraph classes=classes classGroup=classGroup>
|
||||||
<section id="visual-graph" class="barchart" role="region">
|
<section id="visual-graph" class="barchart" role="region">
|
||||||
<#-- Will be populated dynamically via AJAX request -->
|
<#-- Will be populated dynamically via AJAX request -->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue