Skip to content

Commit

Permalink
Fix incorrect usage of condition plan specs array as dictionary (#1604)
Browse files Browse the repository at this point in the history
* remove redundant owner check since non-owner users do not see conditions in order to add in the first place
  • Loading branch information
duranb authored Jan 29, 2025
1 parent 4b442be commit 49bb143
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/modals/ManagePlanSchedulingConditionsModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<script lang="ts">
import { base } from '$app/paths';
import type { CellEditingStoppedEvent, ICellRendererParams, ValueGetterParams } from 'ag-grid-community';
import { keyBy } from 'lodash-es';
import { createEventDispatcher } from 'svelte';
import { PlanStatusMessages } from '../../enums/planStatusMessages';
import { SearchParameters } from '../../enums/searchParameters';
Expand Down Expand Up @@ -100,13 +101,18 @@
let columnDefs = baseColumnDefs;
let allowedSchedulingConditionSpecsMap: Record<
SchedulingConditionPlanSpecification['condition_id'],
SchedulingConditionPlanSpecification
> = {};
let dataGrid: DataGrid<SchedulingConditionMetadata> | undefined = undefined;
let filterText: string = '';
let filteredConditions: SchedulingConditionMetadata[] = [];
let hasCreatePermission: boolean = false;
let hasEditSpecPermission: boolean = false;
let selectedConditions: Record<string, boolean> = {};
$: allowedSchedulingConditionSpecsMap = keyBy($allowedSchedulingConditionSpecs, 'condition_id');
$: filteredConditions = $schedulingConditions
// TODO: remove this after db merge as it becomes redundant
.filter(({ owner, public: isPublic }) => {
Expand Down Expand Up @@ -221,10 +227,10 @@
) => {
const conditionId = parseInt(selectedConditionId);
const isSelected = selectedConditions[conditionId];
const conditionPlanSpec = $allowedSchedulingConditionSpecs[conditionId];
const conditionPlanSpec = allowedSchedulingConditionSpecsMap[conditionId];
if (isSelected && $schedulingPlanSpecification !== null) {
if (!conditionPlanSpec || conditionPlanSpec.condition_metadata?.owner === user?.id) {
if (!conditionPlanSpec) {
return {
...prevConditionPlanSpecUpdates,
conditionPlanSpecsToAdd: [
Expand Down

0 comments on commit 49bb143

Please sign in to comment.