From 7bfc731858e1faf80dea642dd2ef9f0d413d9fe9 Mon Sep 17 00:00:00 2001 From: syam babu Date: Wed, 11 Sep 2024 12:29:37 +0530 Subject: [PATCH 1/6] feat: added navigation from event readonly page to entity page through clicking selection card --- .../List/SelectionItem/SelectionItem.jsx | 8 ++++++- .../Dashboard/EventReadOnly/EventReadOnly.jsx | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/components/List/SelectionItem/SelectionItem.jsx b/src/components/List/SelectionItem/SelectionItem.jsx index 639dcac8..5f5728ce 100644 --- a/src/components/List/SelectionItem/SelectionItem.jsx +++ b/src/components/List/SelectionItem/SelectionItem.jsx @@ -33,6 +33,7 @@ function SelectionItem(props) { edit, creatorId, fallbackConfig, + onClickHandle = { navigationFlag: false, navigationExecute: () => {} }, } = props; const { t } = useTranslation(); const { user } = useSelector(getUserDetails); @@ -61,7 +62,12 @@ function SelectionItem(props) { return (
+ onClick={onClickHandle?.navigationFlag ? onClickHandle?.navigationExecute : null} + style={{ + border: bordered && '1px solid#607EFC', + width: itemWidth && itemWidth, + ...(onClickHandle?.navigationFlag && { cursor: 'pointer' }), + }}> + navigate( + `${PathName.Dashboard}/${calendarId}${PathName.Places}${PathName.AddPlace}?id=${locationPlace?.key}`, + ), + }} /> )}
@@ -905,6 +912,13 @@ function EventReadOnly() { bordered closable={false} itemWidth="100%" + onClickHandle={{ + navigationFlag: true, + navigationExecute: () => + navigate( + `${PathName.Dashboard}/${calendarId}${PathName.Organizations}${PathName.AddOrganization}?id=${organizer?.value}`, + ), + }} /> ); })} @@ -985,6 +999,13 @@ function EventReadOnly() { calendarContentLanguage={calendarContentLanguage} bordered closable={false} + onClickHandle={{ + navigationFlag: true, + navigationExecute: () => + navigate( + `${PathName.Dashboard}/${calendarId}${PathName.People}${PathName.AddPerson}?id=${performer?.value}`, + ), + }} itemWidth="100%" /> ); From 40774b6a6d420e1ec6041d411c75b7eb55c35b12 Mon Sep 17 00:00:00 2001 From: syam babu Date: Wed, 11 Sep 2024 14:13:11 +0530 Subject: [PATCH 2/6] feat: added navigation through non editable selection cards from to entity page --- .../List/SelectionItem/SelectionItem.jsx | 28 +++++++++++++++-- .../Dashboard/EventReadOnly/EventReadOnly.jsx | 23 +++++++------- .../Dashboard/PlaceReadOnly/PlaceReadOnly.jsx | 31 ++++++++++++++++++- 3 files changed, 66 insertions(+), 16 deletions(-) diff --git a/src/components/List/SelectionItem/SelectionItem.jsx b/src/components/List/SelectionItem/SelectionItem.jsx index 5f5728ce..ad93f7df 100644 --- a/src/components/List/SelectionItem/SelectionItem.jsx +++ b/src/components/List/SelectionItem/SelectionItem.jsx @@ -12,6 +12,9 @@ import ReadOnlyProtectedComponent from '../../../layout/ReadOnlyProtectedCompone import LiteralBadge from '../../Badge/LiteralBadge'; import { contentLanguageKeyMap } from '../../../constants/contentLanguage'; import { isDataValid } from '../../../utils/MultiLingualFormItemSupportFunctions.js'; +import { taxonomyClass } from '../../../constants/taxonomyClass.js'; +import { PathName } from '../../../constants/pathName.js'; +import { useNavigate, useParams } from 'react-router-dom'; function SelectionItem(props) { const { icon, @@ -33,11 +36,12 @@ function SelectionItem(props) { edit, creatorId, fallbackConfig, - onClickHandle = { navigationFlag: false, navigationExecute: () => {} }, + onClickHandle = { navigationFlag: false }, } = props; const { t } = useTranslation(); const { user } = useSelector(getUserDetails); - + const navigate = useNavigate(); + const { calendarId } = useParams(); let literalKey = '?'; const promptFlag = calendarContentLanguage.some((language) => { @@ -59,10 +63,28 @@ function SelectionItem(props) { ? t('common.forms.languageLiterals.unKnownLanguagePromptText') : t('common.forms.languageLiterals.knownLanguagePromptText'); + const routinghandler = () => { + const type = onClickHandle?.entityType; + const id = onClickHandle?.entityId; + + if (onClickHandle?.test) { + onClickHandle?.test(); + } + + if (type?.toUpperCase() == taxonomyClass.ORGANIZATION) + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Organizations}/${id}`); + else if (type?.toUpperCase() == taxonomyClass.PERSON) + navigate(`${PathName.Dashboard}/${calendarId}${PathName.People}/${id}`); + else if (type?.toUpperCase() == taxonomyClass.PLACE) + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Places}/${id}`); + else if (type?.toUpperCase() == taxonomyClass.EVENT) + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Events}/${id}`); + }; + return (
- navigate( - `${PathName.Dashboard}/${calendarId}${PathName.Places}${PathName.AddPlace}?id=${locationPlace?.key}`, - ), + entityType: locationPlace?.type ?? 'Place', + entityId: locationPlace?.key, }} /> )} @@ -914,10 +912,8 @@ function EventReadOnly() { itemWidth="100%" onClickHandle={{ navigationFlag: true, - navigationExecute: () => - navigate( - `${PathName.Dashboard}/${calendarId}${PathName.Organizations}${PathName.AddOrganization}?id=${organizer?.value}`, - ), + entityType: organizer?.type, + entityId: organizer?.value, }} /> ); @@ -1001,10 +997,8 @@ function EventReadOnly() { closable={false} onClickHandle={{ navigationFlag: true, - navigationExecute: () => - navigate( - `${PathName.Dashboard}/${calendarId}${PathName.People}${PathName.AddPerson}?id=${performer?.value}`, - ), + entityType: performer?.type, + entityId: performer?.value, }} itemWidth="100%" /> @@ -1032,6 +1026,11 @@ function EventReadOnly() { bordered itemWidth="100%" closable={false} + onClickHandle={{ + navigationFlag: true, + entityType: supporter?.type, + entityId: supporter?.value, + }} /> ); })} diff --git a/src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx b/src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx index ff71ed7b..8e37aa93 100644 --- a/src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx +++ b/src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx @@ -801,6 +801,11 @@ function PlaceReadOnly() { calendarContentLanguage={calendarContentLanguage} bordered itemWidth="423px" + onClickHandle={{ + navigationFlag: true, + entityType: containsPlace?.type ?? taxonomyClass.PLACE, + entityId: containsPlace?.key, + }} /> ); })} @@ -833,6 +838,11 @@ function PlaceReadOnly() { itemWidth="423px" calendarContentLanguage={calendarContentLanguage} bordered + onClickHandle={{ + navigationFlag: true, + entityType: locationPlace?.type ?? taxonomyClass.PLACE, + entityId: locationPlace?.key, + }} /> ) : (

} - // description={moment(event.startDateTime).format('YYYY-MM-DD')} + onClickHandle={{ + navigationFlag: true, + entityType: place?.type ?? taxonomyClass.PLACE, + entityId: place?._id, + }} calendarContentLanguage={calendarContentLanguage} bordered itemWidth="100%" @@ -907,6 +921,11 @@ function PlaceReadOnly() { data-cy="organization-logo" /> } + onClickHandle={{ + navigationFlag: true, + entityType: org?.type ?? taxonomyClass.ORGANIZATION, + entityId: org?._id, + }} calendarContentLanguage={calendarContentLanguage} bordered itemWidth="100%" @@ -937,6 +956,11 @@ function PlaceReadOnly() { calendarContentLanguage={calendarContentLanguage} icon={} bordered + onClickHandle={{ + navigationFlag: true, + entityType: person?.type ?? taxonomyClass.PERSON, + entityId: person?._id, + }} itemWidth="100%" />; })} @@ -965,6 +989,11 @@ function PlaceReadOnly() { icon={} description={moment(event.startDateTime).format('YYYY-MM-DD')} calendarContentLanguage={calendarContentLanguage} + onClickHandle={{ + navigationFlag: true, + entityType: event?.type ?? taxonomyClass.EVENT, + entityId: event?._id, + }} bordered itemWidth="100%" /> From fe192f967a77b07f4bc836931e91af0c23d4fd32 Mon Sep 17 00:00:00 2001 From: syam babu Date: Wed, 11 Sep 2024 14:18:20 +0530 Subject: [PATCH 3/6] feat: added navigation from OrganizationsReadOnly to other readonly page through selectioncard --- .../OrganizationsReadOnly.jsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx b/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx index 24910aee..e8cc5262 100644 --- a/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx +++ b/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx @@ -575,6 +575,11 @@ function OrganizationsReadOnly() { openingHours={locationPlace?.openingHours} calendarContentLanguage={calendarContentLanguage} bordered + onClickHandle={{ + navigationFlag: true, + entityType: locationPlace?.type ?? taxonomyClass.PLACE, + entityId: locationPlace?.value, + }} /> )} @@ -626,6 +631,11 @@ function OrganizationsReadOnly() { calendarContentLanguage={calendarContentLanguage} bordered itemWidth="100%" + onClickHandle={{ + navigationFlag: true, + entityType: place?.type ?? taxonomyClass.PLACE, + entityId: place?._id, + }} />; })}

@@ -652,6 +662,11 @@ function OrganizationsReadOnly() { icon={} calendarContentLanguage={calendarContentLanguage} bordered + onClickHandle={{ + navigationFlag: true, + entityType: person?.type ?? taxonomyClass.PERSON, + entityId: person?._id, + }} itemWidth="100%" />; })} @@ -681,6 +696,11 @@ function OrganizationsReadOnly() { description={moment(event.startDateTime).format('YYYY-MM-DD')} calendarContentLanguage={calendarContentLanguage} bordered + onClickHandle={{ + navigationFlag: true, + entityType: event?.type ?? taxonomyClass.EVENT, + entityId: event?._id, + }} itemWidth="100%" /> ); From 2464e4205067263c3ade12db36ef989b07f8e7d6 Mon Sep 17 00:00:00 2001 From: syam babu Date: Wed, 11 Sep 2024 14:20:28 +0530 Subject: [PATCH 4/6] feat: added navigation from PersonReadOnly to other readonly page by clicking selection card --- .../Dashboard/PersonReadOnly/PersonReadOnly.jsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx b/src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx index ba9f1cfb..490dc854 100644 --- a/src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx +++ b/src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx @@ -531,6 +531,11 @@ function PersonReadOnly() { icon={} calendarContentLanguage={calendarContentLanguage} bordered + onClickHandle={{ + navigationFlag: true, + entityType: place?.type ?? taxonomyClass.PLACE, + entityId: place?._id, + }} itemWidth="100%" />; })} @@ -565,6 +570,11 @@ function PersonReadOnly() { data-cy="organization-logo" /> } + onClickHandle={{ + navigationFlag: true, + entityType: org?.type ?? taxonomyClass.ORGANIZATION, + entityId: org?._id, + }} calendarContentLanguage={calendarContentLanguage} bordered itemWidth="100%" @@ -596,6 +606,11 @@ function PersonReadOnly() { icon={} description={moment(event.startDateTime).format('YYYY-MM-DD')} bordered + onClickHandle={{ + navigationFlag: true, + entityType: event?.type ?? taxonomyClass.EVENT, + entityId: event?._id, + }} calendarContentLanguage={calendarContentLanguage} itemWidth="100%" /> From 8cb0aee7e9f9ec316e5075b045d3eafa5454728c Mon Sep 17 00:00:00 2001 From: syam babu Date: Wed, 11 Sep 2024 14:32:39 +0530 Subject: [PATCH 5/6] feat: added naviagtion from user readonly page to entity page through SelectionItem component. closes #1252 --- .../Accordion/CalendarAccordion/CalendarAccordion.jsx | 11 +++++++++++ src/components/List/SelectionItem/SelectionItem.jsx | 7 ++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/components/Accordion/CalendarAccordion/CalendarAccordion.jsx b/src/components/Accordion/CalendarAccordion/CalendarAccordion.jsx index 0a7b2051..a796242c 100644 --- a/src/components/Accordion/CalendarAccordion/CalendarAccordion.jsx +++ b/src/components/Accordion/CalendarAccordion/CalendarAccordion.jsx @@ -23,6 +23,7 @@ import { sortByOptionsOrgsPlacesPerson } from '../../../constants/sortByOptions' import { useLazyGetAllOrganizationQuery } from '../../../services/organization'; import { UserOutlined } from '@ant-design/icons'; import { useLazyGetAllPeopleQuery } from '../../../services/people'; +import { taxonomyClass } from '../../../constants/taxonomyClass'; const { Panel } = Collapse; @@ -362,6 +363,11 @@ function CalendarAccordion(props) { name={organizer?.name} description={organizer?.description} bordered + onClickHandle={{ + navigationFlag: readOnly, + entityType: organizer?.type ?? taxonomyClass.ORGANIZATION, + entityId: organizer?.value, + }} closable={readOnly ? false : true} itemWidth="100%" onClose={() => { @@ -477,6 +483,11 @@ function CalendarAccordion(props) { ) } + onClickHandle={{ + navigationFlag: readOnly, + entityType: people?.type ?? taxonomyClass.PERSON, + entityId: people?.value, + }} name={people?.name} description={people?.description} calendarContentLanguage={calendarContentLanguage} diff --git a/src/components/List/SelectionItem/SelectionItem.jsx b/src/components/List/SelectionItem/SelectionItem.jsx index ad93f7df..0115e9d0 100644 --- a/src/components/List/SelectionItem/SelectionItem.jsx +++ b/src/components/List/SelectionItem/SelectionItem.jsx @@ -63,13 +63,10 @@ function SelectionItem(props) { ? t('common.forms.languageLiterals.unKnownLanguagePromptText') : t('common.forms.languageLiterals.knownLanguagePromptText'); - const routinghandler = () => { + const routinghandler = (e) => { const type = onClickHandle?.entityType; const id = onClickHandle?.entityId; - - if (onClickHandle?.test) { - onClickHandle?.test(); - } + e.stopPropagation(); if (type?.toUpperCase() == taxonomyClass.ORGANIZATION) navigate(`${PathName.Dashboard}/${calendarId}${PathName.Organizations}/${id}`); From f453e8c42d44073b2edbb41bbdc2a90daae28f38 Mon Sep 17 00:00:00 2001 From: syam babu Date: Fri, 13 Sep 2024 10:51:08 +0530 Subject: [PATCH 6/6] fix: returns interface language data as first priority if required language is not available and if interface language data is available --- src/utils/bilingual.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/utils/bilingual.js b/src/utils/bilingual.js index 9c4123ac..8c593c7c 100644 --- a/src/utils/bilingual.js +++ b/src/utils/bilingual.js @@ -1,5 +1,6 @@ //Function which returns the language key depending on the interface language +import i18next from 'i18next'; import { contentLanguage, contentLanguageKeyMap } from '../constants/contentLanguage'; import { userLanguages } from '../constants/userLanguages'; @@ -39,14 +40,25 @@ export const contentLanguageBilingual = ({ calendarContentLanguage, data, requir **/ if (!data) return ''; + if (requiredLanguageKey && data[requiredLanguageKey]) { return data[requiredLanguageKey]; } + const interfaceLanguage = i18next.language; + + const isInterfaceLanguageDataAvailable = calendarContentLanguage.some( + (lang) => contentLanguageKeyMap[lang] === interfaceLanguage && data[interfaceLanguage], + ); + + if (isInterfaceLanguageDataAvailable) { + return data[interfaceLanguage]; + } + let contentLanguageKey = contentLanguageKeyMap[calendarContentLanguage[0]]; - if (data[contentLanguageKey] === undefined) { + if (!data[contentLanguageKey]) { contentLanguageKey = - Object.values(contentLanguageKeyMap).find((key) => data[key] !== undefined) || Object.keys(data)[0]; // Fallback to the first key in data + Object.values(contentLanguageKeyMap).find((key) => data[key] !== undefined) || Object.keys(data)[0]; } return data[contentLanguageKey] ?? '';