2022-04-12 10:50:01 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxAction,
|
2022-11-23 09:48:23 +00:00
|
|
|
ReduxActionType,
|
2022-04-12 10:50:01 +00:00
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2022-11-14 04:19:25 +00:00
|
|
|
import { UpdateWidgetsPayload } from "reducers/entityReducers/canvasWidgetsReducer";
|
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,
|
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,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
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-04-23 05:43:13 +00:00
|
|
|
triggerPaths?: string[]; // Array of paths in the modify and remove list which are trigger paths
|
2022-11-23 09:48:23 +00:00
|
|
|
postUpdateAction?: ReduxActionType; // Array of action types we need to dispatch after propert updates.
|
2021-03-01 09:45:54 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 08:57:26 +00:00
|
|
|
export const batchUpdateWidgetProperty = (
|
|
|
|
|
widgetId: string,
|
2021-03-01 09:45:54 +00:00
|
|
|
updates: BatchPropertyUpdatePayload,
|
2021-09-21 07:55:56 +00:00
|
|
|
shouldReplay = true,
|
2021-01-25 08:57:26 +00:00
|
|
|
): ReduxAction<UpdateWidgetPropertyPayload> => ({
|
|
|
|
|
type: ReduxActionTypes.BATCH_UPDATE_WIDGET_PROPERTY,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId,
|
|
|
|
|
updates,
|
2021-09-21 07:55:56 +00:00
|
|
|
shouldReplay,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
export const batchUpdateMultipleWidgetProperties = (
|
|
|
|
|
updatesArray: UpdateWidgetPropertyPayload[],
|
|
|
|
|
): ReduxAction<{ updatesArray: UpdateWidgetPropertyPayload[] }> => ({
|
|
|
|
|
type: ReduxActionTypes.BATCH_UPDATE_MULTIPLE_WIDGETS_PROPERTY,
|
|
|
|
|
payload: {
|
|
|
|
|
updatesArray,
|
2021-01-25 08:57:26 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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,
|
2022-05-04 09:45:57 +00:00
|
|
|
shouldRejectDynamicBindingPathList = true,
|
2020-02-26 12:44:56 +00:00
|
|
|
): 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,
|
2022-05-04 09:45:57 +00:00
|
|
|
shouldRejectDynamicBindingPathList,
|
2020-02-26 12:44:56 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-14 04:19:25 +00:00
|
|
|
export const updateMultipleWidgetPropertiesAction = (
|
|
|
|
|
widgetsToUpdate: UpdateWidgetsPayload,
|
|
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.UPDATE_MULTIPLE_WIDGET_PROPERTIES,
|
|
|
|
|
payload: widgetsToUpdate,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-26 12:44:56 +00:00
|
|
|
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;
|
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?: {
|
2022-07-14 07:02:35 +00:00
|
|
|
dynamicBindingPathList?: DynamicPath[];
|
|
|
|
|
dynamicTriggerPathList?: DynamicPath[];
|
|
|
|
|
dynamicPropertyPathList?: DynamicPath[];
|
2021-02-25 14:00:02 +00:00
|
|
|
};
|
2021-09-21 07:55:56 +00:00
|
|
|
shouldReplay?: boolean;
|
2020-02-26 12:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
2021-11-23 08:01:46 +00:00
|
|
|
export interface UpdateCanvasLayoutPayload {
|
2021-03-03 05:26:47 +00:00
|
|
|
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;
|
2022-05-04 09:45:57 +00:00
|
|
|
shouldRejectDynamicBindingPathList?: 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
|
|
|
}
|