Skip to content

Commit

Permalink
fix(templates): resource list;
Browse files Browse the repository at this point in the history
- Fix resource list for Portal.
  • Loading branch information
JVickery-TBS committed Oct 25, 2024
1 parent 83a9a9b commit 2d2f578
Showing 1 changed file with 50 additions and 54 deletions.
104 changes: 50 additions & 54 deletions ckanext/canada/templates/package/snippets/resources.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,58 @@
{% endblock %}
<div class="panel-body resources-side-panel">
{% block resources_list %}
{% if g.is_registry %}
<ul class="list-unstyled nav nav-simple">
{% for resource in resources %}
{% set url = h.url_for(pkg.type ~ '_resource.read', id=pkg.id if is_activity_archive else pkg.name, resource_id=resource.id, **({'activity_id': request.args['activity_id']} if 'activity_id' in request.args else {})) %}
{% set is_active = 'active' if active == resource.id else '' %}
<li class="nav-item justify-content-between position-relative {{ is_active }}">
<a class="resources-side-section-item-link" tabindex="{{ -1 if is_active else 0 }}" href="{{ url }}" title="{{ h.resource_display_name(resource) }}">{{ h.resource_display_name(resource)|truncate(25) }}</a>
{% if can_edit and not is_activity_archive %}
<div class="dropdown position-absolute end-0 me-2">
<button class="btn btn-light btn-sm dropdown-toggle" type="button" id="dropdownRes{{ loop.index }}" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-wrench" aria-hidden="true"></i></button>
<ul class="dropdown-menu" aria-labelledby="dropdownRes{{ loop.index }}">
<li>{% link_for _('Edit resource'), named_route=pkg.type ~ '_resource.edit', id=pkg.name, resource_id=resource.id, class_='dropdown-item', icon='pencil' %}</li>
{% block resources_list_edit_dropdown_inner scoped %}{% endblock %}
{% if h.is_resource_supported_by_xloader(resource) %}
<li>{% link_for _('DataStore'), named_route='xloader.resource_data', id=pkg.name, resource_id=resource.id, class_='dropdown-item', icon='cloud-upload' %}</li>
<li>{% link_for _('Data Dictionary'), named_route='datastore.dictionary', id=pkg.name, resource_id=resource.id, class_='dropdown-item', icon='code' %}</li>
{% endif %}
<li>{% link_for _('Views'), named_route=pkg.type ~ '_resource.views', id=pkg.name, resource_id=resource.id, class_='dropdown-item', icon='chart-bar' %}</li>
<li>
<a class="dropdown-item text-danger" href="{{ h.url_for(pkg.type ~ '_resource.delete', id=pkg.name, resource_id=resource.id) }}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this resource?') }}">
<i class="fa fa-trash" aria-hidden="true"></i>&nbsp;{{ _('Delete resource') }}</a>
</li>
</ul>
</div>
{% endif %}
{% set language_options = h.scheming_get_preset('canada_resource_language').choices %}
<div class="resources-side-section-item-badges">
{% for language in resource.language %}
{% if loop.index <= 2 %}
{% for option in language_options %}
{% if option.value == language %}
<span class="badge res-tag res-tag-lang">
{{ option.label[h.lang()] }}
</span>
{% endif %}
{% endfor %}
<ul class="list-unstyled nav nav-simple">
{% for resource in resources %}
{% set url = h.url_for(pkg.type ~ '_resource.read', id=pkg.id if is_activity_archive else pkg.name, resource_id=resource.id, **({'activity_id': request.args['activity_id']} if 'activity_id' in request.args else {})) %}
{% set is_active = 'active' if active == resource.id else '' %}
<li class="nav-item justify-content-between position-relative {{ is_active }}">
<a class="resources-side-section-item-link" tabindex="{{ -1 if is_active else 0 }}" href="{{ url }}" title="{{ h.resource_display_name(resource) }}">{{ h.resource_display_name(resource)|truncate(25) }}</a>
{% if g.is_registry and can_edit and not is_activity_archive %}
<div class="dropdown position-absolute end-0 me-2">
<button class="btn btn-light btn-sm dropdown-toggle" type="button" id="dropdownRes{{ loop.index }}" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-wrench" aria-hidden="true"></i></button>
<ul class="dropdown-menu" aria-labelledby="dropdownRes{{ loop.index }}">
<li>{% link_for _('Edit resource'), named_route=pkg.type ~ '_resource.edit', id=pkg.name, resource_id=resource.id, class_='dropdown-item', icon='pencil' %}</li>
{% block resources_list_edit_dropdown_inner scoped %}{% endblock %}
{% if h.is_resource_supported_by_xloader(resource) %}
<li>{% link_for _('DataStore'), named_route='xloader.resource_data', id=pkg.name, resource_id=resource.id, class_='dropdown-item', icon='cloud-upload' %}</li>
<li>{% link_for _('Data Dictionary'), named_route='datastore.dictionary', id=pkg.name, resource_id=resource.id, class_='dropdown-item', icon='code' %}</li>
{% endif %}
{% endfor %}
{% if resource.language|length > 2 %}
{% set lang_count = resource.language|length %}
<span class="badge res-tag res-tag-lang">
{{ _('+ %s more').format(lang_count - 2) }}
</span>
{% endif %}
{% if resource.format %}
<span class="badge res-tag">
{{ resource.format }}
</span>
{% endif %}
<li>{% link_for _('Views'), named_route=pkg.type ~ '_resource.views', id=pkg.name, resource_id=resource.id, class_='dropdown-item', icon='chart-bar' %}</li>
<li>
<a class="dropdown-item text-danger" href="{{ h.url_for(pkg.type ~ '_resource.delete', id=pkg.name, resource_id=resource.id) }}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this resource?') }}">
<i class="fa fa-trash" aria-hidden="true"></i>&nbsp;{{ _('Delete resource') }}</a>
</li>
</ul>
</div>
</li>
{% endfor %}
</ul>
{% else %}
{{ super() }}
{% endif %}
{% endif %}
{% set language_options = h.scheming_get_preset('canada_resource_language').choices %}
<div class="resources-side-section-item-badges">
{% for language in resource.language %}
{% if loop.index <= 2 %}
{% for option in language_options %}
{% if option.value == language %}
<span class="badge res-tag res-tag-lang">
{{ option.label[h.lang()] }}
</span>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% if resource.language|length > 2 %}
{% set lang_count = resource.language|length %}
<span class="badge res-tag res-tag-lang">
{{ _('+ %s more').format(lang_count - 2) }}
</span>
{% endif %}
{% if resource.format %}
<span class="badge res-tag">
{{ resource.format }}
</span>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
{% endblock %}
</div>
{% endblock %}
Expand Down

0 comments on commit 2d2f578

Please sign in to comment.