NIHVIVO-3768 grants management page

This commit is contained in:
tworrall 2012-05-25 15:28:56 +00:00
parent eac078a232
commit 2c294c38e9
7 changed files with 279 additions and 4 deletions

View file

@ -0,0 +1,85 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var manageGrants = {
/* *** Initial page setup *** */
onLoad: function() {
this.mixIn();
this.initPage();
},
mixIn: function() {
// Get the custom form data from the page
$.extend(this, customFormData);
},
// Initial page setup. Called only at page load.
initPage: function() {
this.initGrantData();
this.bindEventListeners();
},
// On page load, associate data with each list item. Then we don't
// have to keep retrieving data from or modifying the DOM as we manipulate the
// items.
initGrantData: function() {
$('.grantCheckbox').each(function(index) {
$(this).data(grantData[index]);
});
},
bindEventListeners: function() {
$('.grantCheckbox').click(function() {
manageGrants.processGrant(this);
//return false;
});
},
processGrant: function(grant) {
var add = "";
var retract = "";
var n3String = "<" + $(grant).data('roleUri') + "> <http://vivoweb.org/ontology/core#hideFromDisplay> \"true\" ." ;
if ( $(grant).is(':checked') ) {
add = n3String;
}
else {
retract = n3String;
}
$.ajax({
url: manageGrants.processingUrl,
type: 'POST',
data: {
additions: add,
retractions: retract
},
dataType: 'json',
context: grant, // context for callback
complete: function(request, status) {
if (status === 'success') {
window.status = "The item has been successfully excluded from the profile page.";
} else {
alert('Error processing request: the item cannot be excluded from the profile page.');
$(grant).removeAttr('checked');
}
}
});
},
};
$(document).ready(function() {
manageGrants.onLoad();
});

View file

@ -0,0 +1,56 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Custom form for managing web pages for individuals -->
<#if subjectName?contains(",") >
<#assign lastName = subjectName?substring(0,subjectName?index_of(",")) />
<#assign firstName = subjectName?substring(subjectName?index_of(",") + 1) />
<h2>Manage Grants & Projects for ${firstName} ${lastName}</h2>
<#else>
<h2>Manage Grants & Projects for ${subjectName}</h2>
</#if>
<p style="margin-left:25px;margin-bottom:12px">
Check those grants and projects you want to exclude from the profile page.
<script type="text/javascript">
var grantData = [];
</script>
</p>
<#list allSubclasses as sub>
<h4>${sub}</h4>
<section id="pubsContainer" role="container">
<#assign grantList = grants[sub]>
<ul >
<#list grantList as grant>
<li>
<input type="checkbox" class="grantCheckbox" <#if grant.hideThis??>checked</#if> />${grant.label!}
</li>
<script type="text/javascript">
grantData.push({
"roleUri": "${grant.role!}"
});
</script>
</#list>
</ul>
</section>
</#list>
<br />
<p>
<a href="${urls.referringPage}#research" title="return to profile page">Return to profile page</a>
</p>
<script type="text/javascript">
var customFormData = {
processingUrl: '${urls.base}/edit/primitiveRdfEdit'
};
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />',
'<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/utils.js"></script>',
'<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}/templates/freemarker/edit/forms/js/manageGrantsForIndividual.js"></script>')}