diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2016-02-24 00:22:36 +0300 |
---|---|---|
committer | Rubén Dávila <rdavila84@gmail.com> | 2016-03-05 06:37:03 +0300 |
commit | ed4808555877c668366d98a5408937712ad10d52 (patch) | |
tree | 1a11a41356487d978b6e0ecdf2a84ef20221d192 /app | |
parent | 834b5d49ecb486065e3ecbf8b36becb416eff366 (diff) |
Refactor Merge Requests tab into a custom partial
* Add Labels tab to Groups
* Add decorator for label so it's aware of Milestones.
Diffstat (limited to 'app')
-rw-r--r-- | app/decorators/label_with_milestone.rb | 19 | ||||
-rw-r--r-- | app/models/global_milestone.rb | 6 | ||||
-rw-r--r-- | app/views/groups/milestones/show.html.haml | 8 | ||||
-rw-r--r-- | app/views/projects/milestones/show.html.haml | 14 | ||||
-rw-r--r-- | app/views/shared/milestones/_labels_tab.html.haml | 15 |
5 files changed, 47 insertions, 15 deletions
diff --git a/app/decorators/label_with_milestone.rb b/app/decorators/label_with_milestone.rb new file mode 100644 index 00000000000..a70a4e2f50d --- /dev/null +++ b/app/decorators/label_with_milestone.rb @@ -0,0 +1,19 @@ +class LabelWithMilestone + attr_reader :milestone + + def initialize(label, milestone) + @label, @milestone = label, milestone + end + + def method_missing(meth, *args) + if @label.respond_to?(meth) + @label.send(meth, *args) + else + super + end + end + + def respond_to?(meth) + @label.respond_to?(meth) + end +end diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb index 40193a6f050..e13aaf16732 100644 --- a/app/models/global_milestone.rb +++ b/app/models/global_milestone.rb @@ -87,6 +87,12 @@ class GlobalMilestone @participants ||= milestones.map(&:participants).flatten.compact.uniq end + def labels + @labels ||= milestones.map do |ms| + ms.labels.map { |label| LabelWithMilestone.new(label, ms) } + end.flatten.sort_by!(&:title) + end + def opened_issues issues.opened end diff --git a/app/views/groups/milestones/show.html.haml b/app/views/groups/milestones/show.html.haml index 0a15f49ff12..7ffa3f2d518 100644 --- a/app/views/groups/milestones/show.html.haml +++ b/app/views/groups/milestones/show.html.haml @@ -67,13 +67,17 @@ = link_to '#tab-participants', 'data-toggle' => 'tab' do Participants %span.badge= @milestone.participants.count + %li + = link_to '#tab-labels', 'data-toggle' => 'tab', 'data-show' => '.tab-issues-buttons' do + Labels + %span.badge= @milestone.labels.count .tab-content.milestone-content .tab-pane.active#tab-issues = render 'shared/milestones/issues_tab', unassigned: @milestone.opened_issues.unassigned, assigned: @milestone.opened_issues.assigned, closed: @milestone.closed_issues - .tab-pane#tab-merge-requests = render 'shared/milestones/merge_requests_tab', unassigned: @milestone.opened_merge_requests.unassigned, assigned: @milestone.opened_merge_requests.assigned, closed: @milestone.merge_requests.closed, merged: @milestone.merge_requests.merged - .tab-pane#tab-participants = render 'shared/milestones/participants_tab', users: @milestone.participants + .tab-pane#tab-labels + = render 'shared/milestones/labels_tab', labels: @milestone.labels diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml index 6ca66885eb4..4aa1a53e87e 100644 --- a/app/views/projects/milestones/show.html.haml +++ b/app/views/projects/milestones/show.html.haml @@ -100,16 +100,4 @@ .tab-pane#tab-participants = render 'shared/milestones/participants_tab', users: @users .tab-pane#tab-labels - %ul.bordered-list.manage-labels-list - - @labels.each do |label| - %li - = render_colored_label(label) - - args = [@milestone.project.namespace, @milestone.project, milestone_title: @milestone.title, label_name: label.title] - - options = args.extract_options! - - %span.issues-count - = link_to namespace_project_issues_path(*args, options.merge(state: 'opened')) do - = pluralize label.open_issues_count, 'open issue' - %span.issues-count - = link_to namespace_project_issues_path(*args, options.merge(state: 'closed')) do - = pluralize label.closed_issues_count, 'closed issue' + = render 'shared/milestones/labels_tab', labels: @labels diff --git a/app/views/shared/milestones/_labels_tab.html.haml b/app/views/shared/milestones/_labels_tab.html.haml new file mode 100644 index 00000000000..bb6ce0afb40 --- /dev/null +++ b/app/views/shared/milestones/_labels_tab.html.haml @@ -0,0 +1,15 @@ +%ul.bordered-list.manage-labels-list + - labels.each do |label| + - milestone = @milestone.is_a?(Milestone) ? @milestone : label.milestone + + %li + = render_colored_label(label) + - args = [milestone.project.namespace, milestone.project, milestone_title: milestone.title, label_name: label.title] + - options = args.extract_options! + + %span.issues-count + = link_to namespace_project_issues_path(*args, options.merge(state: 'opened')) do + = pluralize label.open_issues_count, 'open issue' + %span.issues-count + = link_to namespace_project_issues_path(*args, options.merge(state: 'closed')) do + = pluralize label.closed_issues_count, 'closed issue' |