Skip to content

Commit

Permalink
Merge pull request #205 from oarepo/deburred-search-move-to-oarepoui
Browse files Browse the repository at this point in the history
Deburred search move to oarepoui
  • Loading branch information
mirekys authored Feb 4, 2025
2 parents 8b1f4bc + 473979d commit 309339c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ jobs:
python setup.py sdist bdist_wheel
- name: Archive production artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
path: dist

- name: Archive production artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: requirements.txt
path: requirements.txt
2 changes: 1 addition & 1 deletion .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
needs: build12
steps:
- name: Use built artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist
path: dist
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useMemo } from "react";
import { SelectField } from "react-invenio-forms";
import { useFormConfig } from "@js/oarepo_ui";
import { useFormConfig, search } from "@js/oarepo_ui/forms";
import { useFormikContext, getIn } from "formik";
import PropTypes from "prop-types";
import { Dropdown, Divider } from "semantic-ui-react";
import { i18next } from "@translations/oarepo_vocabularies_ui/i18next";
import { search, serializeVocabularyItems } from "@js/oarepo_vocabularies";
import { serializeVocabularyItems } from "@js/oarepo_vocabularies";

export const processVocabularyItems = (
options,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// function that transforms the shape of fields with multiple values to shape accepted by api
import _deburr from "lodash/deburr";
import _escapeRegExp from "lodash/escapeRegExp";
import _filter from "lodash/filter";

export const transformArrayToObject = (arr) => {
const result = {};
Expand All @@ -13,18 +10,3 @@ export const transformArrayToObject = (arr) => {

return result;
};

// custom search function to avoid the issue of not being able to search
// through text in react nodes that are our dropdown options
// requires also name to be returned in serializer which is actually a text
// value
export const search = (filteredOptions, searchQuery) => {
const strippedQuery = _deburr(searchQuery);

const re = new RegExp(_escapeRegExp(strippedQuery), "i");

filteredOptions = _filter(filteredOptions, (opt) =>
re.test(_deburr(opt?.name))
);
return filteredOptions;
};
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-vocabularies
version = 2.1.14
version = 2.1.15
description = Support for custom fields and hierarchy on Invenio vocabularies
authors = Mirek Simek <[email protected]>
readme = README.md
Expand Down

0 comments on commit 309339c

Please sign in to comment.