mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix Grid Links (#2393)
* fix grid links * formatting * remove commented code * revert formatting functions * fix build break
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { $ } from 'vs/base/browser/dom';
|
||||
import { escape } from 'sql/base/common/strings';
|
||||
|
||||
export class DBCellValue {
|
||||
@@ -14,6 +15,7 @@ export class DBCellValue {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format xml field into a hyperlink and performs HTML entity encoding
|
||||
*/
|
||||
@@ -53,4 +55,55 @@ export function textFormatter(row: number, cell: any, value: any, columnDef: any
|
||||
}
|
||||
|
||||
return `<span title="${valueToDisplay}" class="${cellClasses}">${valueToDisplay}</span>`;
|
||||
}
|
||||
}
|
||||
|
||||
/** The following code is a rewrite over the both formatter function using dom builder
|
||||
* rather than string manipulation, which is a safer and easier method of achieving the same goal.
|
||||
* However, when electron is in "Run as node" mode, dom creation acts differently than normal and therefore
|
||||
* the tests to test for html escaping fail. I'm keeping this code around as we should migrate to it if we ever
|
||||
* integrate into actual DOM testing (electron running in normal mode) later on.
|
||||
|
||||
export const hyperLinkFormatter: Slick.Formatter<any> = (row, cell, value, columnDef, dataContext): string => {
|
||||
let classes: Array<string> = ['grid-cell-value-container'];
|
||||
let displayValue = '';
|
||||
|
||||
if (DBCellValue.isDBCellValue(value)) {
|
||||
if (!value.isNull) {
|
||||
displayValue = value.displayValue;
|
||||
classes.push('queryLink');
|
||||
let linkContainer = $('a', {
|
||||
class: classes.join(' '),
|
||||
title: displayValue
|
||||
});
|
||||
linkContainer.innerText = displayValue;
|
||||
return linkContainer.outerHTML;
|
||||
} else {
|
||||
classes.push('missing-value');
|
||||
}
|
||||
}
|
||||
|
||||
let cellContainer = $('span', { class: classes.join(' '), title: displayValue });
|
||||
cellContainer.innerText = displayValue;
|
||||
return cellContainer.outerHTML;
|
||||
};
|
||||
|
||||
export const textFormatter: Slick.Formatter<any> = (row, cell, value, columnDef, dataContext): string => {
|
||||
let displayValue = '';
|
||||
let classes: Array<string> = ['grid-cell-value-container'];
|
||||
|
||||
if (DBCellValue.isDBCellValue(value)) {
|
||||
if (!value.isNull) {
|
||||
displayValue = value.displayValue.replace(/(\r\n|\n|\r)/g, ' ');
|
||||
} else {
|
||||
classes.push('missing-value');
|
||||
displayValue = 'NULL';
|
||||
}
|
||||
}
|
||||
|
||||
let cellContainer = $('span', { class: classes.join(' '), title: displayValue });
|
||||
cellContainer.innerText = displayValue;
|
||||
|
||||
return cellContainer.outerHTML;
|
||||
};
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user