{#
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
#}

{% import 'appbuilder/general/lib.html' as lib %}
{% include 'appbuilder/general/confirm.html' %}
{% include 'appbuilder/general/alert.html' %}

{% block columns %}

{% if fieldsets %}

    {% for fieldset_item in fieldsets %}
        {% if fieldset_item[1].get('expanded') == None %}
            {% set expanded = True %}
        {% else %}
            {% set expanded = fieldset_item[1].get('expanded') %}
        {% endif %}
        {% call lib.accordion_tag(loop.index,fieldset_item[0], expanded) %}
        <div class="table-responsive">
        <table class="table table-bordered">
        {% for item in fieldset_item[1].get('fields') %}
            <tr>
            <th class="col-lg-2 col-md-2 col-sm-2">{{label_columns.get(item)}}</th>
        <td><span id="{{item}}">{{value_columns[include_columns.index(item)]}}</span></td>
            </tr>
        {% endfor %}
        </table></div>
        {% endcall %}
    {% endfor %}

{% else %}
    <div class="table-responsive">
    <table class="table table-bordered">

    {% for item in include_columns %}
        <tr>
            <th class="col-lg-2 col-md-2 col-sm-2">{{label_columns.get(item)}}</th>
            <td>
                <span id="{{item}}">{{value_columns[loop.index-1]}}</span>
            </td>
        </tr>
    {% endfor %}
    </table></div>
{% endif %}

{% endblock columns %}


{% block actions %}
<div class="well well-sm">
    {{ lib.render_action_links(actions, pk, modelview_name) }}
    {{ lib.lnk_back() }}
</div>
{% endblock actions %}
