Skip to content

Commit

Permalink
Merge pull request #1326 from culturecreates/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sahalali authored Sep 13, 2024
2 parents 57d75c9 + 605e9c2 commit be483fa
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/components/Accordion/CalendarAccordion/CalendarAccordion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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={() => {
Expand Down Expand Up @@ -477,6 +483,11 @@ function CalendarAccordion(props) {
<UserOutlined style={{ color: '#607EFC' }} />
)
}
onClickHandle={{
navigationFlag: readOnly,
entityType: people?.type ?? taxonomyClass.PERSON,
entityId: people?.value,
}}
name={people?.name}
description={people?.description}
calendarContentLanguage={calendarContentLanguage}
Expand Down
29 changes: 27 additions & 2 deletions src/components/List/SelectionItem/SelectionItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -33,10 +36,12 @@ function SelectionItem(props) {
edit,
creatorId,
fallbackConfig,
onClickHandle = { navigationFlag: false },
} = props;
const { t } = useTranslation();
const { user } = useSelector(getUserDetails);

const navigate = useNavigate();
const { calendarId } = useParams();
let literalKey = '?';

const promptFlag = calendarContentLanguage.some((language) => {
Expand All @@ -58,10 +63,30 @@ function SelectionItem(props) {
? t('common.forms.languageLiterals.unKnownLanguagePromptText')
: t('common.forms.languageLiterals.knownLanguagePromptText');

const routinghandler = (e) => {
const type = onClickHandle?.entityType;
const id = onClickHandle?.entityId;
e.stopPropagation();

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 (
<div
className="selection-item-wrapper"
style={{ border: bordered && '1px solid#607EFC', width: itemWidth && itemWidth }}>
onClick={onClickHandle?.navigationFlag && routinghandler}
style={{
border: bordered && '1px solid#607EFC',
width: itemWidth && itemWidth,
...(onClickHandle?.navigationFlag && { cursor: 'pointer' }),
}}>
<List.Item
className="selection-item-list-wrapper"
data-cy="list-item"
Expand Down
20 changes: 20 additions & 0 deletions src/pages/Dashboard/EventReadOnly/EventReadOnly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,11 @@ function EventReadOnly() {
openingHours={locationPlace?.openingHours}
calendarContentLanguage={calendarContentLanguage}
bordered
onClickHandle={{
navigationFlag: true,
entityType: locationPlace?.type ?? 'Place',
entityId: locationPlace?.key,
}}
/>
)}
</div>
Expand Down Expand Up @@ -905,6 +910,11 @@ function EventReadOnly() {
bordered
closable={false}
itemWidth="100%"
onClickHandle={{
navigationFlag: true,
entityType: organizer?.type,
entityId: organizer?.value,
}}
/>
);
})}
Expand Down Expand Up @@ -985,6 +995,11 @@ function EventReadOnly() {
calendarContentLanguage={calendarContentLanguage}
bordered
closable={false}
onClickHandle={{
navigationFlag: true,
entityType: performer?.type,
entityId: performer?.value,
}}
itemWidth="100%"
/>
);
Expand All @@ -1011,6 +1026,11 @@ function EventReadOnly() {
bordered
itemWidth="100%"
closable={false}
onClickHandle={{
navigationFlag: true,
entityType: supporter?.type,
entityId: supporter?.value,
}}
/>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,11 @@ function OrganizationsReadOnly() {
openingHours={locationPlace?.openingHours}
calendarContentLanguage={calendarContentLanguage}
bordered
onClickHandle={{
navigationFlag: true,
entityType: locationPlace?.type ?? taxonomyClass.PLACE,
entityId: locationPlace?.value,
}}
/>
)}
</Col>
Expand Down Expand Up @@ -626,6 +631,11 @@ function OrganizationsReadOnly() {
calendarContentLanguage={calendarContentLanguage}
bordered
itemWidth="100%"
onClickHandle={{
navigationFlag: true,
entityType: place?.type ?? taxonomyClass.PLACE,
entityId: place?._id,
}}
/>;
})}
</div>
Expand All @@ -652,6 +662,11 @@ function OrganizationsReadOnly() {
icon={<UserOutlined style={{ color: '#607EFC' }} />}
calendarContentLanguage={calendarContentLanguage}
bordered
onClickHandle={{
navigationFlag: true,
entityType: person?.type ?? taxonomyClass.PERSON,
entityId: person?._id,
}}
itemWidth="100%"
/>;
})}
Expand Down Expand Up @@ -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%"
/>
);
Expand Down
15 changes: 15 additions & 0 deletions src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,11 @@ function PersonReadOnly() {
icon={<EnvironmentOutlined style={{ color: '#607EFC' }} />}
calendarContentLanguage={calendarContentLanguage}
bordered
onClickHandle={{
navigationFlag: true,
entityType: place?.type ?? taxonomyClass.PLACE,
entityId: place?._id,
}}
itemWidth="100%"
/>;
})}
Expand Down Expand Up @@ -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%"
Expand Down Expand Up @@ -596,6 +606,11 @@ function PersonReadOnly() {
icon={<CalendarOutlined style={{ color: '#607EFC' }} />}
description={moment(event.startDateTime).format('YYYY-MM-DD')}
bordered
onClickHandle={{
navigationFlag: true,
entityType: event?.type ?? taxonomyClass.EVENT,
entityId: event?._id,
}}
calendarContentLanguage={calendarContentLanguage}
itemWidth="100%"
/>
Expand Down
31 changes: 30 additions & 1 deletion src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,11 @@ function PlaceReadOnly() {
calendarContentLanguage={calendarContentLanguage}
bordered
itemWidth="423px"
onClickHandle={{
navigationFlag: true,
entityType: containsPlace?.type ?? taxonomyClass.PLACE,
entityId: containsPlace?.key,
}}
/>
);
})}
Expand Down Expand Up @@ -833,6 +838,11 @@ function PlaceReadOnly() {
itemWidth="423px"
calendarContentLanguage={calendarContentLanguage}
bordered
onClickHandle={{
navigationFlag: true,
entityType: locationPlace?.type ?? taxonomyClass.PLACE,
entityId: locationPlace?.key,
}}
/>
) : (
<p
Expand Down Expand Up @@ -872,7 +882,11 @@ function PlaceReadOnly() {
: typeof place?.name === 'string' && place?.name
}
icon={<EnvironmentOutlined style={{ color: '#607EFC' }} />}
// description={moment(event.startDateTime).format('YYYY-MM-DD')}
onClickHandle={{
navigationFlag: true,
entityType: place?.type ?? taxonomyClass.PLACE,
entityId: place?._id,
}}
calendarContentLanguage={calendarContentLanguage}
bordered
itemWidth="100%"
Expand Down Expand Up @@ -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%"
Expand Down Expand Up @@ -937,6 +956,11 @@ function PlaceReadOnly() {
calendarContentLanguage={calendarContentLanguage}
icon={<CalendarOutlined style={{ color: '#607EFC' }} />}
bordered
onClickHandle={{
navigationFlag: true,
entityType: person?.type ?? taxonomyClass.PERSON,
entityId: person?._id,
}}
itemWidth="100%"
/>;
})}
Expand Down Expand Up @@ -965,6 +989,11 @@ function PlaceReadOnly() {
icon={<CalendarOutlined style={{ color: '#607EFC' }} />}
description={moment(event.startDateTime).format('YYYY-MM-DD')}
calendarContentLanguage={calendarContentLanguage}
onClickHandle={{
navigationFlag: true,
entityType: event?.type ?? taxonomyClass.EVENT,
entityId: event?._id,
}}
bordered
itemWidth="100%"
/>
Expand Down
16 changes: 14 additions & 2 deletions src/utils/bilingual.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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] ?? '';
Expand Down

0 comments on commit be483fa

Please sign in to comment.