{% extends "admin/change_form.html" %}
{% block admin_change_form_document_ready %}
{% if tabs %}
<script type="text/javascript" charset="utf-8">
django.jQuery(document).ready(function() {
    var $ = django.jQuery;
    add_tabs('#{{ opts.model_name }}_form tabs.django_vue_tabs');
    $('#{{ opts.model_name }}_form div.django_vue_tabs .tabs-component-panels section').each(function (i, item){
        var data_from = $(item).attr('data-from');
        if (data_from) {
            var parent;
            var data_from_items = data_from.split(',');
            for (var n in data_from_items) {
                parent = $('.' + data_from_items[n]).parent();
                if (parent.hasClass('inline-related')){
                    parent.parent().appendTo(item);
                }else if(parent.hasClass('inline-group')){
                    parent.appendTo(item);
                }else{
                    $('.' + data_from_items[n]).appendTo(item);
                }
            }
        }
    });
});
</script>
{% endif %}
{{ block.super }}
{% endblock %}
{% block field_sets %}
{% if tabs %}
<tabs class="django_vue_tabs">
    {% for tab in tabs %}
      <tab id="{{ tab.0|slugify }}" name="{{ tab.0 }}" data-from="{{ tab.1|join:',' }}"></tab>
    {% endfor %}
</tabs>
{% endif %}
{{ block.super }}
{% endblock %}
