JaysGitLab / cs5667-final-project-revdev

cs5667-final-project-revdev created by GitHub Classroom
MIT License
1 stars 0 forks source link

Feature list reservation #46

Open patrickbeekman opened 6 years ago

patrickbeekman commented 6 years ago

Resolves #17

Listing reservations is now working. One small thing I had to do to get this working was install this library: sudo npm i --save circular-json. There is a problem with node.js and displaying json objects that contain refs such as the EventType, it is called a circular ref and fails to parse the json into a string if it contains this, this was the simplest solution. I have also created a link on the homepage to go to the list Reservation page and vice versa.

patrickbeekman commented 6 years ago

This is almost complete, I am stuck on displaying the eventType on the view. I am able to find the eventType by ID in the database and get the correct string to show butttt the tricky part is how do I access this string outside of the scope of the callback function. Take a look at the getNameFromEventId() and renderList() methods inside reservation.server.controller.js

haietza commented 6 years ago

@patrickbeekman Benjamin and I both encountered this difficulty on our features and determined that using middleware solves the use of returned values outside of callbacks and asynchronicity issues. If you take a look at the reservation date validation, that should give you an example of using middleware. Basically, you create one method in the controller to get the eventType from the database making sure to call next() at the end of it, then you create another method to use the value in the view. In the routes, you pass both methods in the order they should be called. This way, the first method gets the value from the database, you attach it to the response, then you can get it and use it in the view in the second method. Hope this helps - let me know if you want me to take a look at any of it with you!

patrickbeekman commented 6 years ago

I have finally got this working properly! It now requires a user to be logged in, it also now properly displays the eventType names, displays the date in a more readable format, moved the listReservation property in the index view, and merged latest master in.

haietza commented 6 years ago

@patrickbeekman Everything looks great! However, I can see all reservations when logged in as a non-admin user still. Can you double check that please?

Also, did you add any tests? If not, we should add unit tests as a part of the pull request too.

Thanks!