feat: redesign da lista e formulario de funcionarios (badges de perfil/status)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Gustavo
2026-08-14 00:32:07 -03:00
co-authored by Claude Sonnet 5
parent 18029de9f8
commit 9114303507
2 changed files with 65 additions and 49 deletions
+34 -20
View File
@@ -6,26 +6,40 @@
{% if erro %}
<div class="mensagem danger">{{ erro }}</div>
{% endif %}
<form method="post" action="{{ '/funcionarios/' + funcionario.ID|string + '/editar' if funcionario else '/funcionarios/novo' }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<label for="nome">Nome</label>
<input type="text" id="nome" name="nome" value="{{ dados.NOME if dados else (funcionario.NOME if funcionario else '') }}" required>
<label for="login">Login</label>
<input type="text" id="login" name="login" value="{{ dados.LOGIN if dados else (funcionario.LOGIN if funcionario else '') }}" required>
<label for="perfil">Perfil</label>
{% set perfil_atual = dados.PERFIL if dados else (funcionario.PERFIL if funcionario else 'PADRAO') %}
<select id="perfil" name="perfil">
<option value="PADRAO" {{ "selected" if perfil_atual == "PADRAO" else "" }}>Padrão</option>
<option value="ADMIN" {{ "selected" if perfil_atual == "ADMIN" else "" }}>Administrador</option>
</select>
{% if not funcionario %}
<label for="senha">Senha</label>
<input type="password" id="senha" name="senha" required>
<label for="confirmar_senha">Confirmar senha</label>
<input type="password" id="confirmar_senha" name="confirmar_senha" required>
{% endif %}
<button type="submit">Salvar</button>
</form>
<div class="cartao">
<form method="post" action="{{ '/funcionarios/' + funcionario.ID|string + '/editar' if funcionario else '/funcionarios/novo' }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="grid-form">
<div>
<label for="nome">Nome</label>
<input type="text" id="nome" name="nome" value="{{ dados.NOME if dados else (funcionario.NOME if funcionario else '') }}" required>
</div>
<div>
<label for="login">Login</label>
<input type="text" id="login" name="login" value="{{ dados.LOGIN if dados else (funcionario.LOGIN if funcionario else '') }}" required>
</div>
<div>
<label for="perfil">Perfil</label>
{% set perfil_atual = dados.PERFIL if dados else (funcionario.PERFIL if funcionario else 'PADRAO') %}
<select id="perfil" name="perfil">
<option value="PADRAO" {{ "selected" if perfil_atual == "PADRAO" else "" }}>Padrão</option>
<option value="ADMIN" {{ "selected" if perfil_atual == "ADMIN" else "" }}>Administrador</option>
</select>
</div>
{% if not funcionario %}
<div>
<label for="senha">Senha</label>
<input type="password" id="senha" name="senha" required>
</div>
<div>
<label for="confirmar_senha">Confirmar senha</label>
<input type="password" id="confirmar_senha" name="confirmar_senha" required>
</div>
{% endif %}
</div>
<button type="submit">Salvar</button>
</form>
</div>
{% if funcionario %}
<p><small>Para trocar a senha, use "Redefinir senha" na lista de funcionários.</small></p>
{% endif %}
+31 -29
View File
@@ -4,35 +4,37 @@
{% block conteudo %}
<h1>Funcionários</h1>
<p><a class="botao" href="/funcionarios/novo">+ Novo funcionário</a></p>
<table>
<tr><th>Nome</th><th>Login</th><th>Perfil</th><th>Status</th><th></th></tr>
{% for f in funcionarios %}
<tr>
<td>{{ f.NOME }}</td>
<td>{{ f.LOGIN }}</td>
<td>{{ "Administrador" if f.PERFIL == "ADMIN" else "Padrão" }}</td>
<td>{{ "Ativo" if f.ATIVO else "Inativo" }}</td>
<td>
<a class="botao" href="/funcionarios/{{ f.ID }}/editar">Editar</a>
<details style="display:inline-block">
<summary class="botao" style="display:inline-block;cursor:pointer">Redefinir senha</summary>
<form method="post" action="/funcionarios/{{ f.ID }}/redefinir-senha" style="margin-top:8px">
<div class="tabela-wrap">
<table>
<tr><th>Nome</th><th>Login</th><th>Perfil</th><th>Status</th><th></th></tr>
{% for f in funcionarios %}
<tr>
<td>{{ f.NOME }}</td>
<td>{{ f.LOGIN }}</td>
<td><span class="badge {{ 'badge-acento' if f.PERFIL == 'ADMIN' else 'badge-neutro' }}">{{ "Administrador" if f.PERFIL == "ADMIN" else "Padrão" }}</span></td>
<td><span class="badge {{ 'badge-sucesso' if f.ATIVO else 'badge-neutro' }}">{{ "Ativo" if f.ATIVO else "Inativo" }}</span></td>
<td>
<a class="botao" href="/funcionarios/{{ f.ID }}/editar">Editar</a>
<details style="display:inline-block">
<summary class="botao" style="display:inline-block;cursor:pointer">Redefinir senha</summary>
<form method="post" action="/funcionarios/{{ f.ID }}/redefinir-senha" style="margin-top:8px">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<label for="nova_senha-{{ f.ID }}">Nova senha</label>
<input type="password" id="nova_senha-{{ f.ID }}" name="nova_senha" required>
<label for="confirmar_nova_senha-{{ f.ID }}">Confirmar nova senha</label>
<input type="password" id="confirmar_nova_senha-{{ f.ID }}" name="confirmar_nova_senha" required>
<button type="submit">Salvar senha</button>
</form>
</details>
<form method="post" action="/funcionarios/{{ f.ID }}/alternar-ativo" style="display:inline">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<label for="nova_senha-{{ f.ID }}">Nova senha</label>
<input type="password" id="nova_senha-{{ f.ID }}" name="nova_senha" required>
<label for="confirmar_nova_senha-{{ f.ID }}">Confirmar nova senha</label>
<input type="password" id="confirmar_nova_senha-{{ f.ID }}" name="confirmar_nova_senha" required>
<button type="submit">Salvar senha</button>
<button type="submit" onclick="return confirm('{{ "Desativar" if f.ATIVO else "Reativar" }} este funcionário?')">
{{ "Desativar" if f.ATIVO else "Reativar" }}
</button>
</form>
</details>
<form method="post" action="/funcionarios/{{ f.ID }}/alternar-ativo" style="display:inline">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button type="submit" onclick="return confirm('{{ "Desativar" if f.ATIVO else "Reativar" }} este funcionário?')">
{{ "Desativar" if f.ATIVO else "Reativar" }}
</button>
</form>
</td>
</tr>
{% endfor %}
</table>
</td>
</tr>
{% endfor %}
</table>
</div>
{% endblock %}