<div class="panel panel-default">
    <div class="panel-heading">
        <div class="panel-title">
            <a data-toggle="collapse" href="#toggleForm" data-target="#rerun_form" id="toggle_form">
                <i class="fa fa-chevron-right"></i> Re-run reduction job
            </a>
        </div>
    </div>
    <div class="panel-body collapse" id="rerun_form">
        <form id="run_variables" method="POST" action="{% url 'run_confirmation' instrument=instrument.name %}" class="form-horizontal">
            {% csrf_token %}
            <input type="hidden" name="run_range" value="{{ run_number }}">
            <input type="hidden" name="run_version" value="{{ run_version }}">
            <div class="row">
                <div class="col-md-9">
                    {% include "snippets/form_warnings.html" %}
                    <div class="form-group">
                        <label for="run_description" class="control-label col-md-2">
                            Re-run description
                            <a href="#" data-toggle="popover"
                               data-content="This will be appended onto the run number for you and others to identify the reason for re-submitting."
                               data-trigger="hover click focus" data-placement="top" data-container="body" aria-label="This will be appended onto the run number for you and others to identify the reason for re-submitting.">
                                <i class="fa fa-info-circle"></i>
                            </a>
                        </label>
                        <div class="col-md-10">
                            <input type="text" name="run_description" class="form-control" />
                        </div>
                    </div>
                    <div class="js-variables-container">
                        {% include "snippets/edit_variables.html" with standard_variables=standard_variables advanced_variables=advanced_variables instrument=instrument.name only %}
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="well well-sm">
                        <div class="row">
                            <div class="col-md-12">
                                <h4>Additional Actions</h4>
                            </div>
                        </div>
                        <div class="row">
                            <ul class="js-form-actions">
                                <li>
                                    <a href="#resetValues" id="resetValues">Reset variables to initial values used for this run</a>
                                    <a href="#" data-toggle="popover" data-html="true" data-content="Reset the values of the variables to the ones previously used for this run." data-trigger="hover click focus" data-placement="top" data-container="body" aria-label="Reset the values of the variables to the ones previously used for this run.">
                                        <i class="fa fa-info-circle"></i>
                                    </a>
                                </li>
                                {% if current_standard_variables %}
                                <li>
                                    <a href="#currentScript" id="currentScript">Reset to values in the current reduce_vars script</a>
                                    <a href="#" data-toggle="popover" data-html="true" data-content="Reset to the values currently contained in the reduce_vars script." data-trigger="hover click focus" data-placement="top" data-container="body">
                                        <i class="fa fa-info-circle"></i>
                                    </a>
                                </li>
                                {% endif %}
                            </ul>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 js-action-explaination"></div>
                    </div>
                </div>
            </div>
            <div class="form-group variables-buttons">
                <div class="col-md-9 text-right">
                    <input type="submit" value="Re-run with new variables" class="btn btn-success" id="variableSubmit" />
                </div>
            </div>
        </form>
    </div>
</div>

<div class="hide">
    <div class="js-default-variables">
        {% include "snippets/edit_variables.html" with standard_variables=standard_variables advanced_variables=advanced_variables instrument=instrument.name only %}
    </div>
    <div class="js-current-variables">
        {% include "snippets/edit_variables.html" with standard_variables=current_standard_variables advanced_variables=current_advanced_variables instrument=instrument.name only %}
    </div>
</div>