From 96588d06905988ef687989451cb5b07351ddb3ac Mon Sep 17 00:00:00 2001 From: Wingy Date: Mon, 2 Nov 2020 17:43:57 -0500 Subject: [PATCH] Image support --- routes/wishlist/index.js | 2 +- views/note.pug | 5 +++++ views/wishlist.pug | 21 ++++++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/routes/wishlist/index.js b/routes/wishlist/index.js index 12b661e..fbaf59e 100644 --- a/routes/wishlist/index.js +++ b/routes/wishlist/index.js @@ -206,7 +206,7 @@ module.exports = (db) => { return res.redirect(`/wishlist/${req.params.user}`); } for (const type of [ - 'name', 'note', 'url', 'price' + 'name', 'note', 'url', 'price', 'image' ]) { if (!req.body.hasOwnProperty(type)) { req.flash('error', `Missing property ${type}`) diff --git a/views/note.pug b/views/note.pug index a13ec2f..f25226d 100644 --- a/views/note.pug +++ b/views/note.pug @@ -19,6 +19,11 @@ block content label.label Price .control input.input(name='price', value=item.price) + .column + .field + label.label Image URL + .control + input.input(name='image', value=item.image) .field label.label Note .control diff --git a/views/wishlist.pug b/views/wishlist.pug index 3057764..3d259be 100644 --- a/views/wishlist.pug +++ b/views/wishlist.pug @@ -17,6 +17,7 @@ block content .box table.table.has-mobile-cards thead + th(style='width: 15%;') Image th(style='width: 25%;') Name th(style='width: 50%;') Note th(style='width: 10%;') Price @@ -32,6 +33,9 @@ block content each item, index in wishlist if req.user._id === item.addedBy || req.params.user !== req.user._id tr(id=item.id) + td + figure(style='width: 100%; margin: 0;') + img(src=item.image, style='width: 100%;') if item.url td.ugc(data-label='Name') a( @@ -127,11 +131,18 @@ block content else span= item.name hr - if item.note - textarea.textarea.has-fixed-size( - rows=String(config.wishlist.note.rows), - readonly - )= item.note + if item.note || item.image + .columns + if item.image + .column + figure(style='width: 100%; padding: 2em;') + img(src=item.image, style='width: 100%;') + .column.is-three-quarters + if item.note + textarea.textarea.has-fixed-size( + style='height: 100%;' + readonly + )= item.note span.overflowWrap Added by: #{item.addedBy} hr div