Skip to content

Commit

Permalink
Merge pull request #1407 from culturecreates/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sahalali authored Oct 17, 2024
2 parents 417d762 + 6024671 commit 60dffbc
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 20 deletions.
16 changes: 3 additions & 13 deletions src/components/Sort/Sort.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import { sortByOptionsOrgsPlacesPerson, sortOrder } from '../../constants/sortByOptions';
import { useTranslation } from 'react-i18next';
import { Button, Dropdown, Space } from 'antd';
import { SortAscendingOutlined, SortDescendingOutlined, DownOutlined, CloseCircleOutlined } from '@ant-design/icons';
import { SortAscendingOutlined, SortDescendingOutlined, DownOutlined } from '@ant-design/icons';

function Sort(props) {
const { filter, setFilter, setPageNumber, filterClearHandler } = props;
const { filter, setFilter, setPageNumber } = props;
const { t } = useTranslation();
const onSortOrderChange = () => {
if (filter?.order == sortOrder?.ASC)
Expand Down Expand Up @@ -43,6 +43,7 @@ function Sort(props) {
menu={{
items: sortByOptionsOrgsPlacesPerson,
selectable: true,
selectedKeys: [filter?.sort],
defaultSelectedKeys: [filter?.sort],
onSelect: onSortSelect,
}}
Expand Down Expand Up @@ -79,17 +80,6 @@ function Sort(props) {
size={'large'}
data-cy="button-sort-order"
/>
{(filter?.order === sortOrder?.DESC || filter?.sort != sortByOptionsOrgsPlacesPerson[0]?.key) && (
<Button
size="large"
className="filter-buttons"
style={{ color: '#1B3DE6' }}
onClick={filterClearHandler}
data-cy="button-filter-clear">
{t('dashboard.events.filter.clear')}&nbsp;
<CloseCircleOutlined style={{ color: '#1B3DE6', fontSize: '16px' }} />
</Button>
)}
</div>
);
}
Expand Down
13 changes: 13 additions & 0 deletions src/constants/sortByOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export const sortByOptions = [
label: <Translation>{(t) => t('dashboard.events.filter.sort.createdDate')}</Translation>,
key: 'metadata.createdAt',
},
{
label: <Translation>{(t) => t('dashboard.events.filter.sort.dateModified')}</Translation>,
key: 'metadata.modifiedAt',
},
{
label: <Translation>{(t) => t('dashboard.events.filter.sort.eventDate')}</Translation>,
key: 'upcomingEventDate',
Expand All @@ -31,6 +35,11 @@ export const sortByOptionsOrgsPlacesPerson = [
key: 'metadata.createdAt',
['data-cy']: 'createdDate',
},
{
label: <Translation>{(t) => t('dashboard.events.filter.sort.dateModified')}</Translation>,
key: 'metadata.modifiedAt',
['data-cy']: 'modifiedAt',
},
];

export const sortByOptionsUsers = [
Expand Down Expand Up @@ -61,4 +70,8 @@ export const sortByOptionsTaxonomy = [
label: <Translation>{(t) => t('dashboard.taxonomy.listing.sort.createdDate')}</Translation>,
key: 'metadata.createdAt',
},
{
label: <Translation>{(t) => t('dashboard.events.filter.sort.dateModified')}</Translation>,
key: 'metadata.modifiedAt',
},
];
3 changes: 2 additions & 1 deletion src/locales/en/translationEn.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"sortBy": "Sort by",
"name": "Name",
"createdDate": "Date created",
"eventDate": "Event date"
"eventDate": "Event date",
"dateModified": "Date modified"
},
"dates": {
"dates": "Dates",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr/transalationFr.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"sortBy": "Trier par",
"name": "Nom",
"createdDate": "Date de création",
"dateModified": "Date de modification",
"eventDate": "Date d’événement"
},
"dates": {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Dashboard/Events/Events.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function Events() {
: [],
sort: searchParams.get('sortBy')
? searchParams.get('sortBy')
: sessionStorage.getItem('sortBy') ?? sortByOptions[2]?.key,
: sessionStorage.getItem('sortBy') ?? sortByOptions[3]?.key,
order: searchParams.get('order') ? searchParams.get('order') : sessionStorage.getItem('order') ?? sortOrder?.ASC,
dates:
(searchParams.get('startDateRange') || sessionStorage.getItem('startDateRange')) &&
Expand Down Expand Up @@ -358,7 +358,7 @@ function Events() {
const filterClearHandler = () => {
setFilter({
publication: [],
sort: sortByOptions[2]?.key,
sort: sortByOptions[3]?.key,
order: sortOrder?.ASC,
dates: [],
});
Expand Down Expand Up @@ -1034,7 +1034,7 @@ function Events() {
filter?.publication?.length > 0 ||
filter?.dates?.length > 0 ||
filter?.order === sortOrder?.DESC ||
filter?.sort != sortByOptions[2]?.key ||
filter?.sort != sortByOptions[3]?.key ||
organizerFilter?.length > 0 ||
Object.keys(taxonomyFilter)?.length > 0 ||
Object.keys(standardTaxonomyFilter)?.length > 0) && (
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Dashboard/Organizations/Organizations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ function Organizations() {
);
})}
<Col>
{(filter?.order === sortOrder?.DESC || Object.keys(taxonomyFilter)?.length > 0) && (
{(filter?.order === sortOrder?.DESC ||
Object.keys(taxonomyFilter)?.length > 0 ||
filter?.sort != sortByOptionsOrgsPlacesPerson[0]?.key) && (
<Button
size="large"
className="filter-buttons"
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Dashboard/People/People.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ function People() {
<Col>
{(filter?.order === sortOrder?.DESC ||
Object.keys(taxonomyFilter)?.length > 0 ||
Object.keys(standardTaxonomyFilter)?.length > 0) && (
Object.keys(standardTaxonomyFilter)?.length > 0 ||
filter?.sort != sortByOptionsOrgsPlacesPerson[0]?.key) && (
<Button
size="large"
className="filter-buttons"
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Dashboard/Places/Places.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ function Places() {
<Col>
{(filter?.order === sortOrder?.DESC ||
Object.keys(taxonomyFilter)?.length > 0 ||
Object.keys(standardTaxonomyFilter)?.length > 0) && (
Object.keys(standardTaxonomyFilter)?.length > 0 ||
filter?.sort != sortByOptionsOrgsPlacesPerson[0]?.key) && (
<Button
size="large"
className="filter-buttons"
Expand Down

0 comments on commit 60dffbc

Please sign in to comment.