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

Collection Page Facets Filters #566

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7631791
chore: use js-dataverse pr version
g-saracca Dec 9, 2024
1c3e033
feat: move types query param to specific get collection items enum
g-saracca Dec 9, 2024
61371a1
chore: update to new pr js-dataverse version
g-saracca Dec 9, 2024
4770017
feat: types, retrieve facets etc
g-saracca Dec 10, 2024
e1a4275
chore: update js-dataverse version
g-saracca Dec 10, 2024
c6d4f3c
feat: filtering by queries working
g-saracca Dec 10, 2024
01b3a9c
feat: seleceted facets functionality
g-saracca Dec 10, 2024
032a428
feat: improve facet group list styles
g-saracca Dec 10, 2024
52a58d3
fix: encode url facet value before setting the search params
g-saracca Dec 10, 2024
1b1ba36
feat: disable buttons while loading items
g-saracca Dec 10, 2024
2612231
feat: text align left
g-saracca Dec 11, 2024
f028bba
feat: improve list layout
g-saracca Dec 11, 2024
8c19993
feat: show diff message when filter queries applied
g-saracca Dec 11, 2024
c1f4968
feat: remove underline in less and more buttons
g-saracca Dec 11, 2024
0bc201e
feat: facet filers skeleton
g-saracca Dec 11, 2024
452c68d
feat: add locales
g-saracca Dec 11, 2024
bf2a863
feat: udpate js-dataverse and update search criteria
g-saracca Dec 12, 2024
75c6664
feat: revert noItemsMessage
g-saracca Dec 12, 2024
b819c09
feat: add stories
g-saracca Dec 12, 2024
b98a78e
fix: accesibility issues
g-saracca Dec 12, 2024
23f36bc
test: fix and add tests
g-saracca Dec 12, 2024
3089539
test: finish with unit tests
g-saracca Dec 12, 2024
a13a2c9
test: finish with e2e test
g-saracca Dec 12, 2024
e029c43
chore: file alocations tweaks
g-saracca Dec 12, 2024
50a4133
feat: add missing args
g-saracca Dec 12, 2024
b1c639c
feat: move query into collection query params
g-saracca Dec 16, 2024
d170bc8
Merge branch 'develop' into feat/562-add-collection-facets
g-saracca Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@faker-js/faker": "7.6.0",
"@iqss/dataverse-client-javascript": "2.0.0-alpha.6",
"@iqss/dataverse-client-javascript": "2.0.0-pr230.3a26dc9",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/en/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"error": "There was an error publishing your collection."
},
"publishedAlert": "Your collection is now public.",
"addFacetFilter": "Add {{labelName}} facet filter",
"removeSelectedFacet": "Remove {{labelName}} facet filter",
"editedAlert": "You have successfully updated your collection!",
"editCollection": {
"edit": "Edit",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/en/shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"add": "Add",
"cancel": "Cancel",
"continue": "Continue",
"more": "More...",
"less": "Less...",
"pageNumberNotFound": {
"heading": "Page Number Not Found",
"message": "The page number you requested does not exist. Please try a different page number."
Expand Down
12 changes: 12 additions & 0 deletions src/collection/domain/models/CollectionItemSubset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ import { FileItemTypePreview } from '../../../files/domain/models/FileItemTypePr

export interface CollectionItemSubset {
items: CollectionItem[]
facets: CollectionItemsFacet[]
totalItemCount: number
}

export type CollectionItem =
| CollectionItemTypePreview
| DatasetItemTypePreview
| FileItemTypePreview

export interface CollectionItemsFacet {
name: string
friendlyName: string
labels: CollectionItemsFacetLabel[]
}

interface CollectionItemsFacetLabel {
name: string
count: number
}
8 changes: 8 additions & 0 deletions src/collection/domain/models/CollectionItemsQueryParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export enum CollectionItemsQueryParams {
SORT = 'sort',
ORDER = 'order',
START = 'start',
TYPES = 'types',
QUERY = 'q',
FILTER_QUERIES = 'fqs'
}
77 changes: 77 additions & 0 deletions src/collection/domain/models/CollectionSearchCriteria.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { type CollectionItemType } from './CollectionItemType'

export enum SortType {
NAME = 'name',
DATE = 'date'
}

export enum OrderType {
ASC = 'asc',
DESC = 'desc'
}

export type FilterQuery = `${string}:${string}`

export class CollectionSearchCriteria {
constructor(
public readonly searchText?: string,
public readonly itemTypes?: CollectionItemType[],
public readonly sort?: SortType,
public readonly order?: OrderType,
public readonly filterQueries?: FilterQuery[]
) {}

withSearchText(searchText: string | undefined): CollectionSearchCriteria {
return new CollectionSearchCriteria(
searchText,
this.itemTypes,
this.sort,
this.order,
this.filterQueries
)
}

withItemTypes(itemTypes: CollectionItemType[] | undefined): CollectionSearchCriteria {
return new CollectionSearchCriteria(
this.searchText,
itemTypes,
this.sort,
this.order,
this.filterQueries
)
}

withSort(sort: SortType | undefined): CollectionSearchCriteria {
return new CollectionSearchCriteria(
this.searchText,
this.itemTypes,
sort,
this.order,
this.filterQueries
)
}

withOrder(order: OrderType | undefined): CollectionSearchCriteria {
return new CollectionSearchCriteria(
this.searchText,
this.itemTypes,
this.sort,
order,
this.filterQueries
)
}

withFilterQueries(filterQueries: FilterQuery[] | undefined): CollectionSearchCriteria {
return new CollectionSearchCriteria(
this.searchText,
this.itemTypes,
this.sort,
this.order,
filterQueries
)
}

hasSearchText(): boolean {
return !!this.searchText
}
}
20 changes: 0 additions & 20 deletions src/collection/domain/models/CollectionSearchCriteria.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class CollectionJSDataverseRepository implements CollectionRepository {

return {
items: collectionItemsPreviewsMapped,
facets: jsCollectionItemSubset.facets,
totalItemCount: jsCollectionItemSubset.totalItemCount
}
})
Expand Down
2 changes: 0 additions & 2 deletions src/sections/Route.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export const RouteWithParams = {
export enum QueryParamKey {
VERSION = 'version',
PERSISTENT_ID = 'persistentId',
QUERY = 'q',
COLLECTION_ITEM_TYPES = 'types',
g-saracca marked this conversation as resolved.
Show resolved Hide resolved
PAGE = 'page',
COLLECTION_ID = 'collectionId'
}
22 changes: 16 additions & 6 deletions src/sections/collection/CollectionHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Collection } from '@/collection/domain/models/Collection'
import { CollectionItemsQueryParams } from '@/collection/domain/models/CollectionItemsQueryParams'
import { FilterQuery } from '@/collection/domain/models/CollectionSearchCriteria'
import { CollectionItemType } from '@/collection/domain/models/CollectionItemType'
import { QueryParamKey } from '../Route.enum'
import { Collection } from '@/collection/domain/models/Collection'
import { UpwardHierarchyNode } from '@/shared/hierarchy/domain/models/UpwardHierarchyNode'

export class CollectionHelper {
Expand All @@ -9,11 +10,11 @@ export class CollectionHelper {
? parseInt(searchParams.get('page') as string, 10)
: 1

const searchQuery = searchParams.get(QueryParamKey.QUERY)
? decodeURIComponent(searchParams.get(QueryParamKey.QUERY) as string)
const searchQuery = searchParams.get(CollectionItemsQueryParams.QUERY)
? decodeURIComponent(searchParams.get(CollectionItemsQueryParams.QUERY) as string)
: undefined

const typesParam = searchParams.get(QueryParamKey.COLLECTION_ITEM_TYPES) ?? undefined
const typesParam = searchParams.get(CollectionItemsQueryParams.TYPES) ?? undefined

const typesQuery = typesParam
?.split(',')
Expand All @@ -22,7 +23,16 @@ export class CollectionHelper {
Object.values(CollectionItemType).includes(type as CollectionItemType)
) as CollectionItemType[]

return { pageQuery, searchQuery, typesQuery }
const filtersParam = searchParams.get(CollectionItemsQueryParams.FILTER_QUERIES) ?? undefined

const filtersQuery: FilterQuery[] | undefined = filtersParam
? (filtersParam
?.split(',')
.map((filterQuery) => decodeURIComponent(filterQuery))
.filter((decodedFilter) => /^[^:]+:[^:]+$/.test(decodedFilter)) as FilterQuery[])
: undefined

return { pageQuery, searchQuery, typesQuery, filtersQuery }
}

static isRootCollection(collectionHierarchy: Collection['hierarchy']) {
Expand Down
Loading
Loading