{% load i18n %} 
{% load manager_extras %}

<script>
$(document).ready(function() {

	// Call the setup function to allow the sets to be sortable again after
	// loading this view via AJAX
	setup_inplace_editing();
});
</script>

<form action="{% url wger.manager.views.api_edit_set %}?do=edit_set&amp;set={{set.id}}&amp;exercise={{exercise.id}}"
      method="post"
      class="ajax-form-set-edit">
    {% csrf_token %}
    
    <span class="ui-widget">
        {% for current_exercise in set.exercises.all %}
        {% if current_exercise.id == exercise.id %}
        <input type="hidden"
            name="current_exercise"
               value="{{current_exercise.id}}"
               id="set-{{set.id}}-exercercise-id-hidden">
        {% endif %}
        
        <input type="hidden"
               name="exercises"
               value="{{current_exercise.id}}">
        {% endfor%}
        
        
        <input type="text"
               name="exercise_name"
               value="{{exercise.name}}"
               class="ajax-form-exercise-list ajax-form-element"
               id="set-{{set.id}}-exercercise-id">:
    </span>
    
    {% comment %}
        TODO: see if there is a better way to show and edit the sets
              for an exercise. The way this worked, a user had to change the sets,
              save, and edit again. Not very user friendly.
    {% endcomment%}
    <input type="hidden" name="sets" value="{{ set.sets }}" maxlength="2" style="width: 2em;">
    <!--
    {{ set.sets }}
    ×
    -->
    
    
    {% for setting in exercise|get_current_settings:set.id %}
        <input type="text"
               name="setting-{{setting.id}}"
               value="{{ setting.reps }}"
               maxlength="2"
               style="width: 2em;"
               class="ajax-form-element">
    {% endfor %}
    
    {% for setting in new_settings %}
        <input type="text"
               name="new-setting-{{setting}}"
               value=""
               maxlength="2"
               style="width: 2em;"
               class="ajax-form-element">
    {% endfor %}
    
    
    <input type="submit"
           value="{% trans 'Save' %}"
           class="ajax-form-submit" />
    <input type="submit"
          value="{% trans 'Cancel' %}"
          class="ajax-form-cancel" />
</form>
