Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
4cea24f8
Commit
4cea24f8
authored
Feb 01, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted todos.js to axios
parent
43f1088f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
22 deletions
+15
-22
app/assets/javascripts/pages/dashboard/todos/index/todos.js
app/assets/javascripts/pages/dashboard/todos/index/todos.js
+15
-22
No files found.
app/assets/javascripts/pages/dashboard/todos/index/todos.js
View file @
4cea24f8
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
UsersSelect
from
'
~/users_select
'
;
import
UsersSelect
from
'
~/users_select
'
;
import
{
isMetaClick
}
from
'
~/lib/utils/common_utils
'
;
import
{
isMetaClick
}
from
'
~/lib/utils/common_utils
'
;
import
{
__
}
from
'
../../../../locale
'
;
import
flash
from
'
../../../../flash
'
;
import
axios
from
'
../../../../lib/utils/axios_utils
'
;
export
default
class
Todos
{
export
default
class
Todos
{
constructor
()
{
constructor
()
{
...
@@ -59,18 +62,12 @@ export default class Todos {
...
@@ -59,18 +62,12 @@ export default class Todos {
const
target
=
e
.
target
;
const
target
=
e
.
target
;
target
.
setAttribute
(
'
disabled
'
,
true
);
target
.
setAttribute
(
'
disabled
'
,
true
);
target
.
classList
.
add
(
'
disabled
'
);
target
.
classList
.
add
(
'
disabled
'
);
$
.
ajax
({
type
:
'
POST
'
,
axios
[
target
.
dataset
.
method
](
target
.
dataset
.
href
)
url
:
target
.
dataset
.
href
,
.
then
(({
data
})
=>
{
dataType
:
'
json
'
,
data
:
{
'
_method
'
:
target
.
dataset
.
method
,
},
success
:
(
data
)
=>
{
this
.
updateRowState
(
target
);
this
.
updateRowState
(
target
);
return
this
.
updateBadges
(
data
);
this
.
updateBadges
(
data
);
},
}).
catch
(()
=>
flash
(
__
(
'
Error updating todo status.
'
)));
});
}
}
updateRowState
(
target
)
{
updateRowState
(
target
)
{
...
@@ -98,19 +95,15 @@ export default class Todos {
...
@@ -98,19 +95,15 @@ export default class Todos {
e
.
preventDefault
();
e
.
preventDefault
();
const
target
=
e
.
currentTarget
;
const
target
=
e
.
currentTarget
;
const
requestData
=
{
'
_method
'
:
target
.
dataset
.
method
,
ids
:
this
.
todo_ids
};
target
.
setAttribute
(
'
disabled
'
,
true
);
target
.
setAttribute
(
'
disabled
'
,
true
);
target
.
classList
.
add
(
'
disabled
'
);
target
.
classList
.
add
(
'
disabled
'
);
$
.
ajax
({
type
:
'
POST
'
,
axios
[
target
.
dataset
.
method
](
target
.
dataset
.
href
,
{
url
:
target
.
dataset
.
href
,
ids
:
this
.
todo_ids
,
dataType
:
'
json
'
,
}).
then
(({
data
})
=>
{
data
:
requestData
,
this
.
updateAllState
(
target
,
data
);
success
:
(
data
)
=>
{
this
.
updateBadges
(
data
);
this
.
updateAllState
(
target
,
data
);
}).
catch
(()
=>
flash
(
__
(
'
Error updating status for all todos.
'
)));
return
this
.
updateBadges
(
data
);
},
});
}
}
updateAllState
(
target
,
data
)
{
updateAllState
(
target
,
data
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment