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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
9066ac0d
Commit
9066ac0d
authored
Apr 15, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix create label functionality
parent
0556d661
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
41 deletions
+25
-41
app/assets/javascripts/labels_select.js.coffee
app/assets/javascripts/labels_select.js.coffee
+25
-41
No files found.
app/assets/javascripts/labels_select.js.coffee
View file @
9066ac0d
...
@@ -2,14 +2,15 @@ class @LabelsSelect
...
@@ -2,14 +2,15 @@ class @LabelsSelect
constructor
:
->
constructor
:
->
$
(
'.js-label-select'
).
each
(
i
,
dropdown
)
->
$
(
'.js-label-select'
).
each
(
i
,
dropdown
)
->
$dropdown
=
$
(
dropdown
)
$dropdown
=
$
(
dropdown
)
$parent
=
$dropdown
.
parent
()
projectId
=
$dropdown
.
data
(
'project-id'
)
projectId
=
$dropdown
.
data
(
'project-id'
)
labelUrl
=
$dropdown
.
data
(
'labels'
)
labelUrl
=
$dropdown
.
data
(
'labels'
)
issueUpdateURL
=
$dropdown
.
data
(
'issueUpdate'
)
issueUpdateURL
=
$dropdown
.
data
(
'issueUpdate'
)
selectedLabel
=
$dropdown
.
data
(
'selected'
)
selectedLabel
=
$dropdown
.
data
(
'selected'
)
if
selectedLabel
?
if
selectedLabel
?
selectedLabel
=
selectedLabel
.
split
(
','
)
selectedLabel
=
selectedLabel
.
split
(
','
)
newLabelField
=
$
(
'#new_label_name'
)
newLabelField
=
$
(
'#new_label_name'
,
$parent
)
newColorField
=
$
(
'#new_label_color'
)
newColorField
=
$
(
'#new_label_color'
,
$parent
)
showNo
=
$dropdown
.
data
(
'show-no'
)
showNo
=
$dropdown
.
data
(
'show-no'
)
showAny
=
$dropdown
.
data
(
'show-any'
)
showAny
=
$dropdown
.
data
(
'show-any'
)
defaultLabel
=
$dropdown
.
data
(
'default-label'
)
defaultLabel
=
$dropdown
.
data
(
'default-label'
)
...
@@ -18,6 +19,11 @@ class @LabelsSelect
...
@@ -18,6 +19,11 @@ class @LabelsSelect
$block
=
$selectbox
.
closest
(
'.block'
)
$block
=
$selectbox
.
closest
(
'.block'
)
$sidebarCollapsedValue
=
$block
.
find
(
'.sidebar-collapsed-icon span'
)
$sidebarCollapsedValue
=
$block
.
find
(
'.sidebar-collapsed-icon span'
)
$value
=
$block
.
find
(
'.value'
)
$value
=
$block
.
find
(
'.value'
)
$newLabelError
=
$
(
'.js-label-error'
,
$parent
)
$colorPreview
=
$
(
'.js-dropdown-label-color-preview'
,
$parent
)
$newLabelCreateButton
=
$
(
'.js-new-label-btn'
,
$parent
)
$newLabelError
.
hide
()
$loading
=
$block
.
find
(
'.block-loading'
).
fadeOut
()
$loading
=
$block
.
find
(
'.block-loading'
).
fadeOut
()
issueURLSplit
=
issueUpdateURL
.
split
(
'/'
)
if
issueUpdateURL
?
issueURLSplit
=
issueUpdateURL
.
split
(
'/'
)
if
issueUpdateURL
?
...
@@ -33,11 +39,7 @@ class @LabelsSelect
...
@@ -33,11 +39,7 @@ class @LabelsSelect
);
);
labelNoneHTMLTemplate
=
_
.
template
(
'<div class="light">None</div>'
)
labelNoneHTMLTemplate
=
_
.
template
(
'<div class="light">None</div>'
)
if
newLabelField
.
length
and
$dropdown
.
hasClass
'js-extra-options'
if
newLabelField
.
length
$newLabelCreateButton
=
$
(
'.js-new-label-btn'
)
$colorPreview
=
$
(
'.js-dropdown-label-color-preview'
)
$newLabelError
=
$dropdown
.
parent
().
find
(
'.js-label-error'
)
$newLabelError
.
hide
()
# Suggested colors in the dropdown to chose from pre-chosen colors
# Suggested colors in the dropdown to chose from pre-chosen colors
$
(
'.suggest-colors-dropdown a'
).
on
"click"
,
(
e
)
->
$
(
'.suggest-colors-dropdown a'
).
on
"click"
,
(
e
)
->
...
@@ -78,14 +80,17 @@ class @LabelsSelect
...
@@ -78,14 +80,17 @@ class @LabelsSelect
enableLabelCreateButton
=
->
enableLabelCreateButton
=
->
if
newLabelField
.
val
()
isnt
''
and
newColorField
.
val
()
isnt
''
if
newLabelField
.
val
()
isnt
''
and
newColorField
.
val
()
isnt
''
$newLabelError
.
hide
()
$newLabelError
.
hide
()
$
(
'.js-new-label-btn'
).
disable
()
$newLabelCreateButton
.
enable
()
else
$newLabelCreateButton
.
disable
()
saveLabel
=
->
# Create new label with API
# Create new label with API
Api
.
newLabel
projectId
,
{
Api
.
newLabel
projectId
,
{
name
:
newLabelField
.
val
()
name
:
newLabelField
.
val
()
color
:
newColorField
.
val
()
color
:
newColorField
.
val
()
},
(
label
)
->
},
(
label
)
->
$
(
'.js-new-label-btn'
)
.
enable
()
$newLabelCreateButton
.
enable
()
if
label
.
message
?
if
label
.
message
?
$newLabelError
$newLabelError
...
@@ -94,10 +99,6 @@ class @LabelsSelect
...
@@ -94,10 +99,6 @@ class @LabelsSelect
else
else
$
(
'.dropdown-menu-back'
,
$dropdown
.
parent
()).
trigger
'click'
$
(
'.dropdown-menu-back'
,
$dropdown
.
parent
()).
trigger
'click'
$newLabelCreateButton
.
enable
()
else
$newLabelCreateButton
.
disable
()
newLabelField
.
on
'keyup change'
,
enableLabelCreateButton
newLabelField
.
on
'keyup change'
,
enableLabelCreateButton
newColorField
.
on
'keyup change'
,
enableLabelCreateButton
newColorField
.
on
'keyup change'
,
enableLabelCreateButton
...
@@ -108,24 +109,7 @@ class @LabelsSelect
...
@@ -108,24 +109,7 @@ class @LabelsSelect
.
on
'click'
,
(
e
)
->
.
on
'click'
,
(
e
)
->
e
.
preventDefault
()
e
.
preventDefault
()
e
.
stopPropagation
()
e
.
stopPropagation
()
saveLabel
()
if
newLabelField
.
val
()
isnt
''
and
newColorField
.
val
()
isnt
''
$newLabelError
.
hide
()
$
(
'.js-new-label-btn'
).
disable
()
# Create new label with API
Api
.
newLabel
projectId
,
{
name
:
newLabelField
.
val
()
color
:
newColorField
.
val
()
},
(
label
)
->
$
(
'.js-new-label-btn'
).
enable
()
if
label
.
message
?
$newLabelError
.
text
label
.
message
.
show
()
else
$
(
'.dropdown-menu-back'
,
$dropdown
.
parent
()).
trigger
'click'
saveLabelData
=
->
saveLabelData
=
->
selected
=
$dropdown
selected
=
$dropdown
...
...
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