diff --git a/CHANGELOG.md b/CHANGELOG.md index 529e62f4..ebab5bc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ * Update css for fix problem visibility Circulation rules. Refs UICIRC-1311. * *BREAKING* Migration from mod-config and mod-settings to mod-circulation. Refs UICIRC-1247. * Update permissions after migration to mod-circulation. Refs UICIRC-1324. +* Fixed an issue where the value containing the previously selected option was not reset. Refs UICIRC-1317. ## [11.0.4](https://github.com/folio-org/ui-circulation/tree/v11.0.4) (2024-12-10) [Full Changelog](https://github.com/folio-org/ui-circulation/compare/v11.0.3...v11.0.4) diff --git a/src/settings/CheckoutSettings/CheckoutSettings.js b/src/settings/CheckoutSettings/CheckoutSettings.js index 2aac4b34..e8875139 100644 --- a/src/settings/CheckoutSettings/CheckoutSettings.js +++ b/src/settings/CheckoutSettings/CheckoutSettings.js @@ -75,7 +75,9 @@ export const normalize = ({ .filter(([_key, value]) => value === true) .map(([key]) => key); - const selectedCustomFieldPatronIdentifiers = customFieldIdentifiers.map(i => i.value); + const selectedCustomFieldPatronIdentifiers = useCustomFieldsAsIdentifiers + ? customFieldIdentifiers.map(i => i.value) + : []; const prefPatronIdentifier = [ ...selectedDefaultPatronIdentifiers, diff --git a/src/settings/CheckoutSettings/CheckoutSettings.test.js b/src/settings/CheckoutSettings/CheckoutSettings.test.js index ea20bcb0..2514ca48 100644 --- a/src/settings/CheckoutSettings/CheckoutSettings.test.js +++ b/src/settings/CheckoutSettings/CheckoutSettings.test.js @@ -166,4 +166,54 @@ describe('normalize', () => { wildcardLookupEnabled: false, }); }); + + it('should not include custom field identifiers when useCustomFieldsAsIdentifiers is false', () => { + const input = { + audioAlertsEnabled: true, + audioTheme: 'modern', + checkoutTimeout: false, + checkoutTimeoutDuration: '5', + identifiers: { + barcode: true, + custom: [{ value: 'customFields.cf1' }, { value: 'customFields.cf2' }], + }, + useCustomFieldsAsIdentifiers: false, + wildcardLookupEnabled: true, + }; + + expect(normalize(input)).toEqual({ + audioAlertsEnabled: true, + audioTheme: 'modern', + checkoutTimeout: false, + checkoutTimeoutDuration: 5, + prefPatronIdentifier: 'barcode', + useCustomFieldsAsIdentifiers: false, + wildcardLookupEnabled: true, + }); + }); + + it('should include custom field identifiers when useCustomFieldsAsIdentifiers is true', () => { + const input = { + audioAlertsEnabled: true, + audioTheme: 'modern', + checkoutTimeout: false, + checkoutTimeoutDuration: '5', + identifiers: { + barcode: true, + custom: [{ value: 'customFields.cf1' }, { value: 'customFields.cf2' }], + }, + useCustomFieldsAsIdentifiers: true, + wildcardLookupEnabled: true, + }; + + expect(normalize(input)).toEqual({ + audioAlertsEnabled: true, + audioTheme: 'modern', + checkoutTimeout: false, + checkoutTimeoutDuration: 5, + prefPatronIdentifier: 'barcode,customFields.cf1,customFields.cf2', + useCustomFieldsAsIdentifiers: true, + wildcardLookupEnabled: true, + }); + }); });