Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into UIQM-652
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanDenis committed Oct 15, 2024
2 parents c2d8672 + dcc6595 commit 336f74d
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
* [UIQM-695](https://issues.folio.org/browse/UIQM-695) Remove extra `$` from error messages when adding/removing `$t` from 1XX of linked MARC authority record.
* [UIQM-706](https://issues.folio.org/browse/UIQM-706) *BREAKING* Upgrade `marc-records-editor` to `6.0`.
* [UIQM-698](https://issues.folio.org/browse/UIQM-698) Validate 006/007 field lengths.
* [UIQM-704](https://issues.folio.org/browse/UIQM-704) Linked fields - combine split fields before sending for validation.
* [UIQM-708](https://issues.folio.org/browse/UIQM-708) Change 007 Microforms type to allow 4 characters in RRR/RR field.
* [UIQM-714](https://issues.folio.org/browse/UIQM-714) *BREAKING* Upgrade `inventory` to `14.0`.
* [UIQM-709](https://issues.folio.org/browse/UIQM-709) LCCN duplication: Update the bib request query to include only the non-suppressed record in the search results.

## [8.0.1] (https://github.com/folio-org/ui-quick-marc/tree/v8.0.1) (2024-04-18)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"pluginType": "quick-marc",
"displayName": "ui-quick-marc.meta.title",
"okapiInterfaces": {
"inventory": "13.0",
"inventory": "14.0",
"marc-records-editor": "6.0",
"search": "1.2",
"marc-specifications": "1.0",
Expand Down
6 changes: 2 additions & 4 deletions src/QuickMarcEditor/QuickMarcCreateWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const QuickMarcCreateWrapper = ({
marcRecord => autopopulateSubfieldSection(marcRecord, marcType),
marcRecord => cleanBytesFields(marcRecord, fixedFieldSpec, marcType),
marcRecord => formatLeaderForSubmit(marcType, marcRecord),
combineSplitFields,
)(formValues);

return formValuesForCreate;
Expand All @@ -123,10 +124,7 @@ const QuickMarcCreateWrapper = ({
return complete();
}

const formValuesToProcess = flow(
prepareForSubmit,
combineSplitFields,
)(formValues);
const formValuesToProcess = prepareForSubmit(formValues);

let formValuesToHydrate;

Expand Down
6 changes: 2 additions & 4 deletions src/QuickMarcEditor/QuickMarcDeriveWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const QuickMarcDeriveWrapper = ({
marcRecord => autopopulateSubfieldSection(marcRecord, marcType),
marcRecord => cleanBytesFields(marcRecord, fixedFieldSpec, marcType),
marcRecord => formatLeaderForSubmit(marcType, marcRecord),
combineSplitFields,
)(formValues);

return formValuesForDerive;
Expand All @@ -101,10 +102,7 @@ const QuickMarcDeriveWrapper = ({
return complete();
}

const formValuesToProcess = flow(
prepareForSubmit,
combineSplitFields,
)(formValues);
const formValuesToProcess = prepareForSubmit(formValues);

showCallout({ messageId: 'ui-quick-marc.record.saveNew.onSave' });

Expand Down
6 changes: 2 additions & 4 deletions src/QuickMarcEditor/QuickMarcEditWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const QuickMarcEditWrapper = ({
autopopulateMaterialCharsField,
marcRecord => autopopulateSubfieldSection(marcRecord, marcType),
marcRecord => cleanBytesFields(marcRecord, fixedFieldSpec, marcType),
combineSplitFields,
)(formValues);

return formValuesToSave;
Expand All @@ -148,10 +149,7 @@ const QuickMarcEditWrapper = ({
is1xxOr010Updated = are010Or1xxUpdated(initialValues.records, formValues.records);
}

const formValuesToProcess = flow(
prepareForSubmit,
combineSplitFields,
)(formValues);
const formValuesToProcess = prepareForSubmit(formValues);

const path = EXTERNAL_INSTANCE_APIS[marcType];

Expand Down
91 changes: 79 additions & 12 deletions src/QuickMarcEditor/QuickMarcEditWrapper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import { useLocation } from 'react-router';

import QuickMarcEditWrapper from './QuickMarcEditWrapper';
import { useAuthorityLinking } from '../hooks';
import { useMarcRecordMutation } from '../queries';
import {
useMarcRecordMutation,
useValidate,
} from '../queries';
import { QUICK_MARC_ACTIONS } from './constants';
import { MARC_TYPES } from '../common/constants';
import { applyCentralTenantInHeaders } from './utils';
Expand Down Expand Up @@ -43,6 +46,7 @@ jest.mock('../queries', () => ({
isLoading: false,
duplicateLccnCheckingEnabled: false,
}),
useValidate: jest.fn(),
}));

jest.mock('../hooks', () => ({
Expand Down Expand Up @@ -266,17 +270,7 @@ const mockLeaders = {
[MARC_TYPES.AUTHORITY]: authorityLeader,
};

const mockFormValues = jest.fn((marcType) => ({
fields: undefined,
externalId: '17064f9d-0362-468d-8317-5984b7efd1b5',
marcFormat: marcType.toUpperCase(),
leader: mockLeaders[marcType],
parsedRecordDtoId: '1bf159d9-4da8-4c3f-9aac-c83e68356bbf',
parsedRecordId: '1bf159d9-4da8-4c3f-9aac-c83e68356bbf',
records: mockRecords[marcType],
suppressDiscovery: false,
updateInfo: { recordState: 'NEW' },
}));
const mockFormValues = jest.fn();

const mockSpecs = {
[MARC_TYPES.BIB]: fixedFieldSpecBib,
Expand All @@ -286,6 +280,7 @@ const mockSpecs = {
const mockActualizeLinks = jest.fn((formValuesToProcess) => Promise.resolve(formValuesToProcess));
const mockUpdateMarcRecord = jest.fn().mockResolvedValue();
const mockOnCheckCentralTenantPerm = jest.fn().mockReturnValue(false);
const mockValidateFetch = jest.fn().mockResolvedValue({});

jest.mock('@folio/stripes/final-form', () => () => (Component) => ({
onSubmit,
Expand Down Expand Up @@ -421,6 +416,18 @@ describe('Given QuickMarcEditWrapper', () => {
},
};

mockFormValues.mockImplementation((marcType) => ({
fields: undefined,
externalId: '17064f9d-0362-468d-8317-5984b7efd1b5',
marcFormat: marcType.toUpperCase(),
leader: mockLeaders[marcType],
parsedRecordDtoId: '1bf159d9-4da8-4c3f-9aac-c83e68356bbf',
parsedRecordId: '1bf159d9-4da8-4c3f-9aac-c83e68356bbf',
records: mockRecords[marcType],
suppressDiscovery: false,
updateInfo: { recordState: 'NEW' },
}));

useAuthorityLinking.mockReturnValue({
linkableBibFields: [],
actualizeLinks: mockActualizeLinks,
Expand All @@ -439,6 +446,10 @@ describe('Given QuickMarcEditWrapper', () => {
search: 'relatedRecordVersion=1',
});

useValidate.mockReturnValue({
validate: mockValidateFetch,
});

jest.clearAllMocks();
});

Expand Down Expand Up @@ -621,6 +632,62 @@ describe('Given QuickMarcEditWrapper', () => {
expect(mockUpdateMarcRecord).toHaveBeenCalledWith(formValuesForEdit);
});

describe('and there is a linked field', () => {
it('should run backend validation with the content from all split fields', async () => {
const formValues = mockFormValues(MARC_TYPES.BIB);

const field240 = {
'tag': '240',
'content': '$a a $0 http://id.loc.gov/authorities/names/n2016004081 $9 58e3deb0-d1c9-4e22-918d-a393f627e18c',
'indicators': ['\\', '\\'],
'isProtected': false,
'linkDetails': {
'authorityId': '58e3deb0-d1c9-4e22-918d-a393f627e18c',
'authorityNaturalId': 'n2016004081',
'linkingRuleId': 5,
'status': 'ACTUAL',
},
'id': '5cc17747-0b0a-44f6-807e-fd28138bbcaa',
'_isDeleted': false,
'_isLinked': true,
'subfieldGroups': {
'controlled': '$a a',
'uncontrolledAlpha': '$3 test',
'zeroSubfield': '$0 http://id.loc.gov/authorities/names/n2016004081',
'nineSubfield': '$9 58e3deb0-d1c9-4e22-918d-a393f627e18c',
'uncontrolledNumber': '',
},
};

mockFormValues.mockReturnValue({
...formValues,
records: [
field240,
...formValues.records,
],
});

const { getByText } = renderQuickMarcEditWrapper({
instance,
mutator,
});

await act(async () => { fireEvent.click(getByText('stripes-acq-components.FormFooter.save')); });

expect(mockValidateFetch).toHaveBeenCalledWith(expect.objectContaining({
body: expect.objectContaining({
fields: expect.arrayContaining([
expect.objectContaining({
tag: '240',
content: '$a a $3 test $0 http://id.loc.gov/authorities/names/n2016004081 $9 58e3deb0-d1c9-4e22-918d-a393f627e18c',
indicators: ['\\', '\\'],
}),
]),
}),
}));
});
});

describe('when there is an error during POST request', () => {
it('should show an error message', async () => {
const { getByText } = renderQuickMarcEditWrapper({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const MicroformDescriptionFieldConfig = [
{
name: 'Reduction ratio range/Reduction ratio',
type: SUBFIELD_TYPES.STRING,
length: 3,
length: 4,
},
{
name: 'Color',
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/useValidation/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@ export const validateLccnDuplication = async ({
query: `(${lccnQuery})${idQuery}`,
};

if (marcType === MARC_TYPES.BIB) {
searchParams.query += ' not (staffSuppress=="true" and discoverySuppress=="true")';
}

const requests = {
[MARC_TYPES.BIB]: () => ky.get('search/instances', { searchParams }),
[MARC_TYPES.AUTHORITY]: () => ky.get('search/authorities', { searchParams }),
Expand Down
28 changes: 28 additions & 0 deletions src/hooks/useValidation/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,5 +781,33 @@ describe('validators', () => {
expect(rule.message).toHaveBeenCalled();
});
});

it('should call the bib record with the `staffSuppress` and `discoverySuppress` parameters', async () => {
const marcRecords = [{
tag: LEADER_TAG,
content: bibLeader,
}, {
tag: '010',
content: '$a test',
}];
const ky = {
get: jest.fn().mockResolvedValue({}),
};

await validators.validateLccnDuplication({
ky,
marcRecords,
marcType: MARC_TYPES.BIB,
action: QUICK_MARC_ACTIONS.EDIT,
duplicateLccnCheckingEnabled: true,
instanceId: 'instanceId-1',
}, rule);

expect(ky.get).toHaveBeenCalledWith('search/instances', {
searchParams: expect.objectContaining({
query: expect.stringContaining(' not (staffSuppress=="true" and discoverySuppress=="true")'),
}),
});
});
});
});
26 changes: 13 additions & 13 deletions translations/ui-quick-marc/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@
"linkedToMarcAuthority": "链接到MARC规范",
"record.link.validation.invalidHeading": "您根据要控制的书目字段选择了无效的标题。请修改您的选择。",
"record.error.1xx.change": "无法更改<b>保存的 MARC 规范字段{tag} </b> ,因为它控制书目字段。要更改此 1XX,必须取消链接所有受控书目字段。",
"record.error.1xx.add$t": "无法将<b> $t 添加到 $ {tag}字段</b> ,因为它控制无法控制此子字段的书目字段。要更改此 1XX 值,必须取消链接所有无法控制 $t 的受控书目字段。",
"record.error.1xx.remove$t": "无法从 $ {tag}字段中删除<b> $t </b> ,因为它控制需要该子字段的书目字段。要更改此 1XX 值,必须取消链接所有需要控制 $t 的受控书目字段。",
"record.error.1xx.add$t": "无法将<b> $t 添加到{tag}字段</b>因为它控制着无法控制此子字段的书目字段。要更改此 1XX 值,您必须取消链接所有无法控制 $t 的受控书目字段。",
"record.error.1xx.remove$t": "无法<b> 从{tag}字段中移除$t</b>,因为它控制着需要此子字段的书目字段。要更改此 1XX 值,您必须取消链接所有需要控制 $t 的受控书目字段。",
"record.save.updatingLinkedBibRecords": "本记录已成功保存并正在处理中。 <b> {count} </b>个链接的书目记录更新已开始。",
"update-linked-bib-fields.modal.label": "是否确定?",
"update-linked-bib-fields.modal.keep-editing": "继续编辑",
Expand Down Expand Up @@ -398,7 +398,7 @@
"sourceFileLookupModal.fieldLabel": "规范档名称",
"sourceFileLookupModal.placeholder": "选择规范档",
"authority-record.create.title": "创建新的{shared, select, true { shared } false { local } other {}} MARC 规范记录",
"record.error.fieldIsControlled": "<b> {fieldTags} </b>有一个无法保存的子字段,因为该字段由规范记录控制",
"record.error.fieldIsControlled": "由于子字段受规范标题控制,因此无法更新",
"record.error.controlField.content.empty": "记录无法保存。需要规范档",
"record.error.010.absent": "如果没有010字段,则无法保存记录。",
"record.error.010.prefix.absent": "如果010字段中没有前缀,则无法保存记录。",
Expand Down Expand Up @@ -799,7 +799,7 @@
"record.fixedField.Playing cards": "扑克牌",
"record.fixedField.Loose-leaf": "活页",
"record.fixedField.invalid.value": "无效值",
"record.error.008.invalidValue": "无法保存记录。字段 008 在“ {name} ”子字段中包含无效值",
"record.error.008.invalidValue": "无法保存记录。字段 008 在“ {name} ”位置包含无效值",
"record.fixedField.Status": "状态",
"record.fixedField.ELvl": "ELvl 编目等级",
"record.fixedField.MultiLvl": "多级",
Expand Down Expand Up @@ -880,13 +880,13 @@
"leader.Two-dimensional nonprojectable graphic": "二维非投影图片",
"record.searchLink": "按 010 值搜索记录",
"record.error.010.lccnDuplicated": "010 $a 已存在。",
"record.errorMessage.error": "<b>Fail: </b>",
"record.errorMessage.warn": "<b>Warn: </b>",
"record.error.generic": "Communication problem with server. Please try again.",
"validation.modal.heading": "MARC validation rules check",
"validation.modal.message": "There might be a slight delay while the system is checking against the library's validation rules. You can continue to work with {appName} in a different browser tab if needed.",
"record.errorMessage.help": "Help",
"Inventory": "Inventory",
"MARC-authority": "MARC authority",
"record.error.fixedField.invalidLength": "Invalid {name} field length, must be {length} characters."
"record.errorMessage.error": "<b>失败: </b>",
"record.errorMessage.warn": "<b>警告: </b>",
"record.error.generic": "服务器通信出现问题。请重试。",
"validation.modal.heading": "MARC 验证规则检查",
"validation.modal.message": "系统根据图书馆的验证规则进行检查时可能会出现轻微延迟。如有必要,可在其他浏览器选项卡中继续使用{appName} ",
"record.errorMessage.help": "帮助",
"Inventory": "典藏",
"MARC-authority": "MARC规范",
"record.error.fixedField.invalidLength": "{name}字段长度无效,必须为{length}个字符。"
}

0 comments on commit 336f74d

Please sign in to comment.