BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
4cea24f8
Unverified
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
22 deletions
+15
-22
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 @@
import
{
visitUrl
}
from
'~/lib/utils/url_utility'
;
import
UsersSelect
from
'~/users_select'
;
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
{
constructor
()
{
...
...
@@ -59,18 +62,12 @@ export default class Todos {
const
target
=
e
.
target
;
target
.
setAttribute
(
'disabled'
,
true
);
target
.
classList
.
add
(
'disabled'
);
$
.
ajax
({
type
:
'POST'
,
url
:
target
.
dataset
.
href
,
dataType
:
'json'
,
data
:
{
'_method'
:
target
.
dataset
.
method
,
},
success
:
(
data
)
=>
{
axios
[
target
.
dataset
.
method
](
target
.
dataset
.
href
)
.
then
(({
data
})
=>
{
this
.
updateRowState
(
target
);
return
this
.
updateBadges
(
data
);
},
});
this
.
updateBadges
(
data
);
}).
catch
(()
=>
flash
(
__
(
'Error updating todo status.'
)));
}
updateRowState
(
target
)
{
...
...
@@ -98,19 +95,15 @@ export default class Todos {
e
.
preventDefault
();
const
target
=
e
.
currentTarget
;
const
requestData
=
{
'_method'
:
target
.
dataset
.
method
,
ids
:
this
.
todo_ids
};
target
.
setAttribute
(
'disabled'
,
true
);
target
.
classList
.
add
(
'disabled'
);
$
.
ajax
({
type
:
'POST'
,
url
:
target
.
dataset
.
href
,
dataType
:
'json'
,
data
:
requestData
,
success
:
(
data
)
=>
{
this
.
updateAllState
(
target
,
data
);
return
this
.
updateBadges
(
data
);
},
});
axios
[
target
.
dataset
.
method
](
target
.
dataset
.
href
,
{
ids
:
this
.
todo_ids
,
}).
then
(({
data
})
=>
{
this
.
updateAllState
(
target
,
data
);
this
.
updateBadges
(
data
);
}).
catch
(()
=>
flash
(
__
(
'Error updating status for all todos.'
)));
}
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