From 7bc40ac3af5b03052a3d9b4dce3b07c526c40436 Mon Sep 17 00:00:00 2001 From: Wingy Date: Sun, 1 Nov 2020 22:01:30 -0500 Subject: [PATCH] add price --- routes/wishlist/index.js | 12 +++++++++--- views/note.pug | 5 +++++ views/wishlist.pug | 13 +++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/routes/wishlist/index.js b/routes/wishlist/index.js index cc4fba3..2512df8 100644 --- a/routes/wishlist/index.js +++ b/routes/wishlist/index.js @@ -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; diff --git a/views/note.pug b/views/note.pug index e1abf99..a13ec2f 100644 --- a/views/note.pug +++ b/views/note.pug @@ -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 diff --git a/views/wishlist.pug b/views/wishlist.pug index 6e9079f..3057764 100644 --- a/views/wishlist.pug +++ b/views/wishlist.pug @@ -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