#90: updated #index page for pull-requests
This commit is contained in:
parent
397d411252
commit
07b27b934f
|
@ -50,7 +50,7 @@ $(document).ready(function() {
|
|||
return send_index_tracker_request('GET');
|
||||
});
|
||||
|
||||
$('#search_issue').live('submit', function() {
|
||||
$('.ajax_search_form').live('submit', function() {
|
||||
return send_index_tracker_request('GET', $(this).attr("action"), $(this).serialize());
|
||||
});
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ class Projects::IssuesController < Projects::BaseController
|
|||
|
||||
def index(status = 200)
|
||||
@labels = params[:labels] || []
|
||||
@issues = @project.issues.includes(:pull_request).includes(:assignee, :user)
|
||||
@issues = @project.issues.without_pull_requests
|
||||
@issues = @issues.where(:assignee_id => current_user.id) if @is_assigned_to_me = params[:filter] == 'to_me'
|
||||
@issues = @issues.joins(:labels).where(:labels => {:name => @labels}) unless @labels == []
|
||||
# Using mb_chars for correct transform to lowercase ('Русский Текст'.downcase => "Русский Текст")
|
||||
@issues = @issues.where('issues.title ILIKE ?', "%#{params[:search_issue].mb_chars.downcase}%") if params[:search_issue]
|
||||
@issues = @issues.search(params[:search_issue])
|
||||
|
||||
@opened_issues, @closed_issues = @issues.not_closed_or_merged.count, @issues.closed_or_merged.count
|
||||
if params[:status] == 'closed'
|
||||
|
@ -24,10 +24,10 @@ class Projects::IssuesController < Projects::BaseController
|
|||
@issues, @status = @issues.not_closed_or_merged, 'open'
|
||||
end
|
||||
|
||||
@issues = @issues.includes(:assignee, :user).order('issues.serial_id desc').uniq
|
||||
@issues = @issues.includes(:assignee, :user, :pull_request).def_order.uniq
|
||||
.paginate :per_page => 10, :page => params[:page]
|
||||
if status == 200
|
||||
render 'index', :layout => request.xhr? ? 'issues' : 'application'
|
||||
render 'index', :layout => request.xhr? ? 'with_sidebar' : 'application'
|
||||
else
|
||||
render :status => status, :nothing => true
|
||||
end
|
||||
|
|
|
@ -89,22 +89,21 @@ class Projects::PullRequestsController < Projects::BaseController
|
|||
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]
|
||||
@issues_with_pull_request = @project.issues.joins(:pull_request)
|
||||
@issues_with_pull_request = @issues_with_pull_request.search(params[:search_pull_request])
|
||||
|
||||
@opened_issues, @closed_issues = @pull_requests.not_closed_or_merged.count, @pull_requests.closed_or_merged.count
|
||||
@opened_issues, @closed_issues = @issues_with_pull_request.not_closed_or_merged.count, @issues_with_pull_request.closed_or_merged.count
|
||||
if params[:status] == 'closed'
|
||||
@pull_requests, @status = @pull_requests.closed_or_merged, params[:status]
|
||||
@issues_with_pull_request, @status = @issues_with_pull_request.closed_or_merged, params[:status]
|
||||
else
|
||||
@pull_requests, @status = @pull_requests.not_closed_or_merged, 'open'
|
||||
@issues_with_pull_request, @status = @issues_with_pull_request.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]
|
||||
@issues_with_pull_request = @issues_with_pull_request.
|
||||
includes(:assignee, :user, :pull_request).def_order.uniq.
|
||||
paginate :per_page => 10, :page => params[:page]
|
||||
if status == 200
|
||||
render 'index', :layout => request.xhr? ? 'issues' : 'application'
|
||||
render 'index', :layout => request.xhr? ? 'with_sidebar' : 'application'
|
||||
else
|
||||
render :status => status, :nothing => true
|
||||
end
|
||||
|
|
|
@ -28,6 +28,12 @@ class Issue < ActiveRecord::Base
|
|||
scope :needed_checking, where(:issues => {:status => ['open', 'blocked', 'ready', 'already']})
|
||||
scope :not_closed_or_merged, needed_checking
|
||||
scope :closed_or_merged, where(:issues => {:status => ['closed', 'merged']})
|
||||
# Using mb_chars for correct transform to lowercase ('Русский Текст'.downcase => "Русский Текст")
|
||||
scope :search, lambda {|q| where('issues.title ILIKE ?', "%#{q.mb_chars.downcase}%") if q.present?}
|
||||
scope :def_order, order('issues.serial_id desc')
|
||||
scope :without_pull_requests,
|
||||
joins("LEFT OUTER JOIN pull_requests ON issues.id = pull_requests.issue_id").
|
||||
where(:pull_requests => { :issue_id => nil } )
|
||||
|
||||
def assign_uname
|
||||
assignee.uname if assignee
|
||||
|
|
|
@ -15,6 +15,5 @@
|
|||
%li= link_to t("project_menu.wiki"), project_wiki_index_path(@project), :class => (contr == :wiki ? 'active' : nil)
|
||||
%li=# link_to t("project_menu.readme"), "#" #pending
|
||||
- if can? :update, @project
|
||||
%li= link_to t("project_menu.settings"), edit_project_path(@project), :class => (act == :edit && contr == :projects ? 'active' : nil)
|
||||
/
|
||||
%li=link_to t("project_menu.pull_requests"), project_pull_requests_path(@project), :class => (contr == :pull_requests ? 'active' : nil)
|
||||
%li= link_to t("project_menu.settings"), edit_project_path(@project), :class => (act == :edit && contr == :projects ? 'active' : nil)
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
%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.issues.count
|
||||
%td.width30.right=@project.issues.without_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.where(:assignee_id => current_user.id).count
|
||||
=form_tag project_issues_path(@project), :id => 'search_issue', :method => :get do
|
||||
%td.width30.right=@project.issues.without_pull_requests.where(:assignee_id => current_user.id).count
|
||||
=form_tag project_issues_path(@project), :id => 'search_issue', :class => 'ajax_search_form', :method => :get do
|
||||
.bordered.bpadding20
|
||||
=tracker_search_field(:search_issue, t('layout.issues.search'))
|
||||
- if can? :new, @project.issues.new
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
-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
|
||||
=form_tag project_pull_requests_path(@project), :id => 'filter_pull_requests', :method => :get, :class => 'ajax_search_form' do
|
||||
.bordered.bpadding20
|
||||
=tracker_search_field(:search_issue, t('layout.issues.search'))
|
||||
=tracker_search_field(:search_pull_request, t('layout.pull_requests.search'))
|
||||
|
|
|
@ -19,5 +19,5 @@
|
|||
%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
|
||||
= render :partial => 'projects/issues/issue', :collection => @issues_with_pull_request
|
||||
= will_paginate @issues_with_pull_request
|
||||
|
|
|
@ -48,3 +48,7 @@ en:
|
|||
refs: 'branch · tag'
|
||||
base_project: Base project
|
||||
head_project: Head project
|
||||
|
||||
layout:
|
||||
pull_requests:
|
||||
search: Find pull request...
|
||||
|
|
|
@ -50,3 +50,7 @@ ru:
|
|||
refs: 'ветка · тег'
|
||||
base_project: Базовый проект
|
||||
head_project: Проект-источник
|
||||
|
||||
layout:
|
||||
pull_requests:
|
||||
search: Найти пул реквест...
|
||||
|
|
Loading…
Reference in New Issue