mirror of
https://github.com/flextype/flextype.git
synced 2025-08-17 02:24:05 +02:00
feat(admin-plugin): fix templates and partial delete confirmation
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{% extends "plugins/admin/templates/partials/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% if (templates_list | length > 0)
|
||||
{% if (templates_list | length > 0)
|
||||
or(partials_list | length > 0) %}
|
||||
<table class="table">
|
||||
<thead>
|
||||
@@ -28,10 +28,10 @@
|
||||
</td>
|
||||
<td>{{ tr('admin_template') }}</td>
|
||||
<td class="text-right">
|
||||
<button type="button" class="js-dropdown-btn" data-dropdown="dropdown-{{ template.basename }}-{{ theme }}">
|
||||
<button type="button" class="js-dropdown-btn" data-dropdown="dropdown-{{ template.basename }}">
|
||||
<i class="icon">{{ icon('fas fa-ellipsis-h') }}</i>
|
||||
</button>
|
||||
<div id="dropdown-{{ template.basename }}-{{ theme }}" class="dropdown">
|
||||
<div id="dropdown-{{ template.basename }}" class="dropdown">
|
||||
<a class="dropdown__item" href="{{ path_for('admin.templates.edit') }}?id={{ template.basename }}&type=template&theme={{ theme }}">
|
||||
<i class="icon icon--white mr-3">{{ icon('fas fa-edit') }}</i>
|
||||
{{ tr('admin_edit') }}</a>
|
||||
@@ -44,7 +44,7 @@
|
||||
{{ tr('admin_duplicate') }}</a>
|
||||
<div class="dropdown__divider"></div>
|
||||
<a class="dropdown__item" href="javascript:;" onclick="event.preventDefault();
|
||||
document.getElementById('delete-template-id-{{ template.basename }}').submit();">
|
||||
deleteTemplate('{{ template.basename }}', {{ loop.index0 }});">
|
||||
<i class="icon icon--white mr-3">{{ icon('fas fa-trash-alt') }}</i>
|
||||
{{ tr('admin_delete') }}</a>
|
||||
<form id="duplicate-template-id-{{ template.basename }}" action="{{ path_for('admin.templates.duplicateProcess') }}" method="POST" style="display: none;">
|
||||
@@ -75,10 +75,10 @@
|
||||
</td>
|
||||
<td>{{ tr('admin_partial') }}</td>
|
||||
<td class="text-right">
|
||||
<button type="button" class="js-dropdown-btn" data-dropdown="dropdown-{{ template.basename }}-{{ theme }}">
|
||||
<button type="button" class="js-dropdown-btn" data-dropdown="dropdown-{{ partial.basename }}">
|
||||
<i class="icon">{{ icon('fas fa-ellipsis-h') }}</i>
|
||||
</button>
|
||||
<div id="dropdown-{{ template.basename }}-{{ theme }}" class="dropdown">
|
||||
<div id="dropdown-{{ partial.basename }}" class="dropdown">
|
||||
<a class="dropdown__item" href="{{ path_for('admin.templates.edit') }}?id={{ partial.basename }}&type=partial&theme={{ theme }}">
|
||||
<i class="icon icon--white mr-3">{{ icon('fas fa-edit') }}</i>
|
||||
{{ tr('admin_edit') }}</a>
|
||||
@@ -91,7 +91,7 @@
|
||||
{{ tr('admin_duplicate') }}</a>
|
||||
<div class="dropdown__divider"></div>
|
||||
<a class="dropdown__item" href="javascript:;" onclick="event.preventDefault();
|
||||
document.getElementById('delete-partial-id-{{ partial.basename }}').submit();">
|
||||
deletePartial('{{ partial.basename }}', {{ loop.index0 }});">
|
||||
<i class="icon icon--white mr-3">{{ icon('fas fa-trash-alt') }}</i>
|
||||
{{ tr('admin_delete') }}</a>
|
||||
<form id="duplicate-partial-id-{{ partial.basename }}" action="{{ path_for('admin.templates.duplicateProcess') }}" method="POST" style="display: none;">
|
||||
@@ -122,4 +122,39 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block tail %}
|
||||
<script>
|
||||
function deleteTemplate(id, row_num) {
|
||||
if (dropdown.length > 0) {
|
||||
for (let i = 0; i < dropdown.length; i++) {
|
||||
dropdown[i].hide();
|
||||
}
|
||||
}
|
||||
Swal.fire(
|
||||
{title: "{{ tr('admin_confirmation_required') }}", text: "{{ tr('admin_confirmation_required_for_template_delete') }}", showCancelButton: true, confirmButtonText: "{{ tr('admin_yes_iam_sure')|raw }}", cancelButtonText: "{{ tr('admin_cancel') }}", reverseButtons: true}
|
||||
).then((result) => {
|
||||
if (result.value) {
|
||||
document.getElementById('delete-template-id-' + id).submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deletePartial(id, row_num) {
|
||||
if (dropdown.length > 0) {
|
||||
for (let i = 0; i < dropdown.length; i++) {
|
||||
dropdown[i].hide();
|
||||
}
|
||||
}
|
||||
Swal.fire(
|
||||
{title: "{{ tr('admin_confirmation_required') }}", text: "{{ tr('admin_confirmation_required_for_partial_delete') }}", showCancelButton: true, confirmButtonText: "{{ tr('admin_yes_iam_sure')|raw }}", cancelButtonText: "{{ tr('admin_cancel') }}", reverseButtons: true}
|
||||
).then((result) => {
|
||||
if (result.value) {
|
||||
document.getElementById('delete-partial-id-' + id).submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user