{% extends 'publisher/base.html' %}

{% load compress %}
{% load i18n %}
{% load static %}

{% block title %}
    {% trans "Course Run Details" %}
{% endblock title %}

{% block page_content %}
<div class="layout-1t2t layout-flush publisher-container course-detail">
    <main class="layout-col layout-col-b layout-col-b-custom">
        {% if object.course_run_state.is_published %}
            <div class="depth depth-0 published-status">
                <strong>
<!-- Is it possible to make "View it on edx.org" into a link? If so, make it into a link, add a period at the end, and delete "at". If not, keep "at", but remove the colon and add a period after the link. -->
                    {% blocktrans with publish_date|date:'m/d/y' as course_publish_date trimmed %}
                        The About page for this course run was published on {{ course_publish_date }}.
                    {% endblocktrans %}
                    {% if object.preview_url %}
                        {% trans "View it on edx.org at" %}
                    {% endif %}
                </strong>
                {% if object.preview_url %}
                    <a href="{{ object.preview_url }}" target="_blank">{{ object.preview_url }}</a>
                {% endif %}
            </div>
        {% endif %}
        <nav class="administration-nav">
            <div class="tab-container">
                {% if can_view_all_tabs %}
                    <button class="selected" data-tab="#tab-1">{% trans "All" %}</button>
                    {% comment %}Translators: Studio is an edX tool for course creation.{% endcomment %}
                    <button data-tab="#tab-2">{% trans "STUDIO" %}</button>
                    {% comment %}Translators: CAT is an acronym for Course Administration Tool.{% endcomment %}
                    <button data-tab="#tab-3">{% trans "CAT" %}</button>
                    {% comment %}Translators: DRUPAL is an edX marketing site.{% endcomment %}
                    <button data-tab="#tab-4">{% trans "DRUPAL" %}</button>
                    <button data-tab="#tab-5">Salesforce</button>
                {% endif %}
            </div>
        </nav>

        <div id="app">
            <div class="page-header">
                <h2 class="hd-2 emphasized">
                    <span class="course-name">{{ object.title }}</span>
                </h2>
            </div>

            {% include 'alert_messages.html' %}

            <div id="stateChangeAlert" class="alert-messages hidden">
                <div class="alert alert-error" role="alert" tabindex="-1">
                    <div>
                        <p id="stateChangeError" class="alert-copy"></p>
                    </div>
                </div>
            </div>

            <div class="tabs">
                <div id="tab-1" class="tab-content active">
                    {% include 'publisher/course_run_detail/_all.html' %}
                </div>
              {% if can_view_all_tabs %}
                <div id="tab-2" class="tab-content">
                    {% include 'publisher/course_run_detail/_studio.html' %}
                </div>
                <div id="tab-3" class="tab-content">
                    {% include 'publisher/course_run_detail/_cat.html' %}
                </div>
                <div id="tab-4" class="tab-content">
                    {% include 'publisher/course_run_detail/_drupal.html' %}
                </div>
                <div id="tab-5" class="tab-content">
                    {% include 'publisher/course_run_detail/_salesforce.html' %}
                </div>
              {% endif %}
            </div>
        </div>
    </main>

    <aside id="right-panel" class="layout-col layout-col-a layout-col-a-custom">
        <div id="approval-widget" class="approval-widget {% if not publisher_approval_widget_feature %}hidden{% endif %}">
        {% with is_course_run=True %}
          {% include 'publisher/course_run_detail/_widgets.html' %}
        {% endwith %}
        </div>
        <div id="comments-widget" class="comment-container {% if not publisher_comment_widget_feature %}hidden{% endif %}">
            {% include 'comments/add_auth_comments.html' with comment_type='default' %}
            {% include 'comments/comments_list.html' %}
        </div>
    </aside>
</div>
{% include 'publisher/course_run_detail/_instructor_profile.html' %}
{% endblock %}

{% block extra_js %}
    <script src="{% static 'bower_components/clipboard/dist/clipboard.min.js' %}"></script>
    <script src="{% static 'js/publisher/jquery-dateFormat.min.js' %}"></script>
    <script src="{% static 'js/publisher/views/course_detail.js' %}"></script>
    <script src="{% static 'js/publisher/organizations.js' %}"></script>
    <script src="{% static 'js/publisher/comments.js' %}"></script>
    <script src="{% static 'js/publisher/course-tabs.js' %}"></script>
    <script src="{% static 'js/publisher/preview-url.js' %}"></script>
    <script src="{% static 'js/publisher/change-state.js' %}"></script>
    <script src="{% static 'js/publisher/modal-screen.js' %}"></script>
    <script>
        new Clipboard(".btn-copy", {
            text: function(trigger) {
                return $(trigger).parent().next('.copy').html().trim();
            }
        });
    </script>
{% endblock %}
