diff --git a/routes/wishlist/index.js b/routes/wishlist/index.js index 567c46f..5c9b086 100644 --- a/routes/wishlist/index.js +++ b/routes/wishlist/index.js @@ -193,8 +193,10 @@ module.exports = (db) => { req.flash('error', 'Invalid user'); return res.redirect(`/wishlist/${req.params.user}`); } - wishlistItem.note = req.body.note; - wishlist[i] = wishlistItem; + wishlistItem.name = req.body.name; + wishlistItem.note = req.body.note; + wishlistItem.url = req.body.url; + wishlist[i] = wishlistItem; } doc.wishlist = wishlist; await db.put(doc); diff --git a/views/note.pug b/views/note.pug index ca8611e..07dfe30 100644 --- a/views/note.pug +++ b/views/note.pug @@ -3,17 +3,23 @@ extends layout.pug block content a(href='..') Back to #{req.params.user}'s wishlist form.inline(method='POST', action=`/wishlist/${req.params.user}/note/${req.params.id}`) + .columns + .column + .field + label.label Name + .control + input.input(name='name', value=req.query.name) + .column + .field + label.label URL + .control + input.input(name='url', value=req.query.url) .field label.label Note .control textarea.textarea( name='note' - )= req.query.current + )= req.query.note .field.inline .control.inline - input.button.is-primary(type='submit' value='Save Note') - if req.query.current - form.inline(method='POST', style='margin-left: 1em;') - .field.inline - .control.inline - input.button.is-danger(type='submit', value='Delete Note') \ No newline at end of file + input.button.is-primary(type='submit' value='Save Item') \ No newline at end of file diff --git a/views/wishlist.pug b/views/wishlist.pug index 30ece15..a15c17e 100644 --- a/views/wishlist.pug +++ b/views/wishlist.pug @@ -8,7 +8,7 @@ block content thead th(style='width: 25%;') Name th(style='width: 50%;') Note - th Edit Note + th Edit Item th Added By if req.params.user === req.user._id th Move Up @@ -30,9 +30,11 @@ block content else td.ugc(data-label='Name')= item.name td.ugc(data-label='Note')= item.note - td(data-label='Edit Note') + td(data-label='Edit Item') form.inline(method='GET', action=`/wishlist/${req.params.user}/note/${item.id}`) - input(type='hidden', name='current', value=item.note) + input(type='hidden', name='name', value=item.name) + input(type='hidden', name='note', value=item.note) + input(type='hidden', name='url', value=item.url) .field.inline .control.inline button.button.is-text( @@ -133,16 +135,13 @@ block content .control.inline input.inline.button.is-warning(type='submit' value='Remove') if req.user._id === req.params.user || req.user._id === item.addedBy - if (item.note) - form.inline(method='POST', action=`/wishlist/${req.params.user}/note/remove/${item.id}`) - .field.inline - .control.inline - input.inline.button.is-warning(type='submit', value='Remove note') - else - form.inline(method='GET', action=`/wishlist/${req.params.user}/note/${item.id}`) - .field.inline - .control.inline - input.inline.button(type='submit', value='Add note') + form.inline(method='GET', action=`/wishlist/${req.params.user}/note/${item.id}`) + input(type='hidden', name='name', value=item.name) + input(type='hidden', name='note', value=item.note) + input(type='hidden', name='url', value=item.url) + .field.inline + .control.inline + input.inline.button(type='submit', value='Edit item') if index !== firstCanSee && req.user._id === req.params.user form.inline(method='POST', action=`/wishlist/${req.params.user}/move/up/${item.id}`) .field.inline