start of improving modals

merge-requests/208/head
fatchan 4 years ago
parent 766fbe3b8c
commit 6dc671998d
  1. 23
      gulp/res/js/forms.js
  2. 4
      helpers/checks/bancheck.js
  3. 4
      models/forms/makepost.js
  4. 33
      views/includes/banform.pug
  5. 18
      views/includes/managebanform.pug
  6. 2
      views/mixins/modal.pug
  7. 17
      views/pages/ban.pug
  8. 2
      views/pages/globalmanagebans.pug
  9. 2
      views/pages/managebans.pug

@ -6,6 +6,7 @@ function removeModal() {
function doModal(data) {
const modalHtml = modal({ modal: data });
document.body.insertAdjacentHTML('afterbegin', modalHtml);
new formHandler(document.getElementsByClassName('modal')[0].querySelector('form'));
document.getElementById('modalclose').onclick = removeModal;
document.getElementsByClassName('modal-bg')[0].onclick = removeModal;
}
@ -268,15 +269,6 @@ window.addEventListener('DOMContentLoaded', () => {
localStorage.removeItem('myPostId');
}
const forms = document.getElementsByTagName('form');
for(let i = 0; i < forms.length; i++) {
if (forms[i].method === 'post'
&& forms[i].encoding === 'multipart/form-data') {
//used only for file posting forms currently.
new formHandler(forms[i]);
}
}
window.addEventListener('addPost', (e) => {
if (e.detail.hover) {
return; //dont need to handle hovered posts for this
@ -287,3 +279,16 @@ window.addEventListener('DOMContentLoaded', () => {
});
});
window.addEventListener('settingsReady', () => {
const forms = document.getElementsByTagName('form');
for(let i = 0; i < forms.length; i++) {
if (forms[i].method === 'post'
&& forms[i].encoding === 'multipart/form-data') {
//used only for file posting forms currently.
new formHandler(forms[i]);
}
}
})

@ -11,13 +11,11 @@ module.exports = async (req, res, next) => {
const globalBans = bans.filter(ban => { return ban.board === null });
if (globalBans.length > 0 || (res.locals.permLevel >= 4 && globalBans.length !== bans.length)) {
//board staff bypass bans on their own board, but not global bans
const allowAppeal = bans.filter(ban => ban.allowAppeal === true && !ban.appeal).length > 0;
const unseenBans = bans.filter(b => !b.seen).map(b => b._id);
await Bans.markSeen(unseenBans); //mark bans as seen
bans.forEach(ban => ban.seen = true); //mark seen as true in memory for user viewed ban page
return res.status(403).render('ban', {
return dynamicResponse(req, res, 403, 'message', {
bans: bans,
allowAppeal
});
}
}

@ -138,7 +138,7 @@ module.exports = async (req, res, next) => {
};
await Bans.insertOne(ban);
const bans = await Bans.find(res.locals.ip.single, banBoard); //need to query db so it has _id field for appeal checkmark
return res.status(403).render('ban', {
return dynamicResponse(req, res, 403, 'ban', {
bans: bans
});
}
@ -453,7 +453,7 @@ module.exports = async (req, res, next) => {
if (cyclicOverflowPosts.length > 0) {
await deletePosts(cyclicOverflowPosts, req.params.board);
const fileCount = cyclicOverflowPosts.reduce((post, acc) => {
return acc + post.files.length;
return acc + (post.files ? post.files.length : 0);
}, 0);
//reduce amount counted in post by number of posts deleted
await Posts.db.updateOne({

@ -1,18 +1,17 @@
if bans.length === 0
p No bans.
else
input(type='hidden' name='_csrf' value=csrf)
include ../includes/bantable.pug
form.form-post(action=`/forms/appeal`, enctype='application/x-www-form-urlencoded', method='POST')
include ./bantable.pug
for ban in bans
+ban(ban)
.action-wrapper.mv-10
.row
label
input(type='radio' name='option' value='unban' checked='checked')
| Unban
.row
label
input(type='radio' name='option' value='deny_appeal')
| Deny Appeal
input(type='submit' value='submit')
+ban(ban, true)
- const allowAppeal = bans.filter(ban => ban.allowAppeal === true && !ban.appeal).length > 0;
if allowAppeal === true
h4.no-m-p Appeal bans:
.form-wrapper.flexleft.mt-10
input(type='hidden' name='_csrf' value=csrf)
.row
.label Message
textarea(rows='5' name='message' required)
.row
.label Captcha
span.col
include ./captcha.pug
input(type='submit', value='submit')

@ -0,0 +1,18 @@
if bans.length === 0
p No bans.
else
input(type='hidden' name='_csrf' value=csrf)
include ../includes/bantable.pug
for ban in bans
+ban(ban)
.action-wrapper.mv-10
.row
label
input(type='radio' name='option' value='unban' checked='checked')
| Unban
.row
label
input(type='radio' name='option' value='deny_appeal')
| Deny Appeal
input(type='submit' value='submit')

@ -20,6 +20,8 @@ mixin modal(data)
if data.link
.row
a(href=data.link.href target='_blank') #{data.link.text}
else if data.bans
include ../includes/banform.pug
else if data.settings
.row
.form-wrapper.flexleft.mt-10

@ -8,19 +8,4 @@ block head
block content
h1.board-title Banned!
h4.board-description Bans currently in place against your IP:
form.form-post(action=`/forms/appeal`, enctype='application/x-www-form-urlencoded', method='POST')
include ../includes/bantable.pug
for ban in bans
+ban(ban, true)
if allowAppeal === true
h4.no-m-p Appeal bans:
.form-wrapper.flexleft.mt-10
input(type='hidden' name='_csrf' value=csrf)
.row
.label Message
textarea(rows='5' name='message' required)
.row
.label Captcha
span.col
include ../includes/captcha.pug
input(type='submit', value='submit')
include ../includes/banform.pug

@ -13,4 +13,4 @@ block content
hr(size=1)
h4.no-m-p Global Bans & Appeals:
form(action=`/forms/global/editbans` method='POST' enctype='application/x-www-form-urlencoded')
include ../includes/banform.pug
include ../includes/managebanform.pug

@ -14,4 +14,4 @@ block content
hr(size=1)
h4.no-m-p Bans & Appeals:
form(action=`/forms/board/${board._id}/editbans` method='POST' enctype='application/x-www-form-urlencoded')
include ../includes/banform.pug
include ../includes/managebanform.pug

Loading…
Cancel
Save