{% extends 'base.html' %}
{% load i18n %}

{% block head %}
	{{ block.super }}
	<script src="{{ STATIC_URL }}common/js/ajax-modal.js"></script>
{% endblock %}

{% block subtitle %}
	{% if lesson.pk %}
		{% trans 'Edit lesson' %} "{{ lesson.name }}"
	{% else %}
		{% blocktrans trimmed with topic_name=topic.name %}
			New lesson for topic "{{ topic_name }}"
		{% endblocktrans %}
	{% endif %}
{% endblock %}

{% block actions %}
	<a href="{{ topic.curriculum.get_absolute_url }}" class="btn btn-default">
		{% trans 'Back to the curriculum' %}
	</a>
{% endblock %}

{% block main %}
	<form action="{% if lesson.pk %}{{ lesson.get_edit_url }}{% else %}{{ topic.get_lesson_create_url }}{% endif %}" method="post">{% csrf_token %}

		{% include 'extras/form.html' %}

		{% if lesson.pk %}

			<hr>

			<div class="panel panel-default">
				<div class="panel-heading clearfix">
					<div class="pull-left">
						<h4>
							{% trans 'Recommendation levels' %}
						</h4>
					</div>
				</div>
				<div id="recommendation-levels" class="panel-collapse" role="tabpanel" aria-labelledby="heading-recommendation-levels" aria-expanded="false">
					<div class="panel-body">
						<p>{% trans 'Here you can manage <em>recommendation levels</em> linked to this lesson.' %}</p>
					</div>
					<ul class="list-group">

						{% for recommendation_level in lesson.recommendation_thresholds.non_deleted %}
							<li class="list-group-item">
								<b>{{ recommendation_level.level.name }}</b>
								<div class="pull-right">
									<span class="badge">{{ recommendation_level.threshold }}</span>
									<a href="{{ recommendation_level.get_edit_url }}" class="btn btn-primary btn-xs dialog-box">
										<i class="fa fa-pencil"></i> {% trans 'Edit' %}
									</a>
									<a href="{{ recommendation_level.get_delete_url }}" class="btn btn-danger btn-xs dialog-box">
										<i class="fa fa-trash"></i> {% trans 'Delete' %}
									</a>
								</div>
							</li>
						{% endfor %}

					</ul>
					<div class="panel-footer clearfix">
						<div class="pull-right">
							<a href="{{ lesson.get_recommendation_level_create_url }}" class="btn btn-primary dialog-box">
								<i class="fa fa-plus"></i> {% trans 'New recommendation level' %}
							</a>
						</div>
					</div>
				</div>
			</div>

			<hr>

			<div class="panel panel-default">
				<div class="panel-heading clearfix">
					<div class="pull-left">
						<h4>
							{% trans 'Dimension weights' %}
						</h4>
					</div>
				</div>
				<div id="dimension-weights" class="panel-collapse" role="tabpanel" aria-labelledby="heading-dimension-weights" aria-expanded="false">
					<div class="panel-body">
						<p>{% trans 'Here you can manage <em>dimension weights</em> linked to this lesson.' %}</p>
					</div>
					<ul class="list-group">

						{% for dimension_weight in lesson.dimension_weights.non_deleted %}
							<li class="list-group-item">
								{{ dimension_weight.dimension.competency.name }} > <b>{{ dimension_weight.dimension.name }}</b>
								<div class="pull-right">
									<span class="badge">{{ dimension_weight.weight }}</span>
									<a href="{{ dimension_weight.get_edit_url }}" class="btn btn-primary btn-xs dialog-box">
										<i class="fa fa-pencil"></i> {% trans 'Edit' %}
									</a>
									<a href="{{ dimension_weight.get_delete_url }}" class="btn btn-danger btn-xs dialog-box">
										<i class="fa fa-trash"></i> {% trans 'Delete' %}
									</a>
								</div>
							</li>
						{% endfor %}

					</ul>
					<div class="panel-footer clearfix">
						<div class="pull-right">
							<a href="{{ lesson.get_dimension_weight_create_url }}" class="btn btn-primary dialog-box">
								<i class="fa fa-plus"></i> {% trans 'New dimension weight' %}
							</a>
						</div>
					</div>
				</div>
			</div>

		{% endif %}

		<hr>

		<div class="clearfix">
			<a href="{{ competency_tree.get_curriculum_url }}" class="btn btn-default pull-left">
				{% trans 'Cancel' %}
			</a>
			<div class="pull-right">
				<input class="btn btn-primary" type="submit" value="{% trans 'Save and continue editing' %}" />
				<input class="btn btn-primary" type="submit" value="{% trans 'Save' %}" />
			</div>
		</div>
	</form>
{% endblock %}
