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";
|
2022-02-04 12:22:25 +00:00
|
|
|
import { Diff } from "deep-diff";
|
2022-01-28 11:10:05 +00:00
|
|
|
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,
|
|
|
|
|
},
|
2022-02-17 04:31:59 +00:00
|
|
|
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,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-01-28 11:10:05 +00:00
|
|
|
|
2022-02-04 12:22:25 +00:00
|
|
|
export const updateMetaState = (
|
|
|
|
|
updates: Diff<any, any>[],
|
|
|
|
|
updatedDataTree: DataTree,
|
|
|
|
|
) => {
|
2022-01-28 11:10:05 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.UPDATE_META_STATE,
|
|
|
|
|
payload: {
|
2022-02-04 12:22:25 +00:00
|
|
|
updates,
|
|
|
|
|
updatedDataTree,
|
2022-01-28 11:10:05 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|