{% ckan_extends %}

{% block resource_item_title %}
	{% asset 'feedback/feedback-tooltip-css' %}
  <a class="heading" href="{{ url }}" title="{{ res.name or res.description }}">
    {{ h.resource_display_name(res) | truncate(50) }}<span class="format-label" property="dc:format" data-format="{{ res.format.lower() or 'data' }}">{{ h.get_translated(res, 'format') }}</span>
    {{ h.popular('views', res.tracking_summary.total, min=10) if res.tracking_summary }}
  </a>
	<br>
  {% if h.is_enabled_downloads_org(pkg.owner_org) %}
    <a style="color: inherit; text-decoration: none;" href="{{ h.url_for('resource.read', id=pkg.id, resource_id=res.id, package_type='dataset') }}">
      <div class = "bubble">
        <i class="fa-solid fa-arrow-circle-down"></i>
        {{ h.get_resource_downloads(res.id) }}
        <div class="description">{{ _('Downloads') }}</div>
      </div>
    </a>
  {% endif %}
	{% if h.is_enabled_utilizations_org(pkg.owner_org) %}
    <a style="color: inherit; text-decoration: none;" href="{{ h.url_for('utilization.search', id=res.id, disable_keyword=true) }}">
      <div class="bubble">
        <i class="fa-solid fa-seedling"></i>
        {{ h.get_resource_utilizations(res.id) }}
        <div class="description">{{ _('Utilizations') }}</div>
      </div>
    </a>
  {% endif %}
  {% if h.is_enabled_resources_org(pkg.owner_org) %}
    <a style="color: inherit; text-decoration: none;" href="{{ h.url_for('resource_comment.comment', resource_id=res.id) }}">
      <div class="utilization-data bubble">
        <i class="fa-solid fa-comment-dots"></i>
        {{ h.get_resource_comments(res.id) }}
        <div class="description">{{ _('Comments') }}</div>
      </div>
    </a>
    {% if h.is_enabled_rating_org(pkg.owner_org) %}
      <a style="color: inherit; text-decoration: none;" href="{{ h.url_for('resource_comment.comment', resource_id=res.id) }}">
        <div class="utilization-data bubble">
          <i class="fa-solid fa-star"></i>
          {{ h.get_resource_rating(res.id)|round(1) }}
          <div class="description">{{ _('Rating') }}</div>
        </div>
      </a>
    {% endif %}
  {% endif %}
	{% if h.is_enabled_utilizations_org(pkg.owner_org) %}
    <a style="color: inherit; text-decoration: none;" href="{{ h.url_for('utilization.search', id=res.id, disable_keyword=true) }}">
      <div class="bubble">
        <img id="issue-resolution" src="/images/issue_resolution_badge.png">
        {{ h.get_resource_issue_resolutions(res.id) }}
        <div class="description">{{ _('Issue Resolutions') }}</div>
      </div>
    </a>
  {% endif %}
{% endblock %}

{% block resource_item_explore %}
  {% if not url_is_edit %}
  	<div class="dropdown btn-group">
      {% if h.is_base_public_folder_bs3() %}
        <a href="#" class="btn btn-primary dropdown-toggle" type="button" id="dropdownExplorer" data-toggle="dropdown" aria-expanded="false">
          <i class="fa fa-share"></i>
          {{ _('Explore') }}
          <span class="caret"></span>
        </a>
      {% else %}
        <a href="#" class="btn btn-primary dropdown-toggle" type="button" id="dropdownExplorer" data-bs-toggle="dropdown" aria-expanded="false">
          <i class="fa fa-share"></i>
          {{ _('Explore') }}
          <span class="caret"></span>
        </a>
      {% endif %}
    	<ul class="dropdown-menu" aria-labelledby="dropdownExplorer">
      	{% block resource_item_explore_links %}
        	{% block explore_view %}
          	<li>
            	<a class="dropdown-item" href="{{ url }}">
              	{% if res.has_views %}
                	<i class="fa fa-chart-bar"></i>
                	{{ _('Preview') }}
              	{% else %}
                	<i class="fa fa-info-circle"></i>
                	{{ _('More information') }}
              	{% endif %}
            	</a>
          	</li>
        	{% endblock explore_view %}

        	{% if res.url and h.is_url(res.url) %}
      			<li>
        			<a class="dropdown-item resource-url-analytics" href="{{ h.url_for('download.download', id=pkg.id, resource_id=res.id) }}?user-download=true" target="_blank" rel="noreferrer" download>
          			{% if res.has_views or res.url_type == 'upload' %}
            			<i class="fa fa-arrow-circle-down"></i>
            			{{ _('Download') }}
          			{% else %}
            			<i class="fa fa-external-link"></i>
            			{{ _('Go to resource') }}
          			{% endif %}
        			</a>
      			</li>
      		{% endif %}
      		{% if can_edit %}
      			<li>
        			<a class="dropdown-item" href="{{ h.url_for(pkg.type ~ '_resource.edit', id=pkg.name, resource_id=res.id) }}">
          			<i class="fa fa-pencil-square"></i>
          			{{ _('Edit') }}
        			</a>
      			</li>
      		{% endif %}
					{% if h.is_enabled_utilizations_org(pkg.owner_org) %}
            <li>
              <a class="dropdown-item" href="{{ h.url_for('utilization.new', package_name=pkg.name, resource_id=res.id) }}">
                <i class="fa-solid fa-seedling"></i>
								{{ _('Create utilization application') }}
              </a>
            </li>
          {% endif %}
          {% if h.is_enabled_resources_org(pkg.owner_org) %}
            <li>
              <a class="dropdown-item" href="{{ h.url_for('resource_comment.comment', resource_id=res.id) }}">
                <i class="fa-solid fa-comment-dots"></i>
                {{ _('Comment') }}
              </a>
            </li>
          {% endif %}
      	{% endblock %}
    	</ul>
  	</div>
  {% endif %}
{% endblock %}
