-
Notifications
You must be signed in to change notification settings - Fork 3
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/vspc 147 #228
base: develop
Are you sure you want to change the base?
Story/vspc 147 #228
Conversation
… page - Work in progress
… on slide page + Code cleanup
… them, fixed code indentations and div alignments
… shown on public page
…ography not detected by zotero extension
…detection by zotero - work in progress
…aphy, handling null cases of path variables, code cleanup
…rategy Design pattern
…ged Biblio controller and forms - Saving is working - Work in Progress
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the issue with toString and the html method is still in there. any kind of formatting should happen in the template or through external classes, not the model class.
+ type + ", " + note; | ||
} | ||
|
||
public String htmlRenderedReference() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it parses the text returned by toString() (which in this case is "bibliography title: " + biblioTitle + " description: " + description) as Markdown, and then render that Markdown as HTML. it is used in modules for biblio block and reference block to render "Biblio block" and references, its just returning the string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya, that should not be done in the domain model class. that needs to be done in the template or through an extra class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
Parser parser = Parser.builder().build(); | ||
Node document = parser.parse(toString()); | ||
HtmlRenderer renderer = HtmlRenderer.builder().build(); | ||
return renderer.render(document); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before, is this how it should be done? Or should I change it? If yes, then let me know how
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed comment
@Autowired | ||
private IContentBlockManager contentBlockManager; | ||
|
||
@RequestMapping(value = "/staff/module/{id}/slide/{slideId}/bibliography/{biblioId}/references", method = RequestMethod.POST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be .../references/add
String type = rootNode.get("type").asText(); | ||
String note = rootNode.get("note").asText(); | ||
|
||
IBiblioBlock biblio = contentBlockManager.getBiblioBlock(biblioId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably be part of the createReference
method
@Autowired | ||
private IReferenceManager referenceManager; | ||
|
||
@RequestMapping(value = "/staff/module/{moduleId}/slide/{id}/bibliography/{biblioId}/reference/edit", method = RequestMethod.POST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be consistent, either
.../reference/edit
and .../reference/add
or
.../references/edit
and .../references/add
|
||
IReference reference = referenceManager.getReference(id); | ||
if (reference == null) { | ||
return new ResponseEntity<String>(HttpStatus.NOT_FOUND); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to log why this is returned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed, but I don't see the newly added line on the review side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codefactor.io issue
reference.setEditors(editor); | ||
reference.setType(type); | ||
reference.setNote(note); | ||
referenceManager.updateReference((Reference) reference); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should not be necessary to cast to Reference
here
$(".EasyMDEContainer").remove(); | ||
$(e.target).closest('.referenceDivStaff').addClass("open"); | ||
var description = $("div.open p:eq(0)").text(); | ||
defaultValue = description; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's up with the indentation in the couple of lines above?
var alert = $('<input type="hidden" id="currentBiblioId">'); | ||
/* $(alert).attr( 'value', $(this).parent().parent().parent().attr("id"));*/ | ||
$(alert).attr( 'value', $(e.target).closest('.biblioDivStaff').attr("id")); | ||
$('.modal-footer').append(alert); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation (all the above)
//showing the edit bibliography form with all the respective values | ||
$("#editReferenceAlert").show(); | ||
var alert = $('<input type="hidden" id="currentBiblioId">'); | ||
/* $(alert).attr( 'value', $(this).parent().parent().parent().attr("id"));*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove if not needed
+ 'Issue: <span>' + data.issue + '</span>, Pages: <span>' + data.pages + '</span>, ' | ||
+ 'Editors: <span>' + data.editors + '</span>, Type: <span>' + data.type + '</span>, ' | ||
+ 'Note: <span>' + data.note + '</span>' | ||
+ '<input type="hidden" id="deleteReferenceId" value="'+ data.id +'" /><a class="btn deleteReference" href="javascript:;" style="position: absolute; right:0px;"><i style="color: var(--error);" class="fas fa-trash-alt"></i></a></p></div>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this mean that every time I add a new reference, the new div will have an input with the same id? IDs have to be unique.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ids are different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is that possible if it's hard-coded: id="deleteReferenceId"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this code creating an input field for every reference with the id "deleteReferenceId" (and a unique value)? This is what the code looks like, and if that is the case, then the id is not unique (it's "deleteReferenceId" for every hidden input field).
$("#editReferenceAlert").show(); | ||
var alert = $('<input type="hidden" id="currentBiblioId">'); | ||
/* $(alert).attr( 'value', $(this).parent().parent().parent().attr("id"));*/ | ||
$(alert).attr( 'value', $(e.target).closest('.biblioDivStaff').attr("id")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems unnecessarily complicated and brittle.
a) why is the variable called "alert"? It does not contain an alert, does it?
b) if I understand this right, all that this code is trying to do is that the id of the reference that should be deleted in the delete form, right? If so, the block that was clicked on should just have a data attribute that holds the id of the reference that should be deleted. Then get that value here and set it in the input.
c) The input element should probably be already in the modal, and then just set the value here. No need to create a new input element every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same is true for all the other cases where there is similar code here in the file.
reference.setEditors(editor); | ||
reference.setType(type); | ||
reference.setNote(note); | ||
reference.getBiblios().add((BiblioBlock) biblio); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be necessary to cast to BiblioBlock here
@Override | ||
public IReference createReference(String biblioId, String title, String author,String year,String journal, String url, String volume,String issue, String pages,String editor, String type, String note) { | ||
IReference reference = new Reference(); | ||
IBiblioBlock biblio = contentBlockManager.getBiblioBlock(biblioId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line should be right before line 46 or even merged
|
||
@RequestMapping(value = "/staff/module/{moduleId}/slide/{id}/bibliography", method = RequestMethod.POST) | ||
public ResponseEntity<String> addBiblioBlock(@PathVariable("id") String slideId, | ||
@PathVariable("moduleId") String moduleId, @RequestBody String biblioBlockData) throws JsonProcessingException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you have spring parse the json into an object (just create a BiblioBlockData class with the necessary fields and use it here)? This way you can drop line 35-41.
String description = rootNode.get("description").asText(); | ||
Integer contentOrder = contentBlockManager.findMaxContentOrder(slideId); | ||
contentOrder = contentOrder == null ? 0 : contentOrder + 1; | ||
System.out.println("/n/n/n/n"+contentOrder + "/n/n/n/n/n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
@RequestMapping(value = "/staff/module/{id}/slide/{slideId}/bibliography/{biblioId}/reference/add", method = RequestMethod.POST) | ||
public ResponseEntity<String> addReference(@PathVariable("id") String moduleId, @PathVariable("slideId") String slideId, | ||
@PathVariable("biblioId") String biblioId, | ||
@RequestBody String reference, Model model) throws JsonProcessingException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, let spring do the parsing.
vspace/src/main/java/edu/asu/diging/vspace/web/staff/EditBiblioBlockController.java
Show resolved
Hide resolved
|
||
String biblioTitle = rootNode.get("biblioTitle").asText(); | ||
String description = rootNode.get("description").asText(); | ||
String id = rootNode.get("id").asText(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
|
||
IReference reference = referenceManager.getReference(id); | ||
if (reference == null) { | ||
return new ResponseEntity<String>(HttpStatus.NOT_FOUND); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codefactor.io issue
+ 'Issue: <span>' + data.issue + '</span>, Pages: <span>' + data.pages + '</span>, ' | ||
+ 'Editors: <span>' + data.editors + '</span>, Type: <span>' + data.type + '</span>, ' | ||
+ 'Note: <span>' + data.note + '</span>' | ||
+ '<input type="hidden" id="deleteReferenceId" value="'+ data.id +'" /><a class="btn deleteReference" href="javascript:;" style="position: absolute; right:0px;"><i style="color: var(--error);" class="fas fa-trash-alt"></i></a></p></div>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this code creating an input field for every reference with the id "deleteReferenceId" (and a unique value)? This is what the code looks like, and if that is the case, then the id is not unique (it's "deleteReferenceId" for every hidden input field).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still codefactor issues
referenceData.getNote() | ||
); | ||
|
||
return ResponseEntity.ok((Reference) ref); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have to cast here? I would assume you can pass in IRefrence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its not working if I am passing the IReference. Type mismatch: cannot convert from ResponseEntity to ResponseEntity
but why are we avoiding TypeCasting?
$("#confirmDeleteChoiceBlockAlert").find('input').remove(); | ||
$("#confirmDeleteRefAlert").hide(); | ||
var refId = $('.deleteReferenceId').attr('value'); | ||
$('.deleteReferenceId').remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this yet, but what I expect:
- I create multiple references, which means multiple
<input type="hidden" class="deleteReferenceId" ...>
will be created. - the above lines will probably take the first input they find with class
deleteReferenceId
- from that input, the id is used to delete a reference.
That can't be right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deletetion is working properly, I checked with different combinations
Guidelines for Pull Requests
If you haven't yet read our code review guidelines, please do so, You can find them here.
Please confirm the following by adding an x for each item (turn
[ ]
into[x]
).Please provide a brief description of your ticket
(you can copy the ticket if it hasn't changed)
Completed changes for changes for Bibliographies and References.
Anything else the reviewer needs to know?
... describe here ...