From 4b0e386d92c0007e59a61d02e46dae77282d3598 Mon Sep 17 00:00:00 2001 From: Olivia Guyot Date: Sat, 9 Sep 2023 13:00:23 +0200 Subject: [PATCH] feat(editor): adjustements to the record table, add story --- .../pagination-buttons.component.stories.ts | 9 ++--- .../record-table/record-table.component.html | 18 +++++----- .../record-table.component.stories.ts | 34 +++++++++++++++++++ .../record-table/record-table.component.ts | 1 + 4 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 libs/ui/search/src/lib/record-table/record-table.component.stories.ts diff --git a/libs/ui/elements/src/lib/pagination-buttons/pagination-buttons.component.stories.ts b/libs/ui/elements/src/lib/pagination-buttons/pagination-buttons.component.stories.ts index 8a382eb52c..94d61ccaed 100644 --- a/libs/ui/elements/src/lib/pagination-buttons/pagination-buttons.component.stories.ts +++ b/libs/ui/elements/src/lib/pagination-buttons/pagination-buttons.component.stories.ts @@ -1,15 +1,10 @@ import { TranslateModule } from '@ngx-translate/core' -import { - componentWrapperDecorator, - Meta, - moduleMetadata, - StoryObj, -} from '@storybook/angular' +import { Meta, moduleMetadata, StoryObj } from '@storybook/angular' import { TRANSLATE_DEFAULT_CONFIG, UtilI18nModule, } from '@geonetwork-ui/util/i18n' -import { UiInputsModule, ButtonComponent } from '@geonetwork-ui/ui/inputs' +import { ButtonComponent } from '@geonetwork-ui/ui/inputs' import { PaginationButtonsComponent } from './pagination-buttons.component' import { FormsModule } from '@angular/forms' import { action } from '@storybook/addon-actions' diff --git a/libs/ui/search/src/lib/record-table/record-table.component.html b/libs/ui/search/src/lib/record-table/record-table.component.html index 7d5036d744..e93f1977c4 100644 --- a/libs/ui/search/src/lib/record-table/record-table.component.html +++ b/libs/ui/search/src/lib/record-table/record-table.component.html @@ -23,13 +23,13 @@ > record.metadata.title expand_more expand_less record.metadata.author expand_more expand_less - record.metadata.completion + record.metadata.updatedOn expand_more expand_less record.metadata.createdOn expand_more expand_less = { + component: RecordTableComponent, + title: 'Search/RecordTableComponent', + decorators: [ + moduleMetadata({ + declarations: [RecordTableComponent], + imports: [UiInputsModule, MatIconModule], + }), + ], + render: (args: RecordTableComponent) => ({ + props: { + ...args, + recordSelect: action('recordSelect'), + sortByChange: action('sortByChange'), + }, + }), +} +export default meta +type Story = StoryObj + +export const Primary: Story = { + args: { + records: DATASET_RECORDS.concat(DATASET_RECORDS, DATASET_RECORDS), + totalHits: 1234, + }, +} diff --git a/libs/ui/search/src/lib/record-table/record-table.component.ts b/libs/ui/search/src/lib/record-table/record-table.component.ts index a64c25f8d8..e98926e42a 100644 --- a/libs/ui/search/src/lib/record-table/record-table.component.ts +++ b/libs/ui/search/src/lib/record-table/record-table.component.ts @@ -83,6 +83,7 @@ export class RecordTableComponent { newOrder = 'asc' } this.sortByChange.emit([newOrder, col]) + this.sortBy = [newOrder, col] } isSortedBy(col: string, order: 'asc' | 'desc'): boolean {