Added more confirmation dialogs to delete forms
This commit is contained in:
parent
ff179360cc
commit
93270a10fd
|
@ -316,7 +316,9 @@ ready(() => {
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="${element.className}"
|
||||
title="${element.title}" data-submit="">${element.innerHTML}</button>
|
||||
title="${element.title}" data-submit="">
|
||||
${element.dataset.confirm_button_text ?? element.innerHTML}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<div class="btn-group">
|
||||
{{ f.submit(__('form.save'), {'icon_left': 'save'}) }}
|
||||
{% if location %}
|
||||
{{ f.submit(__('form.delete'), {'name': 'delete', 'btn_type': 'danger', 'icon_left': 'trash'}) }}
|
||||
{{ f.delete(__('form.delete'), {'confirm_title': location.name|e}) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -265,6 +265,8 @@ Renders a button.
|
|||
@param {string} [opt.confirm_text] - Optional value for the confirmation text.
|
||||
#}
|
||||
{% macro button(label, opt) %}
|
||||
{%- set icon_left = opt.icon_left is defined ? '<span class="bi bi-' ~ opt.icon_left ~ '"></span>' : '' %}
|
||||
{%- set icon_right = opt.icon_right is defined ? '<span class="bi bi-' ~ opt.icon_right ~ '"></span>' : '' %}
|
||||
<button
|
||||
class="btn btn-{{ opt.btn_type|default('secondary') }}
|
||||
{%- if opt.size is defined %} btn-{{ opt.size }}{% endif %}"
|
||||
|
@ -274,10 +276,13 @@ Renders a button.
|
|||
{%- if opt.value is defined or opt.name is defined %} value="{{ opt.value|default('1') }}"{% endif -%}
|
||||
{%- if opt.confirm_title is defined %} data-confirm_submit_title="{{ opt.confirm_title }}"{% endif -%}
|
||||
{%- if opt.confirm_text is defined %} data-confirm_submit_text="{{ opt.confirm_text }}"{% endif -%}
|
||||
{%- if opt.confirm_button_text is defined %}
|
||||
data-confirm_button_text="{{ icon_left ~ ' ' ~ opt.confirm_button_text ~ ' ' ~ icon_right }}"
|
||||
{%- endif -%}
|
||||
>
|
||||
{%- if opt.icon_left is defined %}<span class="bi bi-{{ opt.icon_left }}"></span>{% endif %}
|
||||
{{ icon_left|raw }}
|
||||
{{ label }}
|
||||
{%- if opt.icon_right is defined %}<span class="bi bi-{{ opt.icon_right }}"></span>{% endif %}
|
||||
{{ icon_right|raw }}
|
||||
</button>
|
||||
{%- endmacro %}
|
||||
|
||||
|
|
|
@ -46,12 +46,12 @@
|
|||
'value': faq ? faq.text : '',
|
||||
}) }}
|
||||
|
||||
{{ f.submit() }}
|
||||
{{ f.submit(__('form.save'), {'icon_left': 'save'}) }}
|
||||
|
||||
{{ f.submit(m.icon('eye'), {'name': 'preview', 'btn_type': 'info', 'title': __('form.preview')}) }}
|
||||
|
||||
{% if faq and faq.id %}
|
||||
{{ f.submit(m.icon('trash'), {'name': 'delete', 'btn_type': 'danger', 'title': __('form.delete')}) }}
|
||||
{{ f.delete(__('form.delete'), {'confirm_title': faq.question[:40]|e})}}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -58,6 +58,18 @@
|
|||
<span class="ms-auto">
|
||||
{{ m.button(m.icon('pencil'), url('/admin/faq/' ~ item.id), 'secondary', 'sm') }}
|
||||
</span>
|
||||
|
||||
<form class="ps-1"
|
||||
action="{{ url('/admin/faq/' ~ item.id) }}"
|
||||
enctype="multipart/form-data"
|
||||
method="post">
|
||||
{{ csrf() }}
|
||||
{{ f.delete(null, {
|
||||
'size': 'sm',
|
||||
'confirm_title': item.question[:40]|e,
|
||||
'confirm_button_text': __('form.delete')
|
||||
}) }}
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -70,12 +70,12 @@
|
|||
|
||||
<p>{{ m.info(__('news.edit.hint')) }}</p>
|
||||
|
||||
{{ f.submit() }}
|
||||
{{ f.submit(__('form.save'), {'icon_left': 'save'}) }}
|
||||
|
||||
{{ f.submit(m.icon('eye'), {'name': 'preview', 'btn_type': 'info', 'title': __('form.preview')}) }}
|
||||
|
||||
{% if news and news.id %}
|
||||
{{ f.submit(m.icon('trash'), {'name': 'delete', 'btn_type': 'danger', 'title': __('form.delete')}) }}
|
||||
{{ f.delete(__('form.delete'), {'confirm_title': news.title[:40]|e}) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends 'layouts/app.twig' %}
|
||||
{% import 'macros/base.twig' as m %}
|
||||
{% import 'macros/form.twig' as f %}
|
||||
|
||||
{% set only_meetings = only_meetings|default(false) %}
|
||||
{% block title %}{{ not only_meetings ? __('news.title') : __('news.title.meetings') }}{% endblock %}
|
||||
|
@ -94,8 +95,19 @@
|
|||
{% endif %}
|
||||
|
||||
{% if has_permission_to('admin_news') %}
|
||||
<div>
|
||||
<div class="d-flex ms-auto">
|
||||
{{ m.button(m.icon('pencil'), url('/admin/news/' ~ news.id), 'secondary', 'sm') }}
|
||||
|
||||
<form class="ps-1"
|
||||
action="{{ url('/admin/news/' ~ news.id) }}" enctype="multipart/form-data"
|
||||
method="post">
|
||||
{{ csrf() }}
|
||||
{{ f.delete(null, {
|
||||
'size': 'sm',
|
||||
'confirm_title': news.title[:40]|e,
|
||||
'confirm_button_text': __('form.delete')
|
||||
}) }}
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -48,13 +48,11 @@
|
|||
}) }}
|
||||
{% endif %}
|
||||
|
||||
{{ f.submit() }}
|
||||
|
||||
{{ f.submit(__('form.save'), {'icon_left': 'save'}) }}
|
||||
{% if is_admin|default(false) %}
|
||||
{{ f.submit(m.icon('eye'), {'name': 'preview', 'btn_type': 'info', 'title': __('form.preview')}) }}
|
||||
|
||||
{% if question and question.id %}
|
||||
{{ f.submit(m.icon('trash'), {'name': 'delete', 'btn_type': 'danger', 'title': __('form.delete')}) }}
|
||||
{{ f.delete(__('form.delete'), {'confirm_title': question.text[:40]|e}) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -42,26 +42,21 @@
|
|||
|
||||
{% if has_permission_to('question.edit') %}
|
||||
{{ m.user(question.user, {'pronoun': true}) }}
|
||||
<div class="d-flex ms-auto">
|
||||
{% endif %}
|
||||
|
||||
{% if question.user.id == user.id or has_permission_to('question.edit') %}
|
||||
<form
|
||||
class="pe-1"
|
||||
action=""
|
||||
enctype="multipart/form-data"
|
||||
method="post"
|
||||
>
|
||||
{{ csrf() }}
|
||||
{{ f.hidden('id', question.id) }}
|
||||
{{ f.delete(null, {'size': 'sm', 'confirm_title': question.text[:40]|e}) }}
|
||||
</form>
|
||||
{% endif %}
|
||||
<div class="d-flex ms-auto">
|
||||
{% if has_permission_to('question.edit') %}
|
||||
{{ m.button(m.icon('pencil'), url('/admin/questions/' ~ question.id), null, 'sm') }}
|
||||
{% endif %}
|
||||
|
||||
{% if has_permission_to('question.edit') %}
|
||||
{{ m.button(m.icon('pencil'), url('/admin/questions/' ~ question.id), null, 'sm') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if question.user.id == user.id or has_permission_to('question.edit') %}
|
||||
<form class="ps-1" method="post" action="">
|
||||
{{ csrf() }}
|
||||
{{ f.hidden('id', question.id) }}
|
||||
{{ f.delete(null, {'size': 'sm', 'confirm_title': question.text[:40]|e, 'confirm_button_text': __('form.delete')}) }}
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
{{ csrf() }}
|
||||
{{ f.hidden('id', session.id[:15]) }}
|
||||
{{ f.submit(
|
||||
__('form.delete'),
|
||||
' ',
|
||||
{'name': 'delete', 'btn_type': 'danger', 'size': 'sm', 'icon_left': 'trash'}
|
||||
) }}
|
||||
</form>
|
||||
|
|
|
@ -46,14 +46,7 @@ class FaqController extends BaseController
|
|||
/** @var Faq $faq */
|
||||
$faq = $this->faq->findOrNew($faqId);
|
||||
|
||||
$data = $this->validate($request, [
|
||||
'question' => 'required',
|
||||
'text' => 'required',
|
||||
'delete' => 'optional|checked',
|
||||
'preview' => 'optional|checked',
|
||||
]);
|
||||
|
||||
if (!is_null($data['delete'])) {
|
||||
if ($request->request->has('delete')) {
|
||||
$faq->delete();
|
||||
|
||||
$this->log->info('Deleted faq "{question}"', ['question' => $faq->question]);
|
||||
|
@ -63,6 +56,13 @@ class FaqController extends BaseController
|
|||
return $this->redirect->to('/faq');
|
||||
}
|
||||
|
||||
$data = $this->validate($request, [
|
||||
'question' => 'required',
|
||||
'text' => 'required',
|
||||
'delete' => 'optional|checked',
|
||||
'preview' => 'optional|checked',
|
||||
]);
|
||||
|
||||
$faq->question = $data['question'];
|
||||
$faq->text = $data['text'];
|
||||
|
||||
|
|
|
@ -62,17 +62,7 @@ class NewsController extends BaseController
|
|||
/** @var News $news */
|
||||
$news = $this->news->findOrNew($newsId);
|
||||
|
||||
$data = $this->validate($request, [
|
||||
'title' => 'required',
|
||||
'text' => 'required',
|
||||
'is_meeting' => 'optional|checked',
|
||||
'is_pinned' => 'optional|checked',
|
||||
'is_highlighted' => 'optional|checked',
|
||||
'delete' => 'optional|checked',
|
||||
'preview' => 'optional|checked',
|
||||
]);
|
||||
|
||||
if (!is_null($data['delete'])) {
|
||||
if ($request->request->has('delete')) {
|
||||
$news->delete();
|
||||
|
||||
$this->log->info(
|
||||
|
@ -88,6 +78,16 @@ class NewsController extends BaseController
|
|||
return $this->redirect->to('/news');
|
||||
}
|
||||
|
||||
$data = $this->validate($request, [
|
||||
'title' => 'required',
|
||||
'text' => 'required',
|
||||
'is_meeting' => 'optional|checked',
|
||||
'is_pinned' => 'optional|checked',
|
||||
'is_highlighted' => 'optional|checked',
|
||||
'delete' => 'optional|checked',
|
||||
'preview' => 'optional|checked',
|
||||
]);
|
||||
|
||||
if (!$news->user) {
|
||||
$news->user()->associate($this->auth->user());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue