From 5dd22f2da1dfa648973fd283668a49ed2cedbf3d Mon Sep 17 00:00:00 2001 From: ducica Date: Sun, 22 Oct 2023 22:31:54 +0200 Subject: [PATCH] app layour + active filters --- .../search/SearchAppActiveFilters.jsx | 57 +++++++++++++++++++ .../js/oarepo_ui/search/SearchAppFacets.jsx | 5 -- .../js/oarepo_ui/search/SearchAppLayout.jsx | 37 ++++++------ .../search/SearchAppResultOptions.jsx | 1 - .../semantic-ui/js/oarepo_ui/search/index.js | 2 +- 5 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppActiveFilters.jsx diff --git a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppActiveFilters.jsx b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppActiveFilters.jsx new file mode 100644 index 00000000..dbcc525b --- /dev/null +++ b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppActiveFilters.jsx @@ -0,0 +1,57 @@ +import PropTypes from "prop-types"; +import React from "react"; +import _groupBy from "lodash/groupBy"; +import _map from "lodash/map"; +import { Label, Icon } from "semantic-ui-react"; +import { withState } from "react-searchkit"; + +const SearchAppActiveFiltersComponent = ({ + filters, + removeActiveFilter, + getLabel, + currentResultsState: { + data: { aggregations }, + }, +}) => { + const groupedData = _groupBy(filters, 0); + + return ( + <> + {_map(groupedData, (filters, key) => ( + + + {filters.map((filter, index) => { + const { label, activeFilter } = getLabel(filter); + return ( + // eslint-disable-next-line react/no-array-index-key + + ); + })} + + ))} + + ); +}; + +export const SearchAppActiveFilters = withState( + SearchAppActiveFiltersComponent +); + +SearchAppActiveFiltersComponent.propTypes = { + filters: PropTypes.array, + removeActiveFilter: PropTypes.func.isRequired, + getLabel: PropTypes.func.isRequired, + currentResultsState: PropTypes.shape({ + data: PropTypes.shape({ + aggregations: PropTypes.object, + }).isRequired, + }).isRequired, +}; diff --git a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppFacets.jsx b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppFacets.jsx index 9e086bc9..3bce9f08 100644 --- a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppFacets.jsx +++ b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppFacets.jsx @@ -1,14 +1,9 @@ import React from "react"; import { BucketAggregation } from "react-searchkit"; -import { i18next } from "@translations/oarepo_ui/i18next"; export const SearchAppFacets = ({ aggs, appName }) => { return (
-
-

{i18next.t("Filters")}

-
-
{aggs.map((agg) => ( diff --git a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppLayout.jsx b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppLayout.jsx index 68d30502..38049d16 100644 --- a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppLayout.jsx +++ b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppLayout.jsx @@ -73,13 +73,20 @@ export const SearchAppLayout = ({ config, hasButtonSidebar }) => { const resultsSortLayoutFacets = { mobile: 14, tablet: 14, - computer: 12, - largeScreen: 12, - widescreen: 12, + computer: 16, + largeScreen: 16, + widescreen: 16, + }; + + const resultsSortLayoutNoFacets = { + mobile: 16, + tablet: 16, + computer: 16, + largeScreen: 16, + widescreen: 16, }; const resultsPaneLayoutNoFacets = resultsPaneLayoutFacets; - const resultsSortLayoutNoFacets = resultsSortLayoutFacets; // make list full width if no facets available const resultsPaneLayout = facetsAvailable @@ -104,14 +111,10 @@ export const SearchAppLayout = ({ config, hasButtonSidebar }) => { - + {facetsAvailable && ( <> { aria-label={i18next.t("Filter results")} /> - - - )} + + + + + {facetsAvailable && ( {