From fb6c341e6f7acc0cde4e6d3c961885dbf0ecf50a Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 10 Oct 2012 04:42:48 -0700 Subject: [PATCH 1/2] add overview of issues in milestone --- app/controllers/issues_controller.rb | 8 +++ app/roles/issue_commonality.rb | 2 +- app/views/issues/_issues.html.haml | 5 +- app/views/issues/index.print.haml | 77 ++++++++++++++++++++++++++++ config/initializers/mime_types.rb | 1 + 5 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 app/views/issues/index.print.haml diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 0f28fc3a111..1fcedf1ff50 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -24,6 +24,14 @@ class IssuesController < ProjectResourceController format.html # index.html.erb format.js format.atom { render layout: false } + format.print do + if params[:milestone_id] + @milestone = Milestone.find params[:milestone_id] + @issues = @milestone.issues.recent + else + redirect_to project_issues_path(@project), notice: "Milestone not specified." + end + end end end diff --git a/app/roles/issue_commonality.rb b/app/roles/issue_commonality.rb index 3d9074867b7..449b58071b5 100644 --- a/app/roles/issue_commonality.rb +++ b/app/roles/issue_commonality.rb @@ -17,7 +17,7 @@ module IssueCommonality scope :closed, where(closed: true) scope :of_group, ->(group) { where(project_id: group.project_ids) } scope :assigned, ->(u) { where(assignee_id: u.id)} - scope :recent, order("created_at DESC") + scope :recent, order('created_at DESC') delegate :name, :email, diff --git a/app/views/issues/_issues.html.haml b/app/views/issues/_issues.html.haml index f82ae8bde58..92fbfee2b19 100644 --- a/app/views/issues/_issues.html.haml +++ b/app/views/issues/_issues.html.haml @@ -6,10 +6,11 @@ .row .span7= paginate @issues, remote: true, theme: "gitlab" .span3.right - %span.cgray.right + %span.cgray.right %span.issue_counter #{@issues.total_count} issues for this filter + - if params[:milestone_id].present? + = link_to 'Print', project_issues_path(@project, :print, milestone_id: params[:milestone_id]), target: '_blank' - else %li %h4.nothing_here_message Nothing to show here - diff --git a/app/views/issues/index.print.haml b/app/views/issues/index.print.haml new file mode 100644 index 00000000000..56ad1815d91 --- /dev/null +++ b/app/views/issues/index.print.haml @@ -0,0 +1,77 @@ +!!! 5 +%html + %head + %meta{charset: "utf-8"} + %title + GitLab + = " > #{@project.name} | Milestone #{@milestone.title} | Issues" + = favicon_link_tag 'favicon.ico' + = stylesheet_link_tag 'application' + %body + .container + .content + %h2= @project.name + + %h2 Milestone + %table.table.table-bordered.table-hover + %tbody + %tr + %td.span2 + %strong ID + %td + = "##{@milestone.id}" + %tr + %td.span2 + %strong Title + %td + = link_to @milestone.title, project_milestone_path(@project, @milestone) + %tr + %td.span2 + %strong Description + %td + = @milestone.description + %tr + %td.span2 + %strong Expires at + %td + = @milestone.due_date + %tr + %td.span2 + %strong Created at + %td + = @milestone.created_at.to_s(:db) + %tr + %td.span2 + %strong Issue stats + %td + = "Total: #{@issues.size}" + %br + = "Open: #{@issues.opened.size}" + %br + = "Closed: #{@issues.closed.size}" + + %h2 Issues + %table.table.table-bordered.table-hover + %thead + %tr + %th ID + %th Title + %th Assigned to + %th Status + %th Created at + %tbody + - @issues.each do |issue| + %tr + %td.span1 + = "##{issue.id}" + %td + = link_to issue.title, project_issue_path(@project, issue) + %td + - if issue.is_assigned? + = link_to issue.assignee_name, project_issue_path(@project, issue) + - else + — + %td + = issue.closed? ? "closed" : "open" + %td.span2 + = issue.created_at.to_s(:db) diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 3549b8362bb..3c90bb325d8 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -5,3 +5,4 @@ # Mime::Type.register_alias "text/html", :iphone Mime::Type.register_alias 'text/plain', :patch +Mime::Type.register_alias 'text/html', :print -- GitLab From 2588fbe3dabc0659e367aa0032b4a7679e16301f Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 10 Oct 2012 04:47:06 -0700 Subject: [PATCH 2/2] add link to project issues overview on milestone page --- app/views/milestones/show.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml index d3b1c092192..f89f3adaa50 100644 --- a/app/views/milestones/show.html.haml +++ b/app/views/milestones/show.html.haml @@ -8,6 +8,7 @@ %i.icon-plus New Issue = link_to 'Browse Issues', project_issues_path(@milestone.project, milestone_id: @milestone.id), class: "btn edit-milestone-link small grouped" + = link_to 'Overview', project_issues_path(@milestone.project, :print, milestone_id: @milestone.id), target: '_blank', class: "btn edit-milestone-link small grouped" - if can?(current_user, :admin_milestone, @project) = link_to edit_project_milestone_path(@project, @milestone), class: "btn small grouped" do %i.icon-edit -- GitLab