-
-
Notifications
You must be signed in to change notification settings - Fork 161
WM | ITP-MAY-25 | NAHOM MESFIN | Sprint 2 | Book Library #315
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
Conversation
cjyuan
left a comment
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 you check if any of this general feedback can help you further improve your code?
https://github.com/cjyuan/Module-Data-Flows/blob/book-library-feedback/debugging/book-library/feedback.md
Doing so can help me speed up the review process. Thanks.
Thanks for the reply, I have checked https://github.com/cjyuan/Module-Data-Flows/blob/book-library-feedback/debugging/book-library/feedback.md and made improvements to the code. |
LonMcGregor
left a comment
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.
Good work on this sprint. It is almost done. I have left some remarks for how you could improve it further
debugging/book-library/script.js
Outdated
| const authorValue = author.value.trim(); | ||
| const pagesValue = pages.value.trim(); | ||
|
|
||
| if (!titleValue || !authorValue || !pagesValue) { |
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.
Are there any values in the form you might want to validate more carefully than just "is there data here"?
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.
yes there are a couple of validation rules i should have added.
line 32
I added a conditon if (!/^[a-zA-Z\s.'-]+$/.test(authorValue) to validate authors value, limiting it to only letters, spaces, periods, apostrophes, and hyphens.
line 38
I added another condition for page number if (!Number.isInteger(pagesNumber) || pagesNumber <= 0) to validate only postive numbers.
debugging/book-library/script.js
Outdated
| deleteButton.addEventListener("click", () => { | ||
| myLibrary.splice(i, 1); // delete immediately | ||
| render(); // update the table | ||
| alert(`Deleted "${book.title}" successfully.`); // optional confirmation |
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.
When you are deleting something like a file on your PC, do you normally expect to be notified after, or is there an interaction that would work that is better than 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.
line 22 - 35
Instead of blocking alerts, i have used a notification function function showNotification(message) which gives a non interrputing visually nicer notification instead of popup alert.
| <label for="title">Title:</label> | ||
| <input | ||
| type="title" | ||
| type="text" |
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.
Right now you need to manually validate the form. Do you know what change you need to make to the HTML and script to make the browser validate the form inputs automatically?
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.
lines 47 & 56
I have removed the some of the manual validations i used earlier in the script and replaced it with an autotmatic error handler in my html for the inputs pattern="[a-zA-Z\s.'-]+" , required min="1"
cjyuan
left a comment
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 changes you made look good. You can go through my additional suggestions later when you have time.
| pattern="[a-zA-Z\s.'-]+" | ||
| title="Only letters, spaces, apostrophes, periods, or hyphens allowed" |
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 approach is good but the pattern might be too restrictive.
| document.getElementById("bookForm").addEventListener("submit", function(event) { | ||
| event.preventDefault(); | ||
| submit(); | ||
| }); |
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.
Placing code that's to be executed once on page load (lines 3-6, 32-35) together could make locating this kind of code easier.
| title.value = ""; | ||
| author.value = ""; | ||
| pages.value = ""; | ||
| check.checked = false; |
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.
We could also use .reset() of a form element to clear the form.
| myLibrary.splice(i, 1); | ||
| render(); | ||
| // Delete button | ||
| const deleteCell = row.insertCell(4); |
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 you think of the pros and cons of these two approaches for creating cells within a row?
- Keeping all the cell creation code in one location, like the original code does.
- Scattering the cell creation code across different locations, like what you did.
Learners, PR Template
Self checklist
Changelist
I debugged and fixed issues preventing books from displaying. and corrected errors when adding a book. then fixed the title/author mix-up, ensured the delete button works, and corrected the read-status logic. I then implemented validation so incomplete book entries show an alert instead of being added to the list.