PromucFlow_constructor/app/client/src/actions/metaActions.ts

61 lines
1.4 KiB
TypeScript
Raw Normal View History

2020-02-07 02:32:52 +00:00
import { ReduxActionTypes, ReduxAction } from "constants/ReduxActionConstants";
2020-04-13 08:24:13 +00:00
import { BatchAction, batchAction } from "actions/batchActions";
import { Diff } from "deep-diff";
import { DataTree } from "entities/DataTree/dataTreeFactory";
2020-02-07 02:32:52 +00:00
2020-03-06 09:45:21 +00:00
export interface UpdateWidgetMetaPropertyPayload {
widgetId: string;
propertyName: string;
propertyValue: any;
}
2020-02-07 02:32:52 +00:00
export const updateWidgetMetaProperty = (
widgetId: string,
propertyName: string,
propertyValue: any,
2020-04-13 08:24:13 +00:00
): BatchAction<UpdateWidgetMetaPropertyPayload> => {
return batchAction({
2020-02-07 02:32:52 +00:00
type: ReduxActionTypes.SET_META_PROP,
payload: {
widgetId,
propertyName,
propertyValue,
},
2020-04-13 08:24:13 +00:00
});
2020-02-07 02:32:52 +00:00
};
2020-03-06 09:45:21 +00:00
export const resetWidgetMetaProperty = (
widgetId: string,
2020-04-13 08:24:13 +00:00
): BatchAction<{ widgetId: string }> => {
return batchAction({
2020-03-06 09:45:21 +00:00
type: ReduxActionTypes.RESET_WIDGET_META,
payload: {
widgetId,
},
postEvalActions: [{ type: ReduxActionTypes.RESET_WIDGET_META_EVALUATED }],
2020-04-13 08:24:13 +00:00
});
2020-03-06 09:45:21 +00:00
};
export const resetChildrenMetaProperty = (
widgetId: string,
): ReduxAction<{ widgetId: string }> => {
return {
type: ReduxActionTypes.RESET_CHILDREN_WIDGET_META,
payload: {
widgetId,
},
};
};
export const updateMetaState = (
updates: Diff<any, any>[],
updatedDataTree: DataTree,
) => {
return {
type: ReduxActionTypes.UPDATE_META_STATE,
payload: {
updates,
updatedDataTree,
},
};
};