[refs #194] some refactotring

This commit is contained in:
Alexander Machehin 2012-02-23 21:57:51 +06:00
parent 9e5e7cd5e4
commit 027012d3e5
6 changed files with 13 additions and 25 deletions

View File

@ -11,8 +11,7 @@ class IssuesController < ApplicationController
def index(status = 200)
@is_assigned_to_me = params[:filter] == 'to_me'
@is_all = params[:filter] == 'all'
@status = (params[:status] if ['open', 'closed'].include? params[:status]) || 'open'
@status = params[:status] == 'closed' ? 'closed' : 'open'
@labels = params[:labels] || []
@issues = @project.issues
@ -21,10 +20,9 @@ class IssuesController < ApplicationController
if params[:search]
@is_assigned_to_me = false
@is_all = 'all'
@status = 'open'
@labels = []
@issues = @project.issues.where('issues.title ILIKE ?', "%#{params[:search]}%")
@issues = @project.issues.where('issues.title ILIKE ?', "%#{params[:search].mb_chars.downcase}%")
end
@issues = @issues.includes(:creator, :user).order('serial_id desc').uniq.paginate :per_page => 10, :page => params[:page]
if status == 200

View File

@ -7,8 +7,7 @@
.div-label-left
.label
.flag{:id => "flag-#{label.name}", :style => "background-color: ##{label.color};"}
.labeltext
=label.name
.labeltext=label.name
=check_box_tag 'labels[]', label.name, @labels.include?(label.name), :style => 'display:none'
.both
.div-label-right=Labeling.joins(:label).where(:labels => {:name => label.name, :project_id => @project.id}).count

View File

@ -4,19 +4,13 @@
%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.issues.count
%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
%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(:user_id => current_user).count
%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(:user_id => current_user).count
=form_tag project_issues_path(@project), :id => 'search_issue', :method => :get do
.bordered.bpadding20
=text_field_tag :search, t('layout.issues.search'), :class => 'gray', :onClick => "if(this.value=='#{t('layout.issues.search')}'){this.value='';this.className='black';}", :onblur => "if(this.value==''){this.value='#{t('layout.issues.search')}';this.className='gray';}"

View File

@ -14,10 +14,7 @@
%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')
%th.th1{:colspan => "2"}=t('layout.issues.number')
%th{:colspan => "2"}=t('layout.issues.description')
%tbody
- @issues.each do |issue|
= render :partial => 'issues/list', :locals => {:issue => issue}
= render :partial => 'issues/issue', :collection => @issues

View File

@ -1,5 +1,5 @@
require 'spec_helper'
describe Tag do
describe Label do
pending "add some examples to (or delete) #{__FILE__}"
end