{% extends 'ftp_deploy/base.html' %}
{% load crispy_forms_tags %}
{% load staticfiles %}

{% block extrahead %}
    <script src="{% static "admin/js/jquery.js" %}"></script>
    <script src="{% static "admin/js/jquery.init.js" %}"></script>
    <script src="{% static "admin/js/urlify.js" %}"></script>
    <script src="{% static "admin/js/prepopulate.js" %}"></script>

    <script type="text/javascript">
         (function($) {
            $(window).load(function(){
                
                var field = {
                    id: '#{{ form.repo_slug_name.auto_id }}',
                    dependency_ids: ['#{{ form.repo_name.auto_id }}'],
                    dependency_list: ['{{ form.repo_name.name }}'],
                    maxLength: {{ form.repo_slug_name.field.max_length|default_if_none:"50" }}
                };
                $(field.id).addClass('prepopulated_field');
                $(field.id).data('dependency_list', field['dependency_list'])
                .prepopulate(field['dependency_ids'], field.maxLength);
            });
        })(django.jQuery);
    </script>

{% endblock extrahead %}

{% block title %}
    {% if service %} 
        <div>
            <div id="service-actions" class="pull-right">
                <div class="btn-group pull-right">
                    <a href="{% url 'ftpdeploy_service_manage' service.pk %}" class="btn btn-primary">Manage</a> 
                    <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
                        <span class="caret"></span>
                        <span class="sr-only">Toggle Dropdown</span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
                        <li><a href="{% url 'ftpdeploy_service_delete' service.pk %}" id="service-delete">Delete</a></li>
                    </ul>
                </div>
            </div>
        </div>
        <h2 class="pull-left">{{service.repo_name}} <small>Edit</small></h2>
    {% else %}
        <h2 class="pull-left">Service <small>Add</small></h2>
    {% endif %}
{% endblock title %}


{% block content %}
    
    <div class="row">

        <div class="col-sm-4">
            {% include "ftp_deploy/menu.html" %}
        </div>

        <div class="col-sm-8">
            {% crispy form %}      
        </div>
    </div>

{% endblock content %}