Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { fakeHyperlinkFormatter } from '../fakeHyperlinkFormatter';

describe('the Edit Icon Formatter', () => {
it('should return a span with the "fake-hyperlink" class when a value is provided', () => {
const value = 'Custom Value';
const result = fakeHyperlinkFormatter(0, 0, value);
expect(result).toBe('<span class="fake-hyperlink">Custom Value</span>');
});

it('should return an empty string formatter when no value is provided', () => {
const value = null;
const result = fakeHyperlinkFormatter(0, 0, value);
expect(result).toBe('');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Formatter } from '../models/formatter.interface';

export const fakeHyperlinkFormatter: Formatter = (_row: number, _cell: number, value: string) => {
return value ? `<span class="fake-hyperlink">${value}</span>` : '';
};
4 changes: 4 additions & 0 deletions src/app/modules/angular-slickgrid/formatters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { dollarColoredBoldFormatter } from './dollarColoredBoldFormatter';
import { dollarColoredFormatter } from './dollarColoredFormatter';
import { dollarFormatter } from './dollarFormatter';
import { editIconFormatter } from './editIconFormatter';
import { fakeHyperlinkFormatter } from './fakeHyperlinkFormatter';
import { hyperlinkFormatter } from './hyperlinkFormatter';
import { iconFormatter } from './iconFormatter';
import { infoIconFormatter } from './infoIconFormatter';
Expand Down Expand Up @@ -150,6 +151,9 @@ export const Formatters = {
/** Displays a Font-Awesome edit icon (fa-pencil) */
editIcon: editIconFormatter,

/** Takes any text value and display it as a fake a hyperlink (only styled as an hyperlink), this can be used in combo with "onCellClick" event */
fakeHyperlink: fakeHyperlinkFormatter,

/**
* Takes an hyperlink cell value and transforms it into a real hyperlink, given that the value starts with 1 of these (http|ftp|https).
* The structure will be "<a href="hyperlink">hyperlink</a>"
Expand Down