diff --git a/productMods/edit/forms/addAuthorsToInformationResource.jsp b/productMods/edit/forms/addAuthorsToInformationResource.jsp
index 3ac90486..b633a7b4 100644
--- a/productMods/edit/forms/addAuthorsToInformationResource.jsp
+++ b/productMods/edit/forms/addAuthorsToInformationResource.jsp
@@ -238,7 +238,7 @@ SPARQL queries for existing values. --%>
EditConfiguration.putConfigInSession(editConfig,session);
}
- //editConfig.addValidator(new PublicationHasAuthorValidator());
+ editConfig.addValidator(new PublicationHasAuthorValidator());
Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri");
@@ -288,11 +288,14 @@ SPARQL queries for existing values. --%>
if ( author != null ) {
request.setAttribute("author", author);
%>
- <%-- RY Should use author short view here instead? --%>
-
-
${author.name}Remove
+
+
+ ${author.URI}
+ ${author.name}
+ Remove
+
<%
}
@@ -340,28 +343,3 @@ SPARQL queries for existing values. --%>
-<%!
-// We'll just rely on rdfs:label for now. In future, the label will be created by the app from
-// last name, first name, and middle name fields, so we don't have to worry about inconsistent
-// ordering.
-/*
-public String getAuthorName(Individual author) {
- String name;
-
- String lastName = author.getDataValue("http://xmlns.com/foaf/0.1/lastName");
- String firstName = author.getDataValue("http://xmlns.com/foaf/0.1/firstName");
-
- if (lastName != null && firstName != null) {
- name = lastName + ", " + firstName;
- String middleName = author.getDataValue("http://vivoweb.org/ontology/core#middleName");
- if (middleName != null) {
- name += " " + middleName;
- }
- }
- else {
- name = author.getName();
- }
- return name;
-}
-*/
-%>
diff --git a/productMods/edit/forms/css/addAuthorsToInformationResource.css b/productMods/edit/forms/css/addAuthorsToInformationResource.css
index 1f123519..1c5d20ac 100644
--- a/productMods/edit/forms/css/addAuthorsToInformationResource.css
+++ b/productMods/edit/forms/css/addAuthorsToInformationResource.css
@@ -9,11 +9,16 @@
margin-bottom: .75em;
}
-#authors a.authorName {
+#authors a.existingAuthor {
display: inline-block;
width: 15em;
}
+/* These are only here for JavaScript to pick up. Don't display!! */
+#authors span.existingAuthorUri {
+ display: none;
+}
+
/* Hide elements not used in non-JS version of form */
#showAddForm,
a.remove,
diff --git a/productMods/edit/forms/js/addAuthorsToInformationResource.js b/productMods/edit/forms/js/addAuthorsToInformationResource.js
index 494c69ae..c33fcf71 100644
--- a/productMods/edit/forms/js/addAuthorsToInformationResource.js
+++ b/productMods/edit/forms/js/addAuthorsToInformationResource.js
@@ -134,25 +134,38 @@ var addAuthorForm = {
var cache = {};
var url = $('#acUrl').val();
+ var existingAuthorUris = addAuthorForm.getExistingAuthorUris();
+ console.log(existingAuthorUris);
+ jQuery.each(existingAuthorUris, function(index, element) {
+ url += '&filter=' + element;
+ });
$('#lastName').autocomplete({
minLength: 2,
- source: function(request, response) {
- if (request.term in cache) {
- response(cache[request.term]);
- return;
- }
-
- $.ajax({
- url: url,
- dataType: 'json',
- data: request,
- success: function(data) {
- cache[request.term] = data;
- response(data);
- }
-
- });
- },
+ source: url,
+// RY For now, not using cache because there are complex interactions between filtering and caching.
+// We want to filter out existingAuthors from autocomplete results, and this seems easiest to do
+// server-side. But if an author gets removed, we need to put them back in the results. If results
+// are cached, the cache needs to be cleared on a remove. Not sure if we have access to it there.
+// Lots of complexity involved, so for now let's try without the cache.
+// source: function(request, response) {
+// if (request.term in cache) {
+// //console.log("found term in cache");
+// response(cache[request.term]);
+// return;
+// }
+//
+// $.ajax({
+// url: url,
+// dataType: 'json',
+// data: request,
+// success: function(data) {
+// cache[request.term] = data;
+// //console.log("not getting term from cache");
+// response(data);
+// }
+//
+// });
+// },
select: function(event, ui) {
addAuthorForm.showSelectedAuthor(ui);
}
@@ -160,6 +173,14 @@ var addAuthorForm = {
},
+ getExistingAuthorUris: function() {
+ var authorUris = $('span.existingAuthorUri');
+ return authorUris.map(function() {
+ return $(this).html();
+ });
+
+ },
+
prepareFieldValuesForSubmit: function() {
var firstName,
middleName,