PromucFlow_constructor/app/client/src/actions/pageActions.tsx

151 lines
3.2 KiB
TypeScript
Raw Normal View History

2019-11-25 05:07:27 +00:00
import { FetchPageRequest } from "api/PageApi";
import { WidgetOperation, WidgetProps } from "widgets/BaseWidget";
2019-11-25 05:07:27 +00:00
import { WidgetType } from "constants/WidgetConstants";
import {
ReduxActionTypes,
ReduxAction,
2019-09-24 12:36:03 +00:00
UpdateCanvasPayload,
SavePageSuccessPayload,
FetchPageListPayload,
2019-11-25 05:07:27 +00:00
} from "constants/ReduxActionConstants";
import { FlattenedWidgetProps } from "reducers/entityReducers/canvasWidgetsReducer";
import { ContainerWidgetProps } from "widgets/ContainerWidget";
export const fetchPageList = (
applicationId: string,
): ReduxAction<FetchPageListPayload> => {
return {
type: ReduxActionTypes.FETCH_PAGE_LIST_INIT,
payload: {
applicationId,
},
};
};
2019-11-05 05:09:50 +00:00
export const fetchPage = (pageId: string): ReduxAction<FetchPageRequest> => {
return {
type: ReduxActionTypes.FETCH_PAGE_INIT,
payload: {
pageId,
2019-09-09 09:08:54 +00:00
},
};
};
export const fetchPageSuccess = () => {
return {
type: ReduxActionTypes.FETCH_PAGE_SUCCESS,
};
};
2019-08-26 12:41:21 +00:00
export type FetchPublishedPageSuccessPayload = {
pageId: string;
dsl: ContainerWidgetProps<WidgetProps>;
pageWidgetId: string;
2019-09-09 09:08:54 +00:00
};
2019-08-26 12:41:21 +00:00
export const fetchPublishedPageSuccess = (
payload: FetchPublishedPageSuccessPayload,
) => ({
type: ReduxActionTypes.FETCH_PUBLISHED_PAGE_SUCCESS,
payload,
});
export const updateCurrentPage = (id: string) => ({
type: ReduxActionTypes.UPDATE_CURRENT_PAGE,
payload: { id },
});
export const updateCanvas = (
2019-09-24 12:36:03 +00:00
payload: UpdateCanvasPayload,
): ReduxAction<UpdateCanvasPayload> => {
return {
type: ReduxActionTypes.UPDATE_CANVAS,
payload,
};
};
export const savePageSuccess = (payload: SavePageSuccessPayload) => {
return {
type: ReduxActionTypes.SAVE_PAGE_SUCCESS,
payload,
};
};
2020-02-21 12:16:49 +00:00
export const updateWidgetNameSuccess = () => {
return {
type: ReduxActionTypes.UPDATE_WIDGET_NAME_SUCCESS,
};
};
export const deletePageSuccess = () => {
return {
type: ReduxActionTypes.DELETE_PAGE_SUCCESS,
};
};
export const updateAndSaveLayout = (widgets: FlattenedWidgetProps) => {
return {
type: ReduxActionTypes.UPDATE_LAYOUT,
payload: { widgets },
};
};
export type WidgetAddChild = {
widgetId: string;
2020-04-03 09:32:13 +00:00
widgetName?: string;
type: WidgetType;
leftColumn: number;
topRow: number;
columns: number;
rows: number;
parentRowSpace: number;
parentColumnSpace: number;
newWidgetId: string;
2020-04-15 11:42:11 +00:00
tabId: string;
2020-03-06 09:45:21 +00:00
props?: Record<string, any>;
};
export type WidgetMove = {
widgetId: string;
leftColumn: number;
topRow: number;
2019-10-03 17:35:13 +00:00
parentId: string;
/*
2019-11-05 05:09:50 +00:00
If newParentId is different from what we have in redux store,
then we have to delete this,
2019-11-05 05:09:50 +00:00
as it has been dropped in another container somewhere.
*/
2019-10-03 17:35:13 +00:00
newParentId: string;
};
export type WidgetRemoveChild = {
widgetId: string;
childWidgetId: string;
};
export type WidgetDelete = {
widgetId: string;
2019-10-03 17:35:13 +00:00
parentId: string;
};
export type WidgetResize = {
widgetId: string;
leftColumn: number;
rightColumn: number;
topRow: number;
bottomRow: number;
};
export const updateWidget = (
operation: WidgetOperation,
widgetId: string,
payload: any,
): ReduxAction<
2019-09-24 12:36:03 +00:00
WidgetAddChild | WidgetMove | WidgetRemoveChild | WidgetResize | WidgetDelete
> => {
return {
type: ReduxActionTypes["WIDGET_" + operation],
payload: { widgetId, ...payload },
};
};