From 56c1a46b371ffc33509c1dbbee8c5644ed6c2fd2 Mon Sep 17 00:00:00 2001
From: Gregoo <versatile.mailbox@gmail.com>
Date: Tue, 4 Feb 2025 19:55:34 +0100
Subject: [PATCH] Differentiate between no sort and no sort-and-filter in
tables
---
static/scripts/table.js | 13 +++++++++++--
templates/instructions/table.html | 4 ++--
templates/macro/table.html | 2 +-
templates/wish/table.html | 4 ++--
4 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/static/scripts/table.js b/static/scripts/table.js
index 669afc57..f96f10bb 100644
--- a/static/scripts/table.js
+++ b/static/scripts/table.js
@@ -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) {
diff --git a/templates/instructions/table.html b/templates/instructions/table.html
index 8ad9f3cf..b2c80077 100644
--- a/templates/instructions/table.html
+++ b/templates/instructions/table.html
@@ -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>
diff --git a/templates/macro/table.html b/templates/macro/table.html
index 0638380f..32cc63c1 100644
--- a/templates/macro/table.html
+++ b/templates/macro/table.html
@@ -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 %}
diff --git a/templates/wish/table.html b/templates/wish/table.html
index 3b037824..ca222427 100644
--- a/templates/wish/table.html
+++ b/templates/wish/table.html
@@ -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>