Skip to content

Commit 6c86904

Browse files
committed
GridCommands: add row index to focus and select commands
1 parent a7175ed commit 6c86904

4 files changed

Lines changed: 9 additions & 8 deletions

File tree

packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/__tests__/focus.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,13 @@ describe('focusRowByIndexCommand', () => {
328328
});
329329

330330
describe('default message', () => {
331-
it('uses the literal `Focus row.` on success', async () => {
331+
it('reports the 1-based row number on the current page on success', async () => {
332332
const instance = await createGrid();
333333
const callbacks = createCallbacks();
334334

335335
await focusRowByIndexCommand.execute(instance, callbacks)({ index: 1 });
336336

337-
expect(callbacks.success).toHaveBeenCalledWith('Focus row.');
337+
expect(callbacks.success).toHaveBeenCalledWith('Focus row number 2 on the current page.');
338338
});
339339

340340
it('passes the same default message to failure when executability fails', async () => {
@@ -343,7 +343,7 @@ describe('focusRowByIndexCommand', () => {
343343

344344
await focusRowByIndexCommand.execute(instance, callbacks)({ index: 1 });
345345

346-
expect(callbacks.failure).toHaveBeenCalledWith('Focus row.');
346+
expect(callbacks.failure).toHaveBeenCalledWith('Focus row number 2 on the current page.');
347347
});
348348
});
349349
});

packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/__tests__/selection.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,14 @@ describe('selectByIndexesCommand', () => {
372372
});
373373

374374
describe('default message', () => {
375-
it('uses literal `Select row(s).`', async () => {
375+
it('reports the 1-based row numbers on the current page on success', async () => {
376376
const instance = await createGrid();
377377
jest.spyOn(instance, 'selectRowsByIndexes').mockReturnValue(Promise.resolve([]) as never);
378378
const callbacks = createCallbacks();
379379

380380
await selectByIndexesCommand.execute(instance, callbacks)({ indexes: [0, 2] });
381381

382-
expect(callbacks.success).toHaveBeenCalledWith('Select row(s).');
382+
expect(callbacks.success).toHaveBeenCalledWith('Select row(s) number 1, 3 on the current page.');
383383
});
384384

385385
it('passes the same default message to failure', async () => {
@@ -388,7 +388,7 @@ describe('selectByIndexesCommand', () => {
388388

389389
await selectByIndexesCommand.execute(instance, callbacks)({ indexes: [0] });
390390

391-
expect(callbacks.failure).toHaveBeenCalledWith('Select row(s).');
391+
expect(callbacks.failure).toHaveBeenCalledWith('Select row(s) number 1 on the current page.');
392392
});
393393
});
394394
});

packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/focus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const focusRowByIndexCommand = defineGridCommand({
8484
description: 'Focus a specific row by its 0-based index within the current page. Index 0 is the first row on the visible page. To focus a row that is not on the current page, use focusRowByKey or call pageIndex first. Requires focusedRowEnabled to be true on the grid.',
8585
schema: focusRowByIndexCommandSchema,
8686
execute: (component, { success, failure }) => async (args): Promise<CommandResult> => {
87-
const defaultMessage = 'Focus row.';
87+
const defaultMessage = `Focus row number ${args.index + 1} on the current page.`;
8888
const dataController = component.getController('data');
8989
const key = dataController.getKeyByRowIndex(args.index);
9090

packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/selection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ export const selectByIndexesCommand = defineGridCommand({
5151
description: 'Select rows by their 0-based indexes within the current page. Index 0 is the first row on the visible page; group/header rows are not selectable. To select rows that are not on the current page, use selectByKeys, or call pageIndex first to switch the page.',
5252
schema: selectByIndexesCommandSchema,
5353
execute: (component, { success, failure }) => async (args): Promise<CommandResult> => {
54-
const defaultMessage = 'Select row(s).';
54+
const rowIndexes = args.indexes.map((index) => index + 1).join(', ');
55+
const defaultMessage = `Select row(s) number ${rowIndexes} on the current page.`;
5556

5657
if (component.option('selection.mode') === 'none') {
5758
return failure(defaultMessage);

0 commit comments

Comments
 (0)