From d2351c6eb538fe75eaa6e170788e87bfe8fa4090 Mon Sep 17 00:00:00 2001 From: Wingysam Date: Fri, 23 Nov 2018 10:29:05 -0500 Subject: [PATCH] Fix being able to see buttons if there is one that you can't see at the top --- routes/wishlist/index.js | 2 ++ views/wishlist.pug | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/routes/wishlist/index.js b/routes/wishlist/index.js index c6c0914..2316add 100644 --- a/routes/wishlist/index.js +++ b/routes/wishlist/index.js @@ -34,12 +34,14 @@ module.exports = (db) => { router.get('/:user', verifyAuth(), async (req, res) => { try { 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 lastCanSeeValue = wishlistReverse.find(element => (element.addedBy === req.params.user)); const lastCanSee = dbUser.wishlist.indexOf(lastCanSeeValue); res.render('wishlist', { title: `Wishlist - ${dbUser._id}`, wishlist: dbUser.wishlist, + firstCanSee, lastCanSee }); } catch (error) { diff --git a/views/wishlist.pug b/views/wishlist.pug index 77ea2e4..305cf55 100644 --- a/views/wishlist.pug +++ b/views/wishlist.pug @@ -26,7 +26,7 @@ block content .control.inline input.inline.button.is-warning(type='submit' value='Remove') 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}`) .field.inline .control.inline