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
Léo-Paul Géneau
gitlab-ce
Commits
a8badbe5
Commit
a8badbe5
authored
Jan 24, 2018
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace $.post in label manager with axios
parent
f35bac57
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
18 deletions
+14
-18
app/assets/javascripts/label_manager.js
app/assets/javascripts/label_manager.js
+14
-18
No files found.
app/assets/javascripts/label_manager.js
View file @
a8badbe5
/* eslint-disable comma-dangle, class-methods-use-this, no-underscore-dangle, no-param-reassign, no-unused-vars, consistent-return, func-names, space-before-function-paren, max-len */
/* eslint-disable comma-dangle, class-methods-use-this, no-underscore-dangle, no-param-reassign, no-unused-vars, consistent-return, func-names, space-before-function-paren, max-len */
import
Sortable
from
'
vendor/Sortable
'
;
import
Sortable
from
'
vendor/Sortable
'
;
import
Flash
from
'
./flash
'
;
import
flash
from
'
./flash
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
export
default
class
LabelManager
{
export
default
class
LabelManager
{
constructor
({
togglePriorityButton
,
prioritizedLabels
,
otherLabels
}
=
{})
{
constructor
({
togglePriorityButton
,
prioritizedLabels
,
otherLabels
}
=
{})
{
...
@@ -50,11 +51,12 @@ export default class LabelManager {
...
@@ -50,11 +51,12 @@ export default class LabelManager {
if
(
persistState
==
null
)
{
if
(
persistState
==
null
)
{
persistState
=
true
;
persistState
=
true
;
}
}
let
xhr
;
const
_this
=
this
;
const
_this
=
this
;
const
url
=
$label
.
find
(
'
.js-toggle-priority
'
).
data
(
'
url
'
);
const
url
=
$label
.
find
(
'
.js-toggle-priority
'
).
data
(
'
url
'
);
let
$target
=
this
.
prioritizedLabels
;
let
$target
=
this
.
prioritizedLabels
;
let
$from
=
this
.
otherLabels
;
let
$from
=
this
.
otherLabels
;
const
rollbackLabelPosition
=
this
.
rollbackLabelPosition
.
bind
(
this
,
$label
,
action
);
if
(
action
===
'
remove
'
)
{
if
(
action
===
'
remove
'
)
{
$target
=
this
.
otherLabels
;
$target
=
this
.
otherLabels
;
$from
=
this
.
prioritizedLabels
;
$from
=
this
.
prioritizedLabels
;
...
@@ -71,40 +73,34 @@ export default class LabelManager {
...
@@ -71,40 +73,34 @@ export default class LabelManager {
return
;
return
;
}
}
if
(
action
===
'
remove
'
)
{
if
(
action
===
'
remove
'
)
{
xhr
=
$
.
ajax
({
axios
.
delete
(
url
)
url
,
.
catch
(
rollbackLabelPosition
);
type
:
'
DELETE
'
});
// Restore empty message
// Restore empty message
if
(
!
$from
.
find
(
'
li
'
).
length
)
{
if
(
!
$from
.
find
(
'
li
'
).
length
)
{
$from
.
find
(
'
.empty-message
'
).
removeClass
(
'
hidden
'
);
$from
.
find
(
'
.empty-message
'
).
removeClass
(
'
hidden
'
);
}
}
}
else
{
}
else
{
xhr
=
this
.
savePrioritySort
(
$label
,
action
);
this
.
savePrioritySort
(
$label
,
action
)
.
catch
(
rollbackLabelPosition
);
}
}
return
xhr
.
fail
(
this
.
rollbackLabelPosition
.
bind
(
this
,
$label
,
action
));
}
}
onPrioritySortUpdate
()
{
onPrioritySortUpdate
()
{
const
xhr
=
this
.
savePrioritySort
();
this
.
savePrioritySort
()
return
xhr
.
fail
(
function
()
{
.
catch
(()
=>
flash
(
this
.
errorMessage
));
return
new
Flash
(
this
.
errorMessage
,
'
alert
'
);
});
}
}
savePrioritySort
()
{
savePrioritySort
()
{
return
$
.
post
({
return
axios
.
post
(
this
.
prioritizedLabels
.
data
(
'
url
'
),
{
url
:
this
.
prioritizedLabels
.
data
(
'
url
'
),
label_ids
:
this
.
getSortedLabelsIds
(),
data
:
{
label_ids
:
this
.
getSortedLabelsIds
()
}
});
});
}
}
rollbackLabelPosition
(
$label
,
originalAction
)
{
rollbackLabelPosition
(
$label
,
originalAction
)
{
const
action
=
originalAction
===
'
remove
'
?
'
add
'
:
'
remove
'
;
const
action
=
originalAction
===
'
remove
'
?
'
add
'
:
'
remove
'
;
this
.
toggleLabelPriority
(
$label
,
action
,
false
);
this
.
toggleLabelPriority
(
$label
,
action
,
false
);
return
new
Flash
(
this
.
errorMessage
,
'
alert
'
);
return
flash
(
this
.
errorMessage
);
}
}
getSortedLabelsIds
()
{
getSortedLabelsIds
()
{
...
...
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