diff --git a/app/controllers/projects/pull_requests_controller.rb b/app/controllers/projects/pull_requests_controller.rb index c61cd190b..67f13b809 100644 --- a/app/controllers/projects/pull_requests_controller.rb +++ b/app/controllers/projects/pull_requests_controller.rb @@ -88,6 +88,28 @@ class Projects::PullRequestsController < Projects::BaseController load_diff_commits_data end + def index(status = 200) + @pull_requests = @project.issues.joins(:pull_request).includes(:pull_request).includes(:assignee, :user) + @pull_requests = @pull_requests.where(:assignee_id => current_user.id) if @is_assigned_to_me = params[:filter] == 'to_me' + # Using mb_chars for correct transform to lowercase ('Русский Текст'.downcase => "Русский Текст") + @pull_requests = @pull_requests.where('issues.title ILIKE ?', "%#{params[:search_issue].mb_chars.downcase}%") if params[:search_issue] + + @opened_issues, @closed_issues = @pull_requests.not_closed_or_merged.count, @pull_requests.closed_or_merged.count + if params[:status] == 'closed' + @pull_requests, @status = @pull_requests.closed_or_merged, params[:status] + else + @pull_requests, @status = @pull_requests.not_closed_or_merged, 'open' + end + + @pull_requests = @pull_requests.includes(:assignee, :user).order('issues.serial_id desc').uniq + .paginate :per_page => 10, :page => params[:page] + if status == 200 + render 'index', :layout => request.xhr? ? 'issues' : 'application' + else + render :status => status, :nothing => true + end + end + def autocomplete_base_project #Maybe slow? ILIKE? items = Project.accessible_by(current_ability, :membered).search(params[:term]) diff --git a/app/views/projects/issues/index.html.haml b/app/views/projects/issues/index.html.haml index 02c05d53f..303538f5d 100644 --- a/app/views/projects/issues/index.html.haml +++ b/app/views/projects/issues/index.html.haml @@ -19,4 +19,4 @@ %th{:colspan => "2"}=t('layout.issues.description') %tbody = render :partial => 'issue', :collection => @issues - = will_paginate @issues \ No newline at end of file + = will_paginate @issues diff --git a/app/views/projects/pull_requests/_index_sidebar.html.haml b/app/views/projects/pull_requests/_index_sidebar.html.haml new file mode 100644 index 000000000..6f25ec81c --- /dev/null +++ b/app/views/projects/pull_requests/_index_sidebar.html.haml @@ -0,0 +1,16 @@ +-content_for :sidebar do + - if current_user + =form_tag project_pull_requests_path(@project), :id => 'filter_issues', :method => :get do + .bordered.nopadding + %h3=t("layout.issues.accessory") + %table + %tr + %td.width18=radio_button_tag :myradio, 'all', !@is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'} + %td.width135=t("layout.issues.all") + %td.width30.right=@project.pull_requests.count + %tr + %td=radio_button_tag :myradio, 'to_me', @is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'} + %td=t("layout.issues.to_me") + %td.width30.right=@project.issues.joins(:pull_request).where(:assignee_id => current_user.id).count + .bordered.bpadding20 + =tracker_search_field(:search_issue, t('layout.issues.search')) diff --git a/app/views/projects/pull_requests/index.html.haml b/app/views/projects/pull_requests/index.html.haml new file mode 100644 index 000000000..50bac1df6 --- /dev/null +++ b/app/views/projects/pull_requests/index.html.haml @@ -0,0 +1,23 @@ +-ar = 'activerecord.attributes.pull_requests' +-set_meta_tags :title => [title_object(@project), t('.title')] +-render 'submenu' +-render 'index_sidebar' + +#closed-switcher.blue-switcher + =hidden_field_tag :issues_status, @status, :id => 'issues_status' + .open + ="#{t('layout.issues.statuses.open')} (#{@opened_issues})" + #closed-tasks.closed + ="#{t('layout.issues.statuses.closed')} (#{@closed_issues})" + #blue-switch-select.selected{:style => "margin-left: #{@status == 'open' ? '0' : '130'}px;"} + .both +.both +#table1 + %table#myTable.tablesorter.tracker{:cellpadding => "0", :cellspacing => "0"} + %thead + %tr + %th.th1{:colspan => "2"}=t('layout.issues.number') + %th{:colspan => "2"}=t('layout.issues.description') + %tbody + = render :partial => 'projects/issues/issue', :collection => @pull_requests + = will_paginate @pull_requests diff --git a/config/routes.rb b/config/routes.rb index 49cb74f1f..161bc86c7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -186,7 +186,7 @@ Rosa::Application.routes.draw do resources :collaborators do get :find, :on => :collection end - resources :pull_requests, :except => [:destroy, :index] do + resources :pull_requests, :except => :destroy do get :autocomplete_base_project, :on => :collection put :merge, :on => :member end