refactor note editing to avoid querystring
This commit is contained in:
parent
ac1c92746c
commit
0b6b9766bc
3 changed files with 7 additions and 11 deletions
|
@ -180,8 +180,10 @@ module.exports = (db) => {
|
|||
return res.redirect(`/wishlist/${req.params.user}`);
|
||||
});
|
||||
|
||||
router.get('/:user/note/:id', verifyAuth(), (_, res) => {
|
||||
res.render('note');
|
||||
router.get('/:user/note/:id', verifyAuth(), async (req, res) => {
|
||||
const doc = await db.get(req.params.user);
|
||||
const item = doc.wishlist.find(item => item.id === req.params.id)
|
||||
res.render('note', { item });
|
||||
});
|
||||
router.post('/:user/note/:id', verifyAuth(), async (req, res) => {
|
||||
const doc = await db.get(req.params.user);
|
||||
|
|
|
@ -8,18 +8,18 @@ block content
|
|||
.field
|
||||
label.label Name
|
||||
.control
|
||||
input.input(name='name', value=req.query.name)
|
||||
input.input(name='name', value=item.name)
|
||||
.column
|
||||
.field
|
||||
label.label URL
|
||||
.control
|
||||
input.input(name='url', value=req.query.url)
|
||||
input.input(name='url', value=item.url)
|
||||
.field
|
||||
label.label Note
|
||||
.control
|
||||
textarea.textarea(
|
||||
name='note'
|
||||
)= req.query.note
|
||||
)= item.note
|
||||
.field.inline
|
||||
.control.inline
|
||||
input.button.is-primary(type='submit' value='Save Item')
|
|
@ -32,9 +32,6 @@ block content
|
|||
td.ugc(data-label='Note')= item.note
|
||||
td(data-label='Edit Item')
|
||||
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
|
||||
button.button.is-text(
|
||||
|
@ -136,9 +133,6 @@ block content
|
|||
input.inline.button.is-warning(type='submit' value='Remove')
|
||||
if req.user._id === req.params.user || req.user._id === item.addedBy
|
||||
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')
|
||||
|
|
Loading…
Reference in a new issue