Add visible newlines to display value for Edit Data cells (#24334)

This commit is contained in:
Alex Ma
2023-09-07 21:55:09 -07:00
committed by GitHub
parent aa006b9da7
commit 22d31afc4a

View File

@@ -227,7 +227,7 @@ export class EditDataGridPanel extends GridParentComponent {
}
else if (Services.DBCellValue.isDBCellValue(value)) {
// If a cell is not edited and retrieved direct from the SQL server, it would be in the form of a DBCellValue.
// We use the DBCellValue's displayValue as the text value.
// We use the DBCellValue's cleaned displayValue as the text value.
returnVal = this.replaceLinebreaks(value.displayValue);
}
else if (typeof value === 'string') {
@@ -477,7 +477,7 @@ export class EditDataGridPanel extends GridParentComponent {
id: columnIndex,
name: escape(c.columnName),
field: columnIndex,
formatter: this.getColumnFormatter,
formatter: (row, cell, value, columnDef, dataContext) => this.getColumnFormatter(row, cell, value, columnDef, dataContext, self.newlinePattern),
isEditable: c.isUpdatable
};
}))
@@ -710,7 +710,6 @@ export class EditDataGridPanel extends GridParentComponent {
let sessionRowId = self.rowIdMappings[self.currentCell.row] !== undefined
? self.rowIdMappings[self.currentCell.row]
: self.currentCell.row;
let restoredValue = this.newlinePattern ? self.currentEditCellValue.replace(/\u0000/g, this.newlinePattern) : self.currentEditCellValue;
return self.dataService.updateCell(sessionRowId, self.currentCell.column - 1, restoredValue);
}).then(
@@ -1256,7 +1255,7 @@ export class EditDataGridPanel extends GridParentComponent {
/*Formatter for Column*/
private getColumnFormatter(row: number | undefined, cell: number | undefined, value: any, columnDef: any | undefined, dataContext: any | undefined): string {
private getColumnFormatter(row: number | undefined, cell: number | undefined, value: any, columnDef: any | undefined, dataContext: any | undefined, newlinePattern: string): string {
let valueToDisplay = '';
let cellClasses = 'grid-cell-value-container';
/* tslint:disable:no-null-keyword */
@@ -1273,8 +1272,6 @@ export class EditDataGridPanel extends GridParentComponent {
// If a cell is not edited and retrieved direct from the SQL server, it would be in the form of a DBCellValue.
// We use it's displayValue and remove newlines for display purposes only.
valueToDisplay = (value.displayValue + '');
valueToDisplay = valueToDisplay.replace(/(\r\n|\n|\r)/g, '\u0000');
valueToDisplay = escape(valueToDisplay.length > 250 ? valueToDisplay.slice(0, 250) + '...' : valueToDisplay);
}
else if (typeof value === 'string' || (value && value.text)) {
// Once a cell has been edited, the cell value will no longer be a DBCellValue until refresh.
@@ -1284,8 +1281,9 @@ export class EditDataGridPanel extends GridParentComponent {
} else {
valueToDisplay = value;
}
valueToDisplay = escape(valueToDisplay.length > 250 ? valueToDisplay.slice(0, 250) + '...' : valueToDisplay);
valueToDisplay = newlinePattern ? valueToDisplay.replace(/\u0000/g, newlinePattern) : valueToDisplay;
}
valueToDisplay = Services.getCellDisplayValue(valueToDisplay);
return '<span title="' + valueToDisplay + '" class="' + cellClasses + '">' + valueToDisplay + '</span>';
}
}