sort entries, add email mailto link
This commit is contained in:
parent
9eb34fd46a
commit
e4cdc78e1f
|
@ -16,17 +16,21 @@ async function handler(req, res, next) {
|
||||||
|
|
||||||
const errors = req.query.error;
|
const errors = req.query.error;
|
||||||
|
|
||||||
let data = {};
|
|
||||||
let sqldata = await Sequelize.Guestbook.findAll({
|
let sqldata = await Sequelize.Guestbook.findAll({
|
||||||
where: {
|
where: {
|
||||||
hidden: false
|
hidden: false
|
||||||
}
|
},
|
||||||
|
order: [
|
||||||
|
['id', 'DESC']
|
||||||
|
]
|
||||||
});
|
});
|
||||||
if (!sqldata) throw new Error('Failed to get guestbook entries');
|
if (!sqldata) throw new Error('Failed to get guestbook entries');
|
||||||
|
|
||||||
for (let i = 0; i != sqldata.length; i++) {
|
/*for (let i = 0; i != sqldata.length; i++) {
|
||||||
data[sqldata[i].id] = sqldata[i];
|
data[sqldata[i].id] = sqldata[i];
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
const data = sqldata;
|
||||||
|
|
||||||
res.send(await Helpers.ViewLoader.load('guestbook.pug', {
|
res.send(await Helpers.ViewLoader.load('guestbook.pug', {
|
||||||
current_route: req.originalUrl,
|
current_route: req.originalUrl,
|
||||||
|
|
|
@ -86,7 +86,7 @@ block content
|
||||||
p No records available.
|
p No records available.
|
||||||
else
|
else
|
||||||
table(class='gb_entries')
|
table(class='gb_entries')
|
||||||
each entry, id in data
|
each entry, i in data
|
||||||
tr(id='gb_entry_' + id)
|
tr(id='gb_entry_' + id)
|
||||||
td(width='20%' class='gb_sender_data')
|
td(width='20%' class='gb_sender_data')
|
||||||
p(style='font-size:9pt')
|
p(style='font-size:9pt')
|
||||||
|
@ -96,7 +96,8 @@ block content
|
||||||
| Sender: #{entry.name}
|
| Sender: #{entry.name}
|
||||||
br
|
br
|
||||||
if (!entry.hidemail)
|
if (!entry.hidemail)
|
||||||
| Email: #{entry.email}
|
| Email:
|
||||||
|
a(href='mailto:' + entry.email)= entry.email
|
||||||
else
|
else
|
||||||
| Email:
|
| Email:
|
||||||
span(class='gb_hidden_mail' style='width:' + (10 * entry.email.length) + 'px')
|
span(class='gb_hidden_mail' style='width:' + (10 * entry.email.length) + 'px')
|
||||||
|
|
Loading…
Reference in New Issue