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

Feature/favorite rooms #422

Closed
wants to merge 14 commits into from
Closed

Feature/favorite rooms #422

wants to merge 14 commits into from

Conversation

nmate980829
Copy link
Contributor

Add feature favorite rooms. #332

@nmate980829 nmate980829 requested review from OmTheTurtle and triszt4n and removed request for OmTheTurtle September 2, 2020 21:51
@nmate980829 nmate980829 force-pushed the feature/favorite-rooms branch from 536fdaf to fc9daa4 Compare September 7, 2020 18:11
Copy link
Member

@triszt4n triszt4n left a 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!

Comment on lines 24 to 54
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))
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you please correct the indentation in this file? Especially here.
Screenshot 2020-09-08 16 59 17

We like to indent using two spaces.
Consistency (even with indentation) is very nice for the developer's eyes. 😄

Copy link
Contributor Author

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.

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

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;
}

@triszt4n triszt4n linked an issue Sep 8, 2020 that may be closed by this pull request
@nmate980829 nmate980829 requested a review from triszt4n September 8, 2020 17:12
if (
req.params.id &&
favorites &&
favorites.findIndex(element => element.room == parseInt(req.params.id)) >= 0
Copy link
Member

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?

Copy link
Contributor Author

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)
}
})

Copy link
Member

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.

favorite: favorites.some(el => el.room == room.floor)
}
})
if (user.floor && user.floor >= 3 && user.floor <= 18) {
Copy link
Member

@OmTheTurtle OmTheTurtle Sep 10, 2020

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.

Copy link
Contributor Author

@nmate980829 nmate980829 Oct 3, 2020

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?

Copy link
Member

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.

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

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.

else
+roomTemplate(room.floor, room.favorite, room.busy)
if rooms.some(el => !el.favorite)
section.mt-5.mb-5 Szintek:
Copy link
Member

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.

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

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.

@OmTheTurtle
Copy link
Member

There are some conflicting files with the latest code in master, please rebase your branch to resolve it.

@triszt4n
Copy link
Member

triszt4n commented Apr 9, 2021

👀

@nmate980829
Copy link
Contributor Author

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?

@OmTheTurtle
Copy link
Member

Whatever is easier for you :) Just don't forget to delete the remote branch too.

@nmate980829 nmate980829 closed this Jun 9, 2021
@nmate980829 nmate980829 deleted the feature/favorite-rooms branch June 9, 2021 15:42
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.

Customizable room order on rooms page
3 participants