Skip to content

Commit

Permalink
fix related plannings not visible in the editor
Browse files Browse the repository at this point in the history
it was only working with primary events, not secondary

STT-72
  • Loading branch information
petrjasek committed Sep 12, 2024
1 parent d66d736 commit 6d6eec5
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/actions/eventsPlanning/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const refetchPlanning = (planningId) => (
(dispatch, getState) => {
const storedPlannings = selectors.planning.storedPlannings(getState());
const plan = get(storedPlannings, planningId);
const relatedEventIds = getRelatedEventIdsForPlanning(plan, 'primary');
const relatedEventIds = getRelatedEventIdsForPlanning(plan);
const eventId = relatedEventIds.length > 0 ? relatedEventIds[0] : undefined;
const events = selectors.eventsPlanning.getRelatedPlanningsList(getState()) || {};

Expand Down
2 changes: 1 addition & 1 deletion client/actions/planning/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const duplicate = (plan) => (
.then((newPlan) => {
notify.success(gettext('Planning duplicated'));
const openInModal = selectors.forms.currentItemIdModal(getState());
const relatedEventIds = getRelatedEventIdsForPlanning(plan, 'primary');
const relatedEventIds = getRelatedEventIdsForPlanning(plan);

if (relatedEventIds.length > 0) {
dispatch(main.unlockAndCancel(plan)).then(() => {
Expand Down
2 changes: 1 addition & 1 deletion client/api/editor/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function getItemInstance(type: EDITOR_TYPE): IEditorAPI['item'] {
return Object.keys(plans)
.filter((planId) => (
plans[planId] != null &&
getRelatedEventIdsForPlanning(plans[planId], 'primary').includes(eventId))
getRelatedEventIdsForPlanning(plans[planId]).includes(eventId))
)
.map((planId) => cloneDeep(plans[planId]));
}
Expand Down
2 changes: 1 addition & 1 deletion client/api/editor/item_planning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function getPlanningInstance(type: EDITOR_TYPE): IEditorAPI['item']['plan
const profile = planningApi.contentProfiles.get('planning');
const groups = getEditorFormGroupsFromProfile(profile);

if (getRelatedEventLinksForPlanning(item, 'primary').length === 0) {
if (getRelatedEventLinksForPlanning(item).length === 0) {
delete groups['associated_event'];
}
const bookmarks = getBookmarksFromFormGroups(groups);
Expand Down
2 changes: 1 addition & 1 deletion client/components/Planning/PlanningDateTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const PlanningDateTime = ({
}: IProps) => {
const coverages = get(item, 'coverages', []);
const coverageTypes = planningUtils.mapCoverageByDate(coverages);
const hasAssociatedEvent = getRelatedEventIdsForPlanning(item, 'primary').length > 0;
const hasAssociatedEvent = getRelatedEventIdsForPlanning(item).length > 0;
const isSameDay = (scheduled) => scheduled && (date == null || moment(scheduled).format('YYYY-MM-DD') === date);
const coverageToDisplay = coverageTypes.filter((coverage) => {
const scheduled = get(coverage, 'planning.scheduled');
Expand Down
2 changes: 1 addition & 1 deletion client/utils/planning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export function mapCoverageByDate(coverages: Array<IPlanningCoverageItem> = []):

// ad hoc plan created directly from planning list and not from an event
function isPlanAdHoc(plan: IPlanningItem): boolean {
return getRelatedEventLinksForPlanning(plan, 'primary').length === 0;
return getRelatedEventLinksForPlanning(plan).length === 0;
}

function isPlanMultiDay(plan: IPlanningItem): boolean {
Expand Down
2 changes: 1 addition & 1 deletion server/planning/search/queries/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def search_by_events(params: Dict[str, Any], query: elastic.ElasticQuery):
elastic.bool_and(
[
elastic.terms(field="related_events._id", values=event_ids),
elastic.term(field="related_events.link_type", value="primary"),
# elastic.term(field="related_events.link_type", value="primary"),
],
"related_events",
)
Expand Down

0 comments on commit 6d6eec5

Please sign in to comment.