Skip to content

Commit

Permalink
automatically expand everything on search (#659)
Browse files Browse the repository at this point in the history
* automatically expand everything on search

* better pattern
  • Loading branch information
chrisclark authored Aug 14, 2024
1 parent e68c55f commit 1ddb6e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 12 additions & 1 deletion explorer/src/js/query-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ function searchFocus() {
searchElement.focus();
}
}
function expandAll(param) {
const searchTerm = document.querySelector('.search').value;
if (searchTerm.trim() !== "") {
document.querySelectorAll('.collapse').forEach(function (element) {
element.classList.add('show');
});
}
}
export function setupQueryList() {

document.querySelectorAll('.query_favorite_toggle').forEach(function (element) {
Expand All @@ -17,7 +25,10 @@ export function setupQueryList() {

let options = {
valueNames: ['sort-name', 'sort-created', 'sort-created', 'sort-last-run', 'sort-run-count', 'sort-connection'],
handlers: {'updated': [searchFocus]}
handlers: {'updated': [searchFocus],
'searchComplete': [expandAll]},
searchDelay: 250,
searchColumns: ['sort-name']
};
new List('queries', options);

Expand Down
8 changes: 4 additions & 4 deletions explorer/templates/explorer/query_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ <h3>{% translate "All Queries" %}</h3>
</thead>
<tbody class="list">
{% for object in object_list %}
<tr {% if object.is_in_category %}class="collapse {{object.collapse_target}}"{% endif %}>
<tr {% if object.is_in_category %}class="collapse {{object.collapse_target}}" data-bs-config='{"delay":0}'{% endif %}>
{% if object.is_header %}
<td colspan="100">
<strong>
<span data-bs-toggle="collapse" style="cursor: pointer;" data-bs-target=".{{object.collapse_target}}">
{{ object.title }} ({{ object.count }})
<i class="bi-plus-circle"></i> {{ object.title }} ({{ object.count }})
</span>
</strong>
</td>
{% else %}
<td class="sort-name{% if object.is_in_category %} indented{% endif %}">
<a href="{% url 'query_detail' object.id %}">{{ object.title }}</a>
<td class="sort-name">
<a href="{% url 'query_detail' object.id %}"{% if object.is_in_category %} class="ms-3"{% endif %}>{{ object.title }}</a>
</td>
<td class="sort-created">{{ object.created_at|date:"m/d/y" }}
{% if object.created_by_user %}
Expand Down

0 comments on commit 1ddb6e8

Please sign in to comment.