Skip to content

Commit

Permalink
Merge pull request #54 from lionick/fix_link_datatable
Browse files Browse the repository at this point in the history
try to fix links at datatable
  • Loading branch information
lionick authored Jul 23, 2024
2 parents ad8a586 + ba92f57 commit 9a43ee7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
18 changes: 4 additions & 14 deletions javascript/src/components/Common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,10 @@ export function calculateMinMax(dataArray) {
return [min, max]
}

export const createAnchorElement = (title, link) => {
const anchor = document.createElement('a');
const linkText = document.createTextNode(title);
anchor.appendChild(linkText);
anchor.title = title;
anchor.href = link;

// FIXME:
// Trying to pass an object directly to the datatable will fail. We need to
// get the HTML string from the element. This causes inconsistent behavior
// which we need to solve. For now we leave it as is.
return anchor.outerHTML;
// return anchor;
}
export const createAnchorElement = (title, link) => ({
title,
link,
});

export const axisChartOptions = (title, hAxisFormat, hAxisTicks) => {
return (
Expand Down
5 changes: 5 additions & 0 deletions javascript/src/components/datatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class Datatable extends Component {
}

listNames = (names, key) => {
//console.log("listNames called with:", names.title);
if (this.props.columnSep && key == this.props.columnSep && typeof names === 'string') {
return renderToString(
<ul>
Expand All @@ -161,6 +162,10 @@ class Datatable extends Component {

</ul>
)
} else if (names && typeof names === 'object' && names.title && names.link) {
return renderToString(
<a href={names.link} title={names.title}>{names.title}</a>
);
} else return (
names
)
Expand Down

0 comments on commit 9a43ee7

Please sign in to comment.