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 86007275
authored
May 27, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix typo
1 parent
0cdbcdba
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
17 deletions
src/components/ModalRepoForm.js
src/stores/ModalRepoForm.js
src/components/ModalRepoForm.js
View file @
8600727
import
React
from
'react'
import
{
Modal
,
Button
}
from
'react-bootstrap'
import
EventEmitter
from
'../libs/eventEmitter'
import
$
from
'jquery'
import
autobind
from
'autobind-decorator'
import
{
observer
,
inject
}
from
'mobx-react'
;
@
inject
([
"modalRepoFormStore"
])
@
observer
@
inject
([
"modalRepoFormStore"
])
@
inject
([
"headerStore"
])
@
observer
@
autobind
export
default
class
ModalRepoForm
extends
React
.
Component
{
store
()
{
...
...
@@ -17,7 +17,6 @@ export default class ModalRepoForm extends React.Component {
}
open
()
{
console
.
log
(
this
);
this
.
store
().
open
();
}
...
...
@@ -26,18 +25,7 @@ export default class ModalRepoForm extends React.Component {
}
save
(
e
)
{
if
(
this
.
refs
.
name
.
value
.
trim
().
length
===
0
)
{
this
.
setState
({
showNameError
:
true
})
return
false
}
else
{
this
.
setState
({
showNameError
:
false
})
e
.
preventDefault
()
$
.
post
(
'/regional_design/repos.json'
,
{
repo
:
this
.
state
},
function
(
data
)
{
this
.
props
.
handleNewRepo
(
data
)
this
.
setState
(
this
.
init_state
)
EventEmitter
.
dispatch
(
'alert'
,
'操作成功'
)
}.
bind
(
this
),
'JSON'
)
}
this
.
store
().
save
(
e
,
this
.
refs
.
name
,
this
.
props
.
headerStore
)
}
render
()
{
...
...
src/stores/ModalRepoForm.js
View file @
8600727
import
{
observable
,
useStrict
,
action
}
from
'mobx'
import
EventEmitter
from
'../libs/eventEmitter'
import
$
from
'jquery'
useStrict
(
true
)
class
ModalRepoFormStore
{
@
observable
showNameError
=
false
@
observable
showModal
=
false
@
observable
name
=
''
...
...
@@ -12,14 +15,30 @@ class ModalRepoFormStore {
@
action
close
()
{
this
.
showModal
=
false
this
.
name
=
""
}
@
action
handleChange
(
e
)
{
this
.
name
=
e
.
target
.
value
}
@
action
save
()
{
addRepo
(
headerStore
,
data
)
{
headerStore
.
addRepo
(
data
)
}
@
action
save
(
e
,
name
,
headerStore
)
{
if
(
name
.
value
.
trim
().
length
===
0
)
{
this
.
showNameError
=
true
return
false
}
else
{
this
.
showNameError
=
false
e
.
preventDefault
()
$
.
post
(
'/regional_design/repos.json'
,
{
repo
:
{
name
:
this
.
name
}
},
(
data
)
=>
{
this
.
close
()
this
.
addRepo
(
headerStore
,
data
)
EventEmitter
.
dispatch
(
'alert'
,
'操作成功'
)
},
'JSON'
)
}
}
}
...
...
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