christmas/views/wishlist.pug

227 lines
9.5 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
2020-12-01 19:09:25 -08:00
if global._CC.config.wishlist.table
.box
table.table.has-mobile-cards
thead
2020-11-02 14:43:57 -08:00
th(style='width: 15%;') Image
2019-11-17 17:14:22 -08:00
th(style='width: 25%;') Name
th(style='width: 50%;') Note
2020-11-01 19:01:30 -08:00
th(style='width: 10%;') Price
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)
2020-11-02 14:43:57 -08:00
td
figure(style='width: 100%; margin: 0;')
2020-11-30 18:23:59 -08:00
img(src=item.image, style='width: 100%; max-height: 20em; object-fit: contain;')
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
2020-12-01 19:09:25 -08:00
if _CC.config.wishlist.note.markdown
2020-12-02 09:18:17 -08:00
td.ugc(data-label='Note')
div!= item.note
2020-12-01 15:14:57 -08:00
else
td.ugc(data-label='Note')= item.note
2020-11-01 19:01:30 -08:00
td.ugc(data-label='Price')= item.price
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
2020-11-01 19:01:30 -08:00
if item.price
.tag
i.fas.fa-tag(style='margin-right: .5em;')
span= item.price
2019-11-16 20:34:04 -08:00
span.overflowWrap
2020-11-01 19:01:30 -08:00
if item.price
span= ' '
2019-11-16 20:34:04 -08:00
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
2020-11-02 14:43:57 -08:00
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
2019-11-16 20:34:04 -08:00
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
2020-11-05 14:42:24 -08:00
label.label Item URL or Name (<a href="/supported-sites">Supported Sites</a>)
2018-11-20 11:19:58 -08:00
.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;')
2020-11-01 19:01:30 -08:00
if item.price
.tag
i.fas.fa-tag(style='margin-right: .5em;')
span= item.price
span= ' '
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
2020-12-01 19:09:25 -08:00
if _CC.config.wishlist.note.markdown
2020-12-01 15:14:57 -08:00
span.is-block.ugc!= item.note
else
span.is-block.ugc= item.note