Updates for menu management and IndividualsForClasses (i.e. internal filters plus custom selection of classes for page) as well as use of data getters predicate in menu model instead of type of Page to get data getter for page.
This commit is contained in:
parent
85bf772de6
commit
843e09a451
24 changed files with 1553 additions and 342 deletions
117
webapp/web/js/menupage/browseByVClasses.js
Normal file
117
webapp/web/js/menupage/browseByVClasses.js
Normal file
|
@ -0,0 +1,117 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
// This file extends and proxies the default behavior defined in vitro/webapp/web/js/menupage/browseByVClass.js
|
||||
|
||||
// Saving the original getIndividuals function from browseByVClass
|
||||
var getPersonIndividuals = browseByVClass.getIndividuals;
|
||||
|
||||
browseByVClass.getIndividuals = function(vclassUri, alpha, page, scroll) {
|
||||
url = encodeURIComponent(vclassUri);
|
||||
var restrictClasses = $('#restrictClasses').val();
|
||||
if(restrictClasses.length > 0) {
|
||||
if(restrictClasses.indexOf(",") != -1) {
|
||||
var restrictClassesArray = restrictClasses.split(",");
|
||||
var restrictUris = restrictClassesArray.join("&vclassId=");
|
||||
url += "&vclassId=" + restrictUris;
|
||||
}
|
||||
else {
|
||||
//does this need to be uri encoded? - assuming already url encoded
|
||||
url += "&vclassId=" + restrictClasses;
|
||||
}
|
||||
}
|
||||
url = this.dataServiceUrl + url;
|
||||
//Get restriction classes from url
|
||||
|
||||
if ( alpha && alpha != "all") {
|
||||
url = url + '&alpha=' + alpha;
|
||||
}
|
||||
if ( page ) {
|
||||
url += '&page=' + page;
|
||||
} else {
|
||||
page = 1;
|
||||
}
|
||||
if ( typeof scroll === "undefined" ) {
|
||||
scroll = true;
|
||||
}
|
||||
|
||||
// Scroll to #menupage-intro page unless told otherwise
|
||||
if ( scroll != false ) {
|
||||
// only scroll back up if we're past the top of the #browse-by section
|
||||
scrollPosition = browseByVClass.getPageScroll();
|
||||
browseByOffset = $('#browse-by').offset();
|
||||
if ( scrollPosition[1] > browseByOffset.top) {
|
||||
$.scrollTo('#menupage-intro', 500);
|
||||
}
|
||||
}
|
||||
|
||||
$.getJSON(url, function(results) {
|
||||
individualList = "";
|
||||
|
||||
// Catch exceptions when empty individuals result set is returned
|
||||
// This is very likely to happen now since we don't have individual counts for each letter and always allow the result set to be filtered by any letter
|
||||
if ( results.individuals.length == 0 ) {
|
||||
browseByVClass.emptyResultSet(results.vclass, alpha)
|
||||
} else {
|
||||
$.each(results.individuals, function(i, item) {
|
||||
label = results.individuals[i].label;
|
||||
firstName = results.individuals[i].firstName;
|
||||
lastName = results.individuals[i].lastName;
|
||||
if ( firstName && lastName ) {
|
||||
fullName = firstName + ' ' + lastName;
|
||||
} else {
|
||||
fullName = label;
|
||||
}
|
||||
moniker = results.individuals[i].moniker;
|
||||
vclassName = results.individuals[i].vclassName;
|
||||
if ( results.individuals[i].preferredTitle == "") {
|
||||
// Use the moniker only if it's not empty and not equal to the VClass name
|
||||
if ( moniker != vclassName && moniker != "" ) {
|
||||
preferredTitle = moniker;
|
||||
} else {
|
||||
preferredTitle = "";
|
||||
}
|
||||
} else {
|
||||
preferredTitle = results.individuals[i].preferredTitle;
|
||||
}
|
||||
uri = results.individuals[i].URI;
|
||||
profileUrl = results.individuals[i].profileUrl;
|
||||
if ( !results.individuals[i].thumbUrl ) {
|
||||
image = browseByVClass.baseUrl + '/images/placeholders/person.thumbnail.jpg';
|
||||
} else {
|
||||
image = browseByVClass.baseUrl + results.individuals[i].thumbUrl;
|
||||
}
|
||||
// Build the content of each list item, piecing together each component
|
||||
listItem = '<li class="vcard individual foaf-person" role="listitem" role="navigation">';
|
||||
listItem += '<img src="'+ image +'" width="90" alt="'+ fullName +'" />';
|
||||
listItem += '<h1 class="fn thumb"><a href="'+ profileUrl +'" title="View the profile page for '+ fullName +'">'+ fullName +'</a></h1>';
|
||||
// Include the calculated preferred title (see above) only if it's not empty
|
||||
if ( preferredTitle != "" ) {
|
||||
listItem += '<span class="title">'+ preferredTitle +'</span>';
|
||||
}
|
||||
listItem += '</li>';
|
||||
// browseByVClass.individualsInVClass.append(listItem);
|
||||
individualList += listItem;
|
||||
})
|
||||
|
||||
// Remove existing content
|
||||
browseByVClass.wipeSlate();
|
||||
|
||||
// And then add the new content
|
||||
browseByVClass.individualsInVClass.append(individualList);
|
||||
|
||||
// Check to see if we're dealing with pagination
|
||||
if ( results.pages.length ) {
|
||||
pages = results.pages;
|
||||
browseByVClass.pagination(pages, page);
|
||||
}
|
||||
//Check if single vclass sent back, otherwise check for vclasses
|
||||
if(results.vclass) {
|
||||
selectedClassHeading = '<h3 class="selected-class">'+ results.vclass.name +'</h3>';
|
||||
browseByVClass.individualsContainer.prepend(selectedClassHeading);
|
||||
}
|
||||
// set selected class, alpha and page
|
||||
browseByVClass.selectedVClass(results.vclass.URI);
|
||||
browseByVClass.selectedAlpha(alpha);
|
||||
}
|
||||
});
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#include "menupage-checkForData.ftl">
|
||||
<#--Not including data check because vclasses don't appear to return entity counts on their own -->
|
||||
<#if !noData>
|
||||
<section id="menupage-intro" class="people" role="region">
|
||||
<h2>${page.title}</h2>
|
||||
</section>
|
||||
|
||||
<#include "menupage-individualsforclasses-browse.ftl">
|
||||
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/menupage/menupage.css" />')}
|
||||
|
||||
<#include "menupage-scripts.ftl">
|
||||
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/menupage/browseByVClasses.js"></script>')}
|
||||
<#else>
|
||||
<# ${noDataNotification} >
|
||||
</#if>
|
|
@ -0,0 +1,41 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Template for browsing individuals in class groups for menupages -->
|
||||
<#import "lib-string.ftl" as str>
|
||||
|
||||
<section id="browse-by" role="region">
|
||||
<nav role="navigation">
|
||||
<ul id="browse-classes">
|
||||
|
||||
<#list vClassGroup as vClass>
|
||||
<#------------------------------------------------------------
|
||||
Need to replace vClassCamel with full URL that allows function
|
||||
to degrade gracefully in absence of JavaScript. Something
|
||||
similar to what Brian had setup with widget-browse.ftl
|
||||
------------------------------------------------------------->
|
||||
<#assign vClassCamel = str.camelCase(vClass.name) />
|
||||
<#-- Only display vClasses with individuals -->
|
||||
<#if (vClass.entityCount > 0)>
|
||||
<li id="${vClassCamel}"><a href="#${vClassCamel}" title="Browse all individuals in this class" data-uri="${vClass.URI}">${vClass.name} <span class="count-classes">(${vClass.entityCount})</span></a></li>
|
||||
</#if>
|
||||
</#list>
|
||||
<#--Including restriction classes as hidden input, for now using just string uri---->
|
||||
<input type="hidden" name="restrictClasses" id="restrictClasses" value="${restrictClasses}"/>
|
||||
</ul>
|
||||
<nav role="navigation">
|
||||
<#assign alphabet = ["A", "B", "C", "D", "E", "F", "G" "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] />
|
||||
<ul id="alpha-browse-individuals">
|
||||
<li><a href="#" class="selected" data-alpha="all">All</a></li>
|
||||
<#list alphabet as letter>
|
||||
<li><a href="#" data-alpha="${letter?lower_case}" title="Browse all individuals whose name starts with ${letter}">${letter}</a></li>
|
||||
</#list>
|
||||
</ul>
|
||||
</nav>
|
||||
</nav>
|
||||
|
||||
<section id="individuals-in-class" role="region">
|
||||
<ul role="list">
|
||||
<#-- Will be populated dynamically via AJAX request -->
|
||||
</ul>
|
||||
</section>
|
||||
</section>
|
Loading…
Add table
Add a link
Reference in a new issue