fix(contacts): пагинация, по умолчанию буква «А», читаемые ширины колонок
Жалоба: при загрузке список широкий, затем узкий — текста не видно; после фильтра по алфавиту карточки всё равно узкие. - Пагинация: page/per_page (25/50/100/200, по умолчанию 50), «← Назад / Вперёд →», «стр. N из M», селектор размера страницы; page клампится. - По умолчанию открывается буква «А» (letter=А), чип «Все» снимает фильтр (letter=all), повторный клик по активной букве ведёт в «Все». - Ширины: .ctab min-width 860px + минимумы колонок 120/90/100/140/130/130/150, overflow:auto у списка вместо сжатия текста; c2 flex:2.6, карточка max-width 460px, у значений в ячейках title с полным текстом. - Страница: 872 КБ → 56 КБ (7 строк на букву А), 127 мс. - spec contacts-ui: добавлены требования «Пагинация и буква по умолчанию» и «Читаемая ширина колонок». Замерено headless-Chromium (метрики из DOM): 1600 px с закрытой ИИ-панелью — c2=938 px, таблица 860 помещается целиком; с открытой — c2=628 и скролл при сохранении минимальных ширин. tests/test_contacts_ui.py — 15/15; контейнер пересобран (healthy), живые запросы: letter=all&per_page=25 → 25 строк, «стр. 1 из 9», page=2 — другие 25.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
<!-- колонка 1: фильтры + алфавитный указатель -->
|
||||
<div class="c1 cfit">
|
||||
<div class="ch"><span>👥 Фильтры</span><span class="cnt">{{ contacts|length }} из {{ total }}</span></div>
|
||||
<div class="ch"><span>👥 Фильтры</span><span class="cnt">{{ found }} из {{ total }}</span></div>
|
||||
<form class="cfilters" hx-get="/contacts" hx-target="#contacts-cols" hx-swap="outerHTML"
|
||||
hx-trigger="input changed delay:350ms, search, submit" hx-push-url="true"
|
||||
onsubmit="return false" autocomplete="off">
|
||||
@@ -36,6 +36,8 @@
|
||||
<button type="submit" class="btn">Найти</button>
|
||||
<a class="btn" href="/contacts">Сбросить</a>
|
||||
</div>
|
||||
<input type="hidden" name="letter" value="{{ letter_param }}">
|
||||
<input type="hidden" name="per_page" value="{{ per_page }}">
|
||||
{% if sort != 'last_name' %}<input type="hidden" name="sort" value="{{ sort }}">{% endif %}
|
||||
{% if dir != 'asc' %}<input type="hidden" name="dir" value="{{ dir }}">{% endif %}
|
||||
</form>
|
||||
@@ -48,10 +50,13 @@
|
||||
</datalist>
|
||||
|
||||
<div class="alpha">
|
||||
<a class="al all{% if not letter %} act{% endif %}" title="весь список"
|
||||
hx-get="{{ params_url('/contacts', params, letter='all', page=1) }}"
|
||||
hx-target="#contacts-cols" hx-swap="outerHTML" hx-push-url="true">Все</a>
|
||||
{% for a in alphabet %}
|
||||
{% if a.count %}
|
||||
<a class="al{% if letter == a.letter %} act{% endif %}" title="{{ a.count }} конт."
|
||||
hx-get="{{ params_url('/contacts', params, letter=('' if letter == a.letter else a.letter)) }}"
|
||||
hx-get="{{ params_url('/contacts', params, letter=('all' if letter == a.letter else a.letter), page=1) }}"
|
||||
hx-target="#contacts-cols" hx-swap="outerHTML" hx-push-url="true">{{ a.letter }}</a>
|
||||
{% else %}
|
||||
<span class="al off" title="нет контактов">{{ a.letter }}</span>
|
||||
@@ -70,6 +75,22 @@
|
||||
<div class="lw" id="clist">
|
||||
{% include "partials/contacts_table.html" %}
|
||||
</div>
|
||||
<div class="cpager">
|
||||
<button class="btn" {% if page_no > 1 %}
|
||||
hx-get="{{ params_url('/contacts', params, page=page_no - 1) }}"
|
||||
hx-target="#contacts-cols" hx-swap="outerHTML" hx-push-url="true"{% else %}disabled{% endif %}>← Назад</button>
|
||||
<span class="pinfo">стр. {{ page_no }} из {{ pages }}</span>
|
||||
<button class="btn" {% if page_no < pages %}
|
||||
hx-get="{{ params_url('/contacts', params, page=page_no + 1) }}"
|
||||
hx-target="#contacts-cols" hx-swap="outerHTML" hx-push-url="true"{% else %}disabled{% endif %}>Вперёд →</button>
|
||||
<label class="pper">на странице
|
||||
<select name="per_page" hx-get="/contacts" hx-include="this"
|
||||
hx-vals="{{ params_json|tojson|forceescape }}"
|
||||
hx-target="#contacts-cols" hx-swap="outerHTML" hx-push-url="true">
|
||||
{% for n in per_page_options %}<option value="{{ n }}"{% if n == per_page %} selected{% endif %}>{{ n }}</option>{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<button class="ctop" id="ctop" title="Наверх, к фильтрам"
|
||||
onclick="var l=document.getElementById('clist'); if(l) l.scrollTop=0; var q=document.getElementById('cq'); if(q) q.focus();">↑</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user