{% extends 'base.html' %}

{% load static %}
{% load rules %}
{% load projectroles_tags %}
{% load projectroles_common_tags %}

{% block content %}
  {% get_django_setting 'PROJECTROLES_KIOSK_MODE' as kiosk_mode %}

  {# Ensure passing CSRF token to Ajax API views #}
  {% csrf_token %}

  {# Sidebar #}
  {% if not kiosk_mode %}
    <div class="sodar-content-left" id="sodar-content-left">

      <div class="col h-100 bg-dark text-center sodar-pr-sidebar collapse show" id="sodar-pr-sidebar">
        <nav class="nav navbar-expand-lg navbar-dark bg-dark sodar-pr-sidebar-nav">
          <div class="navbar-collapse" id="sodar-pr-sidebar-navbar">
            <ul class="navbar-nav flex-column sodar-pr-sidebar-nav-ul">
              <li id="sodar-pr-nav-home" class="nav-item {% if request.resolver_match.url_name == 'home' %}active{% endif %}">
                <a class="nav-link"
                   href="{% url 'home' %}"
                   id="sodar-pr-nav-home-link">
                  <i class="iconify" data-icon="mdi:home" data-height="32"></i><br />Home
                </a>
              </li>
              {% block sidebar %} {# Actual sidebar content #}
                {% include 'projectroles/_project_sidebar.html' %}
              {% endblock sidebar %}
            </ul>
          </div>
        </nav>
      </div>

    </div> <!-- /sodar-content-left -->
  {% endif %}

  <div class="sodar-content-right">

    {# Project breadcrumb #}
    {% block navi_sub_project %}
      {% if project and not kiosk_mode %}
        <div class="sodar-sub-navbar-container" id="sodar-sub-navbar-container">
          <div class="row bg-secondary sodar-pr-navbar" id="sodar-pr-navbar">
            <ol id="sodar-pr-breadcrumb" class="breadcrumb sodar-pr-breadcrumb">
              <li class="breadcrumb-item">
                <a href="{% url 'home' %}"><i class="iconify" data-icon="mdi:home"></i> Home</a></li>
              {% if project.get_parents %}
                {% for p in project.get_parents %}
                  <li class="breadcrumb-item"><a href="{% url 'projectroles:detail' project=p.sodar_uuid %}">{{ p.title }}</a></li>
                {% endfor %}
              {% endif %}
              {% url 'projectroles:detail' project=project.sodar_uuid as detail_url %}
              {% if request.path == detail_url %}
                <li class="breadcrumb-item active">{{ project.title }}</li>
              {% else %}
                <li class="breadcrumb-item"><a href="{% url 'projectroles:detail' project=project.sodar_uuid %}">{{ project.title }}</a></li>
              {% endif %}
              {% block navi_sub_project_extend %}
                 {# Override to display items behind the project in the bread crumb #}
              {% endblock %}
            </ol>
          </div>
        </div>
      {% endif %}
    {% endblock navi_sub_project %}

    <div class="sodar-app-container" id="sodar-app-container">

      {# Django messages / site app messages #}
      {% include 'projectroles/_messages.html' %}

      {# Actual content #}
      <div class="sodar-app-content" id="sodar-app-content">
        {% block projectroles %}
          Projectroles app content here
        {% endblock projectroles %}
      </div>

      {# Footer #}
      {% template_exists 'include/_footer.html' as footer_exists %}
      <footer class="sodar-footer">
        {% if footer_exists %}
          {% include 'include/_footer.html' %}
        {% else %}
          {% include 'projectroles/_footer.html' %}
        {% endif %}
      </footer>

     </div> <!-- /sodar-app-container -->

  </div>  <!-- /sodar-content-right -->

{% endblock content %}

{% block javascript %}
  {{ block.super }}

  <!-- Projectroles Javascript -->
  <script type="text/javascript" src="{% static 'projectroles/js/projectroles.js' %}"></script>

  {# Django admin link warning #}
  {% if request.user.is_superuser %}
    {% get_admin_warning as admin_warning %}
    <script type="text/javascript">
        $(document).ready(function() {
            $('#sodar-navbar-link-admin-warning').click(function () {
                $('#sodar-modal').find('.modal-dialog').addClass('w-50');
                $('.modal-title').text('Warning!');
                var htmlData = '{{ admin_warning|safe }}';
                $('.modal-body').html(htmlData);
           });
        });
    </script>
  {% endif %}

  <script type="text/javascript">
      tour.addStep('tour_intro', {
          title: 'Welcome to the Tour Help!',
          text: 'The tour help describes key elements on the currently ' +
                'opened page and aids you in using available features. ' +
                'Advance on the tour by clicking "Next".',
          advanceOn: '.docs-link click',
          showCancelLink: true
      });
  </script>

{% endblock javascript %}
