NIHVIVO-646 Continued work on custom form for adding authors to publications

This commit is contained in:
rjy7 2010-06-14 16:36:12 +00:00
parent bfcd18096a
commit c11d40a0f9
3 changed files with 46 additions and 19 deletions

View file

@ -214,7 +214,6 @@ SPARQL queries for existing values. --%>
Model model = (Model) application.getAttribute("jenaOntModel"); Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri"); String objectUri = (String) request.getAttribute("objectUri");
System.out.println("OBJECT URI: " + objectUri);
editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing
String subjectUri = vreq.getParameter("subjectUri"); String subjectUri = vreq.getParameter("subjectUri");
@ -242,17 +241,19 @@ SPARQL queries for existing values. --%>
<jsp:include page="${preForm}" /> <jsp:include page="${preForm}" />
<h2>${title}</h2> <h2>${title}</h2>
<ul class="authors"> <ul id="authors">
<% <%
for ( Individual authorship : authorships ) { for ( Individual authorship : authorships ) {
List<Individual> authors = authorship.getRelatedIndividuals(linkedAuthorProperty); Individual author = authorship.getRelatedIndividual(linkedAuthorProperty);
if ( !authors.isEmpty() ) { if ( author != null ) {
Individual author = authors.get(0); request.setAttribute("author", author);
String authorName = getAuthorName(author);
%> %>
<%-- RY Should use author short view here? --%>
<li><span class="authorName"><%= authorName %></span><a href="" class="remove">Remove</a></li> <c:url var="authorHref" value="/individual">
<c:param name="uri" value="${author.URI}"/>
</c:url>
<li><a href="${authorHref}" class="authorName"><%= getAuthorName(author) %></a><a href="" class="remove">Remove</a></li>
<% <%
} }
@ -261,7 +262,10 @@ SPARQL queries for existing values. --%>
</ul> </ul>
<input type="button" value="Add Author" id="showAddForm" /> <div id="showAddForm">
<v:input type="submit" value="Add Author" id="showAddFormButton" cancel="${param.subjectUri}" cancelLabel="Done" />
</div>
<form id="addAuthorForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" > <form id="addAuthorForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
@ -272,7 +276,7 @@ SPARQL queries for existing values. --%>
<input type="hidden" name="personUri" value="" /> <input type="hidden" name="personUri" value="" />
<input type="hidden" name="rank" value="${rank}" /> <input type="hidden" name="rank" value="${rank}" />
<p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="${param.subjectUri}"/></p> <p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="${param.subjectUri}" /></p>
<p id="requiredLegend" class="requiredHint">* required fields</p> <p id="requiredLegend" class="requiredHint">* required fields</p>
</form> </form>

View file

@ -1,25 +1,39 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */ /* $This file is distributed under the terms of the license in /doc/license.txt$ */
ul.authors { #authors {
margin-left: 0; margin-left: 0;
} }
ul.authors li { #authors li {
list-style: none; list-style: none;
margin-bottom: .75em; margin-bottom: .75em;
} }
ul.authors span.authorName { #authors a.authorName {
display: inline-block; display: inline-block;
width: 15em; width: 15em;
} }
/* Hide elements not used in non-JS version of form */ /* Hide elements not used in non-JS version of form */
#showFormButton, #showAddForm,
a.remove { a.remove {
display: none; display: none;
} }
form a:link.cancel, form a:visited.cancel,
#authors a:link.remove, #authors a:visited.remove,
#showAddForm a:link.cancel, #showAddForm a:visited.cancel {
color: #f70;
border-color: #f70;
}
form a:hover.cancel,
#authors a:hover.remove,
#showAddForm a:hover.cancel {
color: #fff;
background: #f70;
}
#content form p.inline { #content form p.inline {
clear: left; clear: left;
margin-bottom: 0; margin-bottom: 0;

View file

@ -15,8 +15,10 @@ var addAuthorForm = {
initObjects: function() { initObjects: function() {
this.form = $('#addAuthorForm'); this.form = $('#addAuthorForm');
this.showFormButton = $('#showAddForm'); this.showFormDiv = $('#showAddForm');
this.showFormButton = $('#showAddFormButton');
this.removeLinks = $('a.remove'); this.removeLinks = $('a.remove');
this.cancel = this.form.find('.cancel');
}, },
// On page load, make changes to the non-Javascript version for the Javascript version. // On page load, make changes to the non-Javascript version for the Javascript version.
@ -24,7 +26,7 @@ var addAuthorForm = {
adjustForJs: function() { adjustForJs: function() {
// Show elements that are hidden by css on load since not used in non-JS version // Show elements that are hidden by css on load since not used in non-JS version
this.showFormButton.show(); this.showFormDiv.show();
this.removeLinks.show(); this.removeLinks.show();
this.form.hide(); this.form.hide();
@ -32,9 +34,16 @@ var addAuthorForm = {
initForm: function() { initForm: function() {
this.showFormButton.bind('click', function() { this.showFormButton.click(function() {
$(this).hide(); addAuthorForm.showFormDiv.hide();
addAuthorForm.form.show(); addAuthorForm.form.show();
return false;
});
this.cancel.click(function() {
addAuthorForm.form.hide();
addAuthorForm.showFormDiv.show();
return false;
}); });
}, },