Skip to content

Commit 2dcf9ec

Browse files
committed
KNOWAGE-9910
- add link styling for table cells to crossnav and link interaction
1 parent 019b5bb commit 2dcf9ec

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

src/modules/documentExecution/dashboard/widget/TableWidget/CellRenderer.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,37 @@ export default class CellRenderer {
175175
}
176176
}
177177

178+
const isCellLinkStyleActive = () => {
179+
if (params.colId === 'iconColumn' || params.colId === 'indexColumn') return false
180+
if (params.node.rowPinned === 'bottom') return false
181+
const interactions = params.propWidget.settings.interactions as IWidgetInteractions
182+
const crossNav = interactions.crossNavigation
183+
if (crossNav?.enabled && crossNav.type === 'singleColumn' && crossNav.column === params.colId) return true
184+
const linkSettings = interactions.link
185+
if (linkSettings?.enabled && linkSettings.links?.length > 0) {
186+
for (const link of linkSettings.links) {
187+
if (link.type === 'singleColumn' && link.column === params.colDef?.columnName) return true
188+
}
189+
}
190+
return false
191+
}
192+
193+
const wrapWithLinkStyle = (content: string) => {
194+
return `<span style="text-decoration: underline; cursor: pointer;">${content}</span>`
195+
}
196+
197+
const linkStyleActive = isCellLinkStyleActive()
198+
178199
if (visType.type) {
179-
if (visType.type.toLowerCase() === 'text' || visType.type.toLowerCase() === 'multiline text') this.eGui.innerHTML = `${visType.prefix}${setCellContent()}${visType.suffix}`
200+
if (visType.type.toLowerCase() === 'text' || visType.type.toLowerCase() === 'multiline text') {
201+
const content = `${visType.prefix}${setCellContent()}${visType.suffix}`
202+
this.eGui.innerHTML = linkStyleActive ? wrapWithLinkStyle(content) : content
203+
}
180204
if (visType.type.toLowerCase() === 'icon') this.eGui.innerHTML = `${visType.prefix}<i class="${styleObject?.icon} p-as-center" />${visType.suffix}`
181-
if (visType.type.toLowerCase() === 'text & icon') this.eGui.innerHTML = `${visType.prefix}${setCellContent()}<i class="${styleObject?.icon} p-as-center" />${visType.suffix}`
205+
if (visType.type.toLowerCase() === 'text & icon') {
206+
const content = `${visType.prefix}${setCellContent()}<i class="${styleObject?.icon} p-as-center" />${visType.suffix}`
207+
this.eGui.innerHTML = linkStyleActive ? wrapWithLinkStyle(content) : content
208+
}
182209
if (visType.type.toLowerCase() === 'bar') {
183210
const percentage = getBarFillPercentage()
184211
this.eGui.innerHTML = `<div class="barContainer" style="background-color:${applyConditionalStyleToBar ? styleObject['background-color'] : visType['background-color']};justify-content:${visType['alignment']}">
@@ -192,7 +219,10 @@ export default class CellRenderer {
192219
</div>`
193220
}
194221
} else if (params.colId === 'iconColumn') createIconColumnIcons()
195-
else this.eGui.innerHTML = setCellContent()
222+
else {
223+
const content = setCellContent()
224+
this.eGui.innerHTML = linkStyleActive ? wrapWithLinkStyle(content) : content
225+
}
196226

197227
truncateCellContent(this.eGui)
198228

0 commit comments

Comments
 (0)