diff --git a/app/static/estilo.css b/app/static/estilo.css index e858973..8d705ec 100644 --- a/app/static/estilo.css +++ b/app/static/estilo.css @@ -271,6 +271,31 @@ a.botao:hover { border-color: var(--cor-acento); color: var(--cor-acento); } .botao-toggle-log:hover { border-color: var(--cor-acento); color: var(--cor-acento); } .secao-log-conteudo { padding-top: 4px; } +.table-clientes { table-layout: fixed; } + +.table-clientes th.col-codigo, .table-clientes td.col-codigo, +.table-clientes th.col-cnpj, .table-clientes td.col-cnpj, +.table-clientes th.col-status, .table-clientes td.col-status { + text-align: center; +} +.table-clientes th.col-acoes, .table-clientes td.col-acoes { text-align: right; } + +.table-clientes td.col-codigo, .table-clientes td.col-cnpj { + font-variant-numeric: tabular-nums; +} +.table-clientes td.col-cnpj { white-space: nowrap; } + +.table-clientes col.col-codigo { width: 90px; } +.table-clientes col.col-razao, .table-clientes col.col-fantasia { width: 27%; } +.table-clientes col.col-cnpj { width: 160px; } +.table-clientes col.col-status { width: 70px; } +.table-clientes col.col-acoes { width: 230px; } + +.table-clientes th, .table-clientes td { padding: 7px 14px; } + +.botao.botao-tabela { margin-top: 0; padding: 7px 12px; font-size: 0.875rem; vertical-align: middle; } +.table-clientes td.col-acoes { white-space: nowrap; } + @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } } diff --git a/app/templates/clientes_lista.html b/app/templates/clientes_lista.html index 9e76ab9..03ef5ae 100644 --- a/app/templates/clientes_lista.html +++ b/app/templates/clientes_lista.html @@ -26,27 +26,35 @@ {% set busca_qs = ('&busca=' + (busca | urlencode)) if busca else '' %} {% set qs_base = ('&ordenar_por=' + ordenar_por + '&direcao=' + direcao + '&por_pagina=' + (por_pagina | string) + '&status=' + status + busca_qs) | safe %}
- +
+ + + + + + + + - {% set colunas_tabela = [("codigo", "Código"), ("razao", "Razão"), ("fantasia", "Fantasia"), ("cnpj", "CNPJ")] %} - {% for campo, rotulo in colunas_tabela %} + {% set colunas_tabela = [("codigo", "Código", "col-codigo"), ("razao", "Razão", "col-razao"), ("fantasia", "Fantasia", "col-fantasia"), ("cnpj", "CNPJ", "col-cnpj")] %} + {% for campo, rotulo, classe_coluna in colunas_tabela %} {% set nova_direcao = "desc" if (ordenar_por == campo and direcao == "asc") else "asc" %} - {% endfor %} - - + + {% for c in clientes %} - - - - - + + + + - diff --git a/tests/test_router_clientes.py b/tests/test_router_clientes.py index daf8175..9bd1be0 100644 --- a/tests/test_router_clientes.py +++ b/tests/test_router_clientes.py @@ -951,3 +951,12 @@ def test_criar_cliente_grava_uf_maiuscula_e_cep_sem_traco(monkeypatch): assert resposta.status_code == 303 assert capturado["dados"]["UF"] == "BA" assert capturado["dados"]["CEP"] == "44430174" + + +def test_listar_clientes_tabela_tem_classe_de_escopo(monkeypatch): + monkeypatch.setattr(router_clientes.db_clientes, "listar_clientes", lambda busca=None, limite=100, offset=0, ordenar_por="razao", direcao="asc", filtro_ativo=1: []) + monkeypatch.setattr(router_clientes.db_clientes, "contar_clientes", lambda busca=None, ordenar_por="razao", filtro_ativo=1: 0) + + resposta = client.get("/clientes") + assert resposta.status_code == 200 + assert '
+ {{ rotulo }}{% if ordenar_por == campo %}{{ " ▲" if direcao == "asc" else " ▼" }}{% endif %} StatusStatus
{{ c.CODIGO }}{{ c.RAZAO }}{{ c.FANTASIA }}{{ c.CNPJ }} + {{ c.CODIGO }}{{ c.RAZAO }}{{ c.FANTASIA }}{{ c.CNPJ }}
@@ -60,9 +68,9 @@
- Abrir - + + Abrir +
' in resposta.text