| {% macro asset_list_item(asset, current_user) %}

| {% set node_type = asset.properties.content_type if asset.properties.content_type else asset.node_type %}

a.card.asset.card-image-fade.mb-2(
	class="js-item-open {% if asset.permissions.world and not current_user.has_cap('subscriber') %}free{% endif %}",
	data-node_id="{{ asset._id }}",
	title="{{ asset.name }}",
	href='{{ url_for_node(node=asset) }}')
	.card-thumbnail
		| {% if asset.picture %}
		img.card-img-top(src="{{ asset.picture.thumbnail('m', api=api) }}", alt="{{ asset.name }}")
		| {% else %}
		.card-img-top.card-icon
			i(class="pi-{{ node_type }}")
		| {% endif %}

		| {% if asset.properties.content_type == 'video' %}

		| {% set view_progress = current_user.nodes.view_progress %}
		| {% if asset._id in view_progress %}
		| {% set progress = current_user.nodes.view_progress[asset._id] %}
		| {% set progress_in_percent = progress.progress_in_percent %}
		| {% set progress_done = progress.done %}
		| {% endif %}

		| {% if progress %}
		.progress.rounded-0
			.progress-bar(
				role="progressbar",
				style="width: {{ progress_in_percent }}%;",
				aria-valuenow="{{ progress_in_percent }}",
				aria-valuemin="0",
				aria-valuemax="100")

		| {% if progress.done %}
		.card-label WATCHED
		| {% endif %}
		| {% endif %} {# endif progress #}
		| {% if asset.properties.duration_seconds %}
		.card-label.right {{ asset.properties.duration_seconds | pretty_duration }}
		| {% endif %}
		| {% endif %} {# endif video #}


	.card-body.py-2.d-flex.flex-column.text-truncate
		.card-title.mb-1.font-weight-bold.text-truncate
			| {{ asset.name | hide_none }}

		ul.card-text.list-unstyled.d-flex.text-black-50.mt-auto.mb-0.text-truncate
			| {% if node_type %}
			li.pr-2.font-weight-bold {{ node_type | undertitle }}
			| {% endif %}
			| {% if asset.project.name %}
			li.pr-2.text-truncate {{ asset.project.name }}
			| {% endif %}
			| {% if asset.user.full_name %}
			li.pr-2.text-truncate {{ asset.user.full_name }}
			| {% endif %}
			| {% if asset._created %}
			li.text-truncate {{ asset._created | pretty_date }}
			| {% endif %}

| {% endmacro %}
