Skip to content

Commit 555973d

Browse files
authored
Merge pull request #268 from ELIXIR-Belgium/nat-tool-fix
Better handling of national resources
2 parents 8c38670 + 23c441c commit 555973d

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

_includes/resource-table-all.html

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@
44
{%- assign tools = site.data.tool_and_resource_list | add_related_pages | sort_natural: "name" %}
55
{%- endif %}
66
{%- assign country_pages = site.pages | where_exp: "item", "item.search_exclude != true" | where_exp:"item","item.national_resources != nil" %}
7-
{%- unless tools.size == 0 or tools == nil %}
7+
{%- unless country_pages.size == 0 %}
8+
{%- assign tool_matches_total = 0 %}
9+
{%- assign query = "related_pages." | append: page.type %}
10+
{%- for country_page in country_pages %}
11+
{%- if include.tag %}
12+
{%- assign tool_matches = country_page.national_resources | where_exp:"resource","resource.related_pages != nil" | where: query, include.tag %}
13+
{%- unless tool_matches.size == 0 %}
14+
{%- assign tool_matches_total = tool_matches_total | plus: tool_matches.size %}
15+
{%- endunless %}
16+
{%- else %}
17+
{%- assign tool_matches_total = tool_matches_total | plus: country_page.national_resources.size %}
18+
{%- endif %}
19+
{%- endfor %}
20+
{%- endunless %}
21+
{%- unless tools.size == 0 and tool_matches_total.size == 0 %}
822
{%- if include.tag %}
923
<a class="visually-hidden-focusable" href='#skip-tool-table'>Skip tool table</a>
1024
{%- if site.theme_variables.headings.resource-table-all-collapse %}
@@ -17,6 +31,7 @@
1731
<div class="collapse info-card" id="tools_collapse">
1832
{%- endif %}
1933
{%- endif %}
34+
{%- unless tools.size == 0 %}
2035
<div class="table-responsive mt-4">
2136
<table class="tooltable table display">
2237
<thead>
@@ -36,14 +51,9 @@
3651
{%- for tool in tools %}
3752
<tr>
3853
{%- assign instances_tool = 0 %}
39-
{%- assign total_county_tools = 0 %}
4054
{%- assign query = "related_pages." | append: page.type %}
4155
{%- for country_page in country_pages %}
4256
{%- assign instance_matches = country_page.national_resources | where: "instance_of", tool.id | where_exp:"resource","resource.related_pages != nil" | where: query, include.tag %}
43-
{%- assign tool_matches = country_page.national_resources | where_exp:"resource","resource.related_pages != nil" | where: query, include.tag %}
44-
{%- unless tool_matches.size == 0 %}
45-
{%- assign total_county_tools = total_county_tools | plus: tool_matches.size %}
46-
{%- endunless %}
4757
{%- unless instance_matches.size == 0 %}
4858
{%- assign instances_tool = instances_tool | plus: instance_matches.size %}
4959
{%- endunless %}
@@ -54,7 +64,7 @@
5464
<td>{{tool.name}}</td>
5565
{%- endif %}
5666
<td>{{tool.description}}
57-
{%- if tool.instance_of or tool.how_to_access or instances_tool != 0 and total_county_tools != 0 and include.tag != nil %}
67+
{%- if tool.instance_of or tool.how_to_access or instances_tool != 0 != 0 and include.tag != nil %}
5868
{%- assign linked_tool = site.data.tool_and_resource_list | where:"id", tool.instance_of | first %}
5969
<div class="d-block mt-1">
6070
{%- if linked_tool %}
@@ -63,7 +73,7 @@
6373
{%- if tool.how_to_access %}
6474
<span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip" title="{{tool.how_to_access}}"><span class="badge text-primary border border-primary"> <i class="fa-solid fa-key"></i></span></span>
6575
{%- endif %}
66-
{%- unless instances_tool == 0 or total_county_tools == 0 or include.tag == nil %}
76+
{%- unless instances_tool == 0 or include.tag == nil %}
6777
<!-- <a href="#national-resources-button">
6878
<span class="badge text-white bg-primary"><i class="fa-solid fa-arrow-circle-down me-2"></i>Different instances available</span>
6979
</a> -->
@@ -99,16 +109,20 @@
99109
</td>
100110
</tr>
101111
{%- endfor %}
112+
{%- if tool_matches_total == 0 or include.tag %}
102113
</tbody>
103114
</table>
104115
</div>
116+
{%- endif %}
105117
{%- if include.tag %}
106118
{%- if site.theme_variables.headings.resource-table-all-collapse %}
107119
</div>
108120
{%- endif %}
109121
<div id="skip-tool-table"></div>
110122
{%- endif %}
111-
{%- unless total_county_tools == 0 or include.tag == nil %}
123+
124+
{%- endunless %}
125+
{%- unless tool_matches_total == 0 %}
112126
{%- if include.tag %}
113127
<a class="visually-hidden-focusable" href='#skip-nat-tool-table'>Skip national tools table</a>
114128
{%- if site.theme_variables.headings.resource-table-all-collapse %}
@@ -120,37 +134,34 @@ <h3 class="{% if site.theme_variables.headings.resource-table-all-collapse %}mb-
120134
</a>
121135
<div class="collapse info-card" id="nat_tools_collapse">
122136
{%- endif %}
123-
{%- endif %}
124137
<p class="mt-4">Tools and resources tailored to users in different countries.</p>
125138
<div class="table-responsive mt-3">
126-
<table class="tooltable table display" id="national-resources-button">
139+
<table class="tooltable table display">
127140
<thead>
128141
<tr class="text-nowrap">
129-
<th>Tool or resource {%- if include.tag -%}
142+
<th>Tool or resource
130143
<a data-bs-toggle="tooltip" data-bs-original-title="This is a curated list which means that not all tools or resources that exist for this topic are listed here. This is mainly because we do not intend to be a registry. In most cases you will only find back the tools or resources that are mentioned in this page.">
131144
<i class="fa-solid fa-info-circle"></i>
132-
</a>{%- endif %}
145+
</a>
133146
</th>
134147
<th>Description</th>
135148
<th>Related pages</th>
136-
<th>Registry {%- if include.tag -%}
149+
<th>Registry
137150
<a data-bs-toggle="tooltip" data-bs-original-title="Links to related information in ELIXIR registries: related policies and standards in FAIRsharing, scientific and technical descriptions of the resource in bio.tools, and related training in TeSS.">
138151
<i class="fa-solid fa-info-circle"></i>
139-
</a>{%- endif %}
152+
</a>
140153
</th>
141154
</tr>
142155
</thead>
143156
<tbody>
144-
{%- assign hide_ids = "resource_title" %}
157+
{%- endif %}
145158
{%- for country_page in country_pages %}
146159
{%- if include.tag %}
147160
{%- assign tool_matches = country_page.national_resources | where_exp:"resource","resource.related_pages != nil" | where: query, include.tag | sort_natural: "name" %}
148161
{%- else %}
149-
{%- assign tool_matches = country_page.national_resources | sort_natural: "name" %}
162+
{%- assign tool_matches = country_page.national_resources %}
150163
{%- endif %}
151164
{%- for tool in tool_matches %}
152-
{%- assign tool_id = tool.name | slugify %}
153-
{%- assign hide_ids = hide_ids | append: " " | append: tool_id %}
154165
<tr>
155166
{% if tool.url %}
156167
<td><a href="{{tool.url}}">{{tool.name}}</a><a href="{{country_page.url | relative_url }}" data-bs-toggle="tooltip" title="{{country_page.title}}"><span class="flag-icon ms-2 shadow-sm flag-icon-{{country_page.country_code | downcase }}"></span></a></td>

0 commit comments

Comments
 (0)