{% extends "build/build_base.html" %}

{% load static %}
{% load i18n %}
{% load markdownify %}

{% block menubar %}
{% include "build/navbar.html" with tab='notes' %}
{% endblock %}

{% block heading %}
{% trans "Build Notes" %}
{% if roles.build.change and not editing %}
<button title='{% trans "Edit notes" %}' class='btn btn-default' id='edit-notes'><span class='fas fa-edit'></span></button>
{% endif %}
{% endblock %}

{% block details %}
{% if editing %}
<hr>
<form method='POST'>
    {% csrf_token %}
        
    {{ form }}
    <hr>
    <button type="submit" class='btn btn-default'>{% trans "Save" %}</button>
    
</form>

{{ form.media }}

{% else %}

{{ build.notes | markdownify }}
{% endif %}

{% endblock %}

{% block js_ready %}
{{ block.super }}

{% if editing %}
{% else %}
$("#edit-notes").click(function() {
    location.href = "{% url 'build-notes' build.id %}?edit=1";
});
{% endif %}

{% endblock %}