Differentiate between no sort and no sort-and-filter in tables

This commit is contained in:
Gregoo 2025-02-04 19:55:34 +01:00
parent 5d6b373769
commit 56c1a46b37
4 changed files with 16 additions and 7 deletions

View File

@ -1,11 +1,16 @@
class BrickTable {
constructor(table, per_page) {
const columns = []
const columns = [];
const no_sort_and_filter = [];
const no_sort = [];
const number = [];
// Read the table header for parameters
table.querySelectorAll('th').forEach((th, index) => {
if (th.dataset.tableNoSortAndFilter) {
no_sort_and_filter.push(index);
}
if (th.dataset.tableNoSort) {
no_sort.push(index);
}
@ -15,8 +20,12 @@ class BrickTable {
}
});
if (no_sort_and_filter.length) {
columns.push({ select: no_sort_and_filter, sortable: false, searchable: false });
}
if (no_sort.length) {
columns.push({ select: no_sort, sortable: false, searchable: false });
columns.push({ select: no_sort, sortable: false });
}
if (number.length) {

View File

@ -6,9 +6,9 @@
<tr>
<th scope="col"><i class="ri-file-line fw-normal"></i> Filename</th>
<th scope="col"><i class="ri-hashtag fw-normal"></i> Set</th>
<th data-table-no-sort="true" class="no-sort" scope="col"><i class="ri-image-line fw-normal"></i> Image</th>
<th data-table-no-sort-and-search="true" class="no-sort" scope="col"><i class="ri-image-line fw-normal"></i> Image</th>
{% if g.login.is_authenticated() %}
<th data-table-no-sort="true" class="no-sort" scope="col"><i class="ri-settings-4-line fw-normal"></i> Actions</th>
<th data-table-no-sort-and-search="true" class="no-sort" scope="col"><i class="ri-settings-4-line fw-normal"></i> Actions</th>
{% endif %}
</tr>
</thead>

View File

@ -2,7 +2,7 @@
<thead>
<tr>
{% if image %}
<th data-table-no-sort="true" class="no-sort" scope="col"><i class="ri-image-line fw-normal"></i> Image</th>
<th data-table-no-sort-and-search="true" class="no-sort" scope="col"><i class="ri-image-line fw-normal"></i> Image</th>
{% endif %}
<th scope="col"><i class="ri-pencil-line fw-normal"></i> Name</th>
{% if color %}

View File

@ -5,7 +5,7 @@
<table data-table="{% if all %}true{% endif %}" class="table table-striped align-middle" id="wish">
<thead>
<tr>
<th data-table-no-sort="true" class="no-sort" scope="col"><i class="ri-image-line fw-normal"></i> Image</th>
<th data-table-no-sort-and-search="true" class="no-sort" scope="col"><i class="ri-image-line fw-normal"></i> Image</th>
<th scope="col"><i class="ri-hashtag fw-normal"></i> Set</th>
<th scope="col"><i class="ri-pencil-line fw-normal"></i> Name</th>
<th scope="col"><i class="price-tag-3-line fw-normal"></i> Theme</th>
@ -13,7 +13,7 @@
<th scope="col"><i class="ri-shapes-line fw-normal"></i> Parts</th>
<th scope="col"><i class="ri-calendar-close-line fw-normal"></i> Retirement</th>
{% if g.login.is_authenticated() %}
<th data-table-no-sort="true" class="no-sort" scope="col"><i class="ri-settings-4-line fw-normal"></i> Actions</th>
<th data-table-no-sort-and-search="true" class="no-sort" scope="col"><i class="ri-settings-4-line fw-normal"></i> Actions</th>
{% endif %}
</tr>
</thead>