Skip to content

Commit

Permalink
UIQM-597: Build initial values for the find-authority plugin using EX…
Browse files Browse the repository at this point in the history
…ACT_PHRASE when there is \ value.
  • Loading branch information
Dmytro-Melnyshyn committed Dec 18, 2023
1 parent 1b07a49 commit 1733c87
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* [UIQM-534](https://issues.folio.org/browse/UIQM-534) Remove fields that have no MARC tag and no subfield value.
* [UIQM-381](https://issues.folio.org/browse/UIQM-381) Create Orig Authority Record: Populate new record with default Leader values.
* [UIQM-526](https://issues.folio.org/browse/UIQM-526) Refactor validation functionality.
* [UIQM-597](https://issues.folio.org/browse/UIQM-597) Build initial values for the find-authority plugin using EXACT_PHRASE when there is '$0' value.

## [7.0.5](https://github.com/folio-org/ui-quick-marc/tree/v7.0.5) (2023-12-11)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
IconButton,
ConfirmationModal,
Loading,
ADVANCED_SEARCH_MATCH_OPTIONS,
} from '@folio/stripes/components';

import { useMarcSource } from '../../../queries';
Expand All @@ -35,6 +36,10 @@ import {
} from '../../../common/constants';
import { QUICK_MARC_ACTIONS } from '../../constants';

const {
EXACT_PHRASE,
} = ADVANCED_SEARCH_MATCH_OPTIONS;

const propTypes = {
action: PropTypes.string.isRequired,
calloutRef: PropTypes.oneOfType([
Expand Down Expand Up @@ -165,11 +170,11 @@ const LinkButton = ({
if (fieldContent.$0?.length) {
const keywordValue = [fieldContent.$a, fieldContent.$d, fieldContent.$t].flat().filter(Boolean).join(' ');
const keywordQuery = keywordValue
? `${searchableIndexesValues.KEYWORD}==${keywordValue}`
? `${searchableIndexesValues.KEYWORD} ${EXACT_PHRASE} ${keywordValue}`
: '';
const identifierQuery = fieldContent.$0
.map(selectIdentifierFromSubfield)
.map(identifier => `${searchableIndexesValues.IDENTIFIER}==${identifier}`)
.map(identifier => `${searchableIndexesValues.IDENTIFIER} ${EXACT_PHRASE} ${identifier}`)
.join(' or ');

initialDropdownValue = searchableIndexesValues.ADVANCED_SEARCH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Pluggable,
useOkapiKy,
} from '@folio/stripes/core';
import { ADVANCED_SEARCH_MATCH_OPTIONS } from '@folio/stripes/components';
import { runAxeTest } from '@folio/stripes-testing';

import { createMemoryHistory } from 'history';
Expand All @@ -19,6 +20,10 @@ import { QUICK_MARC_ACTIONS } from '../../constants';

import Harness from '../../../../test/jest/helpers/harness';

const {
EXACT_PHRASE,
} = ADVANCED_SEARCH_MATCH_OPTIONS;

const mockOnClick = jest.fn();
const mockGetMarcSource = jest.fn(() => ({ json: () => {} }));

Expand Down Expand Up @@ -127,8 +132,8 @@ describe('Given LinkButton', () => {
search: {
dropdownValue: 'advancedSearch',
searchIndex: 'advancedSearch',
searchInputValue: 'identifiers.value==n123456789',
searchQuery: 'identifiers.value==n123456789',
searchInputValue: `identifiers.value ${EXACT_PHRASE} n123456789`,
searchQuery: `identifiers.value ${EXACT_PHRASE} n123456789`,
filters: null,
},
browse: {
Expand All @@ -155,8 +160,8 @@ describe('Given LinkButton', () => {
search: {
dropdownValue: 'advancedSearch',
searchIndex: 'advancedSearch',
searchInputValue: 'identifiers.value==n123456789 or identifiers.value==n987654321',
searchQuery: 'identifiers.value==n123456789 or identifiers.value==n987654321',
searchInputValue: `identifiers.value ${EXACT_PHRASE} n123456789 or identifiers.value ${EXACT_PHRASE} n987654321`,
searchQuery: `identifiers.value ${EXACT_PHRASE} n123456789 or identifiers.value ${EXACT_PHRASE} n987654321`,
filters: null,
},
browse: {
Expand Down Expand Up @@ -211,8 +216,8 @@ describe('Given LinkButton', () => {
search: {
dropdownValue: 'advancedSearch',
searchIndex: 'advancedSearch',
searchInputValue: 'keyword==value1 value2 value3 or identifiers.value==value4 or identifiers.value==value5',
searchQuery: 'keyword==value1 value2 value3 or identifiers.value==value4 or identifiers.value==value5',
searchInputValue: `keyword ${EXACT_PHRASE} value1 value2 value3 or identifiers.value ${EXACT_PHRASE} value4 or identifiers.value ${EXACT_PHRASE} value5`,
searchQuery: `keyword ${EXACT_PHRASE} value1 value2 value3 or identifiers.value ${EXACT_PHRASE} value4 or identifiers.value ${EXACT_PHRASE} value5`,
filters: null,
},
browse: {
Expand Down

0 comments on commit 1733c87

Please sign in to comment.