| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 | /* * << * Davinci * == * Copyright (C) 2016 - 2017 EDP * == * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * >> */import { ActionTypes } from './constants'import { returnType } from 'utils/redux'import { IWidgetRaw, IWidgetBase, IWidgetFormed } from './types'export const WidgetActions = {  loadWidgets(projectId: number) {    return {      type: ActionTypes.LOAD_WIDGETS,      payload: {        projectId      }    }  },  widgetsLoaded(widgets: IWidgetFormed[]) {    return {      type: ActionTypes.LOAD_WIDGETS_SUCCESS,      payload: {        widgets      }    }  },  widgetsLoadedFail() {    return {      type: ActionTypes.LOAD_WIDGETS_FAILURE,      payload: {}    }  },  addWidget(widget: Omit<IWidgetRaw, 'id'>, resolve) {    return {      type: ActionTypes.ADD_WIDGET,      payload: {        widget,        resolve      }    }  },  widgetAdded(result: IWidgetFormed) {    return {      type: ActionTypes.ADD_WIDGET_SUCCESS,      payload: {        result      }    }  },  addWidgetFail() {    return {      type: ActionTypes.ADD_WIDGET_FAILURE,      payload: {}    }  },  loadWidgetDetail(id: number) {    return {      type: ActionTypes.LOAD_WIDGET_DETAIL,      payload: {        id      }    }  },  widgetDetailLoaded(detail, view) {    return {      type: ActionTypes.LOAD_WIDGET_DETAIL_SUCCESS,      payload: {        detail,        view      }    }  },  loadWidgetDetailFail(error) {    return {      type: ActionTypes.LOAD_WIDGET_DETAIL_FAILURE,      payload: {        error      }    }  },  editWidget(widget, resolve) {    return {      type: ActionTypes.EDIT_WIDGET,      payload: {        widget,        resolve      }    }  },  widgetEdited() {    return {      type: ActionTypes.EDIT_WIDGET_SUCCESS,      payload: {}    }  },  editWidgetFail() {    return {      type: ActionTypes.EDIT_WIDGET_FAILURE,      payload: {}    }  },  copyWidget(widget: IWidgetBase, resolve: () => void) {    return {      type: ActionTypes.COPY_WIDGET,      payload: {        widget,        resolve      }    }  },  widgetCopied(fromWidgetId: number, result: IWidgetFormed) {    return {      type: ActionTypes.COPY_WIDGET_SUCCESS,      payload: {        fromWidgetId,        result      }    }  },  copyWidgetFail() {    return {      type: ActionTypes.COPY_WIDGET_FAILURE,      payload: {}    }  },  deleteWidget(id) {    return {      type: ActionTypes.DELETE_WIDGET,      payload: {        id      }    }  },  widgetDeleted(id: number) {    return {      type: ActionTypes.DELETE_WIDGET_SUCCESS,      payload: {        id      }    }  },  deleteWidgetFail() {    return {      type: ActionTypes.DELETE_WIDGET_FAILURE,      payload: {}    }  },  clearCurrentWidget() {    return {      type: ActionTypes.CLEAR_CURRENT_WIDGET,      payload: {}    }  },  executeComputed(sql) {    return {      type: ActionTypes.EXECUTE_COMPUTED_SQL,      payload: {        sql      }    }  }}const mockAction = returnType(WidgetActions)export type WidgetActionType = typeof mockActionexport default WidgetActions
 |