add price

This commit is contained in:
Wingy 2020-11-01 22:01:30 -05:00
parent fcbd556727
commit 7bc40ac3af
3 changed files with 27 additions and 3 deletions

View file

@ -196,9 +196,15 @@ module.exports = (db) => {
req.flash('error', 'Invalid user');
return res.redirect(`/wishlist/${req.params.user}`);
}
wishlistItem.name = req.body.name;
wishlistItem.note = req.body.note;
wishlistItem.url = req.body.url;
for (const type of [
'name', 'note', 'url', 'price'
]) {
if (!req.body.hasOwnProperty(type)) {
req.flash('error', `Missing property ${type}`)
return res.redirect(`/wishlist/${req.params.user}/note/${req.params.id}`)
}
wishlistItem[type] = req.body[type]
}
wishlist[i] = wishlistItem;
}
doc.wishlist = wishlist;

View file

@ -14,6 +14,11 @@ block content
label.label URL
.control
input.input(name='url', value=item.url)
.column
.field
label.label Price
.control
input.input(name='price', value=item.price)
.field
label.label Note
.control

View file

@ -19,6 +19,7 @@ block content
thead
th(style='width: 25%;') Name
th(style='width: 50%;') Note
th(style='width: 10%;') Price
th Edit Item
th Added By
if req.params.user === req.user._id
@ -41,6 +42,7 @@ block content
else
td.ugc(data-label='Name')= item.name
td.ugc(data-label='Note')= item.note
td.ugc(data-label='Price')= item.price
td(data-label='Edit Item')
form.inline(method='GET', action=`${_CC.config.base}wishlist/${req.params.user}/note/${item.id}`)
.field.inline
@ -109,7 +111,13 @@ block content
each item, index in wishlist
if req.user._id === item.addedBy || req.params.user !== req.user._id
.box
if item.price
.tag
i.fas.fa-tag(style='margin-right: .5em;')
span= item.price
span.overflowWrap
if item.price
span= ' '
if item.url
a(
href=item.url,
@ -187,6 +195,11 @@ block print
.print-gift(style='page-break-inside: avoid;')
if index > 0
hr(style='margin-top: .5em; margin-bottom: .5em; background-color: black;')
if item.price
.tag
i.fas.fa-tag(style='margin-right: .5em;')
span= item.price
span= ' '
span.is-size-6.ugc= item.name
span= ' '
span.ugc.has-text-grey= item.url