Skip to content

Commit

Permalink
fix: made the __designer part optional
Browse files Browse the repository at this point in the history
  • Loading branch information
pksorensen committed Nov 27, 2024
1 parent f024002 commit d58fa8e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/designer/src/Components/Drawers/SlideTreeItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const SlideTreeItem: React.FC<SlideTreeItemProps> = ({ setView, setActiveSlide,
}

old.layout.slides[id] = { title: "New Slide", schemaName: "NewSlide", logicalName: "newslide" };
old.__designer.activeSlide = id;
old.__designer = { ...old.__designer ?? {}, activeSlide: id };
return { ...old };
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,9 @@ export const QuickFormSettingsViewHeader: React.FC = () => {
let logicalName = schemaName.toLowerCase();

old.questions[activeQuestion] = { ...old.questions[activeQuestion], schemaName, logicalName, displayName };
// if (text !== activeQuestion)
// delete old.questions[activeQuestion];

if (!old.__designer)
old.__designer = {};

old.__designer.activeQuestion = text;


old.__designer = { ...old.__designer ?? {}, activeQuestion: text };

return { ...old };
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const QuickFormLayoutView = ({ dispatch, slideId, layout }: {

if (oldName !== name) {
dispatch(old => {
const oldslideid = old.__designer.activeSlide!;
const oldslideid = old.__designer?.activeSlide!;
let title = name;
let schemaName = removeNonAlphanumeric(title);
let logicalName = schemaName.toLowerCase();
Expand All @@ -190,10 +190,9 @@ export const QuickFormLayoutView = ({ dispatch, slideId, layout }: {

old.layout.slides[oldslideid] = { ...old.layout.slides[oldslideid], title, schemaName, logicalName };

if (!old.__designer)
old.__designer = {};

old.__designer.activeSlide = oldslideid;
old.__designer = { ...old.__designer ?? {}, activeSlide: oldslideid };

return { ...old };
});
}
Expand All @@ -213,7 +212,7 @@ export const QuickFormLayoutView = ({ dispatch, slideId, layout }: {
if (!quickform.layout.slides)
quickform.layout.slides = {};

let slide = quickform.layout.slides[quickform.__designer.activeSlide!];
let slide = quickform.layout.slides[quickform.__designer?.activeSlide!];
if (!slide)
return quickform;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ export const QuickFormQuestionsView: React.FC<{
old.questions[logicalName] = { ...old.questions[currentQuestion], text, schemaName, logicalName };
delete old.questions[currentQuestion];

if (!old.__designer)
old.__designer = {};

old.__designer.activeQuestion = logicalName;

old.__designer = { ...old.__designer ?? {}, activeQuestion: logicalName };

} else {
old.questions[currentQuestion] = { ...question, text: data.value };
}
Expand Down
2 changes: 1 addition & 1 deletion packages/designer/src/Hooks/useDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare module "@eavfw/quickform-core" {
displayName?: string;
}
interface QuickFormDefinition {
__designer: QuickFormDesignerState,
__designer?: QuickFormDesignerState,
designerLocale?: Locale,
}
}
Expand Down

0 comments on commit d58fa8e

Please sign in to comment.