Replaced confirm pages with dynamic requests on the forum.

This commit is contained in:
flash 2024-12-18 03:07:48 +00:00
parent a8c777d725
commit 265e8f2d4b
18 changed files with 1159 additions and 437 deletions

View file

@ -1,24 +0,0 @@
{% extends 'master.twig' %}
{% from 'macros.twig' import container_title %}
{% from '_layout/input.twig' import input_csrf %}
{% set title = title|default('Confirm your action') %}
{% block content %}
<form action="{{ action|default('') }}" method="{{ method|default('post') }}" class="container confirm">
{{ container_title('<i class="' ~ class|default('fas fa-exclamation-circle') ~ ' fa-fw"></i> ' ~ title) }}
{{ input_csrf() }}
{% for name, value in params|default([]) %}
{% if value is not empty %}
<input type="hidden" name="{{ name }}" value="{{ value }}"/>
{% endif %}
{% endfor %}
<div class="confirm__message">
{{ message|default('Are you sure you w') }}
</div>
<div class="confirm__buttons">
<input type="submit" class="input__button confirm__button" value="Yes">
<a href="{{ return|default('/') }}" class="input__button confirm__button">No</a>
</div>
</form>
{% endblock %}

View file

@ -1,24 +0,0 @@
{% extends 'forum/master.twig' %}
{% from 'macros.twig' import container_title %}
{% from '_layout/input.twig' import input_csrf %}
{% set title = title|default('Confirm your action') %}
{% block content %}
<form action="" method="get" class="container forum__confirm">
{{ container_title('<i class="' ~ class|default('fas fa-exclamation-circle') ~ ' fa-fw"></i> ' ~ title) }}
{{ input_csrf('csrf') }}
{% for name, value in params %}
<input type="hidden" name="{{ name }}" value="{{ value }}">
{% endfor %}
<div class="forum__confirm__message">
{{ message|default('Are you sure you w') }}
</div>
<div class="forum__confirm__buttons">
<button name="confirm" value="1" class="input__button forum__confirm__button">Yes</button>
<button name="confirm" value="0" class="input__button forum__confirm__button">No</button>
</div>
</form>
{% endblock %}

View file

@ -10,10 +10,14 @@
{% block content %}
{{ forum_header(forum_info.name, forum_breadcrumbs, true, canonical_url, [
{
'html': '<i class="far fa-check-circle"></i> Mark as Read',
'url': url('forum-mark-single', {'forum': forum_info.id}),
'display': forum_show_mark_as_read,
'method': 'POST',
html: '<i class="far fa-check-circle"></i> <span class="js-action-text">Mark as Read</span>',
display: forum_show_mark_as_read,
method: 'POST',
url: url('forum-mark-as-read', { category: forum_info.id }),
disableWith: 'Marking as read...',
disableWithTarget: '.js-action-text',
withCsrf: true,
refreshOnSuccess: true,
}
]) }}

View file

@ -13,7 +13,7 @@
{% if forum_show_mark_as_read %}
<div class="container forum__actions">
<a href="{{ url('forum-mark-global') }}" class="input__button forum__actions__button">Mark All Read</a>
<button class="input__button forum__actions__button" type="button" data-method="POST" data-url="{{ url('forum-mark-as-read', { recursive: true }) }}" data-disable-with="Marking as read..." data-with-csrf="1" data-refresh-on-success="1">Mark All Read</button>
</div>
{% endif %}
{% else %}

View file

@ -71,7 +71,7 @@
<div class="forum__header__actions">
{% for action in actions %}
{% if action.display is not defined or action.display %}
<a class="forum__header__action{% if action.class is defined %}{{ action.class }}{% endif %}" href="{{ action.url }}">
<a class="{{ html_classes('forum__header__action', action.class|default('')) }}" {% if action.method is defined %}href="javascript:;" data-method="{{ action.method }}" data-url="{{ action.url }}"{% if action.disableWith is defined %} data-disable-with="{{ action.disableWith }}"{% endif %}{% if action.disableWithTarget is defined %} data-disable-with-target="{{ action.disableWithTarget }}"{% endif %}{% if action.withCsrf|default(false) %} data-with-csrf="1"{% endif %}{% if action.refreshOnSuccess|default(false) %} data-refresh-on-success="1"{% endif %}{% if action.redirectOnSuccess is defined and action.redirectOnSuccess is not empty %} data-redirect-on-success="{{ action.redirectOnSuccess }}"{% endif %}{% if action.confirm is defined %} data-confirm="{{ action.confirm }}"{% endif %}{% else %}href="{{ action.url }}"{% endif %}>
{{ action.html|raw }}
</a>
{% endif %}
@ -549,8 +549,8 @@
{% if perms.can_create_post|default(false) or can_edit or can_delete %}
<div class="forum__post__actions">
{% if post_is_deleted %}
<a href="{{ url('forum-post-restore', {'post': post_id}) }}" class="forum__post__action forum__post__action--restore"><i class="fas fa-magic fa-fw"></i> Restore</a>
<a href="{{ url('forum-post-nuke', {'post': post_id}) }}" class="forum__post__action forum__post__action--nuke"><i class="fas fa-radiation-alt fa-fw"></i> Permanently Delete</a>
<button class="forum__post__action forum__post__action--restore" data-method="POST" data-url="{{ url('forum-post-restore', {'post': post_id}) }}" data-refresh-on-success="1" data-with-csrf="1" data-disable-with="Restoring..." data-disable-with-target=".js-action-text" data-confirm="Are you sure you want to restore this post?"><i class="fas fa-magic fa-fw"></i> <span class="js-action-text">Restore</span></button>
<button class="forum__post__action forum__post__action--nuke" data-method="POST" data-url="{{ url('forum-post-nuke', {'post': post_id}) }}" data-redirect-on-success="{{ url('forum-topic', { topic: post.info.topicId }) }}" data-with-csrf="1" data-disable-with="Nuking..." data-disable-with-target=".js-action-text" data-confirm="Are you sure you want to PERMANENTLY DELETE this post?"><i class="fas fa-radiation-alt fa-fw"></i> <span class="js-action-text">Permanently Delete</span></button>
{% else %}
{# if perms.can_create_post|default(false) %}
<a href="{{ url('forum-post-quote', {'post': post_id}) }}" class="forum__post__action forum__post__action--quote"><i class="fas fa-quote-left fa-fw"></i> Quote</a>
@ -559,7 +559,7 @@
<a href="{{ url('forum-post-edit', {'post': post_id}) }}" class="forum__post__action forum__post__action--edit"><i class="fas fa-edit fa-fw"></i> Edit</a>
{% endif %}
{% if can_delete %}
<a href="{{ url('forum-post-delete', {'post': post_id}) }}" class="forum__post__action forum__post__action--delete"><i class="far fa-trash-alt fa-fw"></i> Delete</a>
<button class="forum__post__action forum__post__action--delete" data-method="DELETE" data-url="{{ url('forum-post-delete', {'post': post_id}) }}" data-redirect-on-success="{{ perms.can_delete_any_post ? url('forum-post', { post: post.info.id }) : url('forum-topic', { topic: post.info.topicId }) }}" data-with-csrf="1" data-disable-with="Deleting..." data-disable-with-target=".js-action-text" data-confirm="Are you sure you want to delete this post?"><i class="fas fa-trash-alt fa-fw"></i> <span class="js-action-text">Delete</span></button>
{% endif %}
{% endif %}
</div>

View file

@ -17,39 +17,71 @@
'page': topic_pagination.page > 1 ? topic_pagination.page : 0,
}) %}
{% set forum_post_csrf = csrf_token() %}
{% set topic_tools = forum_topic_tools(topic_info, topic_pagination, can_reply) %}
{% set topic_notice = forum_topic_locked(topic_info.lockedTime, category_info.archived) ~ forum_topic_redirect(topic_redir_info|default(null)) %}
{% set topic_actions = [
{
'html': '<i class="far fa-trash-alt fa-fw"></i> Delete',
'url': url('forum-topic-delete', { topic: topic_info.id, csrf: csrf_token() }),
'display': topic_can_delete,
html: '<i class="fas fa-trash-alt fa-fw"></i> <span class="js-action-text">Delete</span>',
display: topic_can_delete,
method: 'DELETE',
url: url('forum-topic-delete', { topic: topic_info.id }),
confirm: 'Are you sure you want to delete this topic?',
disableWith: 'Deleting...',
disableWithTarget: '.js-action-text',
withCsrf: true,
refreshOnSuccess: topic_can_delete_any,
redirectOnSuccess: (topic_can_delete_any ? false : url('forum-category', { forum: category_info.id })),
},
{
'html': '<i class="fas fa-magic fa-fw"></i> Restore',
'url': url('forum-topic-restore', { topic: topic_info.id, csrf: csrf_token() }),
'display': topic_can_nuke_or_restore,
html: '<i class="fas fa-magic fa-fw"></i> <span class="js-action-text">Restore</span>',
display: topic_can_nuke_or_restore,
method: 'POST',
url: url('forum-topic-restore', { topic: topic_info.id }),
confirm: 'Are you sure you want to restore this topic?',
disableWith: 'Restoring...',
disableWithTarget: '.js-action-text',
withCsrf: true,
refreshOnSuccess: true,
},
{
'html': '<i class="fas fa-radiation-alt fa-fw"></i> Permanently Delete',
'url': url('forum-topic-nuke', { topic: topic_info.id, csrf: csrf_token() }),
'display': topic_can_nuke_or_restore,
html: '<i class="fas fa-radiation-alt fa-fw"></i> <span class="js-action-text">Permanently Delete</span>',
display: topic_can_nuke_or_restore,
method: 'POST',
url: url('forum-topic-nuke', { topic: topic_info.id }),
confirm: 'Are you sure you want to PERMANENTLY DELETE this topic?',
disableWith: 'Nuking...',
disableWithTarget: '.js-action-text',
withCsrf: true,
redirectOnSuccess: url('forum-category', { forum: category_info.id }),
},
{
'html': '<i class="fas fa-plus-circle fa-fw"></i> Bump',
'url': url('forum-topic-bump', { topic: topic_info.id, csrf: csrf_token() }),
'display': topic_can_bump,
html: '<i class="fas fa-arrow-alt-circle-up fa-fw"></i> <span class="js-action-text">Bump</span>',
display: topic_can_bump,
method: 'POST',
url: url('forum-topic-bump', { topic: topic_info.id }),
disableWith: 'Bumping...',
disableWithTarget: '.js-action-text',
withCsrf: true,
},
{
'html': '<i class="fas fa-lock fa-fw"></i> Lock',
'url': url('forum-topic-lock', { topic: topic_info.id, csrf: csrf_token() }),
'display': topic_can_lock and not topic_info.locked,
html: '<i class="fas fa-lock fa-fw"></i> <span class="js-action-text">Lock</span>',
display: topic_can_lock and not topic_info.locked,
method: 'POST',
url: url('forum-topic-lock', { topic: topic_info.id }),
disableWith: 'Locking...',
disableWithTarget: '.js-action-text',
withCsrf: true,
refreshOnSuccess: true,
},
{
'html': '<i class="fas fa-lock-open fa-fw"></i> Unlock',
'url': url('forum-topic-unlock', { topic: topic_info.id, csrf: csrf_token() }),
'display': topic_can_lock and topic_info.locked,
html: '<i class="fas fa-lock-open fa-fw"></i> <span class="js-action-text">Unlock</span>',
display: topic_can_lock and topic_info.locked,
method: 'POST',
url: url('forum-topic-unlock', { topic: topic_info.id }),
disableWith: 'Unlocking...',
disableWithTarget: '.js-action-text',
withCsrf: true,
refreshOnSuccess: true,
},
] %}