Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- Search bar in inbox/sent: filters by subject, content, sender/recipient - Group chats: create named or ad-hoc groups with Norda members - Group roles: owner, moderator, member with permission hierarchy - Group management: add/remove members, change roles - Photo avatars in message list (fallback to initials) - Unread count API extended to include group messages - Migration 088: message_group, message_group_member, group_message tables Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
453 lines
15 KiB
HTML
Executable File
453 lines
15 KiB
HTML
Executable File
{% extends "base.html" %}
|
|
|
|
{% block title %}Wiadomości - Norda Biznes Partner{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
.messages-page {
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.messages-topbar {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-bottom: var(--spacing-lg);
|
|
gap: var(--spacing-md);
|
|
}
|
|
|
|
.messages-topbar h1 {
|
|
font-size: var(--font-size-2xl);
|
|
color: var(--text-primary);
|
|
margin: 0;
|
|
}
|
|
|
|
.unread-badge {
|
|
background: var(--primary);
|
|
color: white;
|
|
padding: 1px 8px;
|
|
border-radius: 12px;
|
|
font-size: var(--font-size-xs);
|
|
font-weight: 600;
|
|
vertical-align: middle;
|
|
margin-left: var(--spacing-xs);
|
|
}
|
|
|
|
.messages-tabs {
|
|
display: flex;
|
|
gap: 2px;
|
|
background: var(--border-color, #e5e7eb);
|
|
border-radius: var(--radius);
|
|
padding: 2px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.tab-link {
|
|
padding: var(--spacing-xs) var(--spacing-lg);
|
|
border-radius: calc(var(--radius) - 2px);
|
|
text-decoration: none;
|
|
color: var(--text-secondary);
|
|
font-weight: 500;
|
|
font-size: var(--font-size-sm);
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.tab-link:hover {
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.tab-link.active {
|
|
background: var(--surface);
|
|
color: var(--text-primary);
|
|
box-shadow: 0 1px 2px rgba(0,0,0,0.06);
|
|
}
|
|
|
|
.messages-list {
|
|
background: var(--surface);
|
|
border-radius: var(--radius-lg);
|
|
border: 1px solid var(--border-color, #e5e7eb);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.message-item {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: var(--spacing-md) var(--spacing-lg);
|
|
border-bottom: 1px solid var(--border-color, #f3f4f6);
|
|
text-decoration: none;
|
|
color: inherit;
|
|
transition: background 0.15s;
|
|
gap: var(--spacing-md);
|
|
}
|
|
|
|
.message-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.message-item:hover {
|
|
background: rgba(0,0,0,0.02);
|
|
}
|
|
|
|
.message-item.unread {
|
|
background: rgba(37, 99, 235, 0.04);
|
|
}
|
|
|
|
.message-item.unread .message-subject {
|
|
font-weight: 600;
|
|
}
|
|
|
|
.message-avatar {
|
|
width: 42px;
|
|
height: 42px;
|
|
border-radius: 50%;
|
|
background: var(--primary);
|
|
color: white;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-weight: 600;
|
|
font-size: var(--font-size-sm);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.message-item.unread .message-avatar {
|
|
box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
|
|
}
|
|
|
|
.message-body {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.message-top-row {
|
|
display: flex;
|
|
align-items: baseline;
|
|
justify-content: space-between;
|
|
gap: var(--spacing-sm);
|
|
margin-bottom: 2px;
|
|
}
|
|
|
|
.message-subject {
|
|
font-size: var(--font-size-base);
|
|
font-weight: 500;
|
|
color: var(--text-primary);
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
min-width: 0;
|
|
}
|
|
|
|
.message-date {
|
|
font-size: var(--font-size-xs);
|
|
color: var(--text-secondary);
|
|
white-space: nowrap;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.message-bottom-row {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: var(--spacing-sm);
|
|
}
|
|
|
|
.message-preview {
|
|
font-size: var(--font-size-sm);
|
|
color: var(--text-secondary);
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
min-width: 0;
|
|
}
|
|
|
|
.message-sender {
|
|
font-size: var(--font-size-xs);
|
|
color: var(--text-secondary);
|
|
white-space: nowrap;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.message-sender strong {
|
|
color: var(--text-primary);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.message-badges {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
margin-left: var(--spacing-xs);
|
|
}
|
|
|
|
.context-badge-small {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 3px;
|
|
padding: 1px 6px;
|
|
background: #eff6ff;
|
|
border-radius: var(--radius-sm);
|
|
font-size: 11px;
|
|
color: var(--primary);
|
|
}
|
|
|
|
.context-badge-small svg {
|
|
width: 11px;
|
|
height: 11px;
|
|
}
|
|
|
|
.status-pill {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 3px;
|
|
padding: 1px 7px;
|
|
border-radius: 10px;
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
margin-top: 3px;
|
|
}
|
|
.status-pill svg {
|
|
width: 12px;
|
|
height: 12px;
|
|
}
|
|
.status-pill.new-msg {
|
|
background: #dbeafe;
|
|
color: #1d4ed8;
|
|
}
|
|
.status-pill.read {
|
|
background: #dcfce7;
|
|
color: #15803d;
|
|
}
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: var(--spacing-2xl) var(--spacing-lg);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.empty-state p {
|
|
margin: 0 0 var(--spacing-md);
|
|
}
|
|
|
|
.pagination {
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: var(--spacing-xs);
|
|
margin-top: var(--spacing-lg);
|
|
}
|
|
|
|
.pagination a {
|
|
padding: var(--spacing-xs) var(--spacing-md);
|
|
border-radius: var(--radius);
|
|
text-decoration: none;
|
|
color: var(--text-secondary);
|
|
background: var(--surface);
|
|
border: 1px solid var(--border-color, #e5e7eb);
|
|
font-size: var(--font-size-sm);
|
|
}
|
|
|
|
.pagination a:hover {
|
|
background: var(--background);
|
|
}
|
|
|
|
.pagination a.active {
|
|
background: var(--primary);
|
|
color: white;
|
|
border-color: var(--primary);
|
|
}
|
|
|
|
.messages-search {
|
|
position: relative;
|
|
margin-bottom: var(--spacing-md);
|
|
}
|
|
|
|
.messages-search input {
|
|
width: 100%;
|
|
padding: var(--spacing-sm) var(--spacing-md) var(--spacing-sm) 36px;
|
|
border: 1.5px solid var(--border-color, #e5e7eb);
|
|
border-radius: var(--radius);
|
|
font-size: var(--font-size-sm);
|
|
background: white;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.messages-search input:focus {
|
|
border-color: var(--primary);
|
|
outline: none;
|
|
box-shadow: 0 0 0 3px rgba(46, 72, 114, 0.1);
|
|
}
|
|
|
|
.messages-search-icon {
|
|
position: absolute;
|
|
left: 12px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
color: var(--text-muted);
|
|
font-size: 14px;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.messages-search-clear {
|
|
position: absolute;
|
|
right: 8px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
background: none;
|
|
border: none;
|
|
color: var(--text-muted);
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
padding: 4px;
|
|
display: none;
|
|
}
|
|
|
|
.messages-search-clear.visible {
|
|
display: block;
|
|
}
|
|
|
|
@media (max-width: 640px) {
|
|
.messages-topbar {
|
|
flex-wrap: wrap;
|
|
}
|
|
.messages-topbar h1 {
|
|
font-size: var(--font-size-xl);
|
|
}
|
|
.message-item {
|
|
padding: var(--spacing-sm) var(--spacing-md);
|
|
}
|
|
.message-top-row {
|
|
flex-direction: column;
|
|
gap: 0;
|
|
}
|
|
.message-bottom-row {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 2px;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="messages-page">
|
|
<div class="messages-topbar">
|
|
<h1>Wiadomości {% if unread_count > 0 %}<span class="unread-badge">{{ unread_count }}</span>{% endif %}</h1>
|
|
<div class="messages-tabs">
|
|
<a href="{{ url_for('messages_inbox') }}" class="tab-link active">Odebrane</a>
|
|
<a href="{{ url_for('messages_sent') }}" class="tab-link">Wysłane</a>
|
|
</div>
|
|
<div style="display: flex; gap: var(--spacing-xs);">
|
|
<a href="{{ url_for('messages.group_compose') }}" class="btn btn-sm" style="background: white; color: var(--primary); border: 1.5px solid var(--primary); font-weight: 600;">👥 Nowa grupa</a>
|
|
<a href="{{ url_for('messages_new') }}" class="btn btn-primary btn-sm">Nowa wiadomość</a>
|
|
</div>
|
|
</div>
|
|
|
|
<form class="messages-search" method="GET" action="{{ url_for('messages.messages_inbox') }}">
|
|
<span class="messages-search-icon">🔍</span>
|
|
<input type="text" name="q" value="{{ search_query or '' }}" placeholder="Szukaj w wiadomościach..." autocomplete="off">
|
|
<button type="button" class="messages-search-clear {% if search_query %}visible{% endif %}" onclick="this.previousElementSibling.value=''; this.form.submit();">✕</button>
|
|
</form>
|
|
{% if search_query %}
|
|
<div style="margin-bottom: var(--spacing-md); color: var(--text-muted); font-size: var(--font-size-sm);">
|
|
Wyniki wyszukiwania dla: <strong>{{ search_query }}</strong>
|
|
<a href="{{ url_for('messages.messages_inbox') }}" style="margin-left: var(--spacing-sm); color: var(--primary);">Wyczyść</a>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="messages-list">
|
|
{% if group_items %}
|
|
{% for gi in group_items|sort(attribute='sort_date', reverse=True) %}
|
|
<a href="{{ url_for('messages.group_view', group_id=gi.group.id) }}" class="message-item {% if gi.unread_count > 0 %}unread{% endif %}">
|
|
<div class="message-avatar" style="background: #166534; font-size: 14px;">👥</div>
|
|
<div class="message-body">
|
|
<div class="message-top-row">
|
|
<div class="message-subject">
|
|
{{ gi.group.display_name }}
|
|
<span class="message-badges">
|
|
<span style="color: var(--text-secondary); font-size: 11px; background: rgba(46,72,114,0.1); padding: 1px 6px; border-radius: 8px;">{{ gi.group.member_count }} os.</span>
|
|
</span>
|
|
</div>
|
|
<span class="message-date">{{ gi.sort_date.strftime('%d.%m.%Y %H:%M') if gi.sort_date else '' }}</span>
|
|
</div>
|
|
<div class="message-bottom-row">
|
|
{% if gi.last_message %}
|
|
<span class="message-preview">{{ (gi.last_message.sender.name or 'Ktoś') if gi.last_message.sender else 'Ktoś' }}: {{ gi.last_message.content|striptags|truncate(80) }}</span>
|
|
{% else %}
|
|
<span class="message-preview" style="color: var(--text-muted);">Brak wiadomości</span>
|
|
{% endif %}
|
|
</div>
|
|
{% if gi.unread_count > 0 %}
|
|
<span class="status-pill new-msg">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/></svg>
|
|
{{ gi.unread_count }} nowe
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
</a>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if messages %}
|
|
{% for msg in messages %}
|
|
<a href="{{ url_for('messages_view', message_id=msg.id) }}" class="message-item {% if not msg.is_read %}unread{% endif %}">
|
|
<div class="message-avatar">
|
|
{% if msg.sender.avatar_path %}
|
|
<img src="{{ url_for('static', filename='uploads/' + msg.sender.avatar_path) }}" style="width: 100%; height: 100%; border-radius: 50%; object-fit: cover;">
|
|
{% else %}
|
|
{{ (msg.sender.name or msg.sender.email)[0].upper() }}
|
|
{% endif %}
|
|
</div>
|
|
<div class="message-body">
|
|
<div class="message-top-row">
|
|
<div class="message-subject">
|
|
{{ msg.subject or '(brak tematu)' }}
|
|
<span class="message-badges">
|
|
{% if msg.context_type == 'classified' %}
|
|
<span class="context-badge-small">
|
|
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 13.255A23.931 23.931 0 0112 15c-3.183 0-6.22-.62-9-1.745M16 6V4a2 2 0 00-2-2h-4a2 2 0 00-2 2v2m4 6h.01M5 20h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/></svg>
|
|
B2B
|
|
</span>
|
|
{% endif %}
|
|
{% if msg.attachments %}
|
|
<span style="color: var(--text-secondary); font-size: 13px;" title="{{ msg.attachments|length }} załącznik{{ 'ów' if msg.attachments|length > 1 else '' }}">📎</span>
|
|
{% endif %}
|
|
</span>
|
|
</div>
|
|
<span class="message-date">{{ msg.created_at.strftime('%d.%m.%Y %H:%M') }}</span>
|
|
</div>
|
|
<div class="message-bottom-row">
|
|
<span class="message-preview">{{ msg.content[:100] }}{% if msg.content|length > 100 %}…{% endif %}</span>
|
|
<span class="message-sender">Od: <strong>{{ msg.sender.name or msg.sender.email.split('@')[0] }}</strong></span>
|
|
</div>
|
|
{% if not msg.is_read %}
|
|
<span class="status-pill new-msg">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/></svg>
|
|
Nowa
|
|
</span>
|
|
{% else %}
|
|
<span class="status-pill read">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 13l4 4L19 7"/></svg>
|
|
Przeczytana
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
</a>
|
|
{% endfor %}
|
|
{% else %}
|
|
{% if not group_items %}
|
|
<div class="empty-state">
|
|
<p>Brak wiadomości w skrzynce</p>
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if total_pages > 1 %}
|
|
<div class="pagination">
|
|
{% for p in range(1, total_pages + 1) %}
|
|
<a href="{{ url_for('messages_inbox', page=p) }}" class="{% if p == page %}active{% endif %}">{{ p }}</a>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endblock %}
|