Commit dafe5f76 by hfpp2012 yinsigan

constants

1 parent f4c7e025
import * as types from '../constants/ActionTypes'
export const cloneElement = (element) => ({ export const cloneElement = (element) => ({
type: 'CLONE_ELEMENT', type: types.CLONE_ELEMENT,
element element
}) })
export const deleteLastElement = () => ({ export const deleteLastElement = () => ({
type: 'DELETE_LAST_ELEMENT' type: types.DELETE_LAST_ELEMENT
}) })
export const deleteElement = (element) => ({ export const deleteElement = (element) => ({
type: 'DELETE_ELEMENT', type: types.DELETE_ELEMENT,
element element
}) })
export const CLONE_ELEMENT = 'CLONE_ELEMENT'
export const DELETE_LAST_ELEMENT = 'DELETE_LAST_ELEMENT'
export const DELETE_ELEMENT = 'DELETE_ELEMENT'
import { List } from 'immutable' import { List } from 'immutable'
import { CLONE_ELEMENT, DELETE_LAST_ELEMENT, DELETE_ELEMENT } from '../constants/ActionTypes'
const init_state = List([ const init_state = List([
{ id: 1, name: "药库", initialPos: {x: 80, y: 70}, target_type: 'RegionalDesign::Repo' }, { id: 1, name: "药库", initialPos: {x: 80, y: 70}, target_type: 'RegionalDesign::Repo' },
...@@ -8,16 +9,16 @@ const init_state = List([ ...@@ -8,16 +9,16 @@ const init_state = List([
const headergroup = (state = init_state, action) => { const headergroup = (state = init_state, action) => {
switch (action.type) { switch (action.type) {
case 'CLONE_ELEMENT': case CLONE_ELEMENT:
return [ return [
...state, ...state,
action.element action.element
] ]
case 'DELETE_LAST_ELEMENT': case DELETE_LAST_ELEMENT:
return [ return [
...state.slice(0, -1), ...state.slice(0, -1),
] ]
case 'DELETE_ELEMENT': case DELETE_ELEMENT:
const index = state.indexOf(action.element) const index = state.indexOf(action.element)
return [ return [
...state.slice(0, index), ...state.slice(0, index),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!