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 93d82e96
authored
May 22, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
event bind
1 parent
f4edc185
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
6 deletions
src/components/Element.js
src/components/ElementGroup.js
src/components/Header.js
src/components/ModalRepoForm.js
src/components/RegionalDesign.js
src/index.html
src/components/Element.js
View file @
93d82e9
...
...
@@ -24,6 +24,18 @@ export default class Element extends React.Component {
name
:
this
.
props
.
name
,
prev_name
:
this
.
props
.
name
};
this
.
onMouseDown
=
this
.
onMouseDown
.
bind
(
this
);
this
.
onMouseMove
=
this
.
onMouseMove
.
bind
(
this
);
this
.
onMouseUp
=
this
.
onMouseUp
.
bind
(
this
);
this
.
handleCloneElement
=
this
.
handleCloneElement
.
bind
(
this
);
this
.
handleDeleteLastElement
=
this
.
handleDeleteLastElement
.
bind
(
this
);
this
.
handleMoveDropZone
=
this
.
handleMoveDropZone
.
bind
(
this
);
this
.
handleClick
=
this
.
handleClick
.
bind
(
this
);
this
.
handleChange
=
this
.
handleChange
.
bind
(
this
);
this
.
handleBlur
=
this
.
handleBlur
.
bind
(
this
);
this
.
handleKeyPress
=
this
.
handleKeyPress
.
bind
(
this
);
this
.
handleUpdateName
=
this
.
handleUpdateName
.
bind
(
this
);
this
.
handleDoubleClick
=
this
.
handleDoubleClick
.
bind
(
this
);
}
componentDidUpdate
(
props
,
state
)
{
...
...
src/components/ElementGroup.js
View file @
93d82e9
...
...
@@ -12,6 +12,9 @@ export default class ElementGroup extends React.Component {
{
id
:
3
,
name
:
"药架格"
,
initialPos
:
{
x
:
80
,
y
:
70
+
60
*
2
},
target_type
:
'RegionalDesign::DrugBrandreth'
}
]
};
this
.
cloneElement
=
this
.
cloneElement
.
bind
(
this
);
this
.
deleteElement
=
this
.
deleteElement
.
bind
(
this
);
this
.
deleteLastElement
=
this
.
deleteLastElement
.
bind
(
this
);
}
cloneElement
(
element
)
{
...
...
@@ -22,13 +25,13 @@ export default class ElementGroup extends React.Component {
deleteElement
(
element
)
{
const
index
=
this
.
state
.
elements
.
indexOf
(
element
)
const
elements
=
ReactAddonsUpdate
(
this
.
state
.
elements
,
{
$splice
:
[[
index
,
1
]]
})
this
.
replace
State
({
elements
:
elements
})
this
.
set
State
({
elements
:
elements
})
}
// 返回element的index为-1, 删除最后一个元素
deleteLastElement
()
{
const
elements
=
ReactAddonsUpdate
(
this
.
state
.
elements
,
{
$splice
:
[[
-
1
,
1
]]
})
this
.
replace
State
({
elements
:
elements
})
this
.
set
State
({
elements
:
elements
})
}
sidebar
()
{
...
...
src/components/Header.js
View file @
93d82e9
...
...
@@ -10,6 +10,7 @@ export default class Header extends React.Component {
this
.
state
=
{
data
:
null
,
loading
:
true
,
error
:
null
};
this
.
addRepo
=
this
.
addRepo
.
bind
(
this
);
}
componentDidMount
()
{
...
...
@@ -20,7 +21,7 @@ export default class Header extends React.Component {
}
addRepo
(
repo
)
{
cons
t
data
=
ReactAddonsUpdate
(
this
.
state
.
data
,
{
$push
:
[
repo
]
})
le
t
data
=
ReactAddonsUpdate
(
this
.
state
.
data
,
{
$push
:
[
repo
]
})
this
.
setState
({
data
:
data
})
}
...
...
@@ -33,8 +34,8 @@ export default class Header extends React.Component {
result
=
<
span
>
Error
:
{
this
.
state
.
error
.
message
}
<
/span>
;
}
else
{
le
t
data
=
this
.
state
.
data
.
map
((
repo
)
=>
{
le
t
url
=
`/regional_design/
${
repo
.
id
}
?object=repo`
cons
t
data
=
this
.
state
.
data
.
map
((
repo
)
=>
{
cons
t
url
=
`/regional_design/
${
repo
.
id
}
?object=repo`
return
(
<
Link
key
=
{
repo
.
id
}
className
=
'btn btn-default mr15'
to
=
{
url
}
>
{
repo
.
name
}
<
/Link
>
)
...
...
src/components/ModalRepoForm.js
View file @
93d82e9
...
...
@@ -10,6 +10,9 @@ export default class ModalRepoForm extends React.Component {
this
.
state
=
{
showModal
:
false
,
name
:
''
};
this
.
close
=
this
.
close
.
bind
(
this
);
this
.
open
=
this
.
open
.
bind
(
this
);
this
.
handleChange
=
this
.
handleChange
.
bind
(
this
);
}
close
()
{
...
...
src/components/RegionalDesign.js
View file @
93d82e9
...
...
@@ -11,6 +11,9 @@ export default class RegionalDesign extends React.Component {
this
.
state
=
{
data
:
null
,
loading
:
true
,
error
:
null
,
object_name
:
''
,
object_type
:
''
,
children_object_type
:
''
};
this
.
addElement
=
this
.
addElement
.
bind
(
this
);
this
.
updateElement
=
this
.
updateElement
.
bind
(
this
);
this
.
addElement
=
this
.
addElement
.
bind
(
this
);
}
getConfig
(
props
,
key
)
{
...
...
src/index.html
View file @
93d82e9
...
...
@@ -3,7 +3,7 @@
<head>
<meta
charset=
"utf-8"
>
<title>
React App Setup
</title>
<link
rel=
"stylesheet"
href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity=
"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin=
"anonymous
"
>
<link
href=
"https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css"
rel=
"stylesheet
"
>
<style>
.meta-element
{
border
:
1px
solid
#eee
;
...
...
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