Image support

This commit is contained in:
Wingy 2020-11-02 17:43:57 -05:00
parent b62ac06bd1
commit 96588d0690
3 changed files with 22 additions and 6 deletions

View file

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

View file

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

View file

@ -17,6 +17,7 @@ block content
.box .box
table.table.has-mobile-cards table.table.has-mobile-cards
thead thead
th(style='width: 15%;') Image
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(style='width: 10%;') Price
@ -32,6 +33,9 @@ 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
tr(id=item.id) tr(id=item.id)
td
figure(style='width: 100%; margin: 0;')
img(src=item.image, style='width: 100%;')
if item.url if item.url
td.ugc(data-label='Name') td.ugc(data-label='Name')
a( a(
@ -127,11 +131,18 @@ block content
else else
span= item.name span= item.name
hr hr
if item.note if item.note || item.image
textarea.textarea.has-fixed-size( .columns
rows=String(config.wishlist.note.rows), if item.image
readonly .column
)= item.note 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} span.overflowWrap Added by: #{item.addedBy}
hr hr
div div