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

View File

@ -7,8 +7,7 @@
.div-label-left .div-label-left
.label .label
.flag{:id => "flag-#{label.name}", :style => "background-color: ##{label.color};"} .flag{:id => "flag-#{label.name}", :style => "background-color: ##{label.color};"}
.labeltext .labeltext=label.name
=label.name
=check_box_tag 'labels[]', label.name, @labels.include?(label.name), :style => 'display:none' =check_box_tag 'labels[]', label.name, @labels.include?(label.name), :style => 'display:none'
.both .both
.div-label-right=Labeling.joins(:label).where(:labels => {:name => label.name, :project_id => @project.id}).count .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") %h3=t("layout.issues.accessory")
%table %table
%tr %tr
%td.width18 %td.width18=radio_button_tag :myradio, 'all', !@is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'}
=radio_button_tag :myradio, 'all', !@is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'} %td.width135=t("layout.issues.all")
%td.width135 %td.width30.right=@project.issues.count
=t("layout.issues.all")
%td.width30.right
= @project.issues.count
%tr %tr
%td %td=radio_button_tag :myradio, 'to_me', @is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'}
=radio_button_tag :myradio, 'to_me', @is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'} %td=t("layout.issues.to_me")
%td %td.width30.right=@project.issues.where(:user_id => current_user).count
=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 =form_tag project_issues_path(@project), :id => 'search_issue', :method => :get do
.bordered.bpadding20 .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';}" =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"} %table#myTable.tablesorter.tracker{:cellpadding => "0", :cellspacing => "0"}
%thead %thead
%tr %tr
%th.th1{:colspan => "2"} %th.th1{:colspan => "2"}=t('layout.issues.number')
=t('layout.issues.number') %th{:colspan => "2"}=t('layout.issues.description')
%th{:colspan => "2"}
=t('layout.issues.description')
%tbody %tbody
- @issues.each do |issue| = render :partial => 'issues/issue', :collection => @issues
= render :partial => 'issues/list', :locals => {:issue => issue}

View File

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