-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(metadata): create an isolated component
- Loading branch information
1 parent
fd574e1
commit 986083a
Showing
11 changed files
with
116 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,6 @@ | |
} | ||
}, | ||
"volta": { | ||
"node": "18.18.2" | ||
"node": "18.20.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,7 @@ | |
"vitest": "^2.1.2" | ||
}, | ||
"volta": { | ||
"node": "18.18.2", | ||
"npm": "10.2.0" | ||
"node": "18.20.4", | ||
"npm": "10.9.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
import Form from "../Form.jsx"; | ||
import { convertLegacyValues } from "./MetadataValues.js"; | ||
|
||
/** | ||
* @param data Values in JSON format | ||
* @param templates List of template names | ||
* @param onChange Function that return the values in YAML format | ||
* @returns {Element} | ||
* @constructor | ||
*/ | ||
export default function MetadataForm({ data, templates, onChange }) { | ||
const formData = convertLegacyValues(data) | ||
const basicMode = templates.includes('basic') | ||
return <Form formData={formData} basicMode={basicMode} onChange={onChange}/> | ||
} | ||
|
||
MetadataForm.propTypes = { | ||
data: PropTypes.object, | ||
templates: PropTypes.array, | ||
onChange: PropTypes.func, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Convert legacy values. | ||
* @param {object} data | ||
* @returns {*} | ||
*/ | ||
export function convertLegacyValues(data) { | ||
// we convert YYYY/MM/DD dates into ISO YYYY-MM-DD | ||
if (data.date) { | ||
data.date = data.date.replace(/\//g, '-') | ||
} | ||
|
||
// we array-ify legacy string keywords | ||
if (data.keywords) { | ||
data.keywords = data.keywords.map(block => { | ||
if (typeof block.list_f === 'string') { | ||
block.list_f = block.list_f.split(',').map(word => word.trim()) | ||
} | ||
return block | ||
}) | ||
} | ||
|
||
return data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://stylo.huma-num.fr/schemas/corpus-journal-metadata.schema.json", | ||
"title": "Journal metadata", | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"type": "string", | ||
"const": "journal" | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"issue": { | ||
"type": "object", | ||
"properties": { | ||
"title": { | ||
"type": "string" | ||
}, | ||
"identifier": { | ||
"type": "string" | ||
}, | ||
"number": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ | |
"dotenv": "^16.0.3" | ||
}, | ||
"volta": { | ||
"node": "18.18.2", | ||
"npm": "10.2.0" | ||
"node": "18.20.4", | ||
"npm": "10.9.0" | ||
} | ||
} |