Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
hfpp2012
/
react-spd
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d422a40f
authored
Jun 08, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
connect
1 parent
c8cea602
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
27 deletions
src/actions/header.js
src/components/ElementGroup.js
src/reducers/header.js
src/reducers/headergroup.js
src/reducers/index.js
src/actions/header.js
View file @
d422a40
export
const
UPDATE_LANE
=
'UPDATE_LANE'
;
export
function
updateLane
(
updatedLane
)
{
return
{
type
:
UPDATE_LANE
,
...
updatedLane
};
};
export
const
toggleTodo
=
(
id
)
=>
({
type
:
'TOGGLE_TODO'
,
id
})
src/components/ElementGroup.js
View file @
d422a40
...
...
@@ -2,20 +2,10 @@ import React from 'react'
import
Element
from
'./Element'
import
ReactAddonsUpdate
from
'react-addons-update'
import
autobind
from
'autobind-decorator'
import
{
connect
}
from
'react-redux'
@
autobind
export
default
class
ElementGroup
extends
React
.
Component
{
constructor
(
props
){
super
(
props
);
this
.
state
=
{
elements
:
[
{
id
:
1
,
name
:
"药库"
,
initialPos
:
{
x
:
80
,
y
:
70
},
target_type
:
'RegionalDesign::Repo'
},
{
id
:
2
,
name
:
"药架"
,
initialPos
:
{
x
:
80
,
y
:
70
+
60
},
target_type
:
'RegionalDesign::DrugRepo'
},
{
id
:
3
,
name
:
"药架格"
,
initialPos
:
{
x
:
80
,
y
:
70
+
60
*
2
},
target_type
:
'RegionalDesign::DrugBrandreth'
}
]
};
}
class
ElementGroup
extends
React
.
Component
{
cloneElement
(
element
)
{
const
elements
=
ReactAddonsUpdate
(
this
.
state
.
elements
,
{
$push
:
[
element
]
})
this
.
setState
({
elements
:
elements
})
...
...
@@ -38,10 +28,11 @@ export default class ElementGroup extends React.Component {
}
render
()
{
const
{
elements
}
=
this
.
props
return
(
<
div
>
{
this
.
state
.
elements
.
map
(
function
(
element
)
{
elements
.
map
(
function
(
element
)
{
return
(
<
Element
meta_element
=
{
element
}
key
=
{
"key_"
+
element
.
id
}
id
=
{
element
.
id
}
name
=
{
element
.
name
}
initialPos
=
{
element
.
initialPos
}
target_type
=
{
element
.
target_type
}
handleCloneElement
=
{
this
.
cloneElement
}
handleDeleteElement
=
{
this
.
deleteElement
}
handleDeleteLastElement
=
{
this
.
deleteLastElement
}
/
>
)
...
...
@@ -51,3 +42,17 @@ export default class ElementGroup extends React.Component {
)
}
}
const
mapStateToProps
=
(
state
,
ownProps
)
=>
({
elements
:
state
.
headergroup
})
const
mapDispatchToProps
=
(
dispatch
,
ownProps
)
=>
({
})
const
VisibleElementGroup
=
connect
(
mapStateToProps
,
mapDispatchToProps
)(
ElementGroup
)
export
default
VisibleElementGroup
src/reducers/header.js
deleted
100644 → 0
View file @
c8cea60
const
header
=
(
state
=
{},
action
)
=>
{
return
state
;
}
export
default
header
src/reducers/headergroup.js
0 → 100644
View file @
d422a40
const
init_state
=
[
{
id
:
1
,
name
:
"药库"
,
initialPos
:
{
x
:
80
,
y
:
70
},
target_type
:
'RegionalDesign::Repo'
},
{
id
:
2
,
name
:
"药架"
,
initialPos
:
{
x
:
80
,
y
:
70
+
60
},
target_type
:
'RegionalDesign::DrugRepo'
},
{
id
:
3
,
name
:
"药架格"
,
initialPos
:
{
x
:
80
,
y
:
70
+
60
*
2
},
target_type
:
'RegionalDesign::DrugBrandreth'
}
]
const
headergroup
=
(
state
=
init_state
,
action
)
=>
{
return
state
}
export
default
headergroup
src/reducers/index.js
View file @
d422a40
import
{
combineReducers
}
from
'redux'
;
import
header
from
'./header
'
;
import
header
group
from
'./headergroup
'
;
const
rootReducer
=
combineReducers
({
header
header
group
});
export
default
rootReducer
;
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment