Files
sprinkle-organisations/templates/tables/organisations.html.twig
2022-02-21 16:13:28 +00:00

222 lines
10 KiB
Twig

{# 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>
{% if checkAccess('view_organisation_members') %}
<th class="sorter-metanum" data-column-name="member_count" data-column-template="#organisation-table-column-memberCount" data-priority="2" style="min-width: 180px">{{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>
{% endif %}
<th data-column-template="#organisation-table-column-join" data-column-name="join" data-sorter="false" data-filter="false" data-priority="3">{{translate("JOIN")}}/{{translate("LEAVE")}}</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 %}
{% block table_cell_template_info %}
{% verbatim %}
<script id="organisation-table-column-info" type="text/x-handlebars-template">
<td data-text="{{row.name}}">
<strong>
{{#ifx row.is_member '==' 1 }}
<a href="{{site.uri.public}}/organisations/o/{{row.slug}}">{{row.name}}</a>
{{ else }}
{% endverbatim %}{% if hasRole('organisations-admin') or hasRole('site-admin') %}{% verbatim %}
<a href="{{site.uri.public}}/organisations/o/{{row.slug}}">{{row.name}}</a>
{% endverbatim %}{% else %}{% verbatim %}
{{row.name}}
{% endverbatim %}{% endif %}{% verbatim %}
{{/ifx }}
</strong>
</td>
</script>
{% endverbatim %}
{% endblock %}
{% block table_cell_template_description %}
{% verbatim %}
<script id="organisation-table-column-description" type="text/x-handlebars-template">
<td>
{{row.description}}
</td>
</script>
{% endverbatim %}
{% endblock %}
{% block table_cell_template_status %}
{% verbatim %}
<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-yellow">
{% endverbatim %}{{translate("PENDING")}}{% verbatim %}
</span>
{{/ifx }}
</td>
</script>
{% endverbatim %}
{% endblock %}
{% block table_cell_template_memberCount %}
{% verbatim %}
<script id="organisation-table-column-memberCount" type="text/x-handlebars-template">
<td>
{{row.member_count}}
</td>
</script>
{% endverbatim %}
{% endblock %}
{% block table_cell_template_adminCount %}
{% verbatim %}
<script id="organisation-table-column-adminCount" type="text/x-handlebars-template">
<td>
{{row.admin_count}}
</td>
</script>
{% endverbatim %}
{% endblock %}
{% block table_cell_template_join %}
{% verbatim %}
<script id="organisation-table-column-join" type="text/x-handlebars-template">
<td>
<div class="btn-group">
{{#ifx row.is_pending '==' 1 }}
<button type="button" data-slug="{{row.slug}}" class="btn btn-danger js-organisation-cancelJoin" style="min-width: 70px">
{% endverbatim %}{{translate("CANCEL")}}{% verbatim %}
</button>
{{ else }}
{{#ifx row.is_member '==' 1 }}
<button type="button" data-slug="{{row.slug}}" class="btn btn-danger js-organisation-leave" style="min-width: 70px">
{% endverbatim %}{{translate("LEAVE")}}{% verbatim %}
</button>
{{ else }}
{% endverbatim %}{% if (organisationConfig.membership.single_membership == 0) or (current_user.organisations.count == 0) %}{% verbatim %}
<button type="button" data-slug="{{row.slug}}" class="btn btn-success js-organisation-join" style="min-width: 70px">
{% endverbatim %}{{translate("JOIN")}}{% verbatim %}
</button>
{% endverbatim %}{% endif %}{% verbatim %}
{{/ifx}}
{{/ifx}}
</div>
</td>
</script>
{% endverbatim %}
{% endblock %}
{% block table_cell_template_actions %}
{% if hasRole('site-admin') or hasRole('organisations-admin') %}
{% verbatim %}
<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">
{% endverbatim %}{% if checkAccess('update_organisation_field') %}{% verbatim %}
<li>
<a href="#" data-slug="{{row.slug}}" class="js-organisation-edit">
<i class="fas fa-edit"></i> {% endverbatim %}{{translate("ORGANISATION.EDIT")}}{% verbatim %}
</a>
</li>
{% endverbatim %}{% endif %}{% verbatim %}
{% endverbatim %}{% if checkAccess('merge_organisations') %}{% verbatim %}
<li>
<a href="#" data-slug="{{row.slug}}" class="js-organisation-merge">
<i class="fas fa-object-group"></i> {% endverbatim %}{{translate("ORGANISATION.MERGE")}}{% verbatim %}
</a>
</li>
{% endverbatim %}{% endif %}{% verbatim %}
{% endverbatim %}{% if checkAccess('approve_organisation') %}{% verbatim %}
{{#ifx row.flag_approved '==' 0 }}
<li>
<a href="#" data-slug="{{row.slug}}" class="js-organisation-approveRegistration">
<i class="fas fa-thumbs-up"></i> {% endverbatim %}{{translate("ORGANISATION.REGISTRATION.APPROVE")}}{% verbatim %}
</a>
</li>
<li>
<a href="#" data-slug="{{row.slug}}" class="js-organisation-denyRegistration">
<i class="fas fa-thumbs-down"></i> {% endverbatim %}{{translate("ORGANISATION.REGISTRATION.DENY")}}{% verbatim %}
</a>
</li>
{{/ifx }}
{% endverbatim %}{% endif %}{% verbatim %}
{% endverbatim %}{% if checkAccess('delete_organisation') %}{% verbatim %}
{{#ifx row.flag_approved '==' 1 }}
<li>
<a href="#" data-slug="{{row.slug}}" class="js-organisation-delete">
<i class="fas fa-trash-alt"></i> {% endverbatim %}{{translate("ORGANISATION.DELETE")}}{% verbatim %}
</a>
</li>
{{/ifx }}
{% endverbatim %}{% endif %}{% verbatim %}
</ul>
</div>
</td>
</script>
{% endverbatim %}
{% else %}
{% verbatim %}
<script id="organisation-table-column-actions" type="text/x-handlebars-template">
<td>
{{#ifx row.is_admin '==' 1 }}
<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-edit">
<i class="fas fa-edit"></i> {% endverbatim %}{{translate("ORGANISATION.EDIT")}}{% verbatim %}
</a>
</li>
{{#ifx row.flag_approved '==' 0 }}
{{#ifx row.registrant_id '==' {% endverbatim %}{{current_user.id}}{% verbatim %} }}
<li>
<a href="#" data-slug="{{row.slug}}" class="js-organisation-cancelRegistration">
<i class="fas fa-trash-alt"></i> {% endverbatim %}{{translate("ORGANISATION.REGISTRATION.CANCEL")}}{% verbatim %}
</a>
</li>
{{/ifx}}
{{/ifx}}
</ul>
</div>
{{/ifx }}
</td>
</script>
{% endverbatim %}
{% endif %}
{% endblock %}
{% block table_cell_template_extra %}{% endblock %}
{% endblock %}