Skip to content

Commit

Permalink
feat(fav-card): Show fav-card only if logged in
Browse files Browse the repository at this point in the history
and favorites exists, otherwise show last-created
card.
Add info icon,
comment tests for fav-card,
remove favorite star.
  • Loading branch information
Angi-Kinas committed Feb 6, 2024
1 parent 7082763 commit a06eabd
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 56 deletions.
95 changes: 50 additions & 45 deletions apps/datahub-e2e/src/e2e/search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,55 @@ describe('datahub-e2e', () => {
it('should display the number of result hits', () => {
cy.get('gn-ui-results-hits-number').should('contain', 12)
})
it('should display record results in preview cards', () => {
cy.get('mel-datahub-results-card-favorite')
.eq(0)
.find('h1')
.should(
'have.text',
' Cartographie des sols agricoles de la plaine du Rhône '
)

cy.get('mel-datahub-results-card-favorite')
.find('.mel-badge-button')
.should('be.visible')

cy.get('mel-datahub-results-card-favorite')
.find('gn-ui-star-toggle')
.should('be.visible')

cy.get('mel-datahub-results-card-favorite')
.find('mel-datahub-mel-datahub-metadata-quality')
.should('be.visible')
})

describe('interactions with dataset', () => {
beforeEach(() => {
cy.get('mel-datahub-results-card-favorite').first().as('firstResult')
})
it('should open the dataset page in the same application on click', () => {
const urlRegex = /http:\/\/[^/]+:\d+\/dataset/
cy.get('@firstResult').click()
cy.url().should('match', urlRegex)
cy.get('mel-datahub-dataset-page').should('be.visible')
})
it('should filter the search by clicked keyword', () => {
const urlRegex = /http:\/\/[^\/]+:\d+\/search\?q=.+/
cy.get('@firstResult')
.find('.mel-badge-button')
.first()
.as('firstKeyWord')
.should('have.text', ' Usage des sols ')

cy.get('@firstKeyWord').click()
cy.url().should('match', urlRegex)

cy.get('mel-datahub-results-card-search').should('be.visible')
})
})
// ********************
// TODO: This can be activated and tested when we will be able to add favorites

// it('should display record results in preview cards', () => {
// cy.get('mel-datahub-results-card-favorite')
// .eq(0)
// .find('h1')
// .should(
// 'have.text',
// ' Cartographie des sols agricoles de la plaine du Rhône '
// )

// cy.get('mel-datahub-results-card-favorite')
// .find('.mel-badge-button')
// .should('be.visible')

// cy.get('mel-datahub-results-card-favorite')
// .find('gn-ui-star-toggle')
// .should('be.visible')

// cy.get('mel-datahub-results-card-favorite')
// .find('mel-datahub-mel-datahub-metadata-quality')
// .should('be.visible')
// })

// describe('interactions with dataset', () => {
// beforeEach(() => {
// cy.get('mel-datahub-results-card-favorite').first().as('firstResult')
// })
// it('should open the dataset page in the same application on click', () => {
// const urlRegex = /http:\/\/[^/]+:\d+\/dataset/
// cy.get('@firstResult').click()
// cy.url().should('match', urlRegex)
// cy.get('mel-datahub-dataset-page').should('be.visible')
// })
// it('should filter the search by clicked keyword', () => {
// const urlRegex = /http:\/\/[^\/]+:\d+\/search\?q=.+/
// cy.get('@firstResult')
// .find('.mel-badge-button')
// .first()
// .as('firstKeyWord')
// .should('have.text', ' Usage des sols ')

// cy.get('@firstKeyWord').click()
// cy.url().should('match', urlRegex)

// cy.get('mel-datahub-results-card-search').should('be.visible')
// })
// })
// ********************
})
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
<span class="text-[12px] font-bold">{{
(qualityScore / 10).toFixed(1)
}}</span>
<span class="text-gray-2 text-[12px] material-symbols-outlined">
info
</span>
<img class="info-icon" [src]="'/assets/info.svg'" [alt]="'info'" />
</div>

<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<h1 class="font-bold text-[17px] line-clamp-1">
{{ record.title }}
</h1>
<gn-ui-favorite-star></gn-ui-favorite-star>
</div>

<div class="flex flex-col justify-between">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<div class="relative">
<div class="flex gap-4 p-4">
@for (record of searchFacade.results$ | async; track
record.uniqueIdentifier) { @if (true) {
<!-- if favoritesOnly -->
record?.uniqueIdentifier) { @if (favoritesOnlyValue) {
<mel-datahub-results-card-favorite
[style]="'height: 12em;'"
[record]="record"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import { CatalogRecord } from 'geonetwork-ui/libs/common/domain/src/lib/model/re
template: '',
})
export class ResultsListComponent implements OnInit {
@Input() favoritesOnly = false
@Input() set favoritesOnly(value: boolean) {
this.favoritesOnlyValue = value
this.searchFacade.setFavoritesOnly(value)
}
favoritesOnlyValue: boolean
@Input() numberOfResults = 10

constructor(
Expand All @@ -25,7 +29,6 @@ export class ResultsListComponent implements OnInit {
) {}

ngOnInit() {
if (this.favoritesOnly) this.searchFacade.setFavoritesOnly(true)
this.searchFacade
.setConfigRequestFields([...FIELDS_BRIEF, 'createDate', 'changeDate'])
.setPageSize(this.numberOfResults)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1 class="flex justify-center mel-page-title" translate="">
<div class="h-64" gnUiSearchStateContainer="headerHome">
<mel-datahub-results-list-carousel
[numberOfResults]="6"
[favoritesOnly]="true"
[favoritesOnly]="false"
></mel-datahub-results-list-carousel>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ <h1 class="flex mel-page-title" translate="">mel.datahub.search.title</h1>
<div class="h-64" gnUiSearchStateContainer="headerSearch">
<mel-datahub-results-list-carousel
[numberOfResults]="10"
[favoritesOnly]="
(favoritesService.myFavoritesUuid$ | async)?.length > 0
"
></mel-datahub-results-list-carousel>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'
import { RouterFacade, SearchService } from 'geonetwork-ui'
import { FavoritesService, RouterFacade, SearchService } from 'geonetwork-ui'
import { CatalogRecord } from 'geonetwork-ui/libs/common/domain/src/lib/model/record'
import { SortByField } from 'geonetwork-ui/libs/common/domain/src/lib/model/search'

Expand All @@ -12,7 +12,8 @@ import { SortByField } from 'geonetwork-ui/libs/common/domain/src/lib/model/sear
export class SearchHeaderComponent {
constructor(
public routerFacade: RouterFacade,
private searchService: SearchService
private searchService: SearchService,
public favoritesService: FavoritesService
) {}

onFuzzySearchSelection(record: CatalogRecord) {
Expand Down
3 changes: 3 additions & 0 deletions apps/datahub/src/assets/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a06eabd

Please sign in to comment.