{% load static %}
{% load i18n %}


<!-- from INSTANCE DETAIL (1 object) -->


{% if item.dataformat == "string" %}
    {% if item.dataformat_ext == "safe" %} {{ item.value|safe }}
    {% elif item.dataformat_ext == "url" %} <a href="{{ item.value|safe }}">{{ item.value|safe }}</a>
    {% else %} {{ item.value|default:'' }} {% endif %}

{% elif item.dataformat == "boolean" %} 
<div class="d-flex">
    {% if item.value %}<i class="fa fa-check" aria-hidden="true"></i>{% endif %}
</div>

    
{% elif item.dataformat == "int" %}  {{ item.value|default:'' }}

{% elif item.dataformat == "float" %}  {{ item.value|default:'' }}

{% elif item.dataformat == "group" %}  
    <div class="d-flex flex-wrap"> 
    {% for z in item.value %}
    <a class="btn btn-outline-primary btn-sm mx-1 my-1" href="{% url 'app_user:group_detail' z.id %}" role="button">
    {{ z.display|default:z.key }}</a>{% endfor %}   
    </div>   

{% elif item.dataformat == "role" %}  
    <div class="d-flex flex-wrap"> 
    {% for z in item.value %}
    <a class="btn btn-outline-primary btn-sm mx-1 my-1" href="{% url 'app_user:role_detail' z.id %}" role="button">
    {{ z.display|default:z.key }}</a>{% endfor %}   
    </div>  

{% elif item.dataformat == "user" %}
    <div class="d-flex flex-wrap"> 
    {% for z in item.value %}
    <a class="btn btn-outline-primary btn-sm mx-1 my-1" href="{% url 'app_user:user_detail' z.id %}" role="button">
    {{ z.display|default:z.key }}</a>{% endfor %}     
    </div>  

{% elif item.dataformat == "schema" %}  
    <div class="d-flex flex-wrap"> 
    {% for z in item.value %}
    <a class="btn btn-outline-success btn-sm mx-1 my-1" href="{% url 'app_data:instance_detail' z.id %}" role="button">
    {{ z.display|default:z.key }}</a>{% endfor %}
    </div>          

{% elif item.dataformat == "enumerate" %}
    <div class="d-flex flex-wrap">
        {% for z in item.value %} {{ z.widget|safe }} {{ z.value }} {{ z.detail }} <br> {% endfor %}
    </div>
        
{% elif item.dataformat == "external" %}  
    <div class="d-flex flex-wrap"> 
        <i>{{ item.value|default:'' }}</i>
    </div>   

{% elif item.dataformat == "text" %}  
    {% if item.dataformat_ext == "html" %}
        <div>{{ item.value|safe }}</div>
    {% else %}
        <pre>{{ item.value|default:'' }}</pre> 
    {% endif %}

{% elif item.dataformat == "file" %}  
    <div class="d-flex flex-wrap"> 
        {% if item.queryset.0.displayname %}
        <a href="{% url 'app_data:file_display' item.queryset.0.fileid %}">
            <i class="fa fa-file me-2"></i>
            {{ item.queryset.0.displayname }} ({{ item.queryset.0.size}})
        </a>
        {% endif %}
        
        <!-- <input type="hidden" 
            name="current-{{ item.fieldname}}" 
            value="{{item.queryset.0.fileid}}">
        -->
    </div>

{% elif item.dataformat == "password" %}  
<div class="d-flex justify-content-left">
   {{ item.value.0|default:'' }}
</div>

{% else %} {{ item.value|default:'' }}  {% endif %}
