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 179e0aff
authored
Jun 08, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
mapDispatchToProps
1 parent
d422a40f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
11 deletions
src/actions/header.js
src/actions/headergroup.js
src/components/ElementGroup.js
src/actions/header.js
deleted
100644 → 0
View file @
d422a40
export
const
toggleTodo
=
(
id
)
=>
({
type
:
'TOGGLE_TODO'
,
id
})
src/actions/headergroup.js
0 → 100644
View file @
179e0af
export
const
cloneElement
=
(
element
)
=>
({
type
:
'CLONE_ELEMENT'
,
element
})
src/components/ElementGroup.js
View file @
179e0af
...
...
@@ -4,13 +4,10 @@ import ReactAddonsUpdate from 'react-addons-update'
import
autobind
from
'autobind-decorator'
import
{
connect
}
from
'react-redux'
import
{
cloneElement
}
from
'../actions/headergroup'
;
@
autobind
class
ElementGroup
extends
React
.
Component
{
cloneElement
(
element
)
{
const
elements
=
ReactAddonsUpdate
(
this
.
state
.
elements
,
{
$push
:
[
element
]
})
this
.
setState
({
elements
:
elements
})
}
deleteElement
(
element
)
{
const
index
=
this
.
state
.
elements
.
indexOf
(
element
)
const
elements
=
ReactAddonsUpdate
(
this
.
state
.
elements
,
{
$splice
:
[[
index
,
1
]]
})
...
...
@@ -28,13 +25,13 @@ class ElementGroup extends React.Component {
}
render
()
{
const
{
elements
}
=
this
.
props
const
{
elements
,
cloneElement
}
=
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
=
{
this
.
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
=
{
this
.
deleteLastElement
}
/
>
)
}.
bind
(
this
))
}
...
...
@@ -48,6 +45,7 @@ const mapStateToProps = (state, ownProps) => ({
})
const
mapDispatchToProps
=
(
dispatch
,
ownProps
)
=>
({
cloneElement
:
cloneElement
})
const
VisibleElementGroup
=
connect
(
...
...
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