diff --git a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/AuthorityFixedField.js b/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/AuthorityFixedField.js deleted file mode 100644 index 4c6153bc..00000000 --- a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/AuthorityFixedField.js +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import { - BytesField, -} from '../BytesField'; - -const AuthorityFixedField = ({ name, config }) => { - return ( - - ); -}; - -AuthorityFixedField.propTypes = { - name: PropTypes.string.isRequired, - config: PropTypes.object.isRequired, -}; - -AuthorityFixedField.displayName = 'AuthorityFixedField'; - -export default AuthorityFixedField; diff --git a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/BibliographicFixedField.js b/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/BibliographicFixedField.js deleted file mode 100644 index ef9227fe..00000000 --- a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/BibliographicFixedField.js +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import { - BytesField, -} from '../BytesField'; - -const BibliographicFixedField = ({ name, config }) => { - return ( - - ); -}; - -BibliographicFixedField.propTypes = { - name: PropTypes.string.isRequired, - config: PropTypes.object.isRequired, -}; - -BibliographicFixedField.displayName = 'BibliographicFixedField'; - -export default BibliographicFixedField; diff --git a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/HoldingsFixedField.js b/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedField.js similarity index 61% rename from src/QuickMarcEditor/QuickMarcEditorRows/FixedField/HoldingsFixedField.js rename to src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedField.js index 3762d560..4b610da7 100644 --- a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/HoldingsFixedField.js +++ b/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedField.js @@ -5,7 +5,7 @@ import { BytesField, } from '../BytesField'; -const HoldingsFixedField = ({ name, config }) => { +const FixedField = ({ name, config }) => { return ( { ); }; -HoldingsFixedField.propTypes = { +FixedField.propTypes = { name: PropTypes.string.isRequired, config: PropTypes.object.isRequired, }; -HoldingsFixedField.displayName = 'HoldingsFixedField'; - -export default HoldingsFixedField; +export default FixedField; diff --git a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedFieldFactory.js b/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedFieldFactory.js index c747685f..67ad1e32 100644 --- a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedFieldFactory.js +++ b/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedFieldFactory.js @@ -1,35 +1,13 @@ import React from 'react'; -import { MARC_TYPES } from '../../../common/constants'; import { LEADER_TAG } from '../../constants'; import { SUBFIELD_TYPES, } from '../BytesField'; -import HoldingsFixedField from './HoldingsFixedField'; -import AuthorityFixedField from './AuthorityFixedField'; -import BibliographicFixedField from './BibliographicFixedField'; +import FixedField from './FixedField'; export const FixedFieldFactory = { - getFixedFieldByType(marcType) { - let FixedField; - - switch (marcType) { - case MARC_TYPES.HOLDINGS: - FixedField = HoldingsFixedField; - break; - case MARC_TYPES.AUTHORITY: - FixedField = AuthorityFixedField; - break; - case MARC_TYPES.BIB: - FixedField = BibliographicFixedField; - break; - default: - FixedField = null; - } - - return FixedField; - }, getFixedFieldType(fixedFieldSpec, type, subtype) { if (!fixedFieldSpec?.spec) { @@ -97,10 +75,9 @@ export const FixedFieldFactory = { return config; }, - getFixedField(name, marcType, fixedFieldSpec, type, subtype) { - const FixedField = this.getFixedFieldByType(marcType); + getFixedField(name, fixedFieldSpec, type, subtype) { const configFixedField = this.getConfigFixedField(fixedFieldSpec, type, subtype); - return FixedField ? : null; + return ; }, }; diff --git a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedFieldFactory.test.js b/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedFieldFactory.test.js index 2f14907c..c0a4cb12 100644 --- a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedFieldFactory.test.js +++ b/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedFieldFactory.test.js @@ -1,121 +1,88 @@ import '@folio/stripes-acq-components/test/jest/__mock__'; import { FixedFieldFactory } from './FixedFieldFactory'; - -import BibliographicFixedField from './BibliographicFixedField'; -import HoldingsFixedField from './HoldingsFixedField'; -import AuthorityFixedField from './AuthorityFixedField'; -import { MARC_TYPES } from '../../../common/constants'; import fixedFieldSpecBib from '../../../../test/mocks/fixedFieldSpecBib'; import fixedFieldSpecAuth from '../../../../test/mocks/fixedFieldSpecAuth'; import fixedFieldSpecHold from '../../../../test/mocks/fixedFieldSpecHold'; describe('FixedFieldFactory', () => { - it('should create correct marc type fixed field', () => { - expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB).type.displayName, - ).toBe(BibliographicFixedField.displayName); - - expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.AUTHORITY).type.displayName, - ).toBe(AuthorityFixedField.displayName); - - expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.HOLDINGS).type.displayName, - ).toBe(HoldingsFixedField.displayName); - }); - it('should create correct fixed field type', () => { expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'm').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'm').props.config.type, ).toBe('books'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'a').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'a').props.config.type, ).toBe('books'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'd').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'd').props.config.type, ).toBe('books'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'x').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'x').props.config.type, ).toBe(undefined); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 't').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 't').props.config.type, ).toBe('books'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'c').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'c').props.config.type, ).toBe('scores'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'i').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'i').props.config.type, ).toBe('sound_recordings'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'b').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'b').props.config.type, ).toBe('continuing_resources'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'i').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'i').props.config.type, ).toBe('continuing_resources'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 's').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 's').props.config.type, ).toBe('continuing_resources'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 's').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 's').props.config.type, ).toBe('continuing_resources'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'm').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'm').props.config.type, ).toBe('computer_files'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'g').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'g').props.config.type, ).toBe('visual_materials'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'e').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'e').props.config.type, ).toBe('maps'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'f').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'f').props.config.type, ).toBe('maps'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'p').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'p').props.config.type, ).toBe('mixed_materials'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.AUTHORITY, fixedFieldSpecAuth, 'z').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecAuth, 'z').props.config.type, ).toBe('unknown'); expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.AUTHORITY, fixedFieldSpecAuth, 'z').type.displayName, - ).toBe(AuthorityFixedField.displayName); - - expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.HOLDINGS, fixedFieldSpecHold, 'u').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecHold, 'u').props.config.type, ).toBe('unknown'); - - expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.HOLDINGS, fixedFieldSpecHold, 'u').type.displayName, - ).toBe(HoldingsFixedField.displayName); }); it('should return undefined type when there is no matched field', () => { expect( - FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'l').props.config.type, + FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'l').props.config.type, ).toBe(undefined); }); - - it('should return null when marc types is wrong', () => { - expect( - FixedFieldFactory.getFixedField('records', 'instance', fixedFieldSpecBib, 'l'), - ).toBe(null); - }); }); diff --git a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/index.js b/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/index.js index a5b285bb..c4c18bd4 100644 --- a/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/index.js +++ b/src/QuickMarcEditor/QuickMarcEditorRows/FixedField/index.js @@ -1,5 +1,3 @@ export * from './FixedFieldFactory'; -export { default as AutorityFixedField } from './AuthorityFixedField'; -export { default as BibliographicFixedField } from './BibliographicFixedField'; -export { default as HoldingsFixedField } from './HoldingsFixedField'; +export { default as FixedField } from './FixedField'; diff --git a/src/QuickMarcEditor/QuickMarcEditorRows/QuickMarcEditorRows.js b/src/QuickMarcEditor/QuickMarcEditorRows/QuickMarcEditorRows.js index c5b0cd04..db811642 100644 --- a/src/QuickMarcEditor/QuickMarcEditorRows/QuickMarcEditorRows.js +++ b/src/QuickMarcEditor/QuickMarcEditorRows/QuickMarcEditorRows.js @@ -470,7 +470,7 @@ const QuickMarcEditorRows = ({ { isFixedField && ( FixedFieldFactory.getFixedField( - `${name}.content`, marcType, fixedFieldSpec, type, subtype, + `${name}.content`, fixedFieldSpec, type, subtype, ) ) }