{% import "backend/macros.html" as macros %}
{% extends "backend/custom/surround.html" %}
{% block content %}

    {% if not origin %}
        {% set origin = False %}
    {% endif %}
    {% set record = record %}
            {{ macros.getRecordButtons(classname,classid,current_user,record,editable,backlink)}}
            {% if editable %}
            <form method="post" enctype="multipart/form-data" id="form-record" class="main-object-form">
            <!-- Inputs ocultos -->
            <input type="hidden" id="csrf_token" name="csrf_token" value="{{ csrf_token() }}">
            {% if record %}
                <input type="hidden" id="modifiedby_id" name="modifiedby_id" value="{{ current_user.id }}" >
            {%else%}
                <input type="hidden" id="createdby_id" name="createdby_id" value="{{ current_user.id }}" >
            {% endif %}
            {% endif %}
            <div class="bg-white shadow-sm rounded-3 p-4">
                <!-- Aquí va el contenido -->
                <div class="card mb-4">
                    <div class="card-header bg-light fw-semibold">
                        General
                    </div>
                    <div class="card-body">
                        {{ macros.fieldForm(fields["name"],record,editable,origin)}}
                        {{ macros.fieldForm(fields["description"],record,editable,origin)}}
                    </div>
                </div>
                <!-- Aquí va el contenido -->
                <div class="card mb-4">
                    <div class="card-body">
                            <!-- Tabs internos -->
                            <ul class="nav nav-pills mb-3" id="infoTab" role="tablist">
                                <li class="nav-item" role="presentation">
                                    <button class="nav-link active" id="persona-tab" data-bs-toggle="pill"
                                        data-bs-target="#persona" type="button" role="tab">OBJETOS</button>
                                </li>
                            </ul>
                            <div class="tab-content" id="infoTabContent">
                                <!-- Información Clave -->
                                <div class="tab-pane fade show active" id="persona" role="tabpanel">
                                    <!-- Aquí va el contenido de Información Clave y Clasificación -->
                                    <div class="card mb-4">
                                        <div class="card-body">
                                        {% if record %}
                                        {% set fieldsObj = ["id","featuredImage","title","suggestedTitle","creator"] %}
                                        {% set origin = 'objectGroup:' ~ record.id ~ ':' ~ classid %}
                                        {{ macros.getConnectedTable(record, 1, fieldsObj,origin=origin) }}
                                        {% endif %}
                                        </div>
                                    </div>
                                </div>
                            </div>
                    </div>
                </div>
            </div>
            {%if editable %}
            </form>
            {% endif %}
{% endblock %}

