Skip to content
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

[Search page] : Create advanced filters for organizations #933

Merged
merged 10 commits into from
Jul 9, 2024
Merged
2 changes: 1 addition & 1 deletion apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ describe('dataset pages', () => {
})
it('should go to dataset search page when clicking on org name and filter by org', () => {
cy.get('[data-cy="organization-name"]').eq(1).click()
cy.url().should('include', '/search?publisher=')
cy.url().should('include', '/search?organization=')
})
it('should go to dataset search page when clicking on keyword and filter by keyword', () => {
cy.get('gn-ui-expandable-panel').eq(2).click()
Expand Down
8 changes: 5 additions & 3 deletions apps/datahub-e2e/src/e2e/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('datasets', () => {
.click()
})
it('should display all filters', () => {
cy.get('@filters').filter(':visible').should('have.length', 10)
cy.get('@filters').filter(':visible').should('have.length', 12)
cy.get('@filters')
.children()
.then(($dropdowns) =>
Expand All @@ -182,7 +182,7 @@ describe('datasets', () => {
.map((dropdown) => dropdown.getAttribute('data-cy-field'))
)
.should('eql', [
'publisher',
'organization',
'format',
'publicationYear',
'topic',
Expand All @@ -192,11 +192,13 @@ describe('datasets', () => {
'keyword',
'resourceType',
'representationType',
'producerOrg',
'publisherOrg',
])
cy.screenshot({ capture: 'viewport' })
})

describe('publisher filter', () => {
describe('organization filter', () => {
beforeEach(() => {
cy.get('@filters').eq(0).click()
getFilterOptions()
Expand Down
2 changes: 1 addition & 1 deletion apps/datahub-e2e/src/fixtures/config-with-all-filters.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ main_color = "#212029" # All-purpose text color
background_color = "#fdfbff"

[search]
advanced_filters = ['publisher', 'format', 'publicationYear', 'topic', 'isSpatial', 'license', 'inspireKeyword', 'keyword', 'resourceType', 'representationType']
advanced_filters = ['organization', 'format', 'publicationYear', 'topic', 'isSpatial', 'license', 'inspireKeyword', 'keyword', 'resourceType', 'representationType', 'producerOrg', 'publisherOrg']
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jest.mock('@geonetwork-ui/util/app-config', () => {
{
sort: '-createDate',
name: 'sortCeatedDateAndOrg',
filters: { publisher: ['DREAL'] },
filters: { organization: ['DREAL'] },
},
{
name: 'filterCarto',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.
jest.mock('@geonetwork-ui/util/app-config', () => ({
getOptionalSearchConfig: () => ({
ADVANCED_FILTERS: [
'publisher',
'publisherOrg',
'format',
'isSpatial',
'documentStandard',
Expand Down Expand Up @@ -92,7 +92,7 @@ class FieldsServiceMock {
)
public get supportedFields() {
return [
'publisher',
'publisherOrg',
'format',
'isSpatial',
'documentStandard',
Expand Down Expand Up @@ -294,7 +294,7 @@ describe('SearchFiltersComponent', () => {
filter_format: {},
filter_publicationYear: {},
filter_isSpatial: {},
filter_publisher: {},
filter_publisherOrg: {},
filter_topic: {},
filter_license: {},
filter_documentStandard: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class SearchFiltersComponent implements OnInit {
this.platformService.getMe().subscribe((user) => (this.userId = user?.id))
this.searchConfig = (
getOptionalSearchConfig().ADVANCED_FILTERS || [
'publisher',
'organization',
'format',
'publicationYear',
'topic',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<a
data-test="organizationDatasetCount"
[routerLink]="['/', ROUTER_ROUTE_SEARCH]"
[queryParams]="{ publisher: organization.name }"
[queryParams]="{ organization: organization.name }"
>
<gn-ui-figure
class="py-[37px] pl-[47px] rounded-lg border bg-white mb-5 card-shadow cursor-pointer"
Expand Down Expand Up @@ -82,7 +82,7 @@
<div class="ml-auto">
<a
[routerLink]="['/', ROUTER_ROUTE_SEARCH]"
[queryParams]="{ publisher: organization.name }"
[queryParams]="{ organization: organization.name }"
class="gn-ui-btn-primary h-[34px] rounded-lg"
data-test="orgDetailsSearchAllBtn"
translate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ describe('OrganizationDetailsComponent', () => {
expect(orgDetailsSearchAllBtn).toBeTruthy()

expect(orgDetailsSearchAllBtn?.getAttribute('href')).toEqual(
`/${ROUTER_ROUTE_SEARCH}?publisher=${encodeURIComponent(
`/${ROUTER_ROUTE_SEARCH}?organization=${encodeURIComponent(
anOrganizationWithManyDatasets.name
)}`
)
Expand Down
6 changes: 3 additions & 3 deletions conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ background_color = "#fdfbff"
# filter_geometry_data = '{ "coordinates": [...], "type": "Polygon" }'

# The advanced search filters available to the user can be customized with this setting.
# The following fields can be used for filtering: 'publisher', 'format', 'publicationYear', 'standard', 'inspireKeyword', 'keyword', 'topic', 'isSpatial', 'license', 'resourceType', 'representationType'
# The following fields can be used for filtering: 'organization', 'format', 'publicationYear', 'standard', 'inspireKeyword', 'keyword', 'topic', 'isSpatial', 'license', 'resourceType', 'representationType', 'producerOrg', 'publisherOrg'
# any other field will be ignored
# advanced_filters = ['publisher', 'format', 'publicationYear', 'topic', 'isSpatial', 'license']
# advanced_filters = ['organization', 'format', 'publicationYear', 'topic', 'isSpatial', 'license']

# One or several search presets can be defined here; every search preset is composed of:
# - a name (which can be a translation key)
Expand All @@ -90,7 +90,7 @@ background_color = "#fdfbff"
# [[search_preset]]
# name = 'filterByName'
# filters.q = 'Full text search'
# filters.publisher = ['Org 1', 'Org 2']
# filters.organization = ['Org 1', 'Org 2']
# filters.format = ['format 1', 'format 2']
# filters.documentStandard = ['iso19115-3.2018']
# filters.inspireKeyword = ['keyword 1', 'keyword 2']
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ For a list of supported search fields, see [this documentation page](../referenc
The filters should be provided as an array, for instance:

```toml
advanced_filters = ['publisher', 'inspireKeyword', 'keyword', 'topic']
advanced_filters = ['organization', 'inspireKeyword', 'keyword', 'topic']
```

- `[[search_preset]]` (multiple, optional)
Expand All @@ -171,7 +171,7 @@ advanced_filters = ['publisher', 'inspireKeyword', 'keyword', 'topic']
[[search_preset]]
name = 'filterByName'
filters.q = 'full text search'
filters.publisher = ['Org 1', 'Org 2']
filters.organization = ['Org 1', 'Org 2']
filters.format = ['format 1', 'format 2']
filters.documentStandard = ['iso19115-3.2018']
filters.inspireKeyword = ['keyword 1', 'keyword 2']
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/search-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GeoNetwork-UI has built-in logic for several search fields, each of them relying
These fields are used in the following context:

- when building a URL or permalink from several search criteria; these fields will appear as query parameters in the URL, for instance:
`/search?publisher=MyOrg&format=csv&format=excel`
`/search?organization=MyOrg&format=csv&format=excel`
- when specifying advanced filters [in a configuration file](../guide/configure.md#search)

## Fields
cmoinier marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const initialParams: Params = {

class FieldsServiceMock {
mapping = {
publisher: 'OrgForResource',
organization: 'OrgForResource',
q: 'any',
}
buildFiltersFromFieldValues = jest.fn((fieldValues) =>
Expand Down
12 changes: 8 additions & 4 deletions libs/feature/search/src/lib/utils/service/fields.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('FieldsService', () => {
describe('#supportedFields', () => {
it('returns a list of fields', () => {
expect(service.supportedFields).toEqual([
'publisher',
'organization',
'format',
'resourceType',
'representationType',
Expand All @@ -99,13 +99,15 @@ describe('FieldsService', () => {
'q',
'license',
'owner',
'producerOrg',
'publisherOrg',
])
})
})
describe('#getAvailableValues', () => {
let values
beforeEach(async () => {
values = await lastValueFrom(service.getAvailableValues('publisher'))
values = await lastValueFrom(service.getAvailableValues('organization'))
})
it('gets the values from the orgs service', () => {
expect(values).toEqual([{ label: 'orgA (10)', value: 'orgA' }])
Expand All @@ -121,7 +123,7 @@ describe('FieldsService', () => {
beforeEach(async () => {
filters = await lastValueFrom(
service.buildFiltersFromFieldValues({
publisher: ['aa', 'bb'],
organization: ['aa', 'bb'],
format: ['cc', 'dd'],
publicationYear: '2022',
q: 'any',
Expand Down Expand Up @@ -174,12 +176,14 @@ describe('FieldsService', () => {
isSpatial: [],
license: [],
publicationYear: [],
publisher: ['orgB'],
organization: ['orgB'],
q: [],
representationType: [],
resourceType: [],
topic: [],
owner: [],
producerOrg: [],
publisherOrg: [],
})
})
})
Expand Down
18 changes: 16 additions & 2 deletions libs/feature/search/src/lib/utils/service/fields.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ marker('search.filters.keyword')
marker('search.filters.isSpatial')
marker('search.filters.license')
marker('search.filters.publicationYear')
marker('search.filters.publisher')
marker('search.filters.organization')
marker('search.filters.representationType')
marker('search.filters.resourceType')
marker('search.filters.standard')
marker('search.filters.topic')
marker('search.filters.contact')
marker('search.filters.producerOrg')
marker('search.filters.publisherOrg')

@Injectable({
providedIn: 'root',
})
export class FieldsService {
protected fields = {
publisher: new OrganizationSearchField(this.injector),
organization: new OrganizationSearchField(this.injector),
format: new SimpleSearchField('format', this.injector, 'asc'),
resourceType: new TranslatedSearchField(
'resourceType',
Expand Down Expand Up @@ -70,6 +72,18 @@ export class FieldsService {
q: new FullTextSearchField(),
license: new LicenseSearchField(this.injector),
owner: new OwnerSearchField(this.injector),
producerOrg: new MultilingualSearchField(
'originatorOrgForResourceObject',
this.injector,
'asc',
'key'
),
publisherOrg: new MultilingualSearchField(
'distributorOrgForResourceObject',
this.injector,
'asc',
'key'
),
} as Record<string, AbstractSearchField>

get supportedFields() {
Expand Down
9 changes: 7 additions & 2 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"datafeeder.datasetValidation.submitButton": "OK, meine Daten sind korrekt",
"datafeeder.datasetValidation.title": "Stellen Sie sicher, dass Ihre Daten korrekt sind",
"datafeeder.datasetValidation.unknown": " - ",
"datafeeder.datasetValidationCsv.explicitLineNumbers": "",
"datafeeder.datasetValidationCsv.lineNumbers": "",
"datafeeder.form.abstract": "Wie würden Sie Ihren Datensatz beschreiben?",
"datafeeder.form.datepicker": "Wissen Sie, wann der Datensatz erstellt wurde?",
"datafeeder.form.description": "Beschreiben Sie abschließend den Prozess, der zur Erstellung des Datensatzes verwendet wurde",
Expand Down Expand Up @@ -76,6 +78,7 @@
"datafeeder.publishSuccess.geonetworkRecord": "Metadatensatz",
"datafeeder.publishSuccess.illustration.title": "Erledigt, alles ist gut!",
"datafeeder.publishSuccess.mapViewer": "Kartenviewer",
"datafeeder.publishSuccess.ogcFeature": "",
"datafeeder.publishSuccess.subtitle": "Zeigen Sie Ihre Daten an in:",
"datafeeder.publishSuccess.title": "Herzlichen Glückwunsch! \n Ihr Datensatz wurde veröffentlicht",
"datafeeder.publishSuccess.uploadAnotherData": "Ein weiteren Datensatz hochladen",
Expand Down Expand Up @@ -104,7 +107,6 @@
"datafeeder.upload.maxFileSize": "Maximale Dateigröße beträgt {size} MB",
"datafeeder.upload.title": "Laden Sie Ihren Datensatz hoch",
"datafeeder.upload.uploadButton": "Hochladen",
"datafeeder.validation.encoding": "Codierung",
"datafeeder.validation.csv.delimiter": "",
"datafeeder.validation.csv.delimiter.comma": "",
"datafeeder.validation.csv.delimiter.semicolon": "",
Expand All @@ -114,6 +116,7 @@
"datafeeder.validation.csv.quote.none": "",
"datafeeder.validation.csv.quote.simple": "",
"datafeeder.validation.csv.quoteChar": "",
"datafeeder.validation.encoding": "Codierung",
"datafeeder.validation.extent.title": "Hier ist der Datensatzumfang",
"datafeeder.validation.extent.title.unknown": "Das Projektionssystem ist unbekannt",
"datafeeder.validation.projection": "Raumbezugssystem:",
Expand Down Expand Up @@ -392,9 +395,11 @@
"search.filters.minimize": "Minimieren",
"search.filters.myRecords": "Nur meine Datensätze anzeigen",
"search.filters.myRecordsHelp": "Wenn dies aktiviert ist, werden nur von mir erstellte Datensätze angezeigt; Datensätze, die von anderen erstellt wurden, werden nicht angezeigt.",
"search.filters.organization": "",
"search.filters.otherRecords": "Datensätze von einer anderen Person anzeigen",
"search.filters.producerOrg": "",
"search.filters.publicationYear": "Veröffentlichungsjahr",
"search.filters.publisher": "Organisationen",
"search.filters.publisherOrg": "",
"search.filters.representationType": "Repräsentationstyp",
"search.filters.resourceType": "Ressourcentyp",
"search.filters.standard": "Standard",
Expand Down
8 changes: 5 additions & 3 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
"datafeeder.analysisProgressBar.subtitle": "The analysis may take several minutes, please wait.",
"datafeeder.analysisProgressBar.title": "Analyze in progress",
"datafeeder.datasetValidation.datasetInformation": "The provided dataset contains {number} entities",
"datafeeder.datasetValidationCsv.lineNumbers": "Sample of the first 5 lines* of the dataset:",
"datafeeder.datasetValidationCsv.explicitLineNumbers": "*The table must display the first 5 lines (excluding the header)<br>If this is not the case, check that the file is correctly formatted",
"datafeeder.datasetValidation.submitButton": "OK, my data are correct",
"datafeeder.datasetValidation.title": "Make sure your data are correct",
"datafeeder.datasetValidation.unknown": " - ",
"datafeeder.datasetValidationCsv.explicitLineNumbers": "*The table must display the first 5 lines (excluding the header)<br>If this is not the case, check that the file is correctly formatted",
"datafeeder.datasetValidationCsv.lineNumbers": "Sample of the first 5 lines* of the dataset:",
"datafeeder.form.abstract": "How would you describe your dataset?",
"datafeeder.form.datepicker": "Do you know when the dataset was created?",
"datafeeder.form.description": "Finally, please describe the process that was used to create the dataset",
Expand Down Expand Up @@ -395,9 +395,11 @@
"search.filters.minimize": "Minimize",
"search.filters.myRecords": "Show only my records",
"search.filters.myRecordsHelp": "When this is enabled, records only created by myself are shown; records created by others will not show up.",
"search.filters.organization": "Organization",
"search.filters.otherRecords": "Showing records from another person",
"search.filters.producerOrg": "Producer",
"search.filters.publicationYear": "Publication year",
"search.filters.publisher": "Organizations",
"search.filters.publisherOrg": "Publisher",
"search.filters.representationType": "Representation type",
"search.filters.resourceType": "Resource type",
"search.filters.standard": "Standard",
Expand Down
7 changes: 6 additions & 1 deletion translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"datafeeder.datasetValidation.submitButton": "",
"datafeeder.datasetValidation.title": "",
"datafeeder.datasetValidation.unknown": "",
"datafeeder.datasetValidationCsv.explicitLineNumbers": "",
"datafeeder.datasetValidationCsv.lineNumbers": "",
"datafeeder.form.abstract": "",
"datafeeder.form.datepicker": "",
"datafeeder.form.description": "",
Expand Down Expand Up @@ -76,6 +78,7 @@
"datafeeder.publishSuccess.geonetworkRecord": "",
"datafeeder.publishSuccess.illustration.title": "",
"datafeeder.publishSuccess.mapViewer": "",
"datafeeder.publishSuccess.ogcFeature": "",
"datafeeder.publishSuccess.subtitle": "",
"datafeeder.publishSuccess.title": "",
"datafeeder.publishSuccess.uploadAnotherData": "",
Expand Down Expand Up @@ -392,9 +395,11 @@
"search.filters.minimize": "",
"search.filters.myRecords": "",
"search.filters.myRecordsHelp": "",
"search.filters.organization": "",
"search.filters.otherRecords": "",
"search.filters.producerOrg": "",
"search.filters.publicationYear": "",
"search.filters.publisher": "",
"search.filters.publisherOrg": "",
"search.filters.representationType": "",
"search.filters.resourceType": "",
"search.filters.standard": "",
Expand Down
Loading
Loading