2019-11-25 05:07:27 +00:00
|
|
|
import { ReduxActionTypes, ReduxAction } from "constants/ReduxActionConstants";
|
|
|
|
|
import { RenderMode } from "constants/WidgetConstants";
|
2021-02-25 14:00:02 +00:00
|
|
|
import { DynamicPath } from "utils/DynamicBindingUtils";
|
2019-09-18 10:19:50 +00:00
|
|
|
|
2020-02-26 12:44:56 +00:00
|
|
|
export const updateWidgetPropertyRequest = (
|
2019-09-18 10:19:50 +00:00
|
|
|
widgetId: string,
|
2021-01-25 08:57:26 +00:00
|
|
|
propertyPath: string,
|
2019-09-18 10:19:50 +00:00
|
|
|
propertyValue: any,
|
2019-11-08 11:02:00 +00:00
|
|
|
renderMode: RenderMode,
|
2020-02-26 12:44:56 +00:00
|
|
|
): ReduxAction<UpdateWidgetPropertyRequestPayload> => {
|
2019-09-18 10:19:50 +00:00
|
|
|
return {
|
2019-11-06 06:35:15 +00:00
|
|
|
type: ReduxActionTypes.UPDATE_WIDGET_PROPERTY_REQUEST,
|
2019-09-18 10:19:50 +00:00
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
2021-01-25 08:57:26 +00:00
|
|
|
propertyPath,
|
2019-09-18 10:19:50 +00:00
|
|
|
propertyValue,
|
2019-11-08 11:02:00 +00:00
|
|
|
renderMode,
|
2019-09-18 10:19:50 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-01 09:45:54 +00:00
|
|
|
export interface BatchPropertyUpdatePayload {
|
|
|
|
|
modify?: Record<string, unknown>; //Key value pairs of paths and values to update
|
|
|
|
|
remove?: string[]; //Array of paths to delete
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 08:57:26 +00:00
|
|
|
export const batchUpdateWidgetProperty = (
|
|
|
|
|
widgetId: string,
|
2021-03-01 09:45:54 +00:00
|
|
|
updates: BatchPropertyUpdatePayload,
|
2021-01-25 08:57:26 +00:00
|
|
|
): ReduxAction<UpdateWidgetPropertyPayload> => ({
|
|
|
|
|
type: ReduxActionTypes.BATCH_UPDATE_WIDGET_PROPERTY,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
|
|
|
|
updates,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const deleteWidgetProperty = (
|
|
|
|
|
widgetId: string,
|
2021-02-16 10:29:08 +00:00
|
|
|
propertyPaths: string[],
|
2021-01-25 08:57:26 +00:00
|
|
|
): ReduxAction<DeleteWidgetPropertyPayload> => ({
|
|
|
|
|
type: ReduxActionTypes.DELETE_WIDGET_PROPERTY,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
2021-02-16 10:29:08 +00:00
|
|
|
propertyPaths,
|
2021-01-25 08:57:26 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2020-02-26 12:44:56 +00:00
|
|
|
export const setWidgetDynamicProperty = (
|
|
|
|
|
widgetId: string,
|
2021-01-25 08:57:26 +00:00
|
|
|
propertyPath: string,
|
2020-02-26 12:44:56 +00:00
|
|
|
isDynamic: boolean,
|
|
|
|
|
): ReduxAction<SetWidgetDynamicPropertyPayload> => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SET_WIDGET_DYNAMIC_PROPERTY,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
2021-01-25 08:57:26 +00:00
|
|
|
propertyPath,
|
2020-02-26 12:44:56 +00:00
|
|
|
isDynamic,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export interface UpdateWidgetPropertyRequestPayload {
|
2019-09-18 10:19:50 +00:00
|
|
|
widgetId: string;
|
2021-01-25 08:57:26 +00:00
|
|
|
propertyPath: string;
|
2019-09-18 10:19:50 +00:00
|
|
|
propertyValue: any;
|
2019-11-08 11:02:00 +00:00
|
|
|
renderMode: RenderMode;
|
2020-02-26 12:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface UpdateWidgetPropertyPayload {
|
|
|
|
|
widgetId: string;
|
2021-03-01 09:45:54 +00:00
|
|
|
updates: BatchPropertyUpdatePayload;
|
2021-02-25 14:00:02 +00:00
|
|
|
dynamicUpdates?: {
|
|
|
|
|
dynamicBindingPathList: DynamicPath[];
|
|
|
|
|
dynamicTriggerPathList: DynamicPath[];
|
|
|
|
|
};
|
2020-02-26 12:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-03 05:26:47 +00:00
|
|
|
export interface UpdateCanvasLayout {
|
|
|
|
|
width: number;
|
2021-03-16 05:01:37 +00:00
|
|
|
height: number;
|
2021-03-03 05:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
2020-02-26 12:44:56 +00:00
|
|
|
export interface SetWidgetDynamicPropertyPayload {
|
|
|
|
|
widgetId: string;
|
2021-01-25 08:57:26 +00:00
|
|
|
propertyPath: string;
|
2020-02-26 12:44:56 +00:00
|
|
|
isDynamic: boolean;
|
2019-11-14 09:28:51 +00:00
|
|
|
}
|
2021-01-25 08:57:26 +00:00
|
|
|
|
|
|
|
|
export interface DeleteWidgetPropertyPayload {
|
|
|
|
|
widgetId: string;
|
2021-02-16 10:29:08 +00:00
|
|
|
propertyPaths: string[];
|
2021-01-25 08:57:26 +00:00
|
|
|
}
|