Skip to content

Commit

Permalink
deposit form: add fieldPath prop to field components
Browse files Browse the repository at this point in the history
Now explicitly adds the fieldPath prop to field components to move away from relying on defaultProps values.
related to inveniosoftware/react-invenio-deposit#551
  • Loading branch information
nico authored and zzacharo committed Aug 9, 2022
1 parent 4167d0b commit aefea33
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,16 @@ export class RDMDepositForm extends Component {

<ResourceTypeField
options={this.vocabularies.metadata.resource_type}
fieldPath="metadata.resource_type"
required
/>
<TitlesField
options={this.vocabularies.metadata.titles}
fieldPath="metadata.title"
recordUI={record.ui}
required
/>
<PublicationDateField required />
<PublicationDateField required fieldPath="metadata.publication_date" />
<CreatibutorsField
label={i18next.t("Creators")}
labelIcon="user"
Expand All @@ -183,6 +185,7 @@ export class RDMDepositForm extends Component {
required
/>
<DescriptionsField
fieldPath="metadata.description"
options={this.vocabularies.metadata.descriptions}
recordUI={_get(record, "ui", null)}
editorConfig={{
Expand Down Expand Up @@ -251,11 +254,13 @@ export class RDMDepositForm extends Component {
}}
/>
<SubjectsField
fieldPath="metadata.subjects"
initialOptions={_get(record, "ui.subjects", null)}
limitToOptions={this.vocabularies.metadata.subjects.limit_to}
/>

<LanguagesField
fieldPath="metadata.languages"
initialOptions={_get(record, "ui.languages", []).filter(
(lang) => lang !== null
)} // needed because dumped empty record from backend gives [null]
Expand All @@ -267,9 +272,12 @@ export class RDMDepositForm extends Component {
}))
}
/>
<DatesField options={this.vocabularies.metadata.dates} />
<VersionField />
<PublisherField />
<DatesField
fieldPath="metadata.dates"
options={this.vocabularies.metadata.dates}
/>
<VersionField fieldPath="metadata.version" />
<PublisherField fieldPath="metadata.publisher" />
</AccordionField>

<AccordionField
Expand Down Expand Up @@ -371,7 +379,10 @@ export class RDMDepositForm extends Component {
active
label={i18next.t("Related works")}
>
<RelatedWorksField options={this.vocabularies.metadata.identifiers} />
<RelatedWorksField
fieldPath="metadata.related_identifiers"
options={this.vocabularies.metadata.identifiers}
/>
</AccordionField>
{!_isEmpty(this.config.custom_fields.ui) && (
<CustomFields config={this.config.custom_fields.ui} />
Expand Down Expand Up @@ -417,6 +428,7 @@ export class RDMDepositForm extends Component {
<AccessRightField
label={i18next.t("Visibility")}
labelIcon="shield"
fieldPath="access"
/>
{permissions?.can_delete_draft && (
<Card>
Expand Down

0 comments on commit aefea33

Please sign in to comment.