Skip to content

Commit

Permalink
Improve deleted packages lists in trash
Browse files Browse the repository at this point in the history
  • Loading branch information
mjanez committed Oct 19, 2023
1 parent d9713f1 commit cdb0b9a
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
38 changes: 38 additions & 0 deletions ckanext/scheming_dcat/templates/admin/trash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% ckan_extends %}

{% block primary_content_inner %}
<form method="POST" action="{{ h.url_for('admin.trash') }}" id="form-purge-all">
{{ h.csrf_input() }}
<div class="form-actions">
<input type="hidden" name="action" value="all">
<a class="btn btn-danger purge-all"
type="submit"
href="{{ h.url_for('admin.trash', name='all') }}"
data-module="confirm-action"
data-module-with-data=true
data-module-content="{{ _('Are you sure you want to purge everything?') }}">
{{ _('Purge all') }}
</a>
</div>
</form>

{% for ent_type, entities in data.items() %}
{% snippet "scheming_dcat/snippets/data_type.html", ent_type=ent_type, entities=entities, messages=messages %}
{% endfor %}
{% endblock %}

{% block secondary_content %}
<div class="module module-narrow module-shallow">
<h2 class="module-heading">
<i class="fa fa-info-circle"></i>
{{ _("Trash") }}
</h2>
<div class="module-content">
<p>
{% trans %}
Purge deleted datasets, organizations or groups forever and irreversibly.
{% endtrans %}
</p>
</div>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<button class="accordion-item" data-toggle="collapse" data-target="#{{ ent_type }}">
{% if ent_type == "package" %} <i class='fa fa-sitemap'></i>
{% elif ent_type == 'group' %} <i class='fa fa-group'></i>
{% else %} <i class="fa fa-building-o"></i>
{% endif %}
{% if ent_type == 'package' %}
{{ _('Deleted datasets') }}
{% elif ent_type == 'organization' %}
{{ _('Deleted organizations') }}
{% elif ent_type == 'group' %}
{{ _('Deleted groups') }}
{% endif %}
</button>

<!-- expanded by default to prevent problems with disabled js -->
<div id="{{ ent_type }}" class="entities collapse in">
{% set truncate = truncate or 180 %}
{% set truncate_title = truncate_title or 80 %}
<ul class="{{ ent_type }}-list">
{% for entity in entities %}
{% set title = entity.title or entity.name %}
{% set url = h.url_for(entity.type + '.read', id=entity.name) %}

<li>
<div class="trash-dataset-badges">
{{ h.link_to(h.truncate(title, truncate_title), url) }}
{% if entity.private %}
<span class="dataset-private badge pull-left">
<i class="fa fa-lock"></i>
{{ _('Private') }}
</span>
{% endif %}
</div>
<ul class="trash-li-info">
{% if entity.metadata_created %}
<li>{{ _('Created') }}: {{ entity.metadata_created | datetimeformat }}</li>
{% endif %}
{% if entity.notes %}
<li>{{ _('Description') }}: {{ h.markdown_extract(entity.notes, extract_length=100) }}</li>
{% endif %}
</ul>
</li>
{% else %}
<p>
{{ _(messages.empty[ent_type]) }}
</p>
{% endfor %}
</ul>

<!-- show button only if there is entity to purge -->
{% if entities.first() %}
<form method="POST" action="{{ h.url_for('admin.trash') }}" id="form-purge-{{ ent_type }}">
<input type="hidden" name="action" value="{{ent_type}}">
<a href="{{ h.url_for('admin.trash', name=ent_type) }}"
class="btn btn-danger purge-all"
data-module="confirm-action"
data-module-with-data=true
data-module-content="{{ _(messages.confirm[ent_type]) }}">
{{ _('Purge') }}
</a>
</form>
{% endif %}
</div>

0 comments on commit cdb0b9a

Please sign in to comment.