From 77a2fdde095d42413f71818e714136f4ed542881 Mon Sep 17 00:00:00 2001 From: AndyKIron Date: Thu, 28 Sep 2023 14:23:12 +0300 Subject: [PATCH] fix(isct-59): fixed table component preselected rows --- .../components/table/v3/stories/table.component.stories.ts | 6 +++++- .../components/table/v3/stories/table.mock-data.ts | 6 +++--- .../table.story-holder.component.component.ts | 1 + projects/fusion-ui/components/table/v3/table.component.ts | 5 +++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/projects/fusion-ui/components/table/v3/stories/table.component.stories.ts b/projects/fusion-ui/components/table/v3/stories/table.component.stories.ts index 28a22ad33..b49aad4f1 100644 --- a/projects/fusion-ui/components/table/v3/stories/table.component.stories.ts +++ b/projects/fusion-ui/components/table/v3/stories/table.component.stories.ts @@ -20,7 +20,9 @@ import { TABLE_STICKY_COLUMNS_CONFIG, TABLE_SUBHEADER_COLUMNS_CONFIG, ROWS_READONLY_ROW_DATA, - TABLE_TOGGLE_EDIT_COLUMNS_CONFIG + TABLE_TOGGLE_EDIT_COLUMNS_CONFIG, + TABLE_CHECKBOX_COLUMNS_CONFIG, + ROWS_CHECKBOX_DATA } from './table.mock-data'; import {ApiService} from '@ironsource/fusion-ui'; @@ -1800,6 +1802,8 @@ export const InfinityScroll = { render: TableInfinityScrollTemplate, args: { + columns: TABLE_CHECKBOX_COLUMNS_CONFIG, + rows: ROWS_CHECKBOX_DATA, options: { ...TABLE_DEFAULT_OPTIONS, pagination: { diff --git a/projects/fusion-ui/components/table/v3/stories/table.mock-data.ts b/projects/fusion-ui/components/table/v3/stories/table.mock-data.ts index 8283ef616..b432edfc5 100644 --- a/projects/fusion-ui/components/table/v3/stories/table.mock-data.ts +++ b/projects/fusion-ui/components/table/v3/stories/table.mock-data.ts @@ -39,7 +39,7 @@ export const TABLE_SORTING_COLUMNS_CONFIG: TableColumn[] = [ {key: 'website', title: 'Website'} ]; export const TABLE_CHECKBOX_COLUMNS_CONFIG: TableColumn[] = [ - {key: 'selected', type: TableColumnTypeEnum.Checkbox, width: '32px'}, + {key: 'checkbox', type: TableColumnTypeEnum.Checkbox, width: '32px'}, ...TABLE_DEFAULT_COLUMNS_CONFIG ]; export const TABLE_TOGGLE_COLUMNS_CONFIG: TableColumn[] = [ @@ -393,8 +393,8 @@ export const ROWS_TOTALS_DATA = [ }, ...ROWS_DEFAULT_DATA ]; -export const ROWS_CHECKBOX_DATA = ROWS_DEFAULT_DATA.map(row => { - return {selected: false, ...row}; +export const ROWS_CHECKBOX_DATA = ROWS_DEFAULT_DATA.map((row, idx) => { + return {checkbox: idx == 3, ...row}; }); export const ROWS_TOGGLE_DATA = ROWS_DEFAULT_DATA.map(row => { return {live: true, ...row}; diff --git a/projects/fusion-ui/components/table/v3/stories/table.story-holder.component/table.story-holder.component.component.ts b/projects/fusion-ui/components/table/v3/stories/table.story-holder.component/table.story-holder.component.component.ts index 902bbe778..35f10af39 100644 --- a/projects/fusion-ui/components/table/v3/stories/table.story-holder.component/table.story-holder.component.component.ts +++ b/projects/fusion-ui/components/table/v3/stories/table.story-holder.component/table.story-holder.component.component.ts @@ -123,6 +123,7 @@ export class TableStoryHolderComponent implements OnInit, OnDestroy { const newRows = Array.from({length: 20}, (_, i) => { const id = i + shownLength + 1; return { + checkbox: false, id: id, name: id + ' name', username: id + ' UserName', diff --git a/projects/fusion-ui/components/table/v3/table.component.ts b/projects/fusion-ui/components/table/v3/table.component.ts index 2f735c03d..3b711e7b6 100644 --- a/projects/fusion-ui/components/table/v3/table.component.ts +++ b/projects/fusion-ui/components/table/v3/table.component.ts @@ -247,7 +247,9 @@ export class TableComponent implements OnInit, OnDestroy { public tableService: TableService, private uniqueService: UniqueIdService, private cdr: ChangeDetectorRef - ) {} + ) { + this.tableService.clearSelectedRows(); + } ngOnInit() { this.searchFormControl = new FormControl(this.options?.searchOptions?.initalValue || ''); @@ -267,7 +269,6 @@ export class TableComponent implements OnInit, OnDestroy { this.noDataSubMessage = this.options.noDataSubMessage || ''; this.hideHeaderOnEmpty = !isNullOrUndefined(this.options.hideHeaderOnEmpty) ? this.options.hideHeaderOnEmpty : false; this.isAllRowsSelectable = typeof this.options.isAllRowsSelectable === 'undefined' ? true : this.options.isAllRowsSelectable; - this.tableService.clearSelectedRows(); this.scrollListeners(); this.configIconNames = CONFIG_TABLE_BY_UI_STYLE[`style_v2`]; this.wrapperClasses = this.getWrapperClasses();