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
bc7895ff
Commit
bc7895ff
authored
Oct 28, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use label subject to calculate number of issues/mrs within the group
parent
2525e55e
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
25 deletions
+33
-25
app/finders/labels_finder.rb
app/finders/labels_finder.rb
+1
-1
app/models/group_label.rb
app/models/group_label.rb
+4
-0
app/models/label.rb
app/models/label.rb
+15
-15
app/models/project_label.rb
app/models/project_label.rb
+4
-0
app/views/groups/labels/index.html.haml
app/views/groups/labels/index.html.haml
+1
-1
app/views/projects/labels/index.html.haml
app/views/projects/labels/index.html.haml
+2
-2
app/views/shared/_label.html.haml
app/views/shared/_label.html.haml
+6
-6
No files found.
app/finders/labels_finder.rb
View file @
bc7895ff
...
@@ -22,7 +22,7 @@ class LabelsFinder < UnionFinder
...
@@ -22,7 +22,7 @@ class LabelsFinder < UnionFinder
label_ids
<<
project
.
group
.
labels
if
project
.
group
.
present?
label_ids
<<
project
.
group
.
labels
if
project
.
group
.
present?
label_ids
<<
project
.
labels
label_ids
<<
project
.
labels
else
else
label_ids
<<
Label
.
where
(
group_id:
projects
.
group_ids
)
label_ids
<<
Label
.
where
(
group_id:
projects
.
group_ids
.
uniq
)
label_ids
<<
Label
.
where
(
project_id:
projects
.
select
(
:id
))
label_ids
<<
Label
.
where
(
project_id:
projects
.
select
(
:id
))
end
end
...
...
app/models/group_label.rb
View file @
bc7895ff
...
@@ -5,6 +5,10 @@ class GroupLabel < Label
...
@@ -5,6 +5,10 @@ class GroupLabel < Label
alias_attribute
:subject
,
:group
alias_attribute
:subject
,
:group
def
subject_foreign_key
'group_id'
end
def
to_reference
(
source_project
=
nil
,
target_project
=
nil
,
format: :id
)
def
to_reference
(
source_project
=
nil
,
target_project
=
nil
,
format: :id
)
super
(
source_project
,
target_project
,
format:
format
)
super
(
source_project
,
target_project
,
format:
format
)
end
end
...
...
app/models/label.rb
View file @
bc7895ff
...
@@ -92,16 +92,23 @@ class Label < ActiveRecord::Base
...
@@ -92,16 +92,23 @@ class Label < ActiveRecord::Base
nil
nil
end
end
def
open_issues_count
(
user
=
nil
,
project
=
nil
)
def
open_issues_count
(
user
=
nil
)
issues_count
(
user
,
project_id:
project
.
try
(
:id
)
||
project_id
,
state:
'opened'
)
issues_count
(
user
,
state:
'opened'
)
end
end
def
closed_issues_count
(
user
=
nil
,
project
=
nil
)
def
closed_issues_count
(
user
=
nil
)
issues_count
(
user
,
project_id:
project
.
try
(
:id
)
||
project_id
,
state:
'closed'
)
issues_count
(
user
,
state:
'closed'
)
end
end
def
open_merge_requests_count
(
user
=
nil
,
project
=
nil
)
def
open_merge_requests_count
(
user
=
nil
)
merge_requests_count
(
user
,
project_id:
project
.
try
(
:id
)
||
project_id
,
state:
'opened'
)
params
=
{
subject_foreign_key
=>
subject
.
id
,
label_name:
title
,
scope:
'all'
,
state:
'opened'
}
MergeRequestsFinder
.
new
(
user
,
params
.
with_indifferent_access
).
execute
.
count
end
end
def
prioritize!
(
project
,
value
)
def
prioritize!
(
project
,
value
)
...
@@ -167,15 +174,8 @@ class Label < ActiveRecord::Base
...
@@ -167,15 +174,8 @@ class Label < ActiveRecord::Base
end
end
def
issues_count
(
user
,
params
=
{})
def
issues_count
(
user
,
params
=
{})
IssuesFinder
.
new
(
user
,
params
.
reverse_merge
(
label_name:
title
,
scope:
'all'
))
params
.
merge!
(
subject_foreign_key
=>
subject
.
id
,
label_name:
title
,
scope:
'all'
)
.
execute
IssuesFinder
.
new
(
user
,
params
.
with_indifferent_access
).
execute
.
count
.
count
end
def
merge_requests_count
(
user
,
params
=
{})
MergeRequestsFinder
.
new
(
user
,
params
.
reverse_merge
(
label_name:
title
,
scope:
'all'
))
.
execute
.
count
end
end
def
label_format_reference
(
format
=
:id
)
def
label_format_reference
(
format
=
:id
)
...
...
app/models/project_label.rb
View file @
bc7895ff
...
@@ -12,6 +12,10 @@ class ProjectLabel < Label
...
@@ -12,6 +12,10 @@ class ProjectLabel < Label
alias_attribute
:subject
,
:project
alias_attribute
:subject
,
:project
def
subject_foreign_key
'project_id'
end
def
to_reference
(
target_project
=
nil
,
format: :id
)
def
to_reference
(
target_project
=
nil
,
format: :id
)
super
(
project
,
target_project
,
format:
format
)
super
(
project
,
target_project
,
format:
format
)
end
end
...
...
app/views/groups/labels/index.html.haml
View file @
bc7895ff
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
.other-labels
.other-labels
-
if
@labels
.
present?
-
if
@labels
.
present?
%ul
.content-list.manage-labels-list.js-other-labels
%ul
.content-list.manage-labels-list.js-other-labels
=
render
partial:
'shared/label'
,
collection:
@labels
,
as: :label
=
render
partial:
'shared/label'
,
subject:
@group
,
collection:
@labels
,
as: :label
=
paginate
@labels
,
theme:
'gitlab'
=
paginate
@labels
,
theme:
'gitlab'
-
else
-
else
.nothing-here-block
.nothing-here-block
...
...
app/views/projects/labels/index.html.haml
View file @
bc7895ff
...
@@ -22,14 +22,14 @@
...
@@ -22,14 +22,14 @@
%ul
.content-list.manage-labels-list.js-prioritized-labels
{
"data-url"
=>
set_priorities_namespace_project_labels_path
(
@project
.
namespace
,
@project
)
}
%ul
.content-list.manage-labels-list.js-prioritized-labels
{
"data-url"
=>
set_priorities_namespace_project_labels_path
(
@project
.
namespace
,
@project
)
}
%p
.empty-message
{
class:
(
'hidden'
unless
@prioritized_labels
.
empty?
)
}
No prioritized labels yet
%p
.empty-message
{
class:
(
'hidden'
unless
@prioritized_labels
.
empty?
)
}
No prioritized labels yet
-
if
@prioritized_labels
.
present?
-
if
@prioritized_labels
.
present?
=
render
partial:
'shared/label'
,
collection:
@prioritized_labels
,
as: :label
=
render
partial:
'shared/label'
,
subject:
@project
,
collection:
@prioritized_labels
,
as: :label
.other-labels
.other-labels
-
if
can?
(
current_user
,
:admin_label
,
@project
)
-
if
can?
(
current_user
,
:admin_label
,
@project
)
%h5
{
class:
(
'hide'
if
hide
)
}
Other Labels
%h5
{
class:
(
'hide'
if
hide
)
}
Other Labels
%ul
.content-list.manage-labels-list.js-other-labels
%ul
.content-list.manage-labels-list.js-other-labels
-
if
@labels
.
present?
-
if
@labels
.
present?
=
render
partial:
'shared/label'
,
collection:
@labels
,
as: :label
=
render
partial:
'shared/label'
,
subject:
@project
,
collection:
@labels
,
as: :label
=
paginate
@labels
,
theme:
'gitlab'
=
paginate
@labels
,
theme:
'gitlab'
-
if
@labels
.
blank?
-
if
@labels
.
blank?
.nothing-here-block
.nothing-here-block
...
...
app/views/shared/_label.html.haml
View file @
bc7895ff
-
label_css_id
=
dom_id
(
label
)
-
label_css_id
=
dom_id
(
label
)
-
open_issues_count
=
label
.
open_issues_count
(
current_user
,
@project
)
-
open_issues_count
=
label
.
open_issues_count
(
current_user
)
-
open_merge_requests_count
=
label
.
open_merge_requests_count
(
current_user
,
@project
)
-
open_merge_requests_count
=
label
.
open_merge_requests_count
(
current_user
)
%li
{
id:
label_css_id
,
data:
{
id:
label
.
id
}
}
%li
{
id:
label_css_id
,
data:
{
id:
label
.
id
}
}
=
render
"shared/label_row"
,
label:
label
=
render
"shared/label_row"
,
label:
label
...
@@ -12,10 +12,10 @@
...
@@ -12,10 +12,10 @@
.dropdown-menu.dropdown-menu-align-right
.dropdown-menu.dropdown-menu-align-right
%ul
%ul
%li
%li
=
link_to_label
(
label
,
subject:
@project
,
type: :merge_request
)
do
=
link_to_label
(
label
,
subject:
local_assigns
[
:subject
]
,
type: :merge_request
)
do
=
pluralize
open_merge_requests_count
,
'merge request'
=
pluralize
open_merge_requests_count
,
'merge request'
%li
%li
=
link_to_label
(
label
,
subject:
@project
)
do
=
link_to_label
(
label
,
subject:
local_assigns
[
:subject
]
)
do
=
pluralize
open_issues_count
,
'open issue'
=
pluralize
open_issues_count
,
'open issue'
-
if
current_user
-
if
current_user
%li
.label-subscription
{
data:
toggle_subscription_data
(
label
)
}
%li
.label-subscription
{
data:
toggle_subscription_data
(
label
)
}
...
@@ -28,9 +28,9 @@
...
@@ -28,9 +28,9 @@
=
link_to
'Delete'
,
destroy_label_path
(
label
),
title:
'Delete'
,
method: :delete
,
remote:
true
,
data:
{
confirm:
'Remove this label? Are you sure?'
}
=
link_to
'Delete'
,
destroy_label_path
(
label
),
title:
'Delete'
,
method: :delete
,
remote:
true
,
data:
{
confirm:
'Remove this label? Are you sure?'
}
.pull-right.hidden-xs.hidden-sm.hidden-md
.pull-right.hidden-xs.hidden-sm.hidden-md
=
link_to_label
(
label
,
subject:
@project
,
type: :merge_request
,
css_class:
'btn btn-transparent btn-action'
)
do
=
link_to_label
(
label
,
subject:
local_assigns
[
:subject
]
,
type: :merge_request
,
css_class:
'btn btn-transparent btn-action'
)
do
=
pluralize
open_merge_requests_count
,
'merge request'
=
pluralize
open_merge_requests_count
,
'merge request'
=
link_to_label
(
label
,
subject:
@project
,
css_class:
'btn btn-transparent btn-action'
)
do
=
link_to_label
(
label
,
subject:
local_assigns
[
:subject
]
,
css_class:
'btn btn-transparent btn-action'
)
do
=
pluralize
open_issues_count
,
'open issue'
=
pluralize
open_issues_count
,
'open issue'
-
if
current_user
-
if
current_user
...
...
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