-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature/favorite rooms #422
Conversation
536fdaf
to
fc9daa4
Compare
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.
Nice code, clever solution, loved the roomTemplate!
public/js/favorite.js
Outdated
function addFavorite(room) { | ||
if (!room) { | ||
displayMessage('danger', err) | ||
} else { | ||
fetch('/favorites', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ room }), | ||
}) | ||
.then(async (res) => { | ||
switch (res.status) { | ||
case 201: | ||
location.reload() | ||
break | ||
case 401: | ||
displayMessage('danger', UNAUTHORIZED_MESSAGE) | ||
break | ||
case 403: | ||
displayMessage('danger', FORBIDDEN_MESSAGE) | ||
break | ||
case 404: | ||
data = await res.json() | ||
displayMessage('danger', data.message) | ||
break | ||
} | ||
}) | ||
.catch((err) => displayMessage('danger', err)) | ||
} | ||
} |
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.
Sorry for that. My VS code is automatically indenting with tabs, and resets the settings after every restart. I will run a lint with --fix option. That will do it.
views/room/roomTemplate.pug
Outdated
.column.notification(class=`${!group ? 'is-success' : (!group.doNotDisturb? 'is-warning' : 'is-danger')}`) | ||
.columns.is-vcentered.is-gapless | ||
.column.is-narrow | ||
span.icon.is-medium.has-text-warning.mr-2(onClick=`${favorite? `deleteFavorite(${room})` : `addFavorite(${room})`}`) |
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.
Maybe create a .is-clickable
class in additions.scss
, and put it onto this span as well?
Recommendation:
.is-clickable {
cursor: pointer;
}
if ( | ||
req.params.id && | ||
favorites && | ||
favorites.findIndex(element => element.room == parseInt(req.params.id)) >= 0 |
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 we use .some()
here as well?
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.
Sorry, I forgot to replace it. At first I used this method for some mysterious reason, and then changed it.
res.sendStatus(404) | ||
} | ||
}) | ||
|
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 are some leftover whitespaces here.
src/components/rooms/room.routes.ts
Outdated
favorite: favorites.some(el => el.room == room.floor) | ||
} | ||
}) | ||
if (user.floor && user.floor >= 3 && user.floor <= 18) { |
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 think we can completely remove the floor
from the use model and it's mentions from the application as the favorites extends this functionality.
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 I do it in this PR, or should I introduce a new issue for it?
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 it in here since this feature makes the current functionality obsolete.
views/room/index.pug
Outdated
- const group = busyRooms.find(it => it.id === room) | ||
if !group.doNotDisturb | ||
if user && rooms.some(el => el.favorite) | ||
section.mt-5.mb-5 A kedvenceid: |
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'd remove this text, it doesn't really add any extra information.
views/room/index.pug
Outdated
else | ||
+roomTemplate(room.floor, room.favorite, room.busy) | ||
if rooms.some(el => !el.favorite) | ||
section.mt-5.mb-5 Szintek: |
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'd change this to a simple <hr />
or something similar.
views/user/show.pug
Outdated
@@ -4,14 +4,6 @@ block content | |||
h1.title= userToShow.name | |||
if user.id === userToShow.id | |||
h2.subtitle.my-5 Személyes beállítások |
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.
You can remove this line too, as currently there are no settings on the profile page.
There are some conflicting files with the latest code in master, please rebase your branch to resolve it. |
👀 |
I've waited for the new frontend with this pr, and rebased it again, but I think I'd rather delete the branch. It's kinda messy, so I think I'll just rewrite it if thats okay? |
Whatever is easier for you :) Just don't forget to delete the remote branch too. |
Add feature favorite rooms. #332