Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Story/cit 6 #14

Merged
merged 28 commits into from Mar 8, 2019
Merged

Story/cit 6 #14

merged 28 commits into from Mar 8, 2019

Conversation

namrathaov
Copy link
Contributor

Changes to edit authors.

@diging-jenkins
Copy link

Can one of the admins verify this patch?

1 similar comment
@diging-jenkins
Copy link

Can one of the admins verify this patch?

authorSpan.html("");
var affiliationsList = [];
var aff = $("#affiliations").children();
for(var i=1;i<aff.length;i++){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use 'each' here instead of a for loop. Easier to read and maintain.

}

var affiliationString = "";
if (affiliationsList) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is actually a bug in this code that shows empty parentheses if there are no affiliations (affiliationsList needs to be checked if it's empty). This needs to be fixed here and above.

$("#authorList").append("&nbsp;&nbsp; ")
$("#authorModal").modal('hide');
resetAuthorCreationModal();
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is basically the same code as for adding authors, let's reuse the existing code.

$("#uriAuthor").val(authorItem.attr("data-author-uri"));
$("#idAuthor").val(authorItem.attr("data-author-id"));

for(var i=0;i<authorItem.children().length-1;i++){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use 'each' here instead of for loop

if(authorItem.children().length-1>0){
$("#affiliationTemplate").hide();
}
if($("#updateAuthorButton").length == 0){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would that be the case? I think I know what you're doing but I'm pretty sure that is a more elegant way. Why don't you just reuse the existing code and just change the label of the button from 'Add Author' to 'Update Author' when a user clicks on the edit button?

@@ -140,6 +180,31 @@ $(function() {
}, 1000);
});

$(".author-item").on("click", function(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add an 'edit' icon to edit an author instead of clicking on the whole thing.

@@ -163,9 +228,13 @@ $(function() {
function resetAuthorCreationModal() {
$("#firstNameAuthor").val("");
$("#lastNameAuthor").val("");
$("#affiliationTemplate").find("input").val("");
$("#affiliations").html("<div id='affiliationTemplate' class='form-group'><label for='affiliationAuthor'>Affiliation:</label><input type='text' class='form-control' placeholder='Affiliation'></div>");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you're getting rid of the clones of affiliation inputs? Just give them all a class and then remove them by their class name.

@jdamerow jdamerow closed this Feb 6, 2019
@namrathaov
Copy link
Contributor Author

Updated for loop to each and reused existing code for update author.

@namrathaov namrathaov reopened this Feb 14, 2019
authorItem.children("span").each(function(idx, elem){
var affInput = $("#affiliationTemplate").clone();
affInput.removeAttr("id");
affInput.attr("class", affInput.attr("class")+" aff-info");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use 'addClass' function

var affSpan = $("<span>");
affSpan.attr("data-affiliation-id", input.attr("data-affiliation-id"));
affSpan.attr("data-affiliation-name", input.val());
affSpan.val(input.val());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't affSpan a span element? what does calling val() accomplish? form jquery documentation: "This method is typically used to set the values of form fields."

function resetAuthorCreationModal() {
$("#firstNameAuthor").val("");
$("#lastNameAuthor").val("");
$("#affiliationTemplate").find("input").val("");
$("#uriAuthor").val("");
$("#idAuthor").attr("data-author-id","");
$(".aff-info").find("input").val("");
$(".aff-info").remove();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you set the input to empty first, if you then remove the the elements?

@jdamerow jdamerow closed this Feb 14, 2019
@namrathaov
Copy link
Contributor Author

Refactored code.

@namrathaov namrathaov reopened this Feb 15, 2019
@jdamerow
Copy link
Member

Jenkins, test this please.

@jdamerow
Copy link
Member

there are two affiliation fields instead of one when the modal is opened:
image

@jdamerow jdamerow closed this Feb 15, 2019
@namrathaov namrathaov reopened this Feb 18, 2019
@jdamerow
Copy link
Member

Jenkins, test this please.

@jdamerow
Copy link
Member

"Created new authority entry XXX." is not reset when the modal is opened again.

@jdamerow jdamerow closed this Feb 18, 2019
@namrathaov
Copy link
Contributor Author

"Created new authority entry XXX." is not reset when the modal is opened again.

I think my changes in CIT-5 would fix the reset.

@namrathaov namrathaov reopened this Feb 25, 2019
@jdamerow
Copy link
Member

please resolve conflicts

@jdamerow jdamerow closed this Feb 25, 2019
Namratha added 2 commits March 7, 2019 10:16
@namrathaov
Copy link
Contributor Author

Resolved conflicts and generalized edit authors and editors.

@namrathaov namrathaov reopened this Mar 7, 2019
@jdamerow
Copy link
Member

jdamerow commented Mar 7, 2019

retest this please

@jdamerow
Copy link
Member

jdamerow commented Mar 7, 2019

The following exception is thrown now:
java.lang.UnsupportedOperationException: JsonNull com.google.gson.JsonElement.getAsString(JsonElement.java:192) edu.asu.diging.citesphere.core.factory.impl.CitationFactory.lambda$mapPersonFields$1(CitationFactory.java:158) java.lang.Iterable.forEach(Iterable.java:75) edu.asu.diging.citesphere.core.factory.impl.CitationFactory.mapPersonFields(CitationFactory.java:152) edu.asu.diging.citesphere.core.factory.impl.CitationFactory.parseExtra(CitationFactory.java:140) edu.asu.diging.citesphere.core.factory.impl.CitationFactory.createCitation(CitationFactory.java:104) edu.asu.diging.citesphere.core.zotero.impl.ZoteroManager.createCitationResults(ZoteroManager.java:141) edu.asu.diging.citesphere.core.zotero.impl.ZoteroManager.getGroupItems(ZoteroManager.java:61) edu.asu.diging.citesphere.core.service.impl.CitationManager.getGroupItems(CitationManager.java:225) edu.asu.diging.citesphere.core.service.impl.CitationManager$$FastClassBySpringCGLIB$$275ff5c1.invoke(<generated>) org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) org.sp

@jdamerow jdamerow closed this Mar 7, 2019
@namrathaov
Copy link
Contributor Author

[CIT-6] Fixed exception in citation factory to handle json null.

@namrathaov namrathaov reopened this Mar 8, 2019
@jdamerow jdamerow merged commit b0d23fd into develop Mar 8, 2019
@jdamerow jdamerow deleted the story/CIT-6 branch March 8, 2019 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants