Added functionality to permenently delete or restore deleted organisations

This commit is contained in:
2022-02-10 15:52:57 +00:00
parent c3cf97ea50
commit 57dfed304f
10 changed files with 603 additions and 17 deletions

View File

@@ -0,0 +1,17 @@
{% extends "modals/modal.html.twig" %}
{% block modal_title %}{{translate("ORGANISATION.PERMENENT_DELETE")}}{% endblock %}
{% block modal_body %}
<form class="js-form" method="delete" action="{{site.uri.public}}/{{form.action}}">
{% include "forms/csrf.html.twig" %}
<div class="js-form-alerts">
</div>
<h4>{{translate("ORGANISATION.PERMENENT_DELETE_CONFIRM", {name: organisation.name})}}<br><small>{{translate("ACTION_CANNOT_UNDONE")}}</small></h4>
<br>
<div class="btn-group-action">
<button type="submit" class="btn btn-danger btn-lg btn-block">{{translate("ORGANISATION.PERMENENT_DELETE_YES")}}</button>
<button type="button" class="btn btn-default btn-lg btn-block" data-dismiss="modal">{{translate("CANCEL")}}</button>
</div>
</form>
{% endblock %}

View File

@@ -0,0 +1,50 @@
{% extends "pages/abstract/dashboard.html.twig" %}
{% block stylesheets_page %}
<!-- Page-specific CSS asset bundle -->
{{ assets.css('css/form-widgets') | raw }}
{% endblock %}
{# Overrides blocks in head of base template #}
{% block page_title %}{{ translate("DELETED") }} {{ translate("ORGANISATION", 2) }}{% endblock %}
{% block page_description %}{{ translate("ORGANISATION.DELETED_PAGE_DESCRIPTION") }}{% endblock %}
{% block body_matter %}
<div class="row">
<div class="col-md-12">
<div id="widget-deleted-organisations" class="box box-primary">
<div class="box-header">
<h3 class="box-title"><i class="fas fa-fw fa-sitemap"></i> {{ translate("DELETED") }} {{translate('ORGANISATION', 2)}}</h3>
{% include "tables/table-tool-menu.html.twig" %}
</div>
<div class="box-body">
{% include "tables/deleted-organisations.html.twig" with {
"table" : {
"id" : "table-organisations"
}
}
%}
</div>
<div class="box-footer">
<button type="button" class="btn btn-success js-organisation-return">
<i class="fas fa-arrow-left"></i> {{translate("RETURN")}}
</button>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts_page %}
<!-- Include validation rules -->
<script>
{% include "pages/partials/page.js.twig" %}
</script>
<!-- Include form widgets JS -->
{{ assets.js('js/form-widgets') | raw }}
<!-- Include page-specific JS -->
{{ assets.js('js/pages/organisations') | raw }}
{% endblock %}

View File

@@ -31,8 +31,10 @@
<button type="button" class="btn btn-success js-organisation-create">
<i class="fas fa-plus-square"></i> {{translate("ORGANISATION.CREATE")}}
</button>
{% endif %}
{% if checkAccess('register_organisation') %}
<button type="button" class="btn btn-danger js-organisation-viewDeleted">
<i class="fas fa-minus-square"></i> {{translate("VIEW_DELETED")}}
</button>
{% elseif checkAccess('register_organisation') %}
<button type="button" class="btn btn-success js-organisation-register">
<i class="fas fa-plus-square"></i> {{translate("ORGANISATION.REGISTER")}}
</button>

View File

@@ -0,0 +1,104 @@
{# This partial template renders a table of organisations, to be populated with rows via an AJAX request.
# This extends a generic template for paginated tables.
#
# Note that this template contains a "skeleton" table with an empty table body, and then a block of Handlebars templates which are used
# to render the table cells with the data from the AJAX request.
#}
{% extends "tables/table-paginated.html.twig" %}
{% block table %}
<table id="{{table.id}}" class="tablesorter table table-bordered table-hover table-striped" data-sortlist="{{table.sortlist}}">
<thead>
<tr>
<th class="sorter-metatext" data-column-name="name" data-column-template="#organisation-table-column-info" data-priority="1">{{translate('ORGANISATION')}} <i class="fas fa-sort"></i></th>
<th class="sorter-metatext" data-column-name="description" data-column-template="#organisation-table-column-description" data-priority="2">{{translate("DESCRIPTION")}} <i class="fas fa-sort"></i></th>
<th class="filter-select filter-metatext" data-column-name="status" data-column-template="#user-table-column-status" data-priority="2">{{translate("STATUS")}} <i class="fas fa-sort"></i></th>
<th class="sorter-metanum" data-column-name="member_count" data-column-template="#organisation-table-column-memberCount" data-priority="2">{{translate("ORGANISATION.MEMBER_COUNT")}} <i class="fas fa-sort"></i></th>
<th class="sorter-metanum" data-column-name="admin_count" data-column-template="#organisation-table-column-adminCount" data-priority="2">{{translate("ORGANISATION.ADMIN_COUNT")}} <i class="fas fa-sort"></i></th>
<th data-column-template="#organisation-table-column-actions" data-sorter="false" data-filter="false" data-priority="1">{{translate("ACTIONS")}}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
{% endblock %}
{% block table_cell_templates %}
{# This contains a series of <script> blocks, each of which is a client-side Handlebars template.
# Note that these are NOT Twig templates, although the syntax is similar. We wrap them in the `verbatim` tag,
# so that Twig will output them directly into the DOM instead of trying to treat them like Twig templates.
#
# These templates require handlebars-helpers.js, moment.js
#}
{% verbatim %}
<script id="organisation-table-column-info" type="text/x-handlebars-template">
<td data-text="{{row.name}}">
<strong>
<a href="{{site.uri.public}}/organisations/o/{{row.slug}}">{{row.name}}</a>
</strong>
</td>
</script>
<script id="organisation-table-column-description" type="text/x-handlebars-template">
<td>
{{row.description}}
</td>
</script>
<script id="user-table-column-status" type="text/x-handlebars-template">
<td
{{#ifx row.flag_approved '==' 1 }}
data-text="approved"
{{ else }}
data-text="pending"
{{/ifx }}
>
{{#ifx row.flag_approved '==' 1 }}
<span>
{% endverbatim %}{{translate("APPROVED")}}{% verbatim %}
</span>
{{ else }}
<span class="text-danger">
{% endverbatim %}{{translate("PENDING")}}{% verbatim %}
</span>
{{/ifx }}
</td>
</script>
<script id="organisation-table-column-memberCount" type="text/x-handlebars-template">
<td>
{{row.member_count}}
</td>
</script>
<script id="organisation-table-column-adminCount" type="text/x-handlebars-template">
<td>
{{row.admin_count}}
</td>
</script>
<script id="organisation-table-column-actions" type="text/x-handlebars-template">
<td>
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
{% endverbatim %}{{translate("ACTIONS")}}{% verbatim %}
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right" role="menu">
<li>
<a href="#" data-slug="{{row.slug}}" class="js-organisation-restore">
<i class="fas fa-trash-restore"></i> {% endverbatim %}{{translate("ORGANISATION.RESTORE_DELETED")}}{% verbatim %}
</a>
</li>
<li>
<a href="#" data-slug="{{row.slug}}" class="js-organisation-permenentDelete">
<i class="fas fa-trash-alt"></i> {% endverbatim %}{{translate("ORGANISATION.PERMENENT_DELETE")}}{% verbatim %}
</a>
</li>
</ul>
</div>
</td>
</script>
{% endverbatim %}
{% endblock %}