diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/CreatibutorsField/CreatibutorsModal.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/CreatibutorsField/CreatibutorsModal.js index d45cd011b..8d74f1d62 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/CreatibutorsField/CreatibutorsModal.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/CreatibutorsField/CreatibutorsModal.js @@ -16,17 +16,18 @@ import _map from "lodash/map"; import PropTypes from "prop-types"; import React, { Component, createRef } from "react"; import { + AffiliationsSuggestions, RadioField, RemoteSelectField, SelectField, TextField, - AffiliationsSuggestions, } from "react-invenio-forms"; import { Button, Form, Modal } from "semantic-ui-react"; import * as Yup from "yup"; import { AffiliationsField } from "./../AffiliationsField"; import { CreatibutorsIdentifiers } from "./CreatibutorsIdentifiers"; import { CREATIBUTOR_TYPE } from "./type"; +import Overridable from "react-overridable"; const ModalActions = { ADD: "add", @@ -77,27 +78,6 @@ export class CreatibutorsModal extends Component { }); } - CreatorSchema = Yup.object({ - person_or_org: Yup.object({ - type: Yup.string(), - family_name: Yup.string().when("type", (type, schema) => { - if (type === CREATIBUTOR_TYPE.PERSON && this.isCreator()) { - return schema.required(i18next.t("Family name is a required field.")); - } - }), - name: Yup.string().when("type", (type, schema) => { - if (type === CREATIBUTOR_TYPE.ORGANIZATION && this.isCreator()) { - return schema.required(i18next.t("Name is a required field.")); - } - }), - }), - role: Yup.string().when("_", (_, schema) => { - if (!this.isCreator()) { - return schema.required(i18next.t("Role is a required field.")); - } - }), - }); - openModal = () => { this.setState({ open: true, action: null }, () => { const { initialCreatibutor } = this.props; @@ -211,6 +191,27 @@ export class CreatibutorsModal extends Component { return schema === "creators"; }; + CreatorSchema = Yup.object({ + person_or_org: Yup.object({ + type: Yup.string(), + family_name: Yup.string().when("type", (type, schema) => { + if (type === CREATIBUTOR_TYPE.PERSON && this.isCreator()) { + return schema.required(i18next.t("Family name is a required field.")); + } + }), + name: Yup.string().when("type", (type, schema) => { + if (type === CREATIBUTOR_TYPE.ORGANIZATION && this.isCreator()) { + return schema.required(i18next.t("Name is a required field.")); + } + }), + }), + role: Yup.string().when("_", (_, schema) => { + if (!this.isCreator()) { + return schema.required(i18next.t("Role is a required field.")); + } + }), + }); + onSubmit = (values, formikBag) => { const { onCreatibutorChange } = this.props; const { action } = this.state; @@ -580,7 +581,8 @@ export class CreatibutorsModal extends Component { {(_get(values, typeFieldPath) === CREATIBUTOR_TYPE.ORGANIZATION || (showPersonForm && _get(values, typeFieldPath) === CREATIBUTOR_TYPE.PERSON)) && ( - + > + + )}