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