From d30829bb61061bf8e2e294ad9e73ef81d586c421 Mon Sep 17 00:00:00 2001 From: kimakan <45099849+kimakan@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:46:01 +0100 Subject: [PATCH] Fix rendering of filepath for files and images --- daiquiri/core/assets/js/components/table/TableCell.js | 5 ++++- daiquiri/core/assets/js/utils/table.js | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/daiquiri/core/assets/js/components/table/TableCell.js b/daiquiri/core/assets/js/components/table/TableCell.js index 481555338..b0169bff4 100644 --- a/daiquiri/core/assets/js/components/table/TableCell.js +++ b/daiquiri/core/assets/js/components/table/TableCell.js @@ -1,7 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' -import { getBasename, getFileUrl, getLinkUrl, getReferenceUrl, +import { getBasename, getFileUrl, getLinkUrl, getReferenceUrl, isImageColumn, isModalColumn, isFileColumn, isLinkColumn } from '../../utils/table.js' const TableCell = ({ column, value, rowIndex, columnIndex, setActive, showModal }) => { @@ -10,6 +10,9 @@ const TableCell = ({ column, value, rowIndex, columnIndex, setActive, showModal if (column.ucd && column.ucd.includes('meta.ref')) { if (isModalColumn(column)) { // render the modal + if (isImageColumn(column)) { + value = getBasename(value) + } return ( { event.preventDefault() diff --git a/daiquiri/core/assets/js/utils/table.js b/daiquiri/core/assets/js/utils/table.js index fbaa686ab..7e7083161 100644 --- a/daiquiri/core/assets/js/utils/table.js +++ b/daiquiri/core/assets/js/utils/table.js @@ -1,6 +1,12 @@ import { baseUrl } from './meta' -export const getBasename = (string) => string.replace(/^.*[\\/]/, '') +export const getBasename = (string) => { + if (typeof string === 'string' || string instanceof String){ + return string.replace(/^.*[\\/]/, '') + } else { + return string + } +} export const getFileUrl = (column, value) => `${baseUrl}/files/${value}`