Skip to content

Commit

Permalink
Merge pull request #71 from camptocamp/change-keywords-to-categories-…
Browse files Browse the repository at this point in the history
…dataset-page

feat(keywords): Use category keywords, change category filter, change date filter
  • Loading branch information
Angi-Kinas authored May 23, 2024
2 parents 9d471b9 + 39a4e80 commit 4e8021b
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 88 deletions.
4 changes: 2 additions & 2 deletions apps/datahub-e2e/src/e2e/dataset.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('datasets', () => {
it('should display the territories', () => {
cy.get('@mainInfo')
.children('div')
.eq(2)
.eq(1)
.find('div')
.children('span')
.should('have.length.gt', 0)
Expand All @@ -174,7 +174,7 @@ describe('datasets', () => {
it('should display the producer', () => {
cy.get('@mainInfo')
.children('div')
.eq(4)
.eq(3)
.find('span')
.eq(1)
.should('have.text', 'Région Hauts-de-France')
Expand Down
16 changes: 11 additions & 5 deletions apps/datahub-e2e/src/e2e/search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ describe('search', () => {
.find('.mel-badge-button-primary')
.should('not.contain', 'HAUTS-DE-FRANCE')
})
it('should not dislay any place keywords (which are already displayed as categories)', () => {
cy.get('mel-datahub-results-card-search')
.eq(6)
.find('.mel-badge-button-primary')
.should('not.contain', 'Administration, action publique')
})
it('should not dislay html in abstract', () => {
cy.get('mel-datahub-results-card-search')
.eq(5)
Expand Down Expand Up @@ -159,21 +165,21 @@ describe('search', () => {
it('should display the search results in a grid', () => {
cy.get('mel-datahub-results-list-grid').should('be.visible')
})
it('should filter the results when selecting a filter value (topic)', () => {
cy.get('@filters').first().click()
it('should filter the results when selecting a filter value (licence)', () => {
cy.get('@filters').eq(3).click()
getFilterOptions()
cy.get('@options').first().click()
cy.get('@options').eq(1).click()
cy.get('@result-cards').should('have.length', 2)
cy.get('@result-cards')
.first()
.find('h1')
.should('have.text', ' Alpenkonvention ')
.should('have.text', ' Accroches vélos MEL ')
cy.get('@result-cards')
.eq(1)
.find('h1')
.should(
'have.text',
' Patrimoine - Biens classés et zones de protection - Série '
' Mat éolien construit ou en projet dans les Hauts de France '
)
})
it('should filter the results when selecting multiple filter values (producer)', () => {
Expand Down
3 changes: 3 additions & 0 deletions apps/datahub/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
UiMapModule,
GN_UI_VERSION,
WEB_COMPONENT_EMBEDDER_URL,
FieldsService,
} from 'geonetwork-ui'
import {
TranslateLoader,
Expand Down Expand Up @@ -60,6 +61,7 @@ import { MelMapViewComponent } from './dataset/dataset-visualisation/map-view/ma
import { MelDataViewComponent } from './dataset/dataset-visualisation/data-view/data-view.component'
import { environment } from '../environments/environnment'
import { MelModule, MelEmbeddedTranslateLoader } from '@mel-dataplatform/mel'
import { MelFieldsService } from './search/service/fields.service'

@NgModule({
declarations: [
Expand Down Expand Up @@ -147,6 +149,7 @@ import { MelModule, MelEmbeddedTranslateLoader } from '@mel-dataplatform/mel'
provide: LOGIN_URL,
useFactory: () => '${current_url}?login',
},
{ provide: FieldsService, useClass: MelFieldsService },
],
bootstrap: [AppComponent],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<span class="font-semibold" translate="">mel.dataset.updatedOn</span>
<div class="text-primary font-semibold">{{ lastUpdate }}</div>
</div>
} @if(record.topics?.length) {
} @if(displayCategories?.length) {
<div class="flex flex-col gap-2">
<span class="font-semibold" translate="">mel.dataset.categories</span>
<div class="flex gap-1 gap-x-2 flex-row flex-wrap">
@for(topic of record.topics; track $index) {
@for(topic of displayCategories; track $index) {
<span class="mel-badge-primary truncate">
{{ topic }}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ export class DatasetInformationComponent {
get territories() {
return this.record?.keywords?.filter((keyword) => keyword.type === 'place')
}

get displayCategories() {
const categoryKeywords = this.record?.keywords?.filter(
(keyword) => keyword.thesaurus?.name === 'Catégories'
)

return categoryKeywords?.map((keyword) => keyword.label)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ marker('mel.datahub.search.filters.license')
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SearchFiltersComponent {
searchConfig = ['topic', 'publisher', 'publicationYear', 'license'].map(
(filter) => ({
fieldName: filter,
title: `mel.datahub.search.filters.${filter}`,
})
)
searchConfig = [
'categoryKeyword',
'publisher',
'revisionYear',
'license',
].map((filter) => ({
fieldName: filter,
title: `mel.datahub.search.filters.${filter}`,
}))
}
28 changes: 28 additions & 0 deletions apps/datahub/src/app/search/service/fields.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Injectable, Injector } from '@angular/core'
import { marker } from '@biesbjerg/ngx-translate-extract-marker'
import { FieldsService, SimpleSearchField } from 'geonetwork-ui'
import { TranslatedSearchField } from 'geonetwork-ui'

marker('search.filters.categoryKeyword')
@Injectable({
providedIn: 'root',
})
export class MelFieldsService extends FieldsService {
override fields = {
...this.fields,
categoryKeyword: new TranslatedSearchField(
'th_thesaurus_mot_cle_thematique_categories.link',
this.injector,
'asc'
),
revisionYear: new SimpleSearchField(
'revisionYearForResource',
this.injector,
'desc'
),
}

constructor(override injector: Injector) {
super(injector)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export class ResultsListItemComponent {
}

get keywords() {
return this.record?.keywords?.filter((keyword) => keyword.type !== 'place')
return this.record?.keywords?.filter(
(keyword) =>
keyword.type !== 'place' && keyword.thesaurus?.name !== 'Catégories'
)
}

onKeywordClick(keyword: Keyword, event: Event) {
Expand Down
Loading

0 comments on commit 4e8021b

Please sign in to comment.