feat(insights: categories-overview): searching shows the imedaite parents and children to provide better context

This commit is contained in:
Herculino Trotta
2026-09-12 14:15:31 -03:00
parent 52fe81f564
commit 5404716a81
2 changed files with 23 additions and 5 deletions
+18 -2
View File
@@ -5,7 +5,23 @@
class="input input-bordered w-full" class="input input-bordered w-full"
placeholder="{% translate 'Search' %}" placeholder="{% translate 'Search' %}"
_="on input or search _="on input or search
show < tbody>tr /> in <table/> set query to my value.toLowerCase()
when its textContent.toLowerCase() contains my value.toLowerCase()"/> set rows to <tbody>tr/> in <table/>
set paths to []
set matches to []
repeat for row in rows index i
set path to row.getAttribute('data-search-path')
if no path then set path to '#' + i + '/' end
append path to paths
if row.textContent.toLowerCase() contains query then append path to matches end
end
repeat for row in rows index i
set path to paths[i]
set keep to false
repeat for match in matches
if path.startsWith(match) or match.startsWith(path) then set keep to true end
end
if keep then show row else hide row end
end"/>
</label> </label>
</div> </div>
@@ -92,7 +92,7 @@
<tbody> <tbody>
{% for category in total_table.values %} {% for category in total_table.values %}
{# Category row #} {# Category row #}
<tr class="font-semibold"> <tr class="font-semibold" data-search-path="{{ forloop.counter0 }}/">
<th class="text-nowrap">{% if category.name %}{{ category.name }}{% else %}{% trans 'Uncategorized' %}{% endif %}</th> <th class="text-nowrap">{% if category.name %}{{ category.name }}{% else %}{% trans 'Uncategorized' %}{% endif %}</th>
<td class="text-nowrap"> <td class="text-nowrap">
{% for currency in category.currencies.values %} {% for currency in category.currencies.values %}
@@ -184,7 +184,8 @@
{% if show_tags %} {% if show_tags %}
{% for tag_id, tag in category.tags.items %} {% for tag_id, tag in category.tags.items %}
{% if tag.name or not tag.name and category.tags.values|length > 1 %} {% if tag.name or not tag.name and category.tags.values|length > 1 %}
<tr class="bg-base-200"> <tr class="bg-base-200"
data-search-path="{{ forloop.parentloop.counter0 }}/{{ forloop.counter0 }}/">
<td class="ps-6 text-nowrap"> <td class="ps-6 text-nowrap">
<i class="fa-solid fa-hashtag fa-fw me-2 text-base-content/60"></i>{% if tag.name %}{{ tag.name }}{% else %}{% trans 'Untagged' %}{% endif %} <i class="fa-solid fa-hashtag fa-fw me-2 text-base-content/60"></i>{% if tag.name %}{{ tag.name }}{% else %}{% trans 'Untagged' %}{% endif %}
</td> </td>
@@ -277,7 +278,8 @@
{% if show_entities %} {% if show_entities %}
{% for entity_id, entity in tag.entities.items %} {% for entity_id, entity in tag.entities.items %}
{% if entity.name or not entity.name and tag.entities.values|length > 1 %} {% if entity.name or not entity.name and tag.entities.values|length > 1 %}
<tr class="bg-base-300"> <tr class="bg-base-300"
data-search-path="{{ forloop.parentloop.parentloop.counter0 }}/{{ forloop.parentloop.counter0 }}/{{ forloop.counter0 }}/">
<td class="ps-10 text-nowrap"> <td class="ps-10 text-nowrap">
<i class="fa-solid fa-user-group fa-fw me-2 text-base-content/60"></i>{% if entity.name %}{{ entity.name }}{% else %}{% trans 'No entity' %}{% endif %} <i class="fa-solid fa-user-group fa-fw me-2 text-base-content/60"></i>{% if entity.name %}{{ entity.name }}{% else %}{% trans 'No entity' %}{% endif %}
</td> </td>