fabric8-planner
Version:
A planner front-end for Fabric8.
44 lines • 1.49 kB
JavaScript
import { initialState } from '../states/custom-query.state';
import * as CustomQueryActions from './../actions/custom-query.actions';
export var CustomQueryReducer = function (state, action) {
if (state === void 0) { state = initialState; }
switch (action.type) {
case CustomQueryActions.GET_SUCCESS: {
return action.payload;
}
case CustomQueryActions.GET_ERROR: {
return state;
}
case CustomQueryActions.ADD_SUCCESS: {
return state.concat([action.payload]);
}
case CustomQueryActions.DELETE_SUCCESS: {
var index = state.findIndex(function (cq) { return cq.id === action.payload.id; });
if (index > -1) {
state.splice(index, 1);
}
return state.slice();
}
case CustomQueryActions.DELETE_ERROR: {
return state;
}
case CustomQueryActions.SELECT: {
var newState = state.map(function (q) {
q.selected = q.id === action.payload.id;
return q;
});
return newState.slice();
}
case CustomQueryActions.SELECT_NONE: {
var newState = state.map(function (q) {
q.selected = false;
return q;
});
return newState.slice();
}
default: {
return state;
}
}
};
//# sourceMappingURL=custom-query.reducer.js.map