|
|
@@ -26,43 +26,43 @@
|
|
26
|
26
|
|
|
27
|
27
|
<!-- Data Table -->
|
|
28
|
28
|
<div class="clear-both bg-white shadow rounded-lg overflow-x-auto">
|
|
29
|
|
- <table class="w-full border-collapse border border-gray-200 table-fixed">
|
|
30
|
|
- <thead>
|
|
31
|
|
- <tr class="bg-gray-100 text-left text-sm uppercase">
|
|
32
|
|
- {% for field in fields %}
|
|
33
|
|
- <th class="border border-gray-200 px-4 py-2 text-left">{{ field.verbose_name }}</th>
|
|
34
|
|
- {% endfor %}
|
|
35
|
|
- <th class="py-2 px-4 border-b">Actions</th>
|
|
36
|
|
- </tr>
|
|
37
|
|
- </thead>
|
|
38
|
|
- <tbody>
|
|
39
|
|
- {% for obj in page_obj %}
|
|
40
|
|
- <tr class="hover:bg-gray-50">
|
|
41
|
|
- {% for field in fields %}
|
|
42
|
|
- <td class="border border-gray-200 px-4 py-2 whitespace-nowrap">
|
|
43
|
|
- {% if field.name == 'id' %}
|
|
44
|
|
- <a href="{% url update_url obj.pk %}" class="text-blue-500 hover:underline">
|
|
45
|
|
- {{ obj|attr:field.name }}
|
|
46
|
|
- </a>
|
|
47
|
|
- {% else %}
|
|
48
|
|
- {{ obj|attr:field.name}}
|
|
49
|
|
- {% endif %}
|
|
50
|
|
- </td>
|
|
51
|
|
- {% endfor %}
|
|
52
|
|
- <td class="py-2 px-4 border-b whitespace-nowrap">
|
|
53
|
|
- <a href="{% url update_url obj.pk %}"
|
|
54
|
|
- class="bg-blue-500 text-white px-3 py-2 rounded hover:bg-blue-600">Edit</a>
|
|
55
|
|
- <a href="{% url delete_url obj.pk %}"
|
|
56
|
|
- class="bg-red-500 text-white px-3 py-2 rounded hover:bg-red-600">Delete</a>
|
|
57
|
|
- </td>
|
|
58
|
|
- </tr>
|
|
59
|
|
- {% empty %}
|
|
60
|
|
- <tr>
|
|
61
|
|
- <td colspan="5" class="py-4 px-4 text-center text-gray-600">No data available.</td>
|
|
62
|
|
- </tr>
|
|
|
29
|
+<table class="w-full border-collapse border border-gray-200">
|
|
|
30
|
+ <thead>
|
|
|
31
|
+ <tr class="bg-gray-100 text-left text-sm uppercase">
|
|
|
32
|
+ {% for field in fields %}
|
|
|
33
|
+ <th class="border border-gray-200 px-4 py-2 text-left">{{ field.verbose_name }}</th>
|
|
|
34
|
+ {% endfor %}
|
|
|
35
|
+ <th class="py-2 px-4 border-b">Actions</th>
|
|
|
36
|
+ </tr>
|
|
|
37
|
+ </thead>
|
|
|
38
|
+ <tbody>
|
|
|
39
|
+ {% for obj in page_obj %}
|
|
|
40
|
+ <tr class="hover:bg-gray-50">
|
|
|
41
|
+ {% for field in fields %}
|
|
|
42
|
+ <td class="border border-gray-200 px-4 py-2">
|
|
|
43
|
+ {% if field.name == 'id' %}
|
|
|
44
|
+ <a href="{% url update_url obj.pk %}" class="text-blue-500 hover:underline">
|
|
|
45
|
+ {{ obj|attr:field.name }}
|
|
|
46
|
+ </a>
|
|
|
47
|
+ {% else %}
|
|
|
48
|
+ {{ obj|attr:field.name }}
|
|
|
49
|
+ {% endif %}
|
|
|
50
|
+ </td>
|
|
63
|
51
|
{% endfor %}
|
|
64
|
|
- </tbody>
|
|
65
|
|
- </table>
|
|
|
52
|
+ <td class="py-2 px-4 border-b">
|
|
|
53
|
+ <a href="{% url update_url obj.pk %}"
|
|
|
54
|
+ class="bg-blue-500 text-white px-3 py-2 rounded hover:bg-blue-600">Edit</a>
|
|
|
55
|
+ <a href="{% url delete_url obj.pk %}"
|
|
|
56
|
+ class="bg-red-500 text-white px-3 py-2 rounded hover:bg-red-600">Delete</a>
|
|
|
57
|
+ </td>
|
|
|
58
|
+ </tr>
|
|
|
59
|
+ {% empty %}
|
|
|
60
|
+ <tr>
|
|
|
61
|
+ <td colspan="5" class="py-4 px-4 text-center text-gray-600">No data available.</td>
|
|
|
62
|
+ </tr>
|
|
|
63
|
+ {% endfor %}
|
|
|
64
|
+ </tbody>
|
|
|
65
|
+</table>
|
|
66
|
66
|
</div>
|
|
67
|
67
|
|
|
68
|
68
|
<!-- Pagination -->
|
|
|
@@ -88,4 +88,17 @@
|
|
88
|
88
|
</div>
|
|
89
|
89
|
</div>
|
|
90
|
90
|
</div>
|
|
|
91
|
+<style>
|
|
|
92
|
+/* Remove fixed layout and allow columns to grow dynamically */
|
|
|
93
|
+table {
|
|
|
94
|
+ table-layout: auto; /* Default is auto, can be explicitly set */
|
|
|
95
|
+ width: 100%; /* Ensures table spans available space */
|
|
|
96
|
+}
|
|
|
97
|
+
|
|
|
98
|
+th, td {
|
|
|
99
|
+ white-space: nowrap; /* Prevents text wrapping */
|
|
|
100
|
+ text-overflow: ellipsis; /* Adds ellipsis for overflowed content if combined with max-width */
|
|
|
101
|
+ vertical-align: top; /* Aligns content to the top */
|
|
|
102
|
+}
|
|
|
103
|
+</style>
|
|
91
|
104
|
{% endblock %}
|