From 027012d3e5fd26aec8712bcc74586c1495fed49b Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 23 Feb 2012 21:57:51 +0600 Subject: [PATCH] [refs #194] some refactotring --- app/controllers/issues_controller.rb | 6 ++---- .../{_list.html.haml => _issue.html.haml} | 0 app/views/issues/_labels.html.haml | 3 +-- app/views/issues/_sidebar.html.haml | 18 ++++++------------ app/views/issues/index.html.haml | 9 +++------ spec/models/labels_spec.rb | 2 +- 6 files changed, 13 insertions(+), 25 deletions(-) rename app/views/issues/{_list.html.haml => _issue.html.haml} (100%) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 5d50c50fa..0c05340e9 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -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 diff --git a/app/views/issues/_list.html.haml b/app/views/issues/_issue.html.haml similarity index 100% rename from app/views/issues/_list.html.haml rename to app/views/issues/_issue.html.haml diff --git a/app/views/issues/_labels.html.haml b/app/views/issues/_labels.html.haml index 8b06617cf..2d29211c8 100644 --- a/app/views/issues/_labels.html.haml +++ b/app/views/issues/_labels.html.haml @@ -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 diff --git a/app/views/issues/_sidebar.html.haml b/app/views/issues/_sidebar.html.haml index 6999abc9d..1d8f7ade5 100644 --- a/app/views/issues/_sidebar.html.haml +++ b/app/views/issues/_sidebar.html.haml @@ -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';}" diff --git a/app/views/issues/index.html.haml b/app/views/issues/index.html.haml index d1192d717..f59a83b42 100644 --- a/app/views/issues/index.html.haml +++ b/app/views/issues/index.html.haml @@ -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} \ No newline at end of file + = render :partial => 'issues/issue', :collection => @issues \ No newline at end of file diff --git a/spec/models/labels_spec.rb b/spec/models/labels_spec.rb index af7e7325e..dd72c1f9f 100644 --- a/spec/models/labels_spec.rb +++ b/spec/models/labels_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe Tag do +describe Label do pending "add some examples to (or delete) #{__FILE__}" end