{% extends "base.html" %}

{% block title %}
	{{ _("Add %(package_title)s to a collection", package_title=package.title)}}
{% endblock %}

{% block content %}
	<a href="{{ url_for('collections.create_edit', package=package.get_id()) }}" class="btn btn-primary float-end">
		{{ _("Create Collection") }}
	</a>
	<h1>{{ self.title() }}</h1>

	{% from "macros/forms.html" import render_field, render_submit_field, render_checkbox_field %}
	<div class="list-group my-4">
		{% for collection in collections %}
			{% set active = package in collection.packages %}
			<form method="POST" action="">
				<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
				<input type="hidden" name="collection" value="{{ collection.id }}" />
				<button type="submit"
						class="list-group-item list-group-item-action {% if active %}active{% endif %}">
					{% if active %}
						<i class="fas fa-check me-3 text-success"></i>
					{% else %}
						<i class="fas fa-square me-3 text-muted"></i>
					{% endif -%}
					{% if collection.author != current_user %}{{ collection.author.display_name }}: {% endif -%}
					{% if collection.name == 'favorites' %}
						<i class="fas fa-star me-1 text-info"></i>
					{% endif %}
					{% if collection.private %}
						<i class="fas fa-lock me-1" style="color:#ffac33;"></i>
					{% endif %}
					{{ collection.title }}
				</button>
			</form>
		{% else %}
			<div class="list-group-item text-muted">
				<i>{{ _("You don't have any collections") }}</i>
			</div>
		{% endfor %}
	</div>

	<p>
		<a href="{{ package.get_url('packages.view') }}" class="btn btn-secondary">
			{{ _("Done") }}
		</a>
	</p>
{% endblock %}
