Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[STTNHUB-379] fix: Planning items not shown in event preview with AGENDA_DEFAULT_FILTER_HIDE_PLANNING config #1173

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assets/agenda/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ function setListGroupsAndLoadHiddenItems(items: Array<IAgendaItem>, next?: boole

// If there are groups shown, then load the hidden items for those groups
const state = getState();
const {activeGrouping, featuredOnly} = state.agenda;
const {activeGrouping, featuredOnly, itemType} = state.agenda;
const {fromDate, toDate, searchParams} = getAgendaSearchParamsFromState(state);

let minDate: moment.Moment | undefined;
Expand Down Expand Up @@ -376,7 +376,7 @@ function setListGroupsAndLoadHiddenItems(items: Array<IAgendaItem>, next?: boole
}

const groups: Array<IAgendaListGroup> = (searchParams.sortQuery ?? '') === '' ?
groupItems(items, minDate, maxDate, activeGrouping, featuredOnly) :
groupItems(items, minDate, maxDate, activeGrouping, featuredOnly, itemType) :
[{
date: '',
items: items.map((item) => item._id),
Expand Down
18 changes: 15 additions & 3 deletions assets/agenda/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import {get, isEmpty, keyBy, sortBy} from 'lodash';
import moment from 'moment/moment';

import {IAgendaItem, IPlanningItem, IAgendaListGroup, IAgendaListGroupItem, ICoverage, IUser} from 'interfaces';
import {
IAgendaItem,
IPlanningItem,
IAgendaListGroup,
IAgendaListGroupItem,
ICoverage,
IUser,
IAgendaState
} from 'interfaces';
import {
formatDate,
formatMonth,
Expand Down Expand Up @@ -701,8 +709,12 @@ export function groupItems(
minDate: moment.Moment | undefined,
maxDate: moment.Moment | undefined,
activeGrouping: string,
featuredOnly?: boolean
featuredOnly?: boolean,
itemTypeFilter?: IAgendaState['agenda']['itemType']
): Array<IAgendaListGroup> {
const excludePlanningExtraDates = (itemTypeFilter == null || itemTypeFilter === 'events') &&
window.newsroom.client_config.agenda_default_filter_hide_planning === true;

if (items.length === 0) {
return [];
}
Expand All @@ -719,7 +731,7 @@ export function groupItems(
item._hits?.matched_coverages?.length
))
.forEach((item) => {
const itemExtraDates = getExtraDates(item);
const itemExtraDates = excludePlanningExtraDates ? [] : getExtraDates(item);
const itemStartDate = getStartDate(item);
let start: moment.Moment;

Expand Down
1 change: 1 addition & 0 deletions assets/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ interface IClientConfig {
show_user_register?: boolean;
multimedia_website_search_url?: string;
show_default_time_frame_label?: boolean;
agenda_default_filter_hide_planning: boolean;
}

interface Window {
Expand Down
4 changes: 4 additions & 0 deletions newsroom/agenda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@ def init_app(app):

if app.config.get("AGENDA_HIDE_COVERAGE_ASSIGNEES"):
PRIVATE_FIELDS.extend(["*.assigned_desk_*", "*.assigned_user_*"])

app.config["CLIENT_CONFIG"]["agenda_default_filter_hide_planning"] = app.config.get(
"AGENDA_DEFAULT_FILTER_HIDE_PLANNING", False
)
2 changes: 1 addition & 1 deletion newsroom/agenda/agenda.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def apply_filters(self, search: SearchQuery, section_filters=None):
},
}
)
_remove_fields(search.source, ["planning_items", "display_dates"])
_remove_fields(search.source, ["display_dates"])
else:
# Don't include Planning items that are associated with an Event
search.query["bool"]["filter"].append(
Expand Down
Loading