-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #805 from geonetwork/ME/rework-layout
Metadata Editor: rework search results layout, add "create record" button
- Loading branch information
Showing
60 changed files
with
807 additions
and
671 deletions.
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
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 was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
apps/metadata-editor/src/app/create/create-page.component.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Empty file removed
0
apps/metadata-editor/src/app/records/all-records/all-records-list.component.css
Empty file.
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.
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
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 'ngx-translate-testing' | ||
|
||
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') | ||
}) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.