Skip to content

Commit

Permalink
fix: Error occuring when adding a data task after creating a subform (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ErlingHauan authored Oct 11, 2024
1 parent a591d37 commit 63247ee
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion backend/src/Designer/Models/LayoutSets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public class LayoutSetConfig
public string Id { get; set; }

[JsonPropertyName("dataType")]
[CanBeNull] public string DataType { get; set; }
[CanBeNull]
public string DataType { get; set; }

[JsonPropertyName("tasks")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[CanBeNull]
public List<string> Tasks { get; set; }

[JsonPropertyName("type")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public async Task<LayoutSets> AddLayoutSet(AltinnRepoEditingContext altinnRepoEd
{
throw new NonUniqueLayoutSetIdException($"Layout set name, {newLayoutSet.Id}, already exists.");
}
if (newLayoutSet.Tasks != null && layoutSets.Sets.Exists(set => set.Tasks[0] == newLayoutSet.Tasks[0]))
if (newLayoutSet.Tasks != null && layoutSets.Sets.Exists(set => set.Tasks?[0] == newLayoutSet.Tasks[0]))
{
throw new NonUniqueTaskForLayoutSetException($"Layout set with task, {newLayoutSet.Tasks[0]}, already exists.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { LayoutSets } from 'app-shared/types/api/LayoutSetsResponse';

export const getLayoutSetIdFromTaskId = (elementId: string, layoutSets: LayoutSets) => {
const layoutSet = layoutSets.sets.find((set) => set.tasks[0] === elementId);
const layoutSet = layoutSets.sets.find((set) => set.tasks && set.tasks[0] === elementId);
return layoutSet?.id;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ export const ConfigContent = (): React.ReactElement => {
const { t } = useTranslation();
const { bpmnDetails } = useBpmnContext();
const { layoutSets, availableDataModelIds } = useBpmnApiContext();
const layoutSet = layoutSets?.sets.find((set) => set.tasks.includes(bpmnDetails.id));
const layoutSet = layoutSets?.sets.find((set) => set.tasks?.includes(bpmnDetails.id));
const existingDataTypeForTask = layoutSet?.dataType;
const isSigningTask = bpmnDetails.taskType === 'signing';

const taskHasConnectedLayoutSet = layoutSets?.sets?.some((set) => set.tasks[0] == bpmnDetails.id);
const taskHasConnectedLayoutSet = layoutSets?.sets?.some(
(set) => set.tasks && set.tasks[0] == bpmnDetails.id,
);
const { shouldDisplayAction } = useStudioRecommendedNextActionContext();

const studioModeler = new StudioModeler();
Expand Down

0 comments on commit 63247ee

Please sign in to comment.