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/vspc 147 #228

Open
wants to merge 112 commits into
base: develop
Choose a base branch
from
Open

Story/vspc 147 #228

wants to merge 112 commits into from

Conversation

pradeep-017
Copy link
Contributor

@pradeep-017 pradeep-017 commented Jul 6, 2021

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]).

  • I have removed all code style changes that are not necessary (e.g. changing blanks across the whole file that don’t need to be changed, adding empty lines in parts other than your own code)
  • I am not making any changes to files that don’t have any effect (e.g. imports added that don’t need to be added)
  • I do not have any sysout statements in my code or commented out code that isn’t needed anymore
  • I am not reformatting any files in the wrong format or without cause.
  • I am not changing file encoding or line endings to something else than UTF-8, LF
  • My pull request does not show an insane amount of files being changed although my ticket only requires a few files being changed
  • I have added Javadoc/documentation where appropriate
  • I have added test cases where appropriate
  • I have explained any part of my code/implementation decisions that is not be self-explanatory

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 ...

pradeep-017 and others added 30 commits May 5, 2021 16:28
… them, fixed code indentations and div alignments
…aphy, handling null cases of path variables, code cleanup
…ged Biblio controller and forms - Saving is working - Work in Progress
@jdamerow jdamerow closed this Jan 29, 2025
@ajay3568yadav ajay3568yadav reopened this Jan 31, 2025
Copy link
Member

@jdamerow jdamerow left a 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() {
Copy link
Member

Choose a reason for hiding this comment

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

what is this for?

Copy link
Contributor

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
Screenshot 2025-02-07 at 2 53 50 PM

Copy link
Member

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.

Copy link
Contributor

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);
Copy link
Member

Choose a reason for hiding this comment

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

what is this for?

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

addressed comment

@jdamerow jdamerow closed this Feb 7, 2025
@ajay3568yadav ajay3568yadav reopened this Feb 7, 2025
@Autowired
private IContentBlockManager contentBlockManager;

@RequestMapping(value = "/staff/module/{id}/slide/{slideId}/bibliography/{biblioId}/references", method = RequestMethod.POST)
Copy link
Member

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);
Copy link
Member

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)
Copy link
Member

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);
Copy link
Member

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

Copy link
Contributor

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.

Copy link
Member

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);
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

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"));*/
Copy link
Member

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>');
Copy link
Member

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

the ids are different

Copy link
Member

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"

Copy link
Contributor

Choose a reason for hiding this comment

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

Screenshot 2025-03-11 at 4 40 04 PM Screenshot 2025-03-11 at 4 40 22 PM

ids are different for difference references

Copy link
Contributor

Choose a reason for hiding this comment

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

Screenshot 2025-03-11 at 4 42 33 PM for the input as well, the values of the unique id is being stored, and is called while deleting it

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 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"));
Copy link
Member

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.

Copy link
Member

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.

@jdamerow jdamerow closed this Feb 21, 2025
@ajay3568yadav ajay3568yadav reopened this Mar 7, 2025
reference.setEditors(editor);
reference.setType(type);
reference.setNote(note);
reference.getBiblios().add((BiblioBlock) biblio);
Copy link
Member

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);
Copy link
Member

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 {
Copy link
Member

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");
Copy link
Member

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 {
Copy link
Member

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.


String biblioTitle = rootNode.get("biblioTitle").asText();
String description = rootNode.get("description").asText();
String id = rootNode.get("id").asText();
Copy link
Member

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);
Copy link
Member

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>');
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 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).

@jdamerow jdamerow closed this Mar 12, 2025
@ajay3568yadav ajay3568yadav reopened this Mar 13, 2025
Copy link
Member

@jdamerow jdamerow left a 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);
Copy link
Member

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.

Copy link
Contributor

@ajay3568yadav ajay3568yadav Mar 26, 2025

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();
Copy link
Member

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?

Copy link
Contributor

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

@ajay3568yadav
Copy link
Contributor

Screenshot 2025-03-26 at 4 36 13 PM I don't see any codefactor issues?

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.

4 participants