{% set firstView = fsc.views | first %}
{% set doc = firstView.model %}
{% set currentView = fsc.getCurrentView() %}

<div class="container-fluid">
    <div class="row">
        <div class="col">
            {% for docfile in currentView.cursor %}
                <form action="{{ doc.url() }}" method="post" enctype="multipart/form-data">
                    <input type="hidden" name="activetab" value="{{ currentView.getViewName() }}" />
                    <input type="hidden" name="id" value="{{ docfile.id }}" />
                    <input type="hidden" name="multireqtoken" value="{{ fsc.multiRequestProtection.newToken() }}"/>
                    <div class="card shadow mb-3">
                        <div class="card-body">
                            <div class="form-group">
                                <textarea name="observations" class="form-control" placeholder="{{ i18n.trans('observations') }}">{{ docfile.observations }}</textarea>
                            </div>
                            <div class="form-row align-items-end">
                                <div class="col">
                                    {% set file = docfile.getFile() %}
                                    <a href="{{ file.url() }}" class="btn btn-sm btn-outline-primary">
                                        <i class="far fa-file"></i> {{ file.filename }}
                                    </a>
                                </div>
                                <div class="col">
                                    <p class="text-muted mb-0">
                                        {% if docfile.nick %}
                                            <i class="fas fa-user"></i> {{ docfile.nick }} &nbsp;
                                        {% endif %}
                                        <i class="fas fa-calendar-alt"></i> {{ docfile.creationdate }}
                                    </p>
                                </div>
                                <div class="col text-right">
                                    <button type="submit" name="action" value="edit-file" class="btn btn-sm btn-primary">
                                        <i class="fas fa-save fa-fw" aria-hidden="true"></i> {{ i18n.trans('save') }}
                                    </button>
                                    &nbsp;
                                    <div class="btn-group">
                                        <div class="dropdown">
                                            <button class="btn btn-sm btn-danger dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                <i class="fas fa-trash-alt"></i>
                                            </button>
                                            <div class="dropdown-menu dropdown-menu-right">
                                                <button type="submit" name="action" value="delete-file" class="dropdown-item" href="#">
                                                    <i class="far fa-trash-alt fa-fw"></i> {{ i18n.trans('delete-file') }}
                                                </button>
                                                <button type="submit" name="action" value="unlink-file" class="dropdown-item" href="#">
                                                    <i class="fas fa-unlink fa-fw"></i> {{ i18n.trans('unlink-file') }}
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            {% endfor %}
            <form action="{{ doc.url() }}" method="post" enctype="multipart/form-data">
                <input type="hidden" name="activetab" value="{{ currentView.getViewName() }}" />
                <input type="hidden" name="action" value="add-file" />
                <input type="hidden" name="multireqtoken" value="{{ fsc.multiRequestProtection.newToken() }}"/>
                <div class="card border-success shadow">
                    <div class="card-body">
                        <h5 class="card-title">
                            <i class="far fa-file"></i> {{ i18n.trans('new') }}
                        </h5>
                        <div class="form-group">
                            <textarea name="observations" class="form-control" placeholder="{{ i18n.trans('observations') }}"></textarea>
                        </div>
                        <div class="form-row align-items-end">
                            <div class="col">
                                <input type="file" name="new-file" class="form-control-file" required="" />
                                <p class="text-muted mb-0">
                                    {{ i18n.trans('help-server-accepts-filesize', {'%size%': currentView.model.getMaxFileUpload()}) }}
                                </p>
                            </div>
                            <div class="col text-right">
                                <button type="submit" class="btn btn-sm btn-success">
                                    <i class="fas fa-save fa-fw" aria-hidden="true"></i> {{ i18n.trans('save') }}
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
