Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into stojanovic/fe-192-imp…
Browse files Browse the repository at this point in the history
…lement-embargo-settings-panel-on-deposit-form
  • Loading branch information
Ducica committed Feb 10, 2025
2 parents dfda34d + 85221c3 commit a9e92bb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
14 changes: 13 additions & 1 deletion oarepo_ui/resources/components/communities.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@
from invenio_pidstore.errors import PIDDoesNotExistError
from invenio_records_resources.services.errors import PermissionDeniedError
from oarepo_runtime.i18n import lazy_gettext as _

from .base import UIResourceComponent


class AllowedCommunitiesComponent(UIResourceComponent):
def __init__(self, resource) -> None:
"""
:param resource: the resource instance
"""
import warnings

warnings.warn(
"AllowedCommunitiesComponent is deprecated, please use the one from oarepo_communities.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(resource)

def form_config(
self,
*,
Expand Down
18 changes: 18 additions & 0 deletions oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import Overridable, {
} from "react-overridable";
import { BaseFormLayout } from "./components/BaseFormLayout";
import { setIn } from "formik";
import _deburr from "lodash/deburr";
import _escapeRegExp from "lodash/escapeRegExp";
import _filter from "lodash/filter";

export function parseFormAppConfig(rootElementId = "form-app") {
const rootEl = document.getElementById(rootElementId);
Expand Down Expand Up @@ -227,3 +230,18 @@ export const serializeErrors = (
return {};
}
};

// 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, searchKey = "name") => {
const strippedQuery = _deburr(searchQuery);

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

filteredOptions = _filter(filteredOptions, (opt) =>
re.test(_deburr(opt[searchKey]))
);
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-ui
version = 5.2.35
version = 5.2.36
description = UI module for invenio 3.5+
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit a9e92bb

Please sign in to comment.