Skip to content

Glasgow | 26-ITP-May | Francesco Romano Monda | Sprint 2 | Book Library - #553

Open
fromonda wants to merge 3 commits into
CodeYourFuture:mainfrom
fromonda:feature/book-library
Open

Glasgow | 26-ITP-May | Francesco Romano Monda | Sprint 2 | Book Library#553
fromonda wants to merge 3 commits into
CodeYourFuture:mainfrom
fromonda:feature/book-library

Conversation

@fromonda

Copy link
Copy Markdown

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

  • Fixed the initial book list so existing books are displayed on page load.
  • Fixed the error occurring when adding a new book.
  • Corrected author handling so the book’s author is saved/displayed correctly.
  • Fixed the delete functionality so books can be removed from the list.
  • Fixed the read status so it correctly reflects the value selected when adding a book.
  • Added validation to prevent books with missing title, author, page count, or read status from being added.
  • Added an alert when required book information is missing.
  • Fixed other minor issues affecting book list functionality and data handling.

@github-actions

This comment has been minimized.

@fromonda fromonda added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Flows The name of the module. labels Aug 14, 2026
@github-actions

This comment has been minimized.

2 similar comments
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 14, 2026
@fromonda fromonda added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 14, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 14, 2026
@fromonda fromonda changed the title Glasgow | 26-ITP-May | Francesco Romano Monda | Sprint 2 | Module Data Flows Glasgow | 26-ITP-May | Francesco Romano Monda | Sprint 2 | Book Library Aug 14, 2026
@fromonda fromonda added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 14, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you also check if any of this general feedback can help you further improve your code?
https://github.com/CodeYourFuture/Module-Data-Flows/blob/general-review-feedback/debugging/book-library/feedback.md

Doing so can help me speed up the review process. Thanks.

Comment thread debugging/book-library/index.html Outdated
Comment thread debugging/book-library/index.html
@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 14, 2026
@fromonda

Copy link
Copy Markdown
Author

Could you also check if any of this general feedback can help you further improve your code? https://github.com/CodeYourFuture/Module-Data-Flows/blob/general-review-feedback/debugging/book-library/feedback.md

Doing so can help me speed up the review process. Thanks.

Thank you for pointing me towards the improvement guidelines and for trying to speed up the review process. I put all the improvements indicated into practice, although it took some time. I hope the refactoring, input validation, and other changes are better now.

@fromonda fromonda added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 15, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code looks pretty solid.

There seems to be a bug.

Comment on lines 48 to 56
@@ -52,24 +51,19 @@ <h1>Library</h1>
id="pages"
name="pages"
required
min="1"
step="1"
/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Even with these constraints, currently the browser would still allow a user to submit value like 12.345 or -100. Could you find out why and then fix the issue?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I tested this again and found that decimal and negative page values are now rejected and the error message is displayed. It is possible that this issue occurred before I added the error message.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The error message you mentioned is generated by your JS code, and not by the browser.
The browser will only check the input against those constraints when a user submits a form. Currently those input elements are not inside a form, and that's why the browser does not enforce the constraints.

Comment thread debugging/book-library/script.js Outdated
Comment on lines +13 to +26
submitBtn.addEventListener("click", submitBook);

// Add initial books
const book1 = new Book("Robinson Crusoe", "Daniel Defoe", 252, true);
const book2 = new Book(
"The Old Man and the Sea",
"Ernest Hemingway",
127,
true
);

myLibrary.push(book1);
myLibrary.push(book2);
render();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could consider placing all code that runs once on page load in a single function. For example, you could put it inside the page load callback or create a function named init() or setup() and call it once when the page loads.

This makes it easier to locate and manage all the code that runs once when the app starts.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have updated my code by creating an init() function and moving the code that runs when the application starts into it.

library.push(book);
render();
if (!title || !author || !Number.isInteger(pages) || pages < 1) {
showMessage("Please enter valid book information.", "danger");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When I clicked the Submit button without any input, I couldn't see any error message.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I found the issue: I had not included an element with id="message" in my HTML. I added the missing element, and the validation error message now displays correctly when the Submit button is clicked without any input.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was the bug I wanted you to find. You fixed it!

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 15, 2026
@fromonda

Copy link
Copy Markdown
Author

Code looks pretty solid.

There seems to be a bug.

This issue may have been related to the changes I made while fixing the validation and error-message handling.

@fromonda fromonda added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 15, 2026
Comment thread debugging/book-library/script.js Outdated
Comment on lines -4 to -10
const titleInput = document.getElementById("title");
const authorInput = document.getElementById("author");
const pagesInput = document.getElementById("pages");
const checkInput = document.getElementById("check");
const submitBtn = document.getElementById("submitBtn");
const bookList = document.getElementById("bookList");
const messageEl = document.getElementById("message");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This approach is actually safer and preferred. Declaring these shared variables using let is too risky.

@cjyuan

cjyuan commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

I will mark this PR as "Complete" first.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Data-Flows The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants