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

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

{% block section_title %}
	{% trans 'Competencies tree' %}
{% endblock %}

{% block section_actions %}
	{% if competency_tree.can_edit %}
        <a href="{% url 'assessments:import_xls' %}" class="btn btn-warning">
            <i class="fa-plus fa"></i>
            {% trans 'Import Job-Profile' %}
        </a>
        <a href="{{ competency_tree.get_competency_sort_url }}" class="btn btn-primary">
            <i class="fa fa-sort"></i>
            {% trans 'Sort competencies' %}
        </a>
        <a href="{{ competency_tree.get_competency_create_url }}" class="btn btn-primary">
            <i class="fa fa-plus"></i>
            {% trans 'New competency' %}
        </a>
        {% if user.is_superuser %}
            <a href="{{ competency_tree.get_duplicate_url }}" class="btn btn-danger dialog-box">
                <i class="fa fa-copy"></i>
                {% trans 'Duplicate to groups' %}
            </a>
        {% endif %}
    {% endif %}
    {% if competency_tree.can_translate %}
        <div class="btn-group">
            <button class="btn btn-info dropdown-toggle" type="button" id="dropdownTranslation" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                {% trans "Translation" %} <span class="caret"></span>
            </button>
            <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownTranslation">
                <li>
                <a href="{% url 'assessments:export-translation' jobprofile_uuid=current_job_profile.pk %}{% if current_managed_group %}?group_uuid={{ current_managed_group.pk }}{% endif %}">
                    {% trans "Export Translation" %}
                </a>
                </li>
                <li>
                <a href="{% url 'assessments:import-translation' jobprofile_uuid=current_job_profile.pk %}{% if current_managed_group %}?group_uuid={{ current_managed_group.pk }}{% endif %}">
                    {% trans "Import Translation" %}
                </a>
                </li>
            </ul>
        </div>
    {% endif %}
{% endblock %}

{% block section_content %}
	{% for competency in competency_list %}
		<div class="panel panel-default">
			<div class="panel-heading clearfix">
				<div class="pull-left">
					<h4>
						<a href="#{{ competency.id }}" data-toggle="collapse" class="collapsed">
							{{ competency.code }} - {{ competency.name }}
						</a>
					</h4>
				</div>
				{% if competency_tree.can_edit %}
                    <div class="pull-right">
                        <a href="{{ competency.get_edit_url }}" class="btn btn-primary">
                            <i class="fa fa-pencil"></i> {% trans 'Edit' %}
                        </a>
                        <a href="{{ competency.get_delete_url }}" class="btn btn-danger dialog-box">
                            <i class="fa fa-trash"></i> {% trans 'Delete' %}
                        </a>
                    </div>
                {% endif %}
			</div>
			<div id="{{ competency.id }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-{{ competency.id }}" aria-expanded="false">
				<div class="panel-body">
					<p>{{ competency.description }}</p>
				</div>
				<ul class="list-group">
					{% for dimension in competency.dimensions.non_deleted %}
						<li class="list-group-item">
							<b>{{ dimension.code }}</b> - {{ dimension.name }}
							<div class="pull-right">
								<span class="badge">{{ dimension.default_weight }}</span>
                                {% if competency_tree.can_edit %}
                                    <a href="{{ dimension.get_edit_url }}" class="btn btn-primary btn-xs">
                                        <i class="fa fa-pencil"></i> {% trans 'Edit' %}
                                    </a>
                                    <a href="{{ dimension.get_delete_url }}" class="btn btn-danger btn-xs dialog-box">
                                        <i class="fa fa-trash"></i> {% trans 'Delete' %}
                                    </a>
                                {% endif %}
							</div>
						</li>
					{% endfor %}
				</ul>
                {% if competency_tree.can_edit %}
                    <div class="panel-footer clearfix">
                        <div class="pull-right">
                            <a href="{{ competency.get_dimension_sort_url }}" class="btn btn-primary">
                                <i class="fa fa-sort"></i> {% trans 'Sort dimensions' %}
                            </a>
                            <a href="{{ competency.get_dimension_create_url }}" class="btn btn-primary">
                                <i class="fa fa-plus"></i> {% trans 'New dimension' %}
                            </a>
                        </div>
                    </div>
                {% endif %}
			</div>
		</div>
	{% endfor %}
{% endblock %}
