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 413e98bb
authored
Jun 08, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
delete
1 parent
179e0aff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
8 deletions
src/actions/headergroup.js
src/components/ElementGroup.js
src/reducers/headergroup.js
src/actions/headergroup.js
View file @
413e98b
...
...
@@ -2,3 +2,7 @@ export const cloneElement = (element) => ({
type
:
'CLONE_ELEMENT'
,
element
})
export
const
deleteLastElement
=
()
=>
({
type
:
'DELETE_LAST_ELEMENT'
})
src/components/ElementGroup.js
View file @
413e98b
...
...
@@ -4,7 +4,7 @@ import ReactAddonsUpdate from 'react-addons-update'
import
autobind
from
'autobind-decorator'
import
{
connect
}
from
'react-redux'
import
{
cloneElement
}
from
'../actions/headergroup'
;
import
{
cloneElement
,
deleteLastElement
}
from
'../actions/headergroup'
;
@
autobind
class
ElementGroup
extends
React
.
Component
{
...
...
@@ -25,13 +25,13 @@ class ElementGroup extends React.Component {
}
render
()
{
const
{
elements
,
cloneElement
}
=
this
.
props
const
{
elements
,
cloneElement
,
deleteLastElement
}
=
this
.
props
return
(
<
div
>
{
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
=
{
cloneElement
}
handleDeleteElement
=
{
this
.
deleteElement
}
handleDeleteLastElement
=
{
this
.
deleteLastElement
}
/
>
<
Element
meta_element
=
{
element
}
key
=
{
"key_"
+
element
.
id
}
id
=
{
element
.
id
}
name
=
{
element
.
name
}
initialPos
=
{
element
.
initialPos
}
target_type
=
{
element
.
target_type
}
handleCloneElement
=
{
cloneElement
}
handleDeleteElement
=
{
this
.
deleteElement
}
handleDeleteLastElement
=
{
deleteLastElement
}
/
>
)
}.
bind
(
this
))
}
...
...
@@ -45,12 +45,15 @@ const mapStateToProps = (state, ownProps) => ({
})
const
mapDispatchToProps
=
(
dispatch
,
ownProps
)
=>
({
cloneElement
:
cloneElement
cloneElement
:
(
element
)
=>
{
dispatch
(
cloneElement
(
element
))
},
deleteLastElement
:
()
=>
{
dispatch
(
deleteLastElement
())
}
})
const
VisibleElementGroup
=
connect
(
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
ElementGroup
)
export
default
VisibleElementGroup
src/reducers/headergroup.js
View file @
413e98b
...
...
@@ -5,7 +5,15 @@ const init_state = [
]
const
headergroup
=
(
state
=
init_state
,
action
)
=>
{
return
state
switch
(
action
.
type
)
{
case
'CLONE_ELEMENT'
:
return
[
...
state
,
action
.
element
]
default
:
return
state
}
}
export
default
headergroup
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