{% extends 'manage/changelog/master.twig' %}
{% from 'macros.twig' import container_title %}
{% from '_layout/input.twig' import input_csrf, input_text, input_checkbox %}

{% block manage_content %}
    <div class="container">
        <form action="{{ url('manage-changelog-tag', {'tag': tag_info.id|default(0)}) }}" method="post">
            {{ input_csrf() }}

            {{ container_title(tag_new ? 'Adding a new tag' : 'Editing ' ~ tag_info.name ~ ' (' ~ tag_info.id ~ ')') }}

            <label class="form__label" style="width:100%">
                <div class="form__label__text">Name</div>
                <div class="form__label__input">
                    {{ input_text('ct_name', '', tag_info.id is defined ? tag_info.name : '', 'text', '', true, {'maxlength': 255}) }}
                </div>
            </label>

            <label class="form__label" style="width:100%">
                <div class="form__label__text">Description</div>
                <div class="form__label__input">
                    <textarea class="input__textarea" name="ct_desc" maxlength="65535">{{ tag_info.description|default('') }}</textarea>
                </div>
            </label>

            <label class="form__label">
                <div class="form__label__text">Archived</div>
                <div class="form__label__input">
                    {{ input_checkbox('ct_archive', '', tag_info.archived|default(false)) }}
                </div>
            </label>

            {% if not tag_new %}
                <label class="form__label">
                    <div class="form__label__text">Created</div>
                    <div class="form__label__input">
                        {{ input_text('', '', tag_info.createdTime|date('r')) }}
                    </div>
                </label>
            {% endif %}

            <div>
                <button class="input__button">Save</button>
                {% if not tag_new %}
                    <a href="{{ url('manage-changelog-tag-delete', { tag: tag_info.id, csrf: csrf_token() }) }}" class="input__button input__button--destroy" onclick="return confirm('Are you sure?');">Delete</a>
                {%  endif %}
            </div>
        </form>
    </div>
{% endblock %}
