Versiunea funcțională EUMI
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<div class="modal-header bg-dark text-white">
|
||||
<h5 class="modal-title">{% if employee %}Editează Angajat{% else %}Adaugă Angajat Nou{% endif %}</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<form hx-post="{% if employee %}{% url 'users:employee_edit' employee.pk %}{% else %}{% url 'users:employee_create' %}{% endif %}"
|
||||
hx-target="#modal-content-area">
|
||||
{% csrf_token %}
|
||||
<div class="modal-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-bold">Nume complet</label>
|
||||
{{ form.name }}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-bold">Username</label>
|
||||
{{ form.username }}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-bold">Funcție</label>
|
||||
{{ form.role }}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label fw-bold">Nr. Birou</label>
|
||||
{{ form.office_number }}
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label class="form-label fw-bold">Email</label>
|
||||
{{ form.email }}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold">Direcție</label>
|
||||
{{ form.directie }}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold">Serviciu</label>
|
||||
{{ form.serviciu }}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label fw-bold">Compartiment</label>
|
||||
{{ form.compartiment }}
|
||||
</div>
|
||||
<div class="col-md-12 mt-3">
|
||||
<label class="form-label fw-bold">Observații</label>
|
||||
{{ form.observations }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-light">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Anulează</button>
|
||||
<button type="submit" class="btn btn-primary">Salvează</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,31 @@
|
||||
{% for emp in employees %}
|
||||
<tr>
|
||||
<td class="align-middle fw-medium">{{ emp.name }}</td>
|
||||
<td class="align-middle">{{ emp.username }}</td>
|
||||
<td class="align-middle">{{ emp.role }}</td>
|
||||
<td class="align-middle">
|
||||
{% if emp.directie %}<strong>{{ emp.directie.name }}</strong><br>{% endif %}
|
||||
{% if emp.serviciu %}<span class="text-muted">{{ emp.serviciu.name }}</span><br>{% endif %}
|
||||
{% if emp.compartiment %}<small class="text-secondary">{{ emp.compartiment.name }}</small>{% endif %}
|
||||
</td>
|
||||
<td class="align-middle text-center">
|
||||
<!-- Edit Button -->
|
||||
{% if user.is_staff %}
|
||||
<button class="btn btn-sm btn-outline-secondary me-1"
|
||||
hx-get="{% url 'users:employee_edit' emp.id %}"
|
||||
hx-target="#modal-content-area"
|
||||
data-bs-toggle="modal" data-bs-target="#form-modal">
|
||||
✏️ Editează
|
||||
</button>
|
||||
{% endif %}
|
||||
<!-- Print Button -->
|
||||
<a href="{% url 'equipment:print_inventory' emp.id %}" target="_blank" class="btn btn-sm btn-outline-primary">
|
||||
🖨️ Fișă
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-muted py-4">Nu au fost găsiți angajați conform criteriilor de căutare.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,64 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2 class="fw-bold">Angajați</h2>
|
||||
|
||||
<div class="d-flex gap-3 w-50 justify-content-end">
|
||||
<!-- HTMX Live Search Input -->
|
||||
<input class="form-control w-50" type="search"
|
||||
name="search" placeholder="Caută angajat..."
|
||||
hx-get="{% url 'users:user_list' %}"
|
||||
hx-trigger="input changed delay:400ms, search"
|
||||
hx-target="#user-table-body">
|
||||
|
||||
<!-- Add Button (Triggers Modal) -->
|
||||
{% if user.is_staff %}
|
||||
<button class="btn btn-success fw-bold"
|
||||
hx-get="{% url 'users:employee_create' %}"
|
||||
hx-target="#modal-content-area"
|
||||
data-bs-toggle="modal" data-bs-target="#form-modal">
|
||||
+ Adaugă Angajat
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<table class="table table-striped table-hover mb-0">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Nume</th>
|
||||
<th>Username</th>
|
||||
<th>Funcție</th>
|
||||
<th>Structură (Dir / Serv / Comp)</th>
|
||||
<th class="text-center">Acțiuni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- Added hx-trigger="employeeListChanged from:body" so it refreshes on save -->
|
||||
<tbody id="user-table-body" hx-get="{% url 'users:user_list' %}" hx-trigger="employeeListChanged from:body">
|
||||
{% include 'users/partials/user_table.html' %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Empty Bootstrap Modal Container -->
|
||||
<div class="modal fade" id="form-modal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content" id="modal-content-area">
|
||||
<!-- Form will be injected here by HTMX -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Script to automatically close the modal when HTMX triggers 'closeModal' -->
|
||||
<script>
|
||||
document.body.addEventListener('closeModal', function() {
|
||||
var modalEl = document.getElementById('form-modal');
|
||||
var modal = bootstrap.Modal.getInstance(modalEl);
|
||||
if (modal) {
|
||||
modal.hide();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user