{% extends 'timepiece/base.html' %}
{% load bootstrap_toolkit %}

{% block title %}{% if entry %}Update{% else %}Create{% endif %} Entry{% endblock title %}

{% block extrajs %}
    <script type="text/javascript">
        $(document).ready(function() {
            function newParameters(query) {
                query.project = $('#id_project').val();
            }
            $('#id_activity_0').djselectable('option', 'prepareQuery', newParameters);
        });
    </script>
    <script>
        $.ui.djselectable.prototype._comboButtonTemplate = function (input) {
            var icon = $("<i>").addClass("icon-chevron-down");
            // Remove current classes on the text input
            $(input).attr("class", "");
            // Wrap with input-append
            $(input).wrap('<div class="input-append" />');
            // Return button link with the chosen icon
            return $("<a>").append(icon).addClass("btn ");
        };
        $.ui.djselectable.prototype._removeButtonTemplate = function (item) {
            var icon = $("<i>").addClass("icon-remove-sign");
            // Return button link with the chosen icon
            return $("<a>").append(icon).addClass("btn pull-right");
        };
    </script>
{% endblock extrajs %}

{% block crumbs %}
    {{ block.super }}
    {% if entry %}
        <li><span class="divider">/</span> <a href="{% url 'edit_entry' entry.pk %}">Update Entry</a></li>
    {% else %}
        <li><span class="divider">/</span> <a href="{% url 'create_entry' %}">Create Entry</a></li>
    {% endif %}
{% endblock crumbs %}

{% block content %}
    <div class="row-fluid">
        <div class="span12">
            <h2>{% if entry %}Update{% else %}Create{% endif %} Entry</h2>

            <br style="clear: both;" />

            <form class="form-horizontal" action="" method="post" accept-charset="utf-8">
                {% csrf_token %}
                {{ form|as_bootstrap:"horizontal" }}
                <div class="form-actions">
                    <input class="btn btn-primary" type='submit' name='submit' value='Save' />
                    <input class="btn" type='button' value='Cancel' onclick="history.back()" />
                </div>
            </form>
        </div>
    </div>
{% endblock content %}
