2019-11-25 05:07:27 +00:00
|
|
|
import { ReduxActionTypes, ReduxAction } from "constants/ReduxActionConstants";
|
|
|
|
|
import { RenderMode } from "constants/WidgetConstants";
|
2020-04-13 08:24:13 +00:00
|
|
|
import { BatchAction, batchAction } from "actions/batchActions";
|
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,
|
2021-02-16 10:29:08 +00:00
|
|
|
isDynamicTrigger?: boolean,
|
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,
|
2021-02-16 10:29:08 +00:00
|
|
|
isDynamicTrigger,
|
2019-09-18 10:19:50 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-26 12:44:56 +00:00
|
|
|
export const updateWidgetProperty = (
|
|
|
|
|
widgetId: string,
|
2021-01-25 08:57:26 +00:00
|
|
|
updates: Record<string, unknown>,
|
2020-04-13 08:24:13 +00:00
|
|
|
): BatchAction<UpdateWidgetPropertyPayload> => {
|
|
|
|
|
return batchAction({
|
2020-02-26 12:44:56 +00:00
|
|
|
type: ReduxActionTypes.UPDATE_WIDGET_PROPERTY,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
2021-01-25 08:57:26 +00:00
|
|
|
updates,
|
2020-02-26 12:44:56 +00:00
|
|
|
},
|
2020-04-13 08:24:13 +00:00
|
|
|
});
|
2020-02-26 12:44:56 +00:00
|
|
|
};
|
|
|
|
|
|
2021-01-25 08:57:26 +00:00
|
|
|
export const batchUpdateWidgetProperty = (
|
|
|
|
|
widgetId: string,
|
|
|
|
|
updates: Record<string, unknown>,
|
|
|
|
|
): 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;
|
2021-02-16 10:29:08 +00:00
|
|
|
isDynamicTrigger?: boolean;
|
2020-02-26 12:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface UpdateWidgetPropertyPayload {
|
|
|
|
|
widgetId: string;
|
2021-01-25 08:57:26 +00:00
|
|
|
updates: Record<string, unknown>;
|
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
|
|
|
}
|