{% extends 'projects/project_base.html' %}
{% load crispy_forms_tags %}
{% load sekizai_tags %}

{% block project_breadcrumb_links %}
    <li><a href="{% url 'projects_project_view' project.pk %}">{{ project.name }}</a></li>
    <li><a href="{% url 'projects_configuration_list' project.pk %}">Configurations</a></li>
    <li class="active">Update Configuration</li>
{% endblock project_breadcrumb_links %}

{% block content %}
    <h1>{% block action %}Update{% endblock action %} Configuration</h1><br/>

    {% crispy form %}

    {% addtoblock 'js' %}
        <script>
            function set_data_type_field(){
                var data_type = $('#id_data_type').val();
                $('#div_id_value_boolean, #div_id_value, #div_id_value_number').hide();

                if(data_type == 'boolean'){
                    $('#div_id_value_boolean').show();
                }else if(data_type == 'number'){
                    $('#div_id_value_number').show();
                }else{
                    $('#div_id_value').show();
                }
            }

            function show_hide_task_name_field(){
                var task_argument = $('#id_task_argument').is(':checked');
                if(task_argument){
                    $('#div_id_task_name').show();
                }else{
                    $('#div_id_task_name').hide();
                }
            }

            $(function(){
                set_data_type_field();
                $('#id_data_type').change(set_data_type_field);

                show_hide_task_name_field();
                $('#id_task_argument').change(show_hide_task_name_field);
            });
        </script>
    {% endaddtoblock %}
{% endblock %}