Skip to content

Conversation

@zubeydecivelek
Copy link

@zubeydecivelek zubeydecivelek commented Dec 15, 2025

closes CERNDocumentServer/cds-rdm#652

❤️ Thank you for your contribution!

Description

  • This change allows the file names shown on the record page to be customized by passing a small resolver function to the file UI macros.

  • Instead of always displaying the file key, instances can customize how the file name should be derived (for example: using file.metadata.title instead of file.key).

  • New block added to make customization of the file name, without overriding the record_files block.

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

{% if not file.access.hidden %}
{%- set is_remote_file = file.transfer.type == transfer_types.REMOTE %}
{%- if resolve_display_name %}
{%- set display_name = resolve_display_name(file) or file.key %}
Copy link
Member

@zzacharo zzacharo Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{%- set display_name = resolve_display_name(file) or file.key %}
{%- set human_readable_file_name = display_name(file) or file.key %}

{%-set preview_file = files|select_preview_file(default_preview=record_ui["files"]["default_preview"]) %}
{{ preview_file_box(preview_file, record_ui["id"], is_preview, record, include_deleted) }}
{%- endif -%}
{{ file_list_box(files, record_ui["id"], is_preview, include_deleted, record, permissions) }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{ file_list_box(files, record_ui["id"], is_preview, include_deleted, record, permissions) }}
{%- block record_files_container -%}
{{ file_list_box(files, record_ui["id"], is_preview, include_deleted, record, permissions) }}
{%- endblock record_files_container -%}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display user friendly filenames ( if they exist )

2 participants