Skip to content

Commit

Permalink
Multilingual Planning: filter by language and display in the respecti…
Browse files Browse the repository at this point in the history
…ve language when using the 'Event and Planning filters' [SDESK-7138] (#1887)
  • Loading branch information
devketanpro authored Dec 7, 2023
1 parent c8aa073 commit 559f72c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
10 changes: 9 additions & 1 deletion client/apps/Planning/PlanningList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
IContactItem,
SORT_FIELD,
ICommonSearchParams,
ISearchFilter,
} from '../../interfaces';

import * as actions from '../../actions';
Expand Down Expand Up @@ -61,6 +62,7 @@ interface IProps {
listViewType: LIST_VIEW_TYPE;
sortField: SORT_FIELD;
currentSearch: ICommonSearchParams<IEventOrPlanningItem>;
searchFilters: Array<ISearchFilter>;

openPreview(item: IEventOrPlanningItem): void;
edit(item: IEventOrPlanningItem): void;
Expand Down Expand Up @@ -94,7 +96,8 @@ const mapStateToProps = (state) => ({
contacts: selectors.general.contactsById(state),
listViewType: selectors.main.getCurrentListViewType(state),
sortField: selectors.main.getCurrentSortField(state),
currentSearch: selectors.main.currentSearch(state)
currentSearch: selectors.main.currentSearch(state),
searchFilters: selectors.eventsPlanning.combinedViewFilters(state),
});

const mapDispatchToProps = (dispatch) => ({
Expand Down Expand Up @@ -140,6 +143,10 @@ export class PlanningListComponent extends React.PureComponent<IProps> {
}

render() {
const activeSearchFilter = this.props.searchFilters.filter((filter) =>
filter.item_type === FILTER_TYPE[this.props.activeFilter] &&
filter._id === this.props.currentSearch?.filter_id);

const {
groups,
agendas,
Expand Down Expand Up @@ -211,6 +218,7 @@ export class PlanningListComponent extends React.PureComponent<IProps> {
sortField={sortField}
indexItems
searchParams={currentSearch.advancedSearch}
searchFilterParams={activeSearchFilter[0]?.params}
/>
</React.Fragment>
);
Expand Down
11 changes: 9 additions & 2 deletions client/components/Main/ListGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import React from 'react';
import moment from 'moment-timezone';
import {ListGroupItem} from './';
import {Group, Header} from '../UI/List';
import {ICommonAdvancedSearchParams, IEventOrPlanningItem, LIST_VIEW_TYPE, SORT_FIELD} from '../../interfaces';
import {
ICommonAdvancedSearchParams,
IEventOrPlanningItem, ISearchFilter,
LIST_VIEW_TYPE, SORT_FIELD
} from '../../interfaces';
import {timeUtils} from '../../utils';

const TIME_COLUMN_MIN_WIDTH = {
Expand Down Expand Up @@ -78,7 +82,8 @@ interface IProps {
listViewType?: string;
sortField?: string;
listBoxGroupProps: {};
searchParams:ICommonAdvancedSearchParams;
searchParams?: ICommonAdvancedSearchParams;
searchFilterParams?: ISearchFilter['params'];
}

export class ListGroup extends React.Component<IProps> {
Expand Down Expand Up @@ -147,6 +152,7 @@ export class ListGroup extends React.Component<IProps> {
sortField,
listBoxGroupProps,
searchParams,
searchFilterParams,
} = this.props;

// with defaults
Expand Down Expand Up @@ -208,6 +214,7 @@ export class ListGroup extends React.Component<IProps> {
sortField: sortField,
minTimeWidth: minTimeWidth,
searchParams: searchParams,
searchFilterParams: searchFilterParams,
};

if (indexItems) {
Expand Down
8 changes: 5 additions & 3 deletions client/components/Main/ListGroupItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
IEventListItemProps,
IPlanningListItemProps,
IEventOrPlanningItem,
IEventItem, IPlanningItem, IBaseListItemProps, ICommonAdvancedSearchParams
IEventItem, IPlanningItem, IBaseListItemProps, ICommonAdvancedSearchParams, ISearchFilter
} from '../../interfaces';

import {EventItem, EventItemWithPlanning} from '../Events';
Expand All @@ -27,6 +27,7 @@ interface IProps extends Omit<
navigateDown?: boolean;
minTimeWidth?: string;
searchParams?: ICommonAdvancedSearchParams;
searchFilterParams?: ISearchFilter['params'];

onDoubleClick(item: IEventOrPlanningItem): void;
showRelatedPlannings(item: IEventItem): void;
Expand Down Expand Up @@ -123,6 +124,7 @@ export class ListGroupItem extends React.Component<IProps, IState> {
sortField,
minTimeWidth,
searchParams,
searchFilterParams,
} = this.props;
const itemType = getItemType(item);

Expand Down Expand Up @@ -152,7 +154,7 @@ export class ListGroupItem extends React.Component<IProps, IState> {
...itemProps,
item: item as IEventItem,
calendars: calendars,
filterLanguage: searchParams?.language,
filterLanguage: searchParams?.language || searchFilterParams?.language,
multiSelected: indexOf(selectedEventIds, item._id) !== -1,
[EVENTS.ITEM_ACTIONS.EDIT_EVENT.actionName]:
itemActions[EVENTS.ITEM_ACTIONS.EDIT_EVENT.actionName],
Expand Down Expand Up @@ -195,7 +197,7 @@ export class ListGroupItem extends React.Component<IProps, IState> {
contentTypes: contentTypes,
agendas: agendas,
date: date,
filterLanguage: searchParams?.language,
filterLanguage: searchParams?.language || searchFilterParams?.language,
onAddCoverageClick: onAddCoverageClick,
multiSelected: indexOf(selectedPlanningIds, item._id) !== -1,
showAddCoverage: showAddCoverage,
Expand Down
8 changes: 6 additions & 2 deletions client/components/Main/ListPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
IEventOrPlanningItem, IG2ContentType,
ILockedItems,
IPlanningItem,
ISearchFilter,
ISession, LIST_VIEW_TYPE, SORT_FIELD
} from '../../interfaces';

Expand Down Expand Up @@ -68,7 +69,8 @@ interface IProps {
listViewType: LIST_VIEW_TYPE;
sortField: SORT_FIELD;
userInitiatedSearch?: boolean;
searchParams?: ICommonAdvancedSearchParams
searchParams?: ICommonAdvancedSearchParams,
searchFilterParams?: ISearchFilter['params']

onItemClick(item: IEventOrPlanningItem): void;
onDoubleClick(item: IEventOrPlanningItem): void;
Expand Down Expand Up @@ -319,7 +321,8 @@ export class ListPanel extends React.Component<IProps, IState> {
contacts,
listViewType,
sortField,
searchParams
searchParams,
searchFilterParams,
} = this.props;

let indexFrom = 0;
Expand Down Expand Up @@ -399,6 +402,7 @@ export class ListPanel extends React.Component<IProps, IState> {
sortField: sortField,
listBoxGroupProps: listBoxGroupProps,
searchParams: searchParams,
searchFilterParams: searchFilterParams,
...propsForNestedListItems,
};

Expand Down

0 comments on commit 559f72c

Please sign in to comment.