Add the ability to suggest items for someone else without pledging for it (#29)
* add suggest button to wishlist * make suggest button work * remove delete-on-unpledge logic
This commit is contained in:
parent
0e6420f714
commit
b94afc3579
3 changed files with 6 additions and 3 deletions
|
@ -168,6 +168,7 @@ module.exports.strings = {
|
|||
WISHLIST_REMOVE_GUARD: 'Not correct user',
|
||||
WISHLIST_REMOVE_MISSING: 'Failed to find item',
|
||||
WISHLIST_REMOVE_SUCCESS: 'Successfully removed from wishlist',
|
||||
WISHLIST_SUGGEST: 'Suggest item',
|
||||
WISHLIST_TITLE: name => `${_CC.config.siteTitle} - Wishlist - ${name}`,
|
||||
WISHLIST_UNPLEDGE_GUARD: 'You did not pledge for this', // should never happen unless someone makes their own http requests
|
||||
WISHLIST_UNPLEDGE_MISSING: 'Failed to find item',
|
||||
|
|
|
@ -99,7 +99,7 @@ module.exports = (db) => {
|
|||
item.price = productData?.price
|
||||
item.image = productData?.image
|
||||
item.addedBy = req.user._id
|
||||
item.pledgedBy = (req.user._id === req.params.user ? undefined : req.user._id)
|
||||
item.pledgedBy = (req.user._id === req.params.user || req.body.suggest ? undefined : req.user._id)
|
||||
item.note = req.body.note
|
||||
if (url) item.url = url
|
||||
if (!url) item.name = req.body.itemUrlOrName
|
||||
|
@ -150,7 +150,6 @@ module.exports = (db) => {
|
|||
return res.redirect(`/wishlist/${req.params.user}`)
|
||||
}
|
||||
docs.rows[i].doc.wishlist[j].pledgedBy = undefined
|
||||
if (docs.rows[i].doc.wishlist[j].addedBy === req.user._id) docs.rows[i].doc.wishlist.splice(j, 1)
|
||||
await db.put(docs.rows[i].doc)
|
||||
req.flash('success', _CC.lang('WISHLIST_UNPLEDGE_SUCCESS'))
|
||||
return res.redirect(`/wishlist/${req.params.user}`)
|
||||
|
|
|
@ -215,9 +215,12 @@ block content
|
|||
name='note',
|
||||
placeholder=lang('WISHLIST_OPTIONAL')
|
||||
)
|
||||
.field
|
||||
.field.is-grouped
|
||||
.control
|
||||
input.button(type='submit' value=(req.user._id === req.params.user ? lang('WISHLIST_ADD') : lang('WISHLIST_PLEDGE_ITEM')))
|
||||
if req.user._id !== req.params.user
|
||||
.control
|
||||
input.inline.button(type='submit', value=lang('WISHLIST_SUGGEST'), name='suggest')
|
||||
script(src=`${_CC.config.base}js/wishlist.js`)
|
||||
|
||||
block print
|
||||
|
|
Loading…
Reference in a new issue