From b34df280ac5d2ef930b091441bf81d78921e4db0 Mon Sep 17 00:00:00 2001 From: ducica Date: Wed, 8 Jan 2025 13:59:26 +0100 Subject: [PATCH 1/3] scroll container + back button fix --- .../CommunitySelector/CommunitySelector.jsx | 120 ++++++++++-------- .../themes/default/modules/modal.overrides | 6 + setup.cfg | 2 +- 3 files changed, 77 insertions(+), 51 deletions(-) diff --git a/oarepo_communities/ui/communities_components/semantic-ui/js/communities_components/components/CommunitySelector/CommunitySelector.jsx b/oarepo_communities/ui/communities_components/semantic-ui/js/communities_components/components/CommunitySelector/CommunitySelector.jsx index 974837f..da6351e 100644 --- a/oarepo_communities/ui/communities_components/semantic-ui/js/communities_components/components/CommunitySelector/CommunitySelector.jsx +++ b/oarepo_communities/ui/communities_components/semantic-ui/js/communities_components/components/CommunitySelector/CommunitySelector.jsx @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React, { useEffect, useRef } from "react"; import PropTypes from "prop-types"; import { useFormConfig, goBack } from "@js/oarepo_ui"; import { useFormikContext, getIn } from "formik"; @@ -38,6 +38,7 @@ export const GenericCommunityMessage = () => ( export const CommunitySelector = ({ fieldPath }) => { const { values, setFieldValue } = useFormikContext(); + const lastSelectedCommunity = useRef(null); const { formConfig: { allowed_communities, @@ -50,75 +51,94 @@ export const CommunitySelector = ({ fieldPath }) => { if (!values.id) { if (preselected_community) { setFieldValue(fieldPath, preselected_community.id); + lastSelectedCommunity.current = preselected_community.id; } else if (allowed_communities.length === 1) { setFieldValue(fieldPath, allowed_communities[0].id); + lastSelectedCommunity.current = allowed_communities[0].id; } } }, []); + const handleClick = (id) => { setFieldValue(fieldPath, id); + lastSelectedCommunity.current = id; }; + console.log(lastSelectedCommunity.current); return ( !values.id && ( - + {i18next.t("Community selection")} - - {allowed_communities.length > 1 && ( - -

- {i18next.t( - "Please select community in which your work will be published:" - )} -

- - {allowed_communities.map((c) => ( - - ))} - -
- )} - {allowed_communities.length === 0 && ( - - {" "} - - {i18next.t( - "If you are certain that you wish to proceed with the generic community, please click on it below." - )} - - + {allowed_communities.length > 1 && ( +
+

+ {i18next.t( + "Please select community in which your work will be published:" + )} +

+ + {allowed_communities.map((c) => ( - - - )} - - + ))} + +
+ )} + {allowed_communities.length === 0 && ( + + {" "} - {i18next.t("All records must belong to a community.")} + {i18next.t( + "If you are certain that you wish to proceed with the generic community, please click on it below." + )} - - + + + +
+ )} + + + {i18next.t("All records must belong to a community.")} +
- + {lastSelectedCommunity.current ? ( + + ) : ( + + )}
) diff --git a/oarepo_communities/ui/communities_components/semantic-ui/less/oarepo_communities/themes/default/modules/modal.overrides b/oarepo_communities/ui/communities_components/semantic-ui/less/oarepo_communities/themes/default/modules/modal.overrides index 05be7db..b6049bd 100644 --- a/oarepo_communities/ui/communities_components/semantic-ui/less/oarepo_communities/themes/default/modules/modal.overrides +++ b/oarepo_communities/ui/communities_components/semantic-ui/less/oarepo_communities/themes/default/modules/modal.overrides @@ -7,4 +7,10 @@ } } } + &.communities.community-selection-modal { + .communities.communities-list-scroll-container { + max-height: 600px; + overflow-y: auto; + } + } } diff --git a/setup.cfg b/setup.cfg index e08f68c..4bd754a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = oarepo-communities -version = 5.1.3 +version = 5.1.4 description = authors = Ronald Krist readme = README.md From 0522713e19dd750c1af49bdf985bce4b8126d67d Mon Sep 17 00:00:00 2001 From: ducica Date: Wed, 8 Jan 2025 14:42:56 +0100 Subject: [PATCH 2/3] removed console.log --- .../components/CommunitySelector/CommunitySelector.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/oarepo_communities/ui/communities_components/semantic-ui/js/communities_components/components/CommunitySelector/CommunitySelector.jsx b/oarepo_communities/ui/communities_components/semantic-ui/js/communities_components/components/CommunitySelector/CommunitySelector.jsx index da6351e..e89e73e 100644 --- a/oarepo_communities/ui/communities_components/semantic-ui/js/communities_components/components/CommunitySelector/CommunitySelector.jsx +++ b/oarepo_communities/ui/communities_components/semantic-ui/js/communities_components/components/CommunitySelector/CommunitySelector.jsx @@ -63,7 +63,6 @@ export const CommunitySelector = ({ fieldPath }) => { setFieldValue(fieldPath, id); lastSelectedCommunity.current = id; }; - console.log(lastSelectedCommunity.current); return ( !values.id && ( Date: Sun, 19 Jan 2025 13:25:18 +0100 Subject: [PATCH 3/3] using relative units for scroll container --- .../oarepo_communities/themes/default/modules/modal.overrides | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oarepo_communities/ui/communities_components/semantic-ui/less/oarepo_communities/themes/default/modules/modal.overrides b/oarepo_communities/ui/communities_components/semantic-ui/less/oarepo_communities/themes/default/modules/modal.overrides index b6049bd..c0fece1 100644 --- a/oarepo_communities/ui/communities_components/semantic-ui/less/oarepo_communities/themes/default/modules/modal.overrides +++ b/oarepo_communities/ui/communities_components/semantic-ui/less/oarepo_communities/themes/default/modules/modal.overrides @@ -9,7 +9,7 @@ } &.communities.community-selection-modal { .communities.communities-list-scroll-container { - max-height: 600px; + max-height: 50vh; overflow-y: auto; } }