{% extends "base.html" %}

{% block title %}
	{% if tag %}
		Edit {{ tag.get_translated().title }}
	{% else %}
		New tag
	{% endif %}
{% endblock %}

{% block content %}
	<a class="btn btn-primary float-end" href="{{ url_for('admin.create_edit_tag') }}">New Tag</a>
	<a class="btn btn-secondary mb-4" href="{{ url_for('admin.tag_list') }}">Back to list</a>

	{% from "macros/forms.html" import render_field, render_submit_field, render_checkbox_field %}
	<form method="POST" action="" enctype="multipart/form-data">
		{{ form.hidden_tag() }}

		{{ render_field(form.title) }}
		{{ render_field(form.description) }}
		{% if tag %}
			{{ render_field(form.name) }}
		{% endif %}
		{{ render_submit_field(form.submit) }}
		{% if tag %}
			<a class="ms-5" target="_blank" href="{{ url_for('packages.list_all', tag=tag.name) }}">
				View packages with tag
			</a>
		{% endif %}
	</form>
{% endblock %}
