Fix being able to see buttons if there is one that you can't see at the top
This commit is contained in:
parent
ddbaf05936
commit
d2351c6eb5
2 changed files with 3 additions and 1 deletions
|
@ -34,12 +34,14 @@ module.exports = (db) => {
|
||||||
router.get('/:user', verifyAuth(), async (req, res) => {
|
router.get('/:user', verifyAuth(), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const dbUser = await db.get(req.params.user);
|
const dbUser = await db.get(req.params.user);
|
||||||
|
const firstCanSee = dbUser.wishlist.findIndex(element => (element.addedBy === req.params.user));
|
||||||
const wishlistReverse = [...dbUser.wishlist].reverse();
|
const wishlistReverse = [...dbUser.wishlist].reverse();
|
||||||
const lastCanSeeValue = wishlistReverse.find(element => (element.addedBy === req.params.user));
|
const lastCanSeeValue = wishlistReverse.find(element => (element.addedBy === req.params.user));
|
||||||
const lastCanSee = dbUser.wishlist.indexOf(lastCanSeeValue);
|
const lastCanSee = dbUser.wishlist.indexOf(lastCanSeeValue);
|
||||||
res.render('wishlist', {
|
res.render('wishlist', {
|
||||||
title: `Wishlist - ${dbUser._id}`,
|
title: `Wishlist - ${dbUser._id}`,
|
||||||
wishlist: dbUser.wishlist,
|
wishlist: dbUser.wishlist,
|
||||||
|
firstCanSee,
|
||||||
lastCanSee
|
lastCanSee
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ block content
|
||||||
.control.inline
|
.control.inline
|
||||||
input.inline.button.is-warning(type='submit' value='Remove')
|
input.inline.button.is-warning(type='submit' value='Remove')
|
||||||
if req.user._id === req.params.user
|
if req.user._id === req.params.user
|
||||||
if index !== 0
|
if index !== firstCanSee
|
||||||
form.inline(method='POST', action=`/wishlist/${req.params.user}/move/up/${item.id}`)
|
form.inline(method='POST', action=`/wishlist/${req.params.user}/move/up/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
|
|
Loading…
Reference in a new issue