-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metadata Editor: rework search results layout, add "create record" button #805
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5727e81
feat(search): remove results count from results-table component
jahow e223064
feat(search): makes Facade.resetSearch() chainable
jahow 85d4cc3
feat(ME): adjust button style to match mockups
jahow f58d4fa
feat(ME): remove records/all route, only use a single SearchRecordsLi…
jahow bdb165f
feat(ME): remove unused CreatePage component
jahow a0a0bdf
chore: i18n
jahow f6bec55
chore: remove local translate testing module, use npm package instead
jahow 9b61ca2
doc: standalone components and how to test them
jahow 1722551
e2e(ME): adapt tests
jahow aa9b5a7
chore: avoid generic eslint-disable-next-line comments
jahow 8064624
chore: solve several circular dependencies in feature/search
jahow 1a159b3
chore: remove results-table stories as they cannot work outside of an…
jahow bf20692
doc: best practices for storybook
jahow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
apps/metadata-editor/src/app/records/all-records/all-records-list.component.html
This file was deleted.
Oops, something went wrong.
57 changes: 0 additions & 57 deletions
57
apps/metadata-editor/src/app/records/all-records/all-records-list.component.spec.ts
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
apps/metadata-editor/src/app/records/all-records/all-records-list.component.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
apps/metadata-editor/src/app/records/records-count/records-count.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div data-cy="records-information" class="flex flex-row"> | ||
<div | ||
class="text-gray-800" | ||
data-test="records-count" | ||
translate | ||
[translateParams]="{ | ||
displayed: (records$ | async).length, | ||
hits: (recordCount$ | async) | ||
}" | ||
> | ||
results.records.hits.displayedOn | ||
</div> | ||
<div | ||
*ngIf="(selectedRecords$ | async).length as selectedRecordCount" | ||
class="ml-2 text-gray-600" | ||
data-test="selected-count" | ||
translate | ||
[translateParams]="{ amount: selectedRecordCount }" | ||
> | ||
results.records.hits.selected | ||
</div> | ||
</div> |
92 changes: 92 additions & 0 deletions
92
apps/metadata-editor/src/app/records/records-count/records-count.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing' | ||
import { DATASET_RECORDS } from '@geonetwork-ui/common/fixtures' | ||
import { RecordsCountComponent } from './records-count.component' | ||
import { By } from '@angular/platform-browser' | ||
import { BehaviorSubject } from 'rxjs' | ||
import { SearchFacade } from '@geonetwork-ui/feature/search' | ||
import { SelectionService } from '@geonetwork-ui/api/repository' | ||
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler' | ||
import { TranslateTestingModule } from '@geonetwork-ui/util/i18n' | ||
|
||
class SearchFacadeMock { | ||
results$ = new BehaviorSubject(DATASET_RECORDS) | ||
resultsHits$ = new BehaviorSubject(1000) | ||
} | ||
class SelectionServiceMock { | ||
selectedRecordsIdentifiers$ = new BehaviorSubject([]) | ||
} | ||
|
||
describe('RecordsCountComponent', () => { | ||
let component: RecordsCountComponent | ||
let selectionService: SelectionServiceMock | ||
let fixture: ComponentFixture<RecordsCountComponent> | ||
|
||
beforeEach(() => { | ||
const testingModule = TranslateTestingModule.withTranslations({ | ||
en: { | ||
'results.records.hits.displayedOn': | ||
'{displayed, plural, =0{No record.} one{1 record} other{{displayed} records}} {hits, plural, other{displayed on {hits} total.}}', | ||
'results.records.hits.selected': '{ amount } selected', | ||
}, | ||
}) | ||
.withDefaultLanguage('en') | ||
.withCompiler(new TranslateMessageFormatCompiler()) | ||
TestBed.configureTestingModule({ | ||
providers: [ | ||
{ | ||
provide: SearchFacade, | ||
useClass: SearchFacadeMock, | ||
}, | ||
{ | ||
provide: SelectionService, | ||
useClass: SelectionServiceMock, | ||
}, | ||
], | ||
}).overrideComponent(RecordsCountComponent, { | ||
add: { | ||
providers: [...testingModule.providers], | ||
}, | ||
}) | ||
|
||
fixture = TestBed.createComponent(RecordsCountComponent) | ||
selectionService = TestBed.inject(SelectionService) as any | ||
component = fixture.componentInstance | ||
fixture.detectChanges() | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
|
||
describe('records count', () => { | ||
it('shows both visible and total counts', () => { | ||
const el = fixture.debugElement.query( | ||
By.css('[data-test=records-count]') | ||
).nativeElement | ||
expect(el.textContent).toContain('2 records displayed on 1000 total.') | ||
}) | ||
}) | ||
|
||
describe('selected count', () => { | ||
describe('if none selected', () => { | ||
it('does not show anything', () => { | ||
const el = fixture.debugElement.query( | ||
By.css('[data-test=selected-count]') | ||
) | ||
expect(el).toBeFalsy() | ||
}) | ||
}) | ||
describe('if some selected', () => { | ||
beforeEach(() => { | ||
selectionService.selectedRecordsIdentifiers$.next(['1', '2']) | ||
fixture.detectChanges() | ||
}) | ||
it('shows the count', () => { | ||
const el = fixture.debugElement.query( | ||
By.css('[data-test=selected-count]') | ||
).nativeElement | ||
expect(el.textContent).toContain('2 selected') | ||
}) | ||
}) | ||
}) | ||
}) |
44 changes: 44 additions & 0 deletions
44
apps/metadata-editor/src/app/records/records-count/records-count.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
Component, | ||
EventEmitter, | ||
importProvidersFrom, | ||
Output, | ||
} from '@angular/core' | ||
import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' | ||
import { UiInputsModule } from '@geonetwork-ui/ui/inputs' | ||
import { | ||
InteractiveTableColumnComponent, | ||
InteractiveTableComponent, | ||
} from '@geonetwork-ui/ui/layout' | ||
import { MatIconModule } from '@angular/material/icon' | ||
import { TranslateModule } from '@ngx-translate/core' | ||
import { SelectionService } from '@geonetwork-ui/api/repository' | ||
import { CommonModule } from '@angular/common' | ||
import { SearchFacade } from '@geonetwork-ui/feature/search' | ||
|
||
@Component({ | ||
selector: 'md-editor-records-count', | ||
templateUrl: './records-count.component.html', | ||
styleUrls: ['./records-count.component.css'], | ||
standalone: true, | ||
imports: [ | ||
CommonModule, | ||
UiInputsModule, | ||
InteractiveTableComponent, | ||
InteractiveTableColumnComponent, | ||
MatIconModule, | ||
TranslateModule, | ||
], | ||
}) | ||
export class RecordsCountComponent { | ||
@Output() recordClick = new EventEmitter<CatalogRecord>() | ||
|
||
records$ = this.searchFacade.results$ | ||
recordCount$ = this.searchFacade.resultsHits$ | ||
selectedRecords$ = this.selectionService.selectedRecordsIdentifiers$ | ||
|
||
constructor( | ||
private searchFacade: SearchFacade, | ||
private selectionService: SelectionService | ||
) {} | ||
} |
67 changes: 58 additions & 9 deletions
67
apps/metadata-editor/src/app/records/search-records/search-records-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,58 @@ | ||
<md-editor-records-list | ||
[title]=" | ||
(searchText$ | async) | ||
? ('dashboard.records.search' | ||
| translate: { searchText: searchText$ | async }) | ||
: ('dashboard.records.all' | translate) | ||
" | ||
> | ||
</md-editor-records-list> | ||
<main class="bg-white"> | ||
<div class="flex flex-row items-baseline gap-[8px] px-[32px] py-[20px]"> | ||
<ng-container *ngIf="searchText$ | async as searchText; else allRecords"> | ||
<h1 | ||
class="text-[16px] text-main font-title font-bold" | ||
translate | ||
[translateParams]="{ searchText: searchText }" | ||
> | ||
dashboard.records.search | ||
</h1> | ||
<div class="text-[12px]"> | ||
<md-editor-records-count></md-editor-records-count> | ||
</div> | ||
</ng-container> | ||
<ng-template #allRecords> | ||
<h1 class="text-[16px] text-main font-title font-bold" translate> | ||
dashboard.records.all | ||
</h1> | ||
<div class="text-[12px]"> | ||
<md-editor-records-count></md-editor-records-count> | ||
</div> | ||
</ng-template> | ||
</div> | ||
<div | ||
class="flex flex-row items-center mx-[32px] my-[16px] py-[8px] gap-[16px]" | ||
> | ||
<div> | ||
<span class="uppercase" translate>dashboard.results.listMetadata</span> | ||
</div> | ||
<div> | ||
<span class="uppercase" translate>dashboard.results.listResources</span> | ||
</div> | ||
<div class="grow"></div> | ||
<gn-ui-button (buttonClick)="createRecord()" type="primary"> | ||
<mat-icon class="material-symbols-outlined mr-2">edit_document</mat-icon> | ||
<span translate>dashboard.createRecord</span> | ||
</gn-ui-button> | ||
</div> | ||
|
||
<div | ||
class="shadow-md shadow-gray-300 border-[1px] border-gray-200 overflow-hidden rounded bg-white grow mx-[32px] my-[16px]" | ||
> | ||
<gn-ui-results-table | ||
class="text-[14px]" | ||
(recordClick)="editRecord($event)" | ||
></gn-ui-results-table> | ||
|
||
<div class="px-5 py-5 flex justify-center gap-8 items-baseline"> | ||
<div class="grow"> | ||
<gn-ui-pagination-buttons | ||
[currentPage]="searchFacade.currentPage$ | async" | ||
[totalPages]="searchFacade.totalPages$ | async" | ||
(newCurrentPageEvent)="searchService.setPage($event)" | ||
></gn-ui-pagination-buttons> | ||
</div> | ||
</div> | ||
</div> | ||
</main> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind for gap, padding, margin, but should text size be hardcoded in pixels this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I always hardcode pixel values like that now, then there's no need to look for the meaning of e.g.
text-sm
in pixels (also many TW classes userem
instead ofpx
which is one more annoying thing when working with precise mockups).I don't see any drawbacks to this personally, do you think this could be an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends, do you intend to be responsive when people change there screen size, zoom in/out?
I honestly don't know how Tailwind CSS behaves in those cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TW has modifiers for screen sizes so there's really no impact here 🙂
edit: https://tailwindcss.com/docs/responsive-design