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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
05a3479c
Commit
05a3479c
authored
Jan 30, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted labels_select.js to axios
parent
d5041184
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
85 deletions
+85
-85
app/assets/javascripts/labels_select.js
app/assets/javascripts/labels_select.js
+85
-85
No files found.
app/assets/javascripts/labels_select.js
View file @
05a3479c
...
...
@@ -2,9 +2,12 @@
/* global Issuable */
/* global ListLabel */
import
_
from
'
underscore
'
;
import
{
__
}
from
'
./locale
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
import
IssuableBulkUpdateActions
from
'
./issuable_bulk_update_actions
'
;
import
DropdownUtils
from
'
./filtered_search/dropdown_utils
'
;
import
CreateLabelDropdown
from
'
./create_label
'
;
import
flash
from
'
./flash
'
;
export
default
class
LabelsSelect
{
constructor
(
els
,
options
=
{})
{
...
...
@@ -82,99 +85,96 @@ export default class LabelsSelect {
}
$loading
.
removeClass
(
'
hidden
'
).
fadeIn
();
$dropdown
.
trigger
(
'
loading.gl.dropdown
'
);
return
$
.
ajax
({
type
:
'
PUT
'
,
url
:
issueUpdateURL
,
dataType
:
'
JSON
'
,
data
:
data
}).
done
(
function
(
data
)
{
var
labelCount
,
template
,
labelTooltipTitle
,
labelTitles
;
$loading
.
fadeOut
();
$dropdown
.
trigger
(
'
loaded.gl.dropdown
'
);
$selectbox
.
hide
();
data
.
issueURLSplit
=
issueURLSplit
;
labelCount
=
0
;
if
(
data
.
labels
.
length
)
{
template
=
labelHTMLTemplate
(
data
);
labelCount
=
data
.
labels
.
length
;
}
else
{
template
=
labelNoneHTMLTemplate
;
}
$value
.
removeAttr
(
'
style
'
).
html
(
template
);
$sidebarCollapsedValue
.
text
(
labelCount
);
if
(
data
.
labels
.
length
)
{
labelTitles
=
data
.
labels
.
map
(
function
(
label
)
{
return
label
.
title
;
});
if
(
labelTitles
.
length
>
5
)
{
labelTitles
=
labelTitles
.
slice
(
0
,
5
);
labelTitles
.
push
(
'
and
'
+
(
data
.
labels
.
length
-
5
)
+
'
more
'
);
axios
.
put
(
issueUpdateURL
,
data
)
.
then
(({
data
})
=>
{
var
labelCount
,
template
,
labelTooltipTitle
,
labelTitles
;
$loading
.
fadeOut
();
$dropdown
.
trigger
(
'
loaded.gl.dropdown
'
);
$selectbox
.
hide
();
data
.
issueURLSplit
=
issueURLSplit
;
labelCount
=
0
;
if
(
data
.
labels
.
length
)
{
template
=
labelHTMLTemplate
(
data
);
labelCount
=
data
.
labels
.
length
;
}
labelTooltipTitle
=
labelTitles
.
join
(
'
,
'
);
}
else
{
labelTooltipTitle
=
''
;
$sidebarLabelTooltip
.
tooltip
(
'
destroy
'
);
}
$sidebarLabelTooltip
.
attr
(
'
title
'
,
labelTooltipTitle
)
.
tooltip
(
'
fixTitle
'
);
$
(
'
.has-tooltip
'
,
$value
).
tooltip
({
container
:
'
body
'
});
});
else
{
template
=
labelNoneHTMLTemplate
;
}
$value
.
removeAttr
(
'
style
'
).
html
(
template
);
$sidebarCollapsedValue
.
text
(
labelCount
);
if
(
data
.
labels
.
length
)
{
labelTitles
=
data
.
labels
.
map
(
function
(
label
)
{
return
label
.
title
;
});
if
(
labelTitles
.
length
>
5
)
{
labelTitles
=
labelTitles
.
slice
(
0
,
5
);
labelTitles
.
push
(
'
and
'
+
(
data
.
labels
.
length
-
5
)
+
'
more
'
);
}
labelTooltipTitle
=
labelTitles
.
join
(
'
,
'
);
}
else
{
labelTooltipTitle
=
''
;
$sidebarLabelTooltip
.
tooltip
(
'
destroy
'
);
}
$sidebarLabelTooltip
.
attr
(
'
title
'
,
labelTooltipTitle
)
.
tooltip
(
'
fixTitle
'
);
$
(
'
.has-tooltip
'
,
$value
).
tooltip
({
container
:
'
body
'
});
})
.
catch
(()
=>
flash
(
__
(
'
Error saving label update.
'
)));
};
$dropdown
.
glDropdown
({
showMenuAbove
:
showMenuAbove
,
data
:
function
(
term
,
callback
)
{
return
$
.
ajax
({
url
:
labelUrl
}).
done
(
function
(
data
)
{
data
=
_
.
chain
(
data
).
groupBy
(
function
(
label
)
{
return
label
.
title
;
}).
map
(
function
(
label
)
{
var
color
;
color
=
_
.
map
(
label
,
function
(
dup
)
{
return
dup
.
color
;
});
return
{
id
:
label
[
0
].
id
,
title
:
label
[
0
].
title
,
color
:
color
,
duplicate
:
color
.
length
>
1
};
}).
value
();
if
(
$dropdown
.
hasClass
(
'
js-extra-options
'
))
{
var
extraData
=
[];
if
(
showNo
)
{
extraData
.
unshift
({
id
:
0
,
title
:
'
No Label
'
});
}
if
(
showAny
)
{
extraData
.
unshift
({
isAny
:
true
,
title
:
'
Any Label
'
axios
.
get
(
labelUrl
)
.
then
((
res
)
=>
{
let
data
=
_
.
chain
(
res
.
data
).
groupBy
(
function
(
label
)
{
return
label
.
title
;
}).
map
(
function
(
label
)
{
var
color
;
color
=
_
.
map
(
label
,
function
(
dup
)
{
return
dup
.
color
;
});
return
{
id
:
label
[
0
].
id
,
title
:
label
[
0
].
title
,
color
:
color
,
duplicate
:
color
.
length
>
1
};
}).
value
();
if
(
$dropdown
.
hasClass
(
'
js-extra-options
'
))
{
var
extraData
=
[];
if
(
showNo
)
{
extraData
.
unshift
({
id
:
0
,
title
:
'
No Label
'
});
}
if
(
showAny
)
{
extraData
.
unshift
({
isAny
:
true
,
title
:
'
Any Label
'
});
}
if
(
extraData
.
length
)
{
extraData
.
push
(
'
divider
'
);
data
=
extraData
.
concat
(
data
);
}
}
if
(
extraData
.
length
)
{
extraData
.
push
(
'
divider
'
);
data
=
extraData
.
concat
(
data
);
callback
(
data
);
if
(
showMenuAbove
)
{
$dropdown
.
data
(
'
glDropdown
'
).
positionMenuAbove
();
}
}
callback
(
data
);
if
(
showMenuAbove
)
{
$dropdown
.
data
(
'
glDropdown
'
).
positionMenuAbove
();
}
});
})
.
catch
(()
=>
flash
(
__
(
'
Error fetching labels.
'
)));
},
renderRow
:
function
(
label
,
instance
)
{
var
$a
,
$li
,
color
,
colorEl
,
indeterminate
,
removesAll
,
selectedClass
,
spacing
,
i
,
marked
,
dropdownName
,
dropdownValue
;
...
...
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