christmas/views/wishlist.pug

196 lines
8.3 KiB
Text
Raw Normal View History

2018-11-20 11:19:58 -08:00
extends layout.pug
2019-11-18 12:53:21 -08:00
block title
h1
.level
.level-left
.level-item
2019-11-18 13:03:20 -08:00
button.button.is-rounded(onclick='this.firstChild.firstChild.classList.add("fa-pulse"); location.reload()')
2019-11-18 12:53:21 -08:00
span.icon
i.fas.fa-sync-alt
.level-item
span #{config.siteTitle} - #{title}
2018-11-20 11:19:58 -08:00
block content
script(type='data/user_id')= req.user._id
2019-11-16 20:34:04 -08:00
if process.env.TABLE !== 'false'
.box
table.table.has-mobile-cards
thead
2019-11-17 17:14:22 -08:00
th(style='width: 25%;') Name
th(style='width: 50%;') Note
2019-11-18 12:07:57 -08:00
th Edit Item
2019-11-17 04:54:43 -08:00
th Added By
if req.params.user === req.user._id
th Move Up
th Move Down
else
th Pledge
th Delete
tbody
each item, index in wishlist
if req.user._id === item.addedBy || req.params.user !== req.user._id
2019-11-17 15:05:45 -08:00
tr(id=item.id)
if item.url
2019-11-17 06:05:10 -08:00
td.ugc(data-label='Name')
a(
href=item.url,
rel='noopener noreferrer',
target='_blank'
)= (item.name ? item.name : item.url)
else
td.ugc(data-label='Name')= item.name
td.ugc(data-label='Note')= item.note
2019-11-18 12:07:57 -08:00
td(data-label='Edit Item')
2020-10-29 11:14:38 -07:00
form.inline(method='GET', action=`${_CC.config.base}wishlist/${req.params.user}/note/${item.id}`)
2019-11-17 04:20:04 -08:00
.field.inline
.control.inline
button.button.is-text(
type='submit',
style='text-decoration: none;'
disabled=item.addedBy !== req.user._id
2019-11-17 04:20:04 -08:00
)
span.icon
i.far.fa-edit
2019-11-17 04:54:43 -08:00
td.ugc(data-label='Added By')= item.addedBy
if req.params.user === req.user._id
td(data-label='Move Item Up')
2020-10-29 11:14:38 -07:00
form.upForm.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/move/up/${item.id}`)
.field.inline
.control.inline
button.button.is-text(
type='submit',
style='text-decoration: none;',
disabled=index === firstCanSee
)
span.icon
i.fas.fa-arrow-up
td(data-label='Move Item Down')
2020-10-29 11:14:38 -07:00
form.downForm.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/move/down/${item.id}`)
.field.inline
.control.inline
button.button.is-text(
type='submit',
style='text-decoration: none;',
disabled=index === lastCanSee
)
span.icon
i.fas.fa-arrow-down
else
td(data-label='Pledge')
if req.params.user !== req.user._id && !item.pledgedBy
2020-10-29 11:14:38 -07:00
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/pledge/${item.id}`)
.field.inline
.control.inline
input.inline.button.is-primary(type='submit' value='Pledge')
if item.pledgedBy === req.user._id
2020-10-29 11:14:38 -07:00
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/unpledge/${item.id}`)
.field.inline
.control.inline
input.inline.button(type='submit' value='Unpledge')
2019-11-17 04:54:43 -08:00
if item.pledgedBy && item.pledgedBy !== req.user._id
span.ugc Pledged for by #{item.pledgedBy}
td(data-label='Delete Item')
2019-11-17 05:12:00 -08:00
form.inline(
method='POST',
2020-10-29 11:14:38 -07:00
action=`${_CC.config.base}wishlist/${req.params.user}/${req.user._id === req.params.user ? 'remove' : 'unpledge'}/${item.id}`
2019-11-17 05:12:00 -08:00
)
2019-11-17 04:20:04 -08:00
.field.inline
.control.inline
button.button.is-text(
type='submit',
style='text-decoration: none;',
disabled=item.addedBy !== req.user._id
2019-11-17 04:20:04 -08:00
)
span.icon
i.fas.fa-trash
2019-11-16 20:34:04 -08:00
else
each item, index in wishlist
if req.user._id === item.addedBy || req.params.user !== req.user._id
.box
span.overflowWrap
if item.url
a(
href=item.url,
rel='noopener noreferrer',
target='_blank'
)= (item.name ? item.name : item.url)
else
2019-11-16 20:34:04 -08:00
span= item.name
hr
if item.note
textarea.textarea.has-fixed-size(
rows=String(config.wishlist.note.rows),
readonly
)= item.note
span.overflowWrap Added by: #{item.addedBy}
hr
div
if req.params.user !== req.user._id && !item.pledgedBy
2020-10-29 11:14:38 -07:00
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/pledge/${item.id}`)
2018-11-30 13:44:06 -08:00
.field.inline
.control.inline
2019-11-16 20:34:04 -08:00
input.inline.button.is-primary(type='submit' value='Pledge')
if item.pledgedBy === req.user._id
2020-10-29 11:14:38 -07:00
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/unpledge/${item.id}`)
2018-11-30 13:44:06 -08:00
.field.inline
.control.inline
2019-11-16 20:34:04 -08:00
input.inline.button(type='submit' value='Unpledge')
if req.user._id === req.params.user
2020-10-29 11:14:38 -07:00
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/remove/${item.id}`)
2018-11-30 13:44:06 -08:00
.field.inline
.control.inline
2019-11-16 20:34:04 -08:00
input.inline.button.is-warning(type='submit' value='Remove')
if req.user._id === req.params.user || req.user._id === item.addedBy
2020-10-29 11:14:38 -07:00
form.inline(method='GET', action=`${_CC.config.base}wishlist/${req.params.user}/note/${item.id}`)
2019-11-18 12:07:57 -08:00
.field.inline
.control.inline
input.inline.button(type='submit', value='Edit item')
2019-11-16 20:34:04 -08:00
if index !== firstCanSee && req.user._id === req.params.user
2020-10-29 11:14:38 -07:00
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/move/up/${item.id}`)
2019-11-16 20:34:04 -08:00
.field.inline
.control.inline
input.inline.button(type='submit' value='Move item up')
if index !== lastCanSee && req.user._id === req.params.user
2020-10-29 11:14:38 -07:00
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/move/down/${item.id}`)
2019-11-16 20:34:04 -08:00
.field.inline
.control.inline
input.inline.button(type='submit' value='Move item down')
2018-11-20 11:19:58 -08:00
form(method='POST')
.field
label.label Item URL or Name
.control.has-icons-left
2018-11-30 13:44:06 -08:00
input.input(
type='text',
name='itemUrlOrName',
placeholder='https://www.amazon.com/dp/B00ZV9RDKK'
)
2018-11-20 11:19:58 -08:00
span.icon.is-small.is-left
i.fas.fa-gift
2018-11-30 13:44:06 -08:00
.field
label.label Note
2018-11-30 13:55:55 -08:00
.control
2018-11-30 13:44:06 -08:00
textarea.textarea(
name='note',
placeholder='Optional'
)
2018-11-20 11:19:58 -08:00
.field
.control
2019-11-17 06:05:10 -08:00
input.button(type='submit' value=(req.user._id === req.params.user ? 'Add item to wishlist' : 'Pledge item'))
2020-10-29 11:14:38 -07:00
script(src=`${_CC.config.base}js/wishlist.js`)
2019-12-03 13:42:51 -08:00
block print
h1 #{req.params.user}'s Wishlist
2019-12-03 14:15:26 -08:00
.print-gifts
each item, index in wishlist.filter(item => item.addedBy === req.params.user)
.print-gift(style='page-break-inside: avoid;')
2019-12-03 14:33:20 -08:00
if index > 0
hr(style='margin-top: .5em; margin-bottom: .5em; background-color: black;')
2019-12-03 14:22:37 -08:00
span.is-size-6.ugc= item.name
2019-12-03 14:15:26 -08:00
span= ' '
2019-12-03 14:22:37 -08:00
span.ugc.has-text-grey= item.url
span.is-block Added by: #{item.addedBy}
2019-12-03 14:15:26 -08:00
if item.note
.box
2019-12-03 14:22:37 -08:00
span.is-block.ugc= item.note