* Feature: Canvas layer enhancements(DIP) * feedback fixes * fixing build * dip * dip * dip * fixing build * dip * dev fixes * dip * Fixing top bottom resize handles * dip * reposition widget name on top edges. * dip * dip * dip * dip * renaming selectedWidget to lastSelectedWidget * code clean up * Fixing list widget as per grid scale. * Fixing existing specs. * Adding migration test cases. * dip * FIxing proppane in modal. * fixing modal z-indedx. * fix for modal name. * dip * dip * dip * adding test cases for hotkeys. * dip * dip * fixing build * Trying some performance improvements for jests. * 17 mins with runinband lets try without it. * minor bug fixes. * code clean up * save migrated app on fetch. * fixing few cypress tests * fixing cypress tests * fixing cypress tests. * fixing cypress * updated DSL * Addressing code review comments. * test fails * dip * eslint fixes. * fixing debugger cypress tests. * updating latest page version. * updating migration changes to cypress dsl's. * updating chart data fixes for cypress tests. Co-authored-by: Apple <nandan@thinkify.io>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { makeFactory } from "factory.ts";
|
|
import { WidgetProps } from "widgets/BaseWidget";
|
|
import { ContainerWidgetProps } from "widgets/ContainerWidget";
|
|
import defaultTemplate from "../../src/templates/default";
|
|
import { WidgetTypeFactories } from "./Widgets/WidgetTypeFactories";
|
|
const defaultMainContainer: ContainerWidgetProps<WidgetProps> = {
|
|
...(defaultTemplate as any),
|
|
renderMode: "PAGE",
|
|
version: 1,
|
|
isLoading: false,
|
|
};
|
|
|
|
export const mainContainerFactory = makeFactory({ ...defaultMainContainer });
|
|
export const widgetCanvasFactory = makeFactory(mainContainerFactory.build());
|
|
const buildChild = (child: Partial<WidgetProps>): WidgetProps => {
|
|
return WidgetTypeFactories[child.type || "CANVAS_WIDGET"].build({
|
|
...child,
|
|
});
|
|
};
|
|
export const buildChildren = (children: Partial<WidgetProps>[]) => {
|
|
try {
|
|
return children.map((child) => {
|
|
return buildChild(child);
|
|
});
|
|
} catch (error) {
|
|
console.error("Check if child widget data provided");
|
|
}
|
|
};
|
|
|
|
export const buildDslWithChildren = (childData: Partial<WidgetProps>[]) => {
|
|
const children: any = buildChildren(childData);
|
|
return widgetCanvasFactory.build({
|
|
children,
|
|
});
|
|
};
|