#90: added #index action, updated routes

This commit is contained in:
Vokhmin Alexey V 2012-09-26 00:50:40 +04:00
parent d54a50e2e0
commit 397d411252
5 changed files with 63 additions and 2 deletions

View File

@ -88,6 +88,28 @@ class Projects::PullRequestsController < Projects::BaseController
load_diff_commits_data load_diff_commits_data
end 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 def autocomplete_base_project
#Maybe slow? ILIKE? #Maybe slow? ILIKE?
items = Project.accessible_by(current_ability, :membered).search(params[:term]) items = Project.accessible_by(current_ability, :membered).search(params[:term])

View File

@ -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'))

View File

@ -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

View File

@ -186,7 +186,7 @@ Rosa::Application.routes.draw do
resources :collaborators do resources :collaborators do
get :find, :on => :collection get :find, :on => :collection
end end
resources :pull_requests, :except => [:destroy, :index] do resources :pull_requests, :except => :destroy do
get :autocomplete_base_project, :on => :collection get :autocomplete_base_project, :on => :collection
put :merge, :on => :member put :merge, :on => :member
end end