Skip to content

Commit

Permalink
fix: ordering persistet and delete nodes working now in designer
Browse files Browse the repository at this point in the history
  • Loading branch information
pksorensen committed Jun 27, 2024
1 parent 75945c3 commit 512821d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/designer/src/Components/Views/QuickFormLayoutView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useEffect, useMemo } from "react";
import { removeNonAlphanumeric } from "@eavfw/utils";
import { SerializedNodes } from "@craftjs/core"
import { QuickFormDesignerDefinition } from "../../Types/QuickFormDefinition";
import { RowColumnsLayout } from "@eavfw/quickform-core/src/model/json-definitions/Layout";



Expand Down Expand Up @@ -78,7 +79,7 @@ export const QuickFormLayoutView = ({ dispatch, slideId, layout }: {
Object.fromEntries(
Object.entries(
layout.slides[slideId]?.rows ?? {
}).map(([rowid, row]) => {
}).sort(([a, aa], [b, bb]) => (aa.order??-1) - (bb.order??-1)).map(([rowid, row]) => {

if (row.type !== "row")
throw new Error("Only Row is supported currently");
Expand Down Expand Up @@ -215,24 +216,27 @@ export const QuickFormLayoutView = ({ dispatch, slideId, layout }: {
if (!slide)
return quickform;

for (let rowid of nodes?.ROOT.nodes) {
slide.rows = Object.fromEntries(nodes?.ROOT.nodes.map((rowid) => {

let row = nodes[rowid];
if (!row.props.questionid)
continue;
return [];

const type = typeof row.type === "string" ? row.type : row.type.resolvedName;
if (type !== "Question")
continue;
return [];


if (!slide.rows)
slide.rows = {};

slide.rows[rowid] = {
return [[rowid, {
...slide.rows?.[rowid] ?? {},
type: "row",
order: nodes?.ROOT.nodes.indexOf(rowid),
columns: { "column1": { type: "question", ref: row.props.questionid } }
};
}
} as RowColumnsLayout]];

}).flat());


return { ...quickform };
});
Expand Down

0 comments on commit 512821d

Please sign in to comment.