Skip to content

Commit

Permalink
feat(editor): adjustements to the record table, add story
Browse files Browse the repository at this point in the history
  • Loading branch information
jahow committed Sep 9, 2023
1 parent 1d4ff14 commit 00eb9cd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
18 changes: 9 additions & 9 deletions libs/ui/search/src/lib/record-table/record-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
>
<span translate>record.metadata.title</span>
<mat-icon
class="material-symbols-outlined text-base leading-tight"
class="material-symbols-outlined"
*ngIf="isSortedBy('resourceTitleObject.default.keyword', 'desc')"
>
expand_more</mat-icon
>
<mat-icon
class="material-symbols-outlined text-base leading-tight"
class="material-symbols-outlined"
*ngIf="isSortedBy('resourceTitleObject.default.keyword', 'asc')"
>
expand_less</mat-icon
Expand All @@ -47,13 +47,13 @@
>
<span translate>record.metadata.author</span>
<mat-icon
class="material-symbols-outlined text-base leading-tight"
class="material-symbols-outlined"
*ngIf="isSortedBy('recordOwner', 'desc')"
>
expand_more</mat-icon
>
<mat-icon
class="material-symbols-outlined text-base leading-tight"
class="material-symbols-outlined"
*ngIf="isSortedBy('recordOwner', 'asc')"
>
expand_less</mat-icon
Expand All @@ -66,15 +66,15 @@
extraClass="px-3 py-2 space-x-1"
(buttonClick)="setSortBy('changeDate')"
>
<span translate>record.metadata.completion</span>
<span translate>record.metadata.updatedOn</span>
<mat-icon
class="material-symbols-outlined text-base leading-tight"
class="material-symbols-outlined"
*ngIf="isSortedBy('changeDate', 'desc')"
>
expand_more</mat-icon
>
<mat-icon
class="material-symbols-outlined text-base leading-tight"
class="material-symbols-outlined"
*ngIf="isSortedBy('changeDate', 'asc')"
>
expand_less</mat-icon
Expand All @@ -89,13 +89,13 @@
>
<span translate>record.metadata.createdOn</span>
<mat-icon
class="material-symbols-outlined text-base leading-tight"
class="material-symbols-outlined"
*ngIf="isSortedBy('createDate', 'desc')"
>
expand_more</mat-icon
>
<mat-icon
class="material-symbols-outlined text-base leading-tight"
class="material-symbols-outlined"
*ngIf="isSortedBy('createDate', 'asc')"
>
expand_less</mat-icon
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Meta, StoryObj } from '@storybook/angular'
import { moduleMetadata } from '@storybook/angular'
import { RecordTableComponent } from './record-table.component'
import { DATASET_RECORDS } from '@geonetwork-ui/common/fixtures'
import { action } from '@storybook/addon-actions'
import { MatIconModule } from '@angular/material/icon'
import { UiInputsModule } from '@geonetwork-ui/ui/inputs'

const meta: Meta<RecordTableComponent> = {
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<RecordTableComponent>

export const Primary: Story = {
args: {
records: DATASET_RECORDS.concat(DATASET_RECORDS, DATASET_RECORDS),
totalHits: 1234,
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 00eb9cd

Please sign in to comment.