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

Metadata fields section on create collection page #451

Merged
merged 54 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ade8508
chore: remove comment
g-saracca Jul 26, 2024
e9a9755
feat: initial work, use fields from root functionality
g-saracca Jul 26, 2024
b8f98f1
feat: files refactor, reset values functionality
g-saracca Jul 26, 2024
8edc586
feat: move constants to collection form
g-saracca Jul 26, 2024
1f2bde1
chore: update latest version of js-dataverse
g-saracca Jul 26, 2024
039ccc5
feat: add inputLevels to mapper
g-saracca Jul 26, 2024
8729e1d
feat: dynamic root text
g-saracca Jul 26, 2024
8c0834d
feat: get block names configured on the collection
g-saracca Jul 26, 2024
a99c265
feat: remove disabled from fields
g-saracca Jul 29, 2024
1629a4a
feat: temporal use case
g-saracca Jul 29, 2024
c6c1d8c
feat: more work
g-saracca Jul 30, 2024
ce235f9
feat(design system): allow bordered prop
g-saracca Jul 30, 2024
68c858c
feat: new data mappers
g-saracca Jul 30, 2024
3dc04f8
feat: correctly defined base inputLevels
g-saracca Jul 30, 2024
3b07a60
feat: clean up, refactor all blocks fetching
g-saracca Jul 30, 2024
129acda
feat: hidden readonly radio if parent chexbox is not checked
g-saracca Jul 31, 2024
031904e
feat: disabled table input level fields
g-saracca Jul 31, 2024
d635324
feat: required by dataverse fields
g-saracca Jul 31, 2024
5209f64
feat: back to default inputLevels and block names values when checkin…
g-saracca Jul 31, 2024
779527b
refactor: move DynamicFieldsButtons component to shared folder
g-saracca Jul 31, 2024
c934154
chore: remove todos
g-saracca Jul 31, 2024
c4e64db
feat: remove inputLevels from not selected blocks
g-saracca Jul 31, 2024
6634a77
feat: merge input levels for default values
g-saracca Aug 1, 2024
02dd1ac
feat: if field is not included, back to optional
g-saracca Aug 1, 2024
7a612f0
feat: change input levels table disable status
g-saracca Aug 1, 2024
efa4e86
feat: make composed parent field required if all sub fields are required
g-saracca Aug 1, 2024
7734cb3
Merge branch 'develop' into 444-metadata-fields-section-create-collec…
g-saracca Aug 2, 2024
2427fb7
chore: update js-dv version
g-saracca Aug 2, 2024
5a0e2e1
feat: refactor temporal get all blocks info
g-saracca Aug 2, 2024
bacd125
feat: update mock repositories and stories
g-saracca Aug 2, 2024
a7b4a47
feat: add necessary things for tests to not break
g-saracca Aug 2, 2024
90c08f7
feat: make required by dataverse fields required by default and dont …
g-saracca Aug 2, 2024
5bd24f6
feat: back to disable button
g-saracca Aug 2, 2024
72f8715
feat: rename component
g-saracca Aug 5, 2024
14b79c3
feat: use locale
g-saracca Aug 5, 2024
66a18db
chore: use docker compose v2
g-saracca Aug 5, 2024
1cb0b77
feat: required by dataverse by isRequired property
g-saracca Aug 5, 2024
97173ca
feat: make parent required if at least one subfield becomes required
g-saracca Aug 5, 2024
8b51c8e
fix: use controlId only if not custom select
g-saracca Aug 5, 2024
7aa2698
test: Collection form tests
g-saracca Aug 5, 2024
4a201fd
test: helper tests
g-saracca Aug 5, 2024
9c0e476
Merge branch 'develop' into 444-metadata-fields-section-create-collec…
g-saracca Aug 6, 2024
39e098a
feat: add locales
g-saracca Aug 6, 2024
9da36b4
feat: improve AlertProvider tests
g-saracca Aug 6, 2024
8f4769f
fix: avoid boostrap warning
g-saracca Aug 6, 2024
0246bea
feat: add more tests
g-saracca Aug 6, 2024
c4db090
chore: use ghcr dataverse image tag
g-saracca Aug 6, 2024
aea2fa6
feat: disable and set to optional a conditionally required field
g-saracca Aug 6, 2024
35a5b5d
chore: update pull request template to match js-dataverse repo
g-saracca Aug 6, 2024
9648e46
feat: change loading name and back test.yml as original
g-saracca Aug 7, 2024
9424690
fix typo
g-saracca Aug 9, 2024
a7aa7be
test: match collection model response
g-saracca Aug 9, 2024
9abeed4
chore: update to latest version of js-dv and change registry
g-saracca Aug 19, 2024
f33b875
comment out js outdated file upload use case
g-saracca Aug 19, 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
16 changes: 8 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
**What this PR does / why we need it**:
## What this PR does / why we need it:

**Which issue(s) this PR closes**:
## Which issue(s) this PR closes:

Closes #
- Closes #

**Special notes for your reviewer**:
## Special notes for your reviewer:

**Suggestions on how to test this**:
## Suggestions on how to test this:

**Does this PR introduce a user interface change? If mockups are available, please link/include them here**:
## Does this PR introduce a user interface change? If mockups are available, please link/include them here:

**Is there a release notes update needed for this change?**:
## Is there a release notes update needed for this change?:

**Additional documentation**:
## Additional documentation:
2 changes: 1 addition & 1 deletion dev-env/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
POSTGRES_VERSION=13
DATAVERSE_DB_USER=dataverse
SOLR_VERSION=9.3.0
REGISTRY=docker.io
REGISTRY=ghcr.io
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-pr155.be01a3f",
"@iqss/dataverse-client-javascript": "2.0.0-pr169.5c26a1e",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand Down
1 change: 1 addition & 0 deletions packages/design-system/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
- **FormTextArea:** extend Props Interface to accept `autoFocus` prop.
- **FormSelect:** extend Props Interface to accept `autoFocus` prop.
- **Stack:** NEW Stack element to manage layouts.
- **Table:** extend Props Interface to accept `bordered` prop to add or remove borders on all sides of the table and cells. Defaults to true.

# [1.1.0](https://github.com/IQSS/dataverse-frontend/compare/@iqss/dataverse-design-system@1.0.1...@iqss/dataverse-design-system@1.1.0) (2024-03-12)

Expand Down
10 changes: 7 additions & 3 deletions packages/design-system/src/lib/components/table/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { PropsWithChildren } from 'react'
import { Table as TableBS } from 'react-bootstrap'
import styles from './Table.module.scss'

export function Table({ children }: PropsWithChildren) {
interface TableProps {
bordered?: boolean
children: React.ReactNode
}

export function Table({ bordered = true, children }: TableProps) {
return (
<TableBS striped bordered className={styles.table}>
<TableBS striped bordered={bordered} className={styles.table}>
{children}
</TableBS>
)
Expand Down
25 changes: 23 additions & 2 deletions public/locales/en/createCollection.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,35 @@
"invalid": "Email is not a valid email"
},
"metadataFields": {
"label": "Metadata Fields",
"helperText": "Choose the metadata fields to use in dataset templates and when adding a dataset to this dataverse."
"sectionLabel": "Metadata Fields",
"helperText": "Choose the metadata fields to use in dataset templates and when adding a dataset to this dataverse.",
"useMetadataFieldsFrom": "Use metadata fields from",
"citationMetadata": "Citation Metadata (Required)",
"geospatialMetadata": "Geospatial Metadata",
"socialScienceMetadata": "Social Science and Humanities Metadata",
"astrophysicsMetadata": "Astronomy and Astrophysics Metadata",
"biomedicalMetadata": "Life Sciences Metadata",
"journalMetadata": "Journal Metadata",
"inputLevelsTable": {
"hideTableAriaLabel": "Hide input levels table",
"requiredByDataverse": "Required by Dataverse",
"hidden": "Hidden",
"optional": "Optional",
"required": "Required",
"conditionallyRequired": "Conditionally Required"
}
},
"browseSearchFacets": {
"label": "Browse/Search Facets",
"helperText": "Choose the metadata fields to use as facets for browsing datasets and dataverses in this dataverse."
}
},
"confirmResetModal": {
"title": "Reset Modifications",
"warning": "Are you sure you want to reset the selected metadata fields? If you do this, any customizations (hidden, required, optional) you have done will no longer appear.",
"continue": "Continue",
"cancel": "Cancel"
},
"submitStatus": {
"success": "Collection created successfully."
},
Expand Down
2 changes: 0 additions & 2 deletions public/locales/en/datasetMetadataForm.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
"submitting": "Form Submitting",
"submissionSuccess": "Form submission successful"
},
"addRowButton": "Add",
"deleteRowButton": "Delete",
"saveButton": {
"createMode": "Save Dataset",
"editMode": "Save Changes"
Expand Down
4 changes: 3 additions & 1 deletion public/locales/en/shared.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"asterisksIndicateRequiredFields": "Asterisks indicate required fields"
"asterisksIndicateRequiredFields": "Asterisks indicate required fields",
"remove": "Remove",
"add": "Add"
}
7 changes: 7 additions & 0 deletions src/collection/domain/models/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ export interface Collection {
isReleased: boolean
description?: string
affiliation?: string
inputLevels?: CollectionInputLevel[]
}

export interface CollectionInputLevel {
datasetFieldName: string
include: boolean
required: boolean
}
11 changes: 11 additions & 0 deletions src/collection/domain/useCases/DTOs/CollectionDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ export interface CollectionDTO {
name: string
contacts: string[]
type: CollectionType
affiliation?: string
description?: string
metadataBlockNames?: string[]
facetIds?: string[]
inputLevels?: CollectionInputLevelDTO[]
}

export enum CollectionType {
Expand All @@ -17,6 +22,12 @@ export enum CollectionType {
DEPARTMENT = 'DEPARTMENT'
}

export interface CollectionInputLevelDTO {
datasetFieldName: string
include: boolean
required: boolean
}

export const collectionTypeOptions = {
RESEARCHERS: {
label: 'Researchers',
Expand Down
3 changes: 2 additions & 1 deletion src/collection/infrastructure/mappers/JSCollectionMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export class JSCollectionMapper {
jsCollection.name,
jsCollection.alias,
jsCollection.isPartOf
)
),
inputLevels: jsCollection.inputLevels
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/metadata-block-info/domain/models/MetadataBlockInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ export interface MetadataBlockInfo {
displayOnCreate: boolean
}

export enum MetadataBlockName {
CITATION = 'citation',
GEOSPATIAL = 'geospatial',
ASTROPHYSICS = 'astrophysics',
BIOMEDICAL = 'biomedical',
CODE_META = 'codeMeta20',
COMPUTATIONAL_WORKFLOW = 'computationalworkflow',
JOURNAL = 'journal',
SOCIAL_SCIENCE = 'socialscience'
}

export interface MetadataBlockInfoWithMaybeValues extends MetadataBlockInfo {
metadataFields: Record<string, MetadataFieldWithMaybeValue>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { MetadataBlockInfoDisplayFormat, MetadataBlockInfo } from '../models/Met

export interface MetadataBlockInfoRepository {
getByName: (name: string) => Promise<MetadataBlockInfoDisplayFormat | undefined>
getAllTemporal: (names: string[]) => Promise<MetadataBlockInfo[]>
getDisplayedOnCreateByCollectionId: (
collectionId: number | string
) => Promise<MetadataBlockInfo[]>
getByColecctionId: (collectionId: number | string) => Promise<MetadataBlockInfo[]>
getByCollectionId: (collectionId: number | string) => Promise<MetadataBlockInfo[]>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { MetadataBlockInfoRepository } from '../repositories/MetadataBlockInfoRepository'
import { MetadataBlockInfo } from '../models/MetadataBlockInfo'

export async function getAllMetadataBlocksInfoTemporal(
metadataBlockInfoRepository: MetadataBlockInfoRepository,
names: string[]
): Promise<MetadataBlockInfo[]> {
return metadataBlockInfoRepository.getAllTemporal(names).catch((error: Error) => {
throw new Error(error.message)
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function getMetadataBlockInfoByCollectionId(
metadataBlockInfoRepository: MetadataBlockInfoRepository,
collectionId: number | string
): Promise<MetadataBlockInfo[]> {
return metadataBlockInfoRepository.getByColecctionId(collectionId).catch((error: Error) => {
return metadataBlockInfoRepository.getByCollectionId(collectionId).catch((error: Error) => {
throw new Error(error.message)
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ export class MetadataBlockInfoJSDataverseRepository implements MetadataBlockInfo
})
}

getByColecctionId(collectionIdOrAlias: number | string): Promise<MetadataBlockInfo[]> {
// TODO: This will be replaced to a new use case that will return all metadata blocks info
getAllTemporal(names: string[]): Promise<MetadataBlockInfo[]> {
const blockPromises = names.map((name) => getMetadataBlockByName.execute(name))

return Promise.all(blockPromises)
.then((jsMetadataBlockInfo: JSMetadataBlockInfo[]) => {
return jsMetadataBlockInfo
})
.catch((error: ReadError) => {
throw new Error(error.message)
})
}

getByCollectionId(collectionIdOrAlias: number | string): Promise<MetadataBlockInfo[]> {
return getCollectionMetadataBlocks
.execute(collectionIdOrAlias)
.then((metadataBlocks: MetadataBlockInfo[]) => {
Expand Down
Loading
Loading