{% extends "aa_bulletin_board/base.html" %}

{% load django_bootstrap5 %}
{% load i18n %}
{% load static %}

{% block page_title %}
    {% translate "Bulletin Board" as app_name %}

    {% if bulletin %}
        {% translate "Edit bulletin" as page_title %}
        {{ page_title|title }} » {{ bulletin.title }}
    {% else %}
        {% translate "Create new bulletin" as page_title %}
        {{ page_title|title }}
    {% endif %}

    » {{ app_name }}
{% endblock %}

{% block aabulletinboard_header %}
    {% if bulletin %}
        {% include "framework/header/page-header.html" with title=bulletin.title %}
    {% else %}
        {% translate "Create new bulletin" as header_text %}
        {% include "framework/header/page-header.html" with title=header_text %}
    {% endif %}
{% endblock %}

{% block aabulletinboard_body %}
    <div class="card">
        <div class="card-header">
            <div class="card-title mb-0">
                <a class="btn btn-secondary btn-sm" href="{% if bulletin %}{% url 'aa_bulletin_board:view_bulletin' bulletin.slug %}{% else %}{% url 'aa_bulletin_board:dashboard' %}{% endif %}">{% translate "Back" %}</a>
            </div>
        </div>

        <div class="card-body aa-bulletin-boad-edit-bulletin">
            <form id="aa-bulletin-board-bulletin-form" autocomplete="off" action="{% if bulletin %}{% url 'aa_bulletin_board:edit_bulletin' bulletin.slug %}{% else %}{% url 'aa_bulletin_board:create_bulletin' %}{% endif %}" method="post">
                {% csrf_token %}

                {% bootstrap_form form %}

                {% if bulletin %}
                    {% translate "Update bulletin" as button_text %}
                {% else %}
                    {% translate "Create bulletin" as button_text %}
                {% endif %}

                {% bootstrap_button button_type="submit" button_class="btn btn-success" content=button_text|title %}
            </form>
        </div>
    </div>
{% endblock %}

{% block extra_javascript %}
    {% include "aa_bulletin_board/bundles/sumoselect-js.html" %}
    {% include "aa_bulletin_board/bundles/ckeditor5-js.html" %}

    <script>
        'use strict';

        $('.aa-bulletin-boad-edit-bulletin select').SumoSelect(
            {okCancelInMulti: true, selectAll: true}
        );
    </script>
{% endblock %}

{% block extra_css %}
    {% include "aa_bulletin_board/bundles/ckeditor5-css.html" %}
    {% include "aa_bulletin_board/bundles/sumoselect-css.html" %}
    {% include "aa_bulletin_board/bundles/aa-bulletin-board-css.html" %}
{% endblock %}
