From 7879e4b19bf6d2cff40b6fc2f38e97f89b830ebc Mon Sep 17 00:00:00 2001 From: Ryan Shaw Date: Fri, 13 Sep 2024 14:57:42 -0400 Subject: [PATCH 1/2] convert yearPublished to string before trimming yearPublished may be a number in some cases, e.g. Heritage Data --- modules/periodo-app/src/forms/AuthorityForm/NonLDSourceForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/periodo-app/src/forms/AuthorityForm/NonLDSourceForm.js b/modules/periodo-app/src/forms/AuthorityForm/NonLDSourceForm.js index 6aa49d37..6dbd4eea 100644 --- a/modules/periodo-app/src/forms/AuthorityForm/NonLDSourceForm.js +++ b/modules/periodo-app/src/forms/AuthorityForm/NonLDSourceForm.js @@ -75,7 +75,7 @@ A full citation is encouraged, but a title alone is sufficient.`, my: 3, name: 'yearPublished', label: 'Year published', - value: (value.yearPublished || '').trim(), + value: (value.yearPublished || '').toString().trim(), onChange: this.handleChange, }), From 8abee29641f93055d59fc41b31289a291d10fbad Mon Sep 17 00:00:00 2001 From: Ryan Shaw Date: Fri, 13 Sep 2024 14:59:06 -0400 Subject: [PATCH 2/2] properly display but do not change or remove sameAs property when editing authorities --- .../periodo-app/src/forms/AuthorityForm/NonLDSourceForm.js | 4 ++-- modules/periodo-app/src/forms/AuthorityForm/index.js | 2 ++ modules/periodo-app/src/forms/validate.js | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/periodo-app/src/forms/AuthorityForm/NonLDSourceForm.js b/modules/periodo-app/src/forms/AuthorityForm/NonLDSourceForm.js index 6dbd4eea..c8601f31 100644 --- a/modules/periodo-app/src/forms/AuthorityForm/NonLDSourceForm.js +++ b/modules/periodo-app/src/forms/AuthorityForm/NonLDSourceForm.js @@ -29,7 +29,7 @@ module.exports = RandomID(class NonLDSourceForm extends React.Component { } render() { - const { onValueChange } = this.props + const { onValueChange, sameAs } = this.props , value = this.props.value || {} @@ -67,7 +67,7 @@ A full citation is encouraged, but a title alone is sufficient.`, my: 3, name: 'sameAs', label: 'Same as (read-only)', - value: value.sameAs || '', + value: sameAs || '', disabled: true, }), diff --git a/modules/periodo-app/src/forms/AuthorityForm/index.js b/modules/periodo-app/src/forms/AuthorityForm/index.js index ae34a1b7..6e7e300f 100644 --- a/modules/periodo-app/src/forms/AuthorityForm/index.js +++ b/modules/periodo-app/src/forms/AuthorityForm/index.js @@ -13,6 +13,7 @@ const h = require('react-hyperscript') const lenses = { source: R.lensProp('source'), + sameAs: R.lensProp('sameAs'), locator: R.lensPath([ 'source', 'locator' ]), editorialNote: R.lensProp('editorialNote'), } @@ -49,6 +50,7 @@ module.exports = Validated( const formProps = { value: get(lenses.source), onValueChange: value => set(lenses.source, value), + sameAs: get(lenses.sameAs), } return ( diff --git a/modules/periodo-app/src/forms/validate.js b/modules/periodo-app/src/forms/validate.js index d3fd293b..7c5f0915 100644 --- a/modules/periodo-app/src/forms/validate.js +++ b/modules/periodo-app/src/forms/validate.js @@ -18,6 +18,7 @@ const VALID_AUTHORITY_FIELDS = [ 'source', 'periods', 'editorialNote', + 'sameAs', ] const VALID_AUTHORITY_SOURCE_AGENT_FIELDS = [