loko/streetup/documents/templates/documents/document_list.html

253 lines
No EOL
16 KiB
HTML

{% extends "documents/base_documents.html" %}
{% load i18n %}
{% block content %}
<div class="container-fluid py-4">
<div class="d-flex justify-content-between align-items-center mb-2">
<div>
<h2 class="mb-0">{% translate "Document Management" %}</h2>
</div>
<div class="d-flex gap-2">
<a class="btn btn-outline-primary" href="{% url 'documents:folder_create' %}?{% if current_folder %}parent={{ current_folder.slug }}&amp;{% endif %}next={{ request.get_full_path|urlencode }}">
<i class="bi bi-folder-plus"></i> {% translate "New folder" %}
</a>
<a class="btn btn-primary" href="{% url 'documents:create' %}{% if current_folder %}?folder={{ current_folder.slug }}{% endif %}"><i class="bi bi-plus-circle"></i> {% translate "New document" %}</a>
</div>
</div>
<nav aria-label="{% translate 'Breadcrumb' %}" class="mb-4">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item {% if not breadcrumbs %}active{% endif %}">
{% if breadcrumbs %}
<a href="{% url 'documents:list' %}{% if current_sort and current_sort != 'name' %}?sort={{ current_sort }}{% endif %}">{% translate "Document Management" %}</a>
{% else %}
{% translate "Document Management" %}
{% endif %}
</li>
{% for folder in breadcrumbs %}
<li class="breadcrumb-item {% if forloop.last %}active{% endif %}">
{% if forloop.last %}
{{ folder.name }}
{% else %}
<a href="{% url 'documents:list' %}?folder={{ folder.slug }}{% if current_sort and current_sort != 'name' %}&amp;sort={{ current_sort }}{% endif %}">{{ folder.name }}</a>
{% endif %}
</li>
{% endfor %}
</ol>
</nav>
<form method="get" class="row g-2 align-items-end mb-4">
{% if request.GET.folder %}
<input type="hidden" name="folder" value="{{ request.GET.folder }}">
{% endif %}
<div class="col-md-12 col-lg-4">
<label class="form-label" for="search">{% translate "Search" %}</label>
<input type="text" class="form-control" name="search" id="search" value="{{ request.GET.search }}" placeholder="{% translate 'Title or keyword' %}">
</div>
<div class="col-md-6 col-lg-2">
<label class="form-label" for="type">{% translate "Type" %}</label>
<select class="form-select" name="type" id="type">
<option value="">{% translate "All" %}</option>
{% for type in types %}
<option value="{{ type.code }}" {% if request.GET.type == type.code %}selected{% endif %}>{{ type.label }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-6 col-lg-2">
<label class="form-label" for="tag">{% translate "Tag" %}</label>
<select class="form-select" name="tag" id="tag">
<option value="">{% translate "All" %}</option>
{% for tag in tags %}
<option value="{{ tag.slug }}" {% if request.GET.tag == tag.slug %}selected{% endif %}>{{ tag.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-6 col-lg-2 d-grid">
<button type="submit" class="btn btn-outline-primary">{% translate "Filter" %}</button>
</div>
</form>
<div class="table-responsive">
<table class="table table-striped align-middle">
<thead>
<tr>
<th scope="col"{% if title_sort.is_active %} aria-sort="{% if title_sort.direction == 'asc' %}ascending{% else %}descending{% endif %}"{% endif %}>
<a class="text-decoration-none text-reset" href="?{{ title_sort.next_query }}">
{% translate "Title" %}
{% if title_sort.is_active %}
{% if title_sort.direction == 'asc' %}
<i class="bi bi-arrow-up-short"></i>
{% else %}
<i class="bi bi-arrow-down-short"></i>
{% endif %}
{% endif %}
</a>
</th>
<th scope="col"{% if updated_sort.is_active %} aria-sort="{% if updated_sort.direction == 'asc' %}ascending{% else %}descending{% endif %}"{% endif %}>
<a class="text-decoration-none text-reset" href="?{{ updated_sort.next_query }}">
{% translate "Updated at" %}
{% if updated_sort.is_active %}
{% if updated_sort.direction == 'desc' %}
<i class="bi bi-arrow-down-short"></i>
{% else %}
<i class="bi bi-arrow-up-short"></i>
{% endif %}
{% endif %}
</a>
</th>
<th>{% translate "Updated by" %}</th>
<th>{% translate "Tags" %}</th>
<th>{% translate "Folders" %}</th>
<th>{% translate "Linked items" %}</th>
<th class="text-end">{% translate "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for item in listing_items %}
{% if item.type == "folder" %}
{% with folder=item.object %}
<tr class="table-light">
<td>
<i class="bi bi-folder {% if not folder.is_predefined %}text-warning{% endif %}"></i>
<a href="{% url 'documents:list' %}?folder={{ folder.slug }}{% if current_sort and current_sort != 'name' %}&amp;sort={{ current_sort }}{% endif %}">{{ folder.name }}</a>
</td>
<td>{{ folder.updated_at|date:"SHORT_DATETIME_FORMAT" }}</td>
<td>{{ item.updated_by|default:"—" }}</td>
<td><span class="text-muted">—</span></td>
<td>
{% with parents=folder.parent_folders.all %}
{% if parents %}
{% for parent in parents %}
<span class="badge bg-secondary">{{ parent.name }}</span>
{% empty %}
{% endfor %}
{% else %}
<span class="text-muted">{% translate "None" %}</span>
{% endif %}
{% endwith %}
</td>
<td><span class="text-muted">—</span></td>
<td class="text-end">
{% if folder.created_by_id == request.user.id or is_documents_admin %}
<a class="btn btn-sm btn-outline-primary me-1" style="border-style: hidden;" href="{% url 'documents:folder_share' folder.pk %}" title="{% translate 'Manage sharing' %}">
<i class="bi bi-share"></i>
</a>
{% endif %}
{% if not folder.is_predefined %}
{% if folder.created_by_id == request.user.id or is_documents_admin %}
<div class="btn-group" role="group" aria-label="{% translate 'Folder actions' %}">
<a class="btn btn-sm btn-outline-secondary" style="border-style: hidden;" href="{% url 'documents:folder_edit' folder.pk %}?next={{ request.get_full_path|urlencode }}" title="{% translate 'Edit folder' %}">
<i class="bi bi-pencil"></i>
</a>
<a class="btn btn-sm btn-outline-danger" style="border-style: hidden;" href="{% url 'documents:folder_delete' folder.pk %}?next={{ request.get_full_path|urlencode }}" title="{% translate 'Delete folder' %}">
<i class="bi bi-trash"></i>
</a>
</div>
{% elif not folder.created_by_id == request.user.id and not is_documents_admin %}
<span class="text-muted">—</span>
{% endif %}
{% else %}
{% if not folder.created_by_id == request.user.id and not is_documents_admin %}
<span class="text-muted">—</span>
{% endif %}
{% endif %}
</td>
</tr>
{% endwith %}
{% else %}
{% with document=item.object %}
<tr>
<td>
{% if document.latest_version %}
{% with document.latest_version.filename|slice:"-4:" as ext4 %}
{% with document.latest_version.filename|slice:"-5:" as ext5 %}
{% if ext4 == ".pdf" %}
<i class="bi bi-file-earmark-pdf text-danger"></i>
{% elif ext4 == ".doc" or ext5 == ".docx" %}
<i class="bi bi-file-earmark-word text-primary"></i>
{% elif ext4 == ".xls" or ext5 == ".xlsx" %}
<i class="bi bi-file-earmark-excel text-success"></i>
{% elif ext4 == ".ppt" or ext5 == ".pptx" %}
<i class="bi bi-file-earmark-ppt text-warning"></i>
{% elif ext4 == ".jpg" or ext5 == ".jpeg" or ext4 == ".png" or ext4 == ".gif" %}
<i class="bi bi-file-earmark-image text-info"></i>
{% else %}
<i class="bi bi-file-earmark"></i>
{% endif %}
{% endwith %}
{% endwith %}
{% else %}
<i class="bi bi-file-earmark"></i>
{% endif %}
<a href="{{ document.get_absolute_url }}">{{ document.title }}{% if document.get_file_extension %} ({{ document.get_file_extension }}){% endif %}</a>
</td>
<td>{{ document.updated_at|date:"SHORT_DATETIME_FORMAT" }}</td>
<td>{{ item.updated_by|default:"—" }}</td>
<td>
{% for tag in document.tags.all %}
<span class="badge bg-secondary">{{ tag.name }}</span>
{% empty %}
<span class="text-muted">{% translate "None" %}</span>
{% endfor %}
</td>
<td>
{% for folder in document.folders.all %}
<span class="badge bg-light text-dark">{{ folder.name }}</span>
{% empty %}
<span class="text-muted">{% translate "None" %}</span>
{% endfor %}
</td>
<td>
{% for attachment in document.attachments.all %}
<span class="badge bg-light text-dark">{{ attachment.content_object }}</span>
{% empty %}
<span class="text-muted">{% translate "None" %}</span>
{% endfor %}
</td>
<td class="text-end">
{% if item.can_delete %}
<a class="btn btn-sm btn-outline-danger" style="border-style: hidden;" href="{% url 'documents:delete' document.pk %}?next={{ request.get_full_path|urlencode }}" title="{% translate 'Delete document' %}">
<i class="bi bi-trash"></i>
</a>
{% else %}
<span class="text-muted">—</span>
{% endif %}
</td>
</tr>
{% endwith %}
{% endif %}
{% empty %}
<tr>
<td colspan="7" class="text-center py-4 text-muted">
<i class="bi bi-folder2-open display-6"></i>
<p class="mt-2">{% translate "No document available yet." %}</p>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% if is_paginated %}
<nav aria-label="{% translate 'Documents pagination' %}">
<ul class="pagination justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item">
<a class="page-link" href="?{% if current_querystring %}{{ current_querystring }}&amp;{% endif %}page={{ page_obj.previous_page_number }}">&laquo;</a>
</li>
{% endif %}
{% for page_number in paginator.page_range %}
<li class="page-item {% if page_number == page_obj.number %}active{% endif %}">
<a class="page-link" href="?{% if current_querystring %}{{ current_querystring }}&amp;{% endif %}page={{ page_number }}">{{ page_number }}</a>
</li>
{% endfor %}
{% if page_obj.has_next %}
<li class="page-item">
<a class="page-link" href="?{% if current_querystring %}{{ current_querystring }}&amp;{% endif %}page={{ page_obj.next_page_number }}">&raquo;</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
</div>
{% endblock content %}