diff --git a/src/app/modules/angular-slickgrid/formatters/__tests__/fakeHyperlinkFormatter.spec.ts b/src/app/modules/angular-slickgrid/formatters/__tests__/fakeHyperlinkFormatter.spec.ts new file mode 100644 index 000000000..092a46b8b --- /dev/null +++ b/src/app/modules/angular-slickgrid/formatters/__tests__/fakeHyperlinkFormatter.spec.ts @@ -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('Custom Value'); + }); + + it('should return an empty string formatter when no value is provided', () => { + const value = null; + const result = fakeHyperlinkFormatter(0, 0, value); + expect(result).toBe(''); + }); +}); diff --git a/src/app/modules/angular-slickgrid/formatters/fakeHyperlinkFormatter.ts b/src/app/modules/angular-slickgrid/formatters/fakeHyperlinkFormatter.ts new file mode 100644 index 000000000..6d10f1731 --- /dev/null +++ b/src/app/modules/angular-slickgrid/formatters/fakeHyperlinkFormatter.ts @@ -0,0 +1,5 @@ +import { Formatter } from '../models/formatter.interface'; + +export const fakeHyperlinkFormatter: Formatter = (_row: number, _cell: number, value: string) => { + return value ? `${value}` : ''; +}; diff --git a/src/app/modules/angular-slickgrid/formatters/index.ts b/src/app/modules/angular-slickgrid/formatters/index.ts index dee4d6219..7721d045b 100644 --- a/src/app/modules/angular-slickgrid/formatters/index.ts +++ b/src/app/modules/angular-slickgrid/formatters/index.ts @@ -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'; @@ -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 "hyperlink"