Skip to content

Commit

Permalink
Merge pull request #451 from IQSS/444-metadata-fields-section-create-…
Browse files Browse the repository at this point in the history
…collection

Metadata fields section on create collection page
  • Loading branch information
GPortas authored Aug 19, 2024
2 parents 393e926 + f33b875 commit 7bc5d41
Show file tree
Hide file tree
Showing 62 changed files with 5,944 additions and 172 deletions.
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=docker.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.aa49f06",
"@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/[email protected]...@iqss/[email protected]) (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
4 changes: 2 additions & 2 deletions src/files/infrastructure/FileJSDataverseRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
getFileDownloadCount,
getFileUserPermissions,
uploadFile as jsUploadFile,
addUploadedFileToDataset,
ReadError
} from '@iqss/dataverse-client-javascript'
import { FileCriteria } from '../domain/models/FileCriteria'
Expand Down Expand Up @@ -307,6 +306,7 @@ export class FileJSDataverseRepository implements FileRepository {
}

addUploadedFile(datasetId: number | string, file: FileHolder, storageId: string): Promise<void> {

Check warning on line 308 in src/files/infrastructure/FileJSDataverseRepository.ts

View workflow job for this annotation

GitHub Actions / lint

'datasetId' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 308 in src/files/infrastructure/FileJSDataverseRepository.ts

View workflow job for this annotation

GitHub Actions / lint

'file' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 308 in src/files/infrastructure/FileJSDataverseRepository.ts

View workflow job for this annotation

GitHub Actions / lint

'storageId' is defined but never used. Allowed unused args must match /^_/u
return addUploadedFileToDataset.execute(datasetId, file.file, storageId)
return new Promise<void>(() => {})
// return addUploadedFilesToDataset.execute(datasetId, file.file)
}
}
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

0 comments on commit 7bc5d41

Please sign in to comment.