Skip to content

Commit 3160bf5

Browse files
committed
feat: make resouce type badge clickable
1 parent c540fa1 commit 3160bf5

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/detail.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,19 @@
231231
<div class="right floated right aligned column">
232232

233233
{% if record_ui["ui"]["resource_type"] %}
234-
<span role="note"
235-
class="ui label horizontal small neutral mb-5"
236-
aria-label="{{ _('Resource type') }}"
234+
{% set rt_id = record_ui["ui"]["resource_type"]["id"] %}
235+
{% if "-" in rt_id %}
236+
{% set rt_filter = "resource_type%3A" ~ rt_id.split("-")[0] ~ "%2Binner%3A" ~ rt_id %}
237+
{% else %}
238+
{% set rt_filter = "resource_type%3A" ~ rt_id %}
239+
{% endif %}
240+
<a href="/search?q=&f={{ rt_filter }}"
241+
role="note"
242+
class="ui label horizontal small neutral mb-5"
243+
aria-label="{{ _('Resource type') }}"
237244
>
238245
{{ record_ui["ui"]["resource_type"]["title_l10n"] }}
239-
</span>
246+
</a>
240247
{% endif %}
241248

242249
<span role="note"

invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/RecordsResultsListItem.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class RecordsResultsListItem extends Component {
4747
"ui.resource_type.title_l10n",
4848
i18next.t("No resource type")
4949
);
50+
const resourceTypeId = _get(result, "ui.resource_type.id", "");
51+
const resourceTypeFilter = resourceTypeId.includes("-")
52+
? `resource_type%3A${resourceTypeId.split("-")[0]}%2Binner%3A${resourceTypeId}`
53+
: `resource_type%3A${resourceTypeId}`;
5054
const subjects = _get(result, "ui.subjects", []);
5155
const title = _get(result, "metadata.title", i18next.t("No title"));
5256
const version = _get(result, "ui.version", null);
@@ -90,7 +94,13 @@ class RecordsResultsListItem extends Component {
9094
<Label horizontal size="small" className="primary theme-primary">
9195
{publicationDate} ({version})
9296
</Label>
93-
<Label horizontal size="small" className="neutral">
97+
<Label
98+
horizontal
99+
size="small"
100+
className="neutral"
101+
as="a"
102+
href={`/search?q=&f=${resourceTypeFilter}`}
103+
>
94104
{resourceType}
95105
</Label>
96106
<Label

0 commit comments

Comments
 (0)