From 9ba79a0685619f725b7e25bc2db572c05488bcff Mon Sep 17 00:00:00 2001 From: rjy7 Date: Thu, 1 Jul 2010 15:15:54 +0000 Subject: [PATCH] NIHVIVO-646 Store authorship rank with authorship listing. Fixes to js name-splitting routine. --- .../forms/addAuthorsToInformationResource.jsp | 21 +++++++------------ .../js/addAuthorsToInformationResource.js | 12 +++++------ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/productMods/edit/forms/addAuthorsToInformationResource.jsp b/productMods/edit/forms/addAuthorsToInformationResource.jsp index 64d0e4b2..56859aad 100644 --- a/productMods/edit/forms/addAuthorsToInformationResource.jsp +++ b/productMods/edit/forms/addAuthorsToInformationResource.jsp @@ -253,8 +253,8 @@ SPARQL queries for existing values. --%> Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri); List authorships = infoResource.getRelatedIndividuals(predicateUri); - String rankUri = "http://vivoweb.org/ontology/core#authorRank"; - DataPropertyComparator comp = new DataPropertyComparator(rankUri); + String rankPredicateUri = "http://vivoweb.org/ontology/core#authorRank"; + DataPropertyComparator comp = new DataPropertyComparator(rankPredicateUri); Collections.sort(authorships, comp); vreq.setAttribute("infoResourceName", infoResource.getName()); @@ -299,14 +299,7 @@ SPARQL queries for existing values. --%> int rank = 0; for ( Individual authorship : authorships ) { - int rank1 = Integer.valueOf(authorship.getDataValue(rankUri)); - String rankValue = authorship.getDataValue(rankUri); // full value, including xsd type if present - if (rankValue == null) { - rankValue = ""; - rank = 0; - } else { - rank = Integer.valueOf(rankValue); // just the integer value - } + rank = Integer.valueOf(authorship.getDataValue(rankPredicateUri)); Individual author = authorship.getRelatedIndividual(linkedAuthorProperty); if ( author != null ) { request.setAttribute("author", author); @@ -324,7 +317,7 @@ SPARQL queries for existing values. --%> <%-- --%>
  • - + <%-- This span will be used in the next phase, when we display a message that the author has been removed. That text will replace the a.authorLink. --%> ${author.name} @@ -337,8 +330,8 @@ SPARQL queries for existing values. --%> } // A new author will be ranked last when added. // This wouldn't handle gaps in the ranking: vreq.setAttribute("rank", authorships.size()+1); - vreq.setAttribute("newRank", rank + 1); - vreq.setAttribute("rankPred", rankUri); + request.setAttribute("newRank", rank + 1); + request.setAttribute("rankPred", rankPredicateUri); %> @@ -368,7 +361,7 @@ SPARQL queries for existing values. --%> - + " /> diff --git a/productMods/edit/forms/js/addAuthorsToInformationResource.js b/productMods/edit/forms/js/addAuthorsToInformationResource.js index 7de829ba..dfe844ee 100644 --- a/productMods/edit/forms/js/addAuthorsToInformationResource.js +++ b/productMods/edit/forms/js/addAuthorsToInformationResource.js @@ -92,7 +92,6 @@ var addAuthorForm = { // selection, show first and middle name fields. this.lastNameField.keydown(function(event) { if (event.keyCode === 13) { - console.log('in keydown') addAuthorForm.onLastNameChange(); return false; } @@ -158,18 +157,17 @@ var addAuthorForm = { // User may have typed first name as well as last name into last name field. // If so, when showing first and middle name fields, move anything after a comma - // into the first name field. + // or space into the first name field. fixNames: function() { var lastNameInput = this.lastNameField.val(), - names = lastNameInput.split(','), - lastName = names[0].replace(/[, ]+$/, ''), - firstName; + names = lastNameInput.split(/[, ]+/), + lastName = names[0]; this.lastNameField.val(lastName); if (names.length > 1) { - firstName = names[1].replace(/^[, ]+/, ''); - this.firstNameField.val(firstName); + //firstName = names[1].replace(/^[, ]+/, ''); + this.firstNameField.val(names[1]); } },