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 f3002db8
authored
Jun 08, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
redux
1 parent
89a2ec97
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
9 deletions
src/actions/headergroup.js
src/components/ElementGroup.js
src/reducers/headergroup.js
src/actions/headergroup.js
View file @
f3002db
...
...
@@ -7,6 +7,7 @@ export const deleteLastElement = () => ({
type
:
'DELETE_LAST_ELEMENT'
})
export
const
deleteElement
=
()
=>
({
type
:
'DELETE_ELEMENT'
export
const
deleteElement
=
(
element
)
=>
({
type
:
'DELETE_ELEMENT'
,
element
})
src/components/ElementGroup.js
View file @
f3002db
...
...
@@ -9,12 +9,6 @@ import * as HeaderGroupActions from '../actions/headergroup'
@
autobind
class
ElementGroup
extends
React
.
Component
{
deleteElement
(
element
)
{
const
index
=
this
.
state
.
elements
.
indexOf
(
element
)
const
elements
=
ReactAddonsUpdate
(
this
.
state
.
elements
,
{
$splice
:
[[
index
,
1
]]
})
this
.
setState
({
elements
:
elements
})
}
sidebar
()
{
return
document
.
getElementById
(
'sidebar'
)
}
...
...
@@ -26,7 +20,7 @@ class ElementGroup extends React.Component {
{
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
=
{
actions
.
cloneElement
}
handleDeleteElement
=
{
thi
s
.
deleteElement
}
handleDeleteLastElement
=
{
actions
.
deleteLastElement
}
/
>
<
Element
meta_element
=
{
element
}
key
=
{
"key_"
+
element
.
id
}
id
=
{
element
.
id
}
name
=
{
element
.
name
}
initialPos
=
{
element
.
initialPos
}
target_type
=
{
element
.
target_type
}
handleCloneElement
=
{
actions
.
cloneElement
}
handleDeleteElement
=
{
action
s
.
deleteElement
}
handleDeleteLastElement
=
{
actions
.
deleteLastElement
}
/
>
)
}.
bind
(
this
))
}
...
...
src/reducers/headergroup.js
View file @
f3002db
...
...
@@ -15,6 +15,12 @@ const headergroup = (state = init_state, action) => {
return
[
...
state
.
slice
(
0
,
-
1
),
]
case
'DELETE_ELEMENT'
:
const
index
=
state
.
indexOf
(
action
.
element
)
return
[
...
state
.
slice
(
0
,
index
),
...
state
.
slice
(
index
+
1
)
]
default
:
return
state
}
...
...
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