{# backend/templates/communications/chat_list.html #} {% extends "base.html" %} {% load static django_bootstrap5 %} {% block title %}Мои чаты{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{# ===== НОВАЯ ШАПКА С КОМПОНЕНТОМ ===== #} {% include "includes/components/page_header.html" with icon="bi-chat-dots" title="Мои чаты" search_id="chatSearch" search_placeholder="Поиск по названию или участникам" create_as_card=True create_modal="chatCreateModal" create_text="Создать чат" %} {# ===== ДВУХКОЛОНОЧНАЯ СТРУКТУРА ===== #}
{# Левая колонка - иконки типов чатов #}
{# Правая колонка - список чатов #}
{# ===== 1) ГЛОБАЛЬНЫЙ ===== #}
Глобальный
{% for chat in chats %} {% if chat.type == 'global' %} {% with last=chat.last_message.0 %}
{# Аватар или иконка #}
{% if chat.avatar %} {{ chat.name }} {% else %} {% endif %}
{{ chat.name|default:"Глобальный чат" }} {{ chat.messages.count }} +{{ chat.unread_count|default:0 }}
{% if last %} {{ last.created_at|date:"d.m.Y H:i" }} · {{ last.author.get_full_name|default:last.author.username }}: {{ last.content|default:"(вложение)"|truncatechars:120 }} {% else %} Сообщений пока нет. {% endif %}
{# Меню действий - Глобальный чат #}
{% endwith %} {% endif %} {% endfor %}
{# ===== 2) ОТДЕЛЫ ===== #}
Отделы
{% for chat in chats %} {% if chat.type == 'department' %} {% with last=chat.last_message.0 %}
Чат отдела: {{ chat.department.name }} {{ chat.messages.count }} +{{ chat.unread_count|default:0 }}
{% if last %} {{ last.created_at|date:"d.m.Y H:i" }} · {{ last.author.get_full_name|default:last.author.username }}: {{ last.content|default:"(вложение)"|truncatechars:120 }} {% else %} Сообщений пока нет. {% endif %}
{# Меню действий - Отдел #}
{% endwith %} {% endif %} {% endfor %}
{# ===== 3) ЛИЧНЫЕ ===== #}
Личные
{% for chat in chats %} {% if chat.type == 'private' %} {% with last=chat.last_message.0 %}
{% with p0=chat.participants.all.0 p1=chat.participants.all.1 %} {% if p0 and p0 != user and p0.avatar %} {{ p0.get_full_name|default:p0.username }} {% elif p1 and p1 != user and p1.avatar %} {{ p1.get_full_name|default:p1.username }} {% else %} {% endif %} {% endwith %}
{% if last %} {{ last.created_at|date:"d.m.Y H:i" }} · {{ last.author.get_full_name|default:last.author.username }}: {{ last.content|default:"(вложение)"|truncatechars:120 }} {% else %} Сообщений пока нет. {% endif %}
{# Меню действий - Личный чат #}
{% endwith %} {% endif %} {% endfor %}
{# ===== 4) ГРУППЫ ===== #}
Группы
{% for chat in chats %} {% if chat.type == 'group' %} {% with last=chat.last_message.0 %}
{% if chat.avatar %} {{ chat.name }} {% else %} {% endif %}
{{ chat.name }} {{ chat.messages.count }} +{{ chat.unread_count|default:0 }}
{% if last %} {{ last.created_at|date:"d.m.Y H:i" }} · {{ last.author.get_full_name|default:last.author.username }}: {{ last.content|default:"(вложение)"|truncatechars:120 }} {% else %} Сообщений пока нет. {% endif %}
{# Меню действий #}
{% endwith %} {% endif %} {% endfor %}
{# ===== 5) КАНАЛЫ ===== #}
Каналы
{% for chat in chats %} {% if chat.type == 'channel' %} {% with last=chat.last_message.0 %}
{% if chat.avatar %} {{ chat.name }} {% else %} {% endif %}
{{ chat.name }} {{ chat.messages.count }} +{{ chat.unread_count|default:0 }}
{% if last %} {{ last.created_at|date:"d.m.Y H:i" }} · {{ last.author.get_full_name|default:last.author.username }}: {{ last.content|default:"(вложение)"|truncatechars:120 }} {% else %} Сообщений пока нет. {% endif %}
{# Меню действий #}
{% endwith %} {% endif %} {% endfor %}
{# ===== 6) ОБЪЯВЛЕНИЯ ===== #}
Объявления
{% for chat in chats %} {% if chat.type == 'announcement' %} {% with last=chat.last_message.0 %}
{% if chat.avatar %} {{ chat.name }} {% else %} {% endif %}
{{ chat.name }} {{ chat.messages.count }} +{{ chat.unread_count|default:0 }}
{% if last %} {{ last.created_at|date:"d.m.Y H:i" }} · {{ last.author.get_full_name|default:last.author.username }}: {{ last.content|default:"(вложение)"|truncatechars:120 }} {% else %} Сообщений пока нет. {% endif %}
{# Меню действий #}
{% endwith %} {% endif %} {% endfor %}
{% if not chats %}
Чатов пока нет. Начните с поиска сотрудника.
{% endif %}
{# конец chat-list-main #}
{# конец d-flex #}
{# ===== МОДАЛКА СОЗДАНИЯ ЧАТА ===== #} {# Подключаем chat-list-enhanced.js для WebSocket и контекстного меню #} {% endblock %}