Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, expect, it } from '@jest/globals';
import { AI_COLUMN_NAME } from '@ts/grids/grid_core/ai_column/const';
import { columnHasValue } from '@ts/grids/grid_core/columns_controller/m_columns_controller_utils';
import type { Column } from '@ts/grids/grid_core/columns_controller/types';

const column = (partial: Partial<Column>): Column => partial as Column;

describe('columnHasValue', () => {
it('should be true for a data column', () => {
expect(columnHasValue(column({ dataField: 'name' }))).toBe(true);
});

it('should be false for a command column', () => {
expect(columnHasValue(column({ command: 'select' }))).toBe(false);
});

it('should be true for the AI column even though it carries a command', () => {
expect(columnHasValue(column({ command: AI_COLUMN_NAME, type: AI_COLUMN_NAME }))).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1097,4 +1097,8 @@ export const isColumnNameRequired = function ({ type = '' }: Column): boolean {
return COMMAND_COLUMNS_WITH_REQUIRED_NAMES.includes(type);
};

export const columnHasValue = (column: Column): boolean => (
!column.command || column.type === AI_COLUMN_NAME
);

export const getColumnHeaderCellSelector = (visibleIndex: number): string => `.dx-header-row td[aria-colindex="${visibleIndex + 1}"]`;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AI_COLUMN_NAME } from '@ts/grids/grid_core/ai_column/const';
import { columnHasValue } from '@ts/grids/grid_core/columns_controller/m_columns_controller_utils';
import type { Column } from '@ts/grids/grid_core/columns_controller/types';

import type { RawItemData } from '../../data_source_adapter/types';
Expand All @@ -13,7 +13,7 @@ export function generateRowValues(
const emptyValue = isModified ? undefined : null;

return columns.map((column) => {
if (column.command && column.type !== AI_COLUMN_NAME) {
if (!columnHasValue(column)) {
return emptyValue;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { columnHasValue } from '@ts/grids/grid_core/columns_controller/m_columns_controller_utils';
import type { Column } from '@ts/grids/grid_core/columns_controller/types';

import { AI_COLUMN_NAME } from '../ai_column/const';
import gridCoreUtils from '../m_utils';

export const getCellText = (
column: Column,
displayValue: unknown,
): string => (
!column.command || column.type === AI_COLUMN_NAME
columnHasValue(column)
? gridCoreUtils.formatValue(displayValue, column) as string
: ''
);
Expand Down
Loading