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
5cefd8ab
Commit
5cefd8ab
authored
Apr 19, 2016
by
Arinde Eniola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some refactoring
parent
259970ca
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
49 deletions
+48
-49
app/assets/javascripts/issues.js.coffee
app/assets/javascripts/issues.js.coffee
+27
-20
app/assets/javascripts/labels_select.js.coffee
app/assets/javascripts/labels_select.js.coffee
+5
-8
app/assets/javascripts/lib/url_utility.js.coffee
app/assets/javascripts/lib/url_utility.js.coffee
+6
-10
app/assets/javascripts/merge_requests.js.coffee
app/assets/javascripts/merge_requests.js.coffee
+1
-0
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+7
-9
app/views/shared/_labels_row.html.haml
app/views/shared/_labels_row.html.haml
+2
-2
No files found.
app/assets/javascripts/issues.js.coffee
View file @
5cefd8ab
...
...
@@ -3,6 +3,7 @@
Issues
.
initTemplates
()
Issues
.
initSearch
()
Issues
.
initChecks
()
Issues
.
toggleLabelFilters
()
$
(
"body"
).
on
"ajax:success"
,
".close_issue, .reopen_issue"
,
->
t
=
$
(
this
)
...
...
@@ -20,11 +21,20 @@
Issue
.
labelRow
=
_
.
template
(
'<% _.each(labels, function(label){ %>
<span class="label-row">
<a href="#"><span class="label color-label" style="background-color: <%= label.color %>; color: #FFFFFF" title="<%= label.description %>" data-container="body"><%= label.title %></span></a>
<a href="#"><span class="label color-label
has-tooltip
" style="background-color: <%= label.color %>; color: #FFFFFF" title="<%= label.description %>" data-container="body"><%= label.title %></span></a>
</span>
<% }); %>'
)
toggleLabelFilters
:
()
->
$filteredLabels
=
$
(
'.filtered-labels'
)
if
$filteredLabels
.
find
(
'.label-row'
).
length
>
0
#$filteredLabels.show()
$filteredLabels
.
slideDown
().
css
({
'overflow'
:
'visible'
})
else
#$filteredLabels.hide()
$filteredLabels
.
slideUp
().
css
({
'overflow'
:
'visible'
})
reload
:
->
Issues
.
initChecks
()
$
(
'#filter_issue_search'
).
val
(
$
(
'#issue_search'
).
val
())
...
...
@@ -43,13 +53,15 @@
paramKeys
=
[
'author_id'
,
'milestone_title'
,
'assignee_id'
,
'issue_search'
]
for
paramKey
in
paramKeys
newParams
[
paramKey
]
=
gl
.
utils
.
get
UrlParameter
(
paramKey
)
or
''
newParams
[
paramKey
]
=
gl
.
utils
.
get
ParameterValues
(
paramKey
)[
0
]
or
''
if
stateFilters
.
length
stateFilters
.
find
(
'a'
).
each
->
initialUrl
=
gl
.
utils
.
removeParamQueryString
(
$
(
this
).
attr
(
'href'
),
'label_name[]'
)
if
gl
.
utils
.
getParamQueryString
(
'label_name[]'
)
newUrl
=
"
#{
gl
.
utils
.
mergeUrlParams
(
newParams
,
initialUrl
)
}
&
#{
gl
.
utils
.
getParamQueryString
(
'label_name[]'
)
}
"
labelNameValues
=
gl
.
utils
.
getParameterValues
(
'label_name[]'
)
if
labelNameValues
labelNameQueryString
=
(
"label_name[]=
#{
value
}
"
for
value
in
labelNameValues
).
join
(
'&'
)
newUrl
=
"
#{
gl
.
utils
.
mergeUrlParams
(
newParams
,
initialUrl
)
}
&
#{
labelNameQueryString
}
"
else
newUrl
=
gl
.
utils
.
mergeUrlParams
(
newParams
,
initialUrl
)
$
(
this
).
attr
'href'
,
newUrl
...
...
@@ -84,29 +96,24 @@
Issues
.
reload
()
Issues
.
updateStateFilters
()
$filteredLabels
=
$
(
'.filtered-labels'
)
$filteredLabelsSpans
=
$filteredLabels
.
find
(
'
span
'
)
$filteredLabelsSpans
=
$filteredLabels
.
find
(
'
.label-row
'
)
gl
.
animate
.
animateEach
(
$filteredLabelsSpans
,
'fadeOutDown'
,
20
,
{
cssStart
:
{
$filteredLabelsSpans
,
'fadeOutDown'
,
20
,
cssStart
:
opacity
:
1
},
cssEnd
:
{
cssEnd
:
opacity
:
0
}
}).
then
(
->
).
then
(
->
if
typeof
Issue
.
labelRow
is
'function'
$filteredLabels
.
html
(
Issue
.
labelRow
(
data
))
$spans
=
$filteredLabels
.
find
(
'span'
)
$spans
.
css
(
'opacity'
,
0
)
return
gl
.
animate
.
animateEach
(
$spans
,
'fadeInUp'
,
20
,
{
cssStart
:
{
Issues
.
toggleLabelFilters
()
$spans
=
$filteredLabels
.
find
(
'.label-row'
)
$spans
.
css
(
'opacity'
,
0
)
return
gl
.
animate
.
animateEach
$spans
,
'fadeInUp'
,
20
,
cssStart
:
opacity
:
0
},
cssEnd
:
{
cssEnd
:
opacity
:
1
}
})
)
dataType
:
"json"
...
...
app/assets/javascripts/labels_select.js.coffee
View file @
5cefd8ab
...
...
@@ -224,7 +224,7 @@ class @LabelsSelect
selected_labels
=
$
(
'.js-label-select'
).
siblings
(
'.dropdown-menu-labels'
).
find
(
'.is-active'
)
if
selected
and
selected
.
title
?
if
selected_labels
and
selected_labels
.
length
>
1
if
selected_labels
.
length
>
1
"
#{
selected
.
title
}
+
#{
selected_labels
.
length
-
1
}
more"
else
selected
.
title
...
...
@@ -247,7 +247,7 @@ class @LabelsSelect
hidden
:
->
page
=
$
(
'body'
).
data
'page'
isIssueIndex
=
page
is
'projects:issues:index'
isMRIndex
=
page
is
page
is
'projects:merge_requests:index'
isMRIndex
=
page
is
'projects:merge_requests:index'
$selectbox
.
hide
()
# display:block overrides the hide-collapse rule
...
...
@@ -256,11 +256,8 @@ class @LabelsSelect
if
$dropdown
.
hasClass
(
'js-filter-submit'
)
and
(
isIssueIndex
or
isMRIndex
)
selectedLabels
=
$dropdown
.
closest
(
'form'
)
.
find
(
"input[type='hidden'][name='
#{
$dropdown
.
data
(
'fieldName'
)
}
']"
)
Issues
.
filterResults
(
$dropdown
.
closest
(
'form'
),
$dropdown
.
data
(
'fieldName'
)
)
.
find
(
"input:hidden[name='
#{
$dropdown
.
data
(
'fieldName'
)
}
']"
)
Issues
.
filterResults
$dropdown
.
closest
(
'form'
)
else
if
$dropdown
.
hasClass
(
'js-filter-submit'
)
$dropdown
.
closest
(
'form'
).
submit
()
else
...
...
@@ -270,7 +267,7 @@ class @LabelsSelect
clicked
:
(
label
)
->
page
=
$
(
'body'
).
data
'page'
isIssueIndex
=
page
is
'projects:issues:index'
isMRIndex
=
page
is
page
is
'projects:merge_requests:index'
isMRIndex
=
page
is
'projects:merge_requests:index'
if
$dropdown
.
hasClass
(
'js-filter-submit'
)
and
(
isIssueIndex
or
isMRIndex
)
if
not
$dropdown
.
hasClass
'js-multiselect'
selectedLabel
=
label
.
title
...
...
app/assets/javascripts/lib/url_utility.js.coffee
View file @
5cefd8ab
...
...
@@ -3,16 +3,20 @@
w
.
gl
?=
{}
w
.
gl
.
utils
?=
{}
w
.
gl
.
utils
.
getUrlParameter
=
(
sParam
)
->
# Returns an array containing the value(s) of the
# of the key passed as an argument
w
.
gl
.
utils
.
getParameterValues
=
(
sParam
)
->
sPageURL
=
decodeURIComponent
(
window
.
location
.
search
.
substring
(
1
))
sURLVariables
=
sPageURL
.
split
(
'&'
)
sParameterName
=
undefined
values
=
[]
i
=
0
while
i
<
sURLVariables
.
length
sParameterName
=
sURLVariables
[
i
].
split
(
'='
)
if
sParameterName
[
0
]
is
sParam
return
if
sParameterName
[
1
]
is
undefined
then
true
else
sParameterName
[
1
]
values
.
push
(
sParameterName
[
1
])
i
++
values
# #
# @param {Object} params - url keys and value to merge
...
...
@@ -28,14 +32,6 @@
newUrl
=
"
#{
newUrl
}#{
(
if
newUrl
.
indexOf
(
'?'
)
>
0
then
'&'
else
'?'
)
}#{
paramName
}
=
#{
paramValue
}
"
newUrl
# get parameter query string from url.
w
.
gl
.
utils
.
getParamQueryString
=
(
param
)
->
pageURL
=
decodeURIComponent
(
window
.
location
.
search
.
substring
(
1
))
urlVariables
=
pageURL
.
split
(
'&'
)
(
variables
for
variables
in
urlVariables
when
variables
.
indexOf
(
param
)
>
-
1
).
join
(
'&'
)
# removes parameter query string from url. returns the modified url
w
.
gl
.
utils
.
removeParamQueryString
=
(
url
,
param
)
->
url
=
decodeURIComponent
(
url
)
...
...
app/assets/javascripts/merge_requests.js.coffee
View file @
5cefd8ab
...
...
@@ -3,6 +3,7 @@
#
@
MergeRequests
=
init
:
->
$
(
'.filtered-labels'
).
hide
()
MergeRequests
.
initSearch
()
# Make sure we trigger ajax request only after user stop typing
...
...
app/helpers/issuables_helper.rb
View file @
5cefd8ab
...
...
@@ -18,22 +18,20 @@ module IssuablesHelper
def
multi_label_name
(
current_labels
,
default_label
)
# current_labels may be a string from before
if
current_labels
.
respond_to?
(
'any?'
)
if
current_labels
.
any?
if
current_labels
.
count
>
1
"
#{
current_labels
[
0
]
}
+
#{
current_labels
.
count
-
1
}
more"
else
current_labels
[
0
]
end
if
current_labels
.
is_a?
(
Array
)
if
current_labels
.
count
>
1
"
#{
current_labels
[
0
]
}
+
#{
current_labels
.
count
-
1
}
more"
else
default_label
current_labels
[
0
]
end
els
e
els
if
current_labels
.
is_a?
(
String
)
if
current_labels
.
nil?
||
current_labels
.
empty?
default_label
else
current_labels
end
else
default_label
end
end
...
...
app/views/shared/_labels_row.html.haml
View file @
5cefd8ab
-
labels
.
each
do
|
l
|
-
labels
.
each
do
|
l
abel
|
%span
.label-row
=
link_to_label
(
l
,
tooltip:
false
)
\ No newline at end of file
=
link_to_label
(
label
,
tooltip:
false
)
\ No newline at end of file
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