Skip to content

Commit

Permalink
Bugfix supporting both Lumino v1 and v2
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Mar 18, 2024
1 parent 0bfd309 commit 7dcd240
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export abstract class BeakerXCellRenderer extends TextRenderer {
const highlighterColor = this.dataGrid.highlighterManager.getCellBackground(config);
const focusedColor = this.dataGrid.cellFocusManager.getFocussedCellBackground(config);
const initialColor = selectionColor && highlighterColor && DataGridStyle.darken(highlighterColor);

return (
focusedColor ||
selectionColor ||
Expand Down Expand Up @@ -165,15 +165,15 @@ export abstract class BeakerXCellRenderer extends TextRenderer {
) {
return Theme.DEFAULT_HEADER_FONT_COLOR;
}

if (
config.region === 'body' &&
this.dataGrid.rowManager.rows[config.row] &&
this.dataGrid.rowManager.rows[config.row].cells &&
this.dataGrid.rowManager.rows[config.row].cells[config.column].fontColor
) {
return DataGridStyle.formatColor(this.dataGrid.rowManager.rows[config.row].cells[config.column].fontColor);
}
}

return Theme.DEFAULT_DATA_FONT_COLOR;
}
Expand All @@ -200,7 +200,7 @@ export abstract class BeakerXCellRenderer extends TextRenderer {
if (!result.font) {
return result;
}

// Resolve the text color for the cell.
result.color = CellRenderer.resolveOption(this.textColor, config);

Expand Down
14 changes: 6 additions & 8 deletions beakerx_tabledisplay/js/src/dataGrid/column/DataGridColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,26 +300,24 @@ export class DataGridColumn {
let minMax;
const dataType = this.getDataType();
const displayType = this.getDisplayType();
const valuesIterator = () => {
return this.dataGrid.dataModel.getColumnValuesIterator(this);
};
const values = Array.from(this.dataGrid.dataModel.getColumnValuesIterator(this));
const valueResolver = this.dataGrid.dataModel.getColumnValueResolver(
displayType === ALL_TYPES.html ? displayType : dataType,
);

if (dataType === ALL_TYPES.html || displayType === ALL_TYPES.html) {
this.resizeHTMLRows(valuesIterator());
this.resizeHTMLRows(values);
} else if (dataType === ALL_TYPES['formatted integer']) {
stringMinMax = minmax(valuesIterator(), ColumnValuesIterator.longestString(valueResolver));
stringMinMax = minmax(values, ColumnValuesIterator.longestString(valueResolver));
} else if (dataType === ALL_TYPES.string) {
minMax = minmax(
filter(valuesIterator(), (value) => this.canStringBeConvertedToNumber(value)),
filter(values, (value) => this.canStringBeConvertedToNumber(value)),
ColumnValuesIterator.minMax(this.dataGrid.dataModel.getColumnValueResolver(ALL_TYPES.double)),
);
stringMinMax = minmax(valuesIterator(), ColumnValuesIterator.longestString(valueResolver));
stringMinMax = minmax(values, ColumnValuesIterator.longestString(valueResolver));
} else {
minMax = minmax(
filter(valuesIterator(), (value) => !Number.isNaN(valueResolver(value))),
filter(values, (value) => !Number.isNaN(valueResolver(value))),
ColumnValuesIterator.minMax(valueResolver),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class UniqueEntriesHighlighter extends Highlighter {
const generateColor = this.getColorGenerationFn(1, 1);

reduce(
this.model.getColumnValuesIterator(this.column),
Array.from(this.model.getColumnValuesIterator(this.column)),
(acc, value) => {
if (acc.indexOf(value) === -1) {
acc.push(value);
Expand Down
8 changes: 4 additions & 4 deletions beakerx_tabledisplay/js/src/dataGrid/row/RowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { filter, toArray } from '@lumino/algorithm';
import { filter } from '@lumino/algorithm';
import { Theme } from '../../utils/Theme';
import { ColumnFilter } from '../column/ColumnFilter';
import { ColumnManager } from '../column/ColumnManager';
Expand Down Expand Up @@ -98,15 +98,15 @@ export class RowManager {
}

applyFilterToRows(evalFn, formatFns) {
this.rows = toArray(
filter(this.rowsIterator, (row) =>
this.rows = Array.from(
filter(Array.from(this.rowsIterator), (row) =>
evalFn ? evalFn(row, formatFns) : this.evaluateFilterExpression(row, formatFns),
),
);
}

resetRows() {
this.rows = toArray(this.rowsIterator);
this.rows = Array.from(this.rowsIterator);
}

keepSorting() {
Expand Down

0 comments on commit 7dcd240

Please sign in to comment.