From b4264efed5aad0291b76d86c67ec08d593909f6d Mon Sep 17 00:00:00 2001 From: Dmytro-Melnyshyn Date: Wed, 1 Nov 2023 13:43:30 +0200 Subject: [PATCH] UIQM-573: Edit MARC authority | Allow user to Add/Edit 010 '' when linking is based on 001. --- CHANGELOG.md | 4 +-- src/QuickMarcEditor/utils.js | 24 ++----------- src/QuickMarcEditor/utils.test.js | 57 ------------------------------- 3 files changed, 3 insertions(+), 82 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 600b6f49..eadf4b68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,8 @@ ## [8.0.0] (IN PROGRESS) * [UIQM-580](https://issues.folio.org/browse/UIQM-580) *BREAKING* Move QuickMarcView, PrintPopup and getHeaders to stripes-marc-components. - -## [7.1.0] (IN PROGRESS) - * [UIQM-543](https://issues.folio.org/browse/UIQM-543) Remove eslint deps that are already listed in eslint-config-stripes. +* [UIQM-573](https://issues.folio.org/browse/UIQM-573) Edit MARC authority | Allow user to Add/Edit 010 $a when linking is based on 001. ## [7.0.2](https://github.com/folio-org/ui-quick-marc/tree/v7.0.2) (2023-10-27) diff --git a/src/QuickMarcEditor/utils.js b/src/QuickMarcEditor/utils.js index 002db85a..027ea901 100644 --- a/src/QuickMarcEditor/utils.js +++ b/src/QuickMarcEditor/utils.js @@ -90,12 +90,6 @@ export const getContentSubfieldValue = (content = '') => { }, {}); }; -const is001LinkedToBibRecord = (initialRecords, naturalId) => { - const field001 = initialRecords.find(record => record.tag === '001'); - - return naturalId === field001?.content.replaceAll(' ', ''); -}; - export const is010LinkedToBibRecord = (initialRecords, naturalId) => { const initial010Field = initialRecords.find(record => record.tag === '010'); @@ -108,13 +102,6 @@ export const is010LinkedToBibRecord = (initialRecords, naturalId) => { return naturalId === initial010$a?.replaceAll(' ', ''); }; -export const is010$aCreated = (initial, updated) => { - const initial010 = initial.find(rec => rec.tag === '010'); - const updated010 = updated.find(rec => rec.tag === '010'); - - return !initial010 && updated010 && !!getContentSubfieldValue(updated010.content).$a?.[0]; -}; - export const is010$aUpdated = (initial, updated) => { const initial010 = initial.find(rec => rec.tag === '010'); const updated010 = updated.find(rec => rec.tag === '010'); @@ -857,7 +844,7 @@ const validateMarcAuthority1xxField = (initialRecords, formValuesToSave) => { return undefined; }; -const validateLinkedAuthority010Field = (field010, initialRecords, records, naturalId) => { +const validateLinkedAuthority010Field = (field010, initialRecords, naturalId) => { if (is010LinkedToBibRecord(initialRecords, naturalId)) { if (!field010) { return ; @@ -872,13 +859,6 @@ const validateLinkedAuthority010Field = (field010, initialRecords, records, natu return undefined; } - if ( - is001LinkedToBibRecord(initialRecords, naturalId) - && (is010$aCreated(initialRecords, records) || is010$aUpdated(initialRecords, records)) - ) { - return ; - } - return undefined; }; @@ -900,7 +880,7 @@ const validateAuthority010Field = (initialRecords, records, naturalId, marcRecor } if (isLinked) { - return validateLinkedAuthority010Field(field010, initialRecords, records, naturalId); + return validateLinkedAuthority010Field(field010, initialRecords, naturalId); } return undefined; diff --git a/src/QuickMarcEditor/utils.test.js b/src/QuickMarcEditor/utils.test.js index 049fdf08..730a7dab 100644 --- a/src/QuickMarcEditor/utils.test.js +++ b/src/QuickMarcEditor/utils.test.js @@ -1209,63 +1209,6 @@ describe('QuickMarcEditor utils', () => { }).props.id).toBe('ui-quick-marc.record.error.1xx.remove$t'); }); - it('should return an error if 010 $a edited and 001 is linked', () => { - const newInitialValues = { - ...initialValues, - records: [ - ...initialValues.records, - { - content: 'n 83073672 ', - tag: '001', - }, - { - tag: '010', - content: '$a 63943573', - }, - ], - }; - - const record = cloneDeep(newInitialValues); - - record.records[4].content += 'test'; - - expect(utils.validateMarcRecord({ - marcRecord: record, - initialValues: newInitialValues, - marcType: MARC_TYPES.AUTHORITY, - linksCount, - naturalId: 'n83073672', - }).props.id).toBe('ui-quick-marc.record.error.010.edit$a'); - }); - - it('should return an error if 010 $a created and 001 is linked', () => { - const newInitialValues = { - ...initialValues, - records: [ - ...initialValues.records, - { - content: 'n 83073672 ', - tag: '001', - }, - ], - }; - - const record = cloneDeep(newInitialValues); - - record.records.push({ - tag: '010', - content: '$a 63943573', - }); - - expect(utils.validateMarcRecord({ - marcRecord: record, - initialValues: newInitialValues, - marcType: MARC_TYPES.AUTHORITY, - linksCount, - naturalId: 'n83073672', - }).props.id).toBe('ui-quick-marc.record.error.010.edit$a'); - }); - it('should return an error if 010 $a removed and 010 is linked', () => { const newInitialValues = { ...initialValues,