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'); req.flash('error', 'Invalid user');
return res.redirect(`/wishlist/${req.params.user}`); return res.redirect(`/wishlist/${req.params.user}`);
} }
wishlistItem.name = req.body.name; for (const type of [
wishlistItem.note = req.body.note; 'name', 'note', 'url', 'price'
wishlistItem.url = req.body.url; ]) {
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; wishlist[i] = wishlistItem;
} }
doc.wishlist = wishlist; doc.wishlist = wishlist;

View file

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

View file

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