export default function indexEditor()

in app/addons/documents/index-editor/reducers.js [131:219]


export default function indexEditor(state = initialState, action) {
  const { options } = action;
  switch (action.type) {

    case ActionTypes.CLEAR_INDEX:
      return {
        ...initialState
      };

    case ActionTypes.EDIT_INDEX:
      return editIndex(state, options);

    case ActionTypes.EDIT_NEW_INDEX:
      return editIndex(state, options);

    case ActionTypes.VIEW_NAME_CHANGE:
      return {
        ...state,
        viewName: action.name
      };

    case ActionTypes.SELECT_REDUCE_CHANGE:
      let newReduce = action.reduceSelectedOption;
      if (newReduce === 'NONE') {
        newReduce = '';
      }
      if (newReduce === 'CUSTOM') {
        newReduce = defaultReduce;
      }
      return {
        ...state,
        view: {
          ...state.view,
          reduce: newReduce
        }
      };

    case ActionTypes.DESIGN_DOC_CHANGE:
      return {
        ...state,
        designDocId: options.value
      };

    case ActionTypes.VIEW_SAVED:
      return state;

    case ActionTypes.VIEW_CREATED:
      return state;

    case ActionTypes.VIEW_ADD_DESIGN_DOC:
      return {
        ...state,
        designDocId: action.designDoc._id
      };

    case ActionTypes.VIEW_UPDATE_MAP_CODE:
      return {
        ...state,
        view: {
          ...state.view,
          map: action.code
        }
      };

    case ActionTypes.VIEW_UPDATE_REDUCE_CODE:
      return {
        ...state,
        view: {
          ...state.view,
          reduce: action.code
        }
      };

    case ActionTypes.DESIGN_DOC_NEW_NAME_UPDATED:
      return {
        ...state,
        newDesignDocName: options.value
      };

    case ActionTypes.DESIGN_DOC_NEW_PARTITIONED_UPDATED:
      return {
        ...state,
        newDesignDocPartitioned: options.value
      };

    default:
      return state;
  }
}