Issue Labels: Edit, show, index + filter

This commit is contained in:
Dmitriy Zaporozhets 2012-06-27 21:20:35 +03:00
parent 4c1f435ab7
commit 1b1e77c728
12 changed files with 93 additions and 29 deletions

View file

@ -29,7 +29,7 @@ gem "thin"
gem "unicorn" gem "unicorn"
gem "git" gem "git"
gem "acts_as_list" gem "acts_as_list"
gem "acts-as-taggable-on", "~> 2.1.0" gem "acts-as-taggable-on", "2.3.1"
gem "drapper" gem "drapper"
gem "resque", "~> 1.20.0" gem "resque", "~> 1.20.0"
gem "httparty" gem "httparty"

View file

@ -89,8 +89,8 @@ GEM
activesupport (3.2.5) activesupport (3.2.5)
i18n (~> 0.6) i18n (~> 0.6)
multi_json (~> 1.0) multi_json (~> 1.0)
acts-as-taggable-on (2.1.1) acts-as-taggable-on (2.3.1)
rails rails (~> 3.0)
acts_as_list (0.1.6) acts_as_list (0.1.6)
addressable (2.2.8) addressable (2.2.8)
ansi (1.4.2) ansi (1.4.2)
@ -351,7 +351,7 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
acts-as-taggable-on (~> 2.1.0) acts-as-taggable-on (= 2.3.1)
acts_as_list acts_as_list
annotate! annotate!
autotest autotest

View file

@ -177,6 +177,14 @@ a:focus {
&.label-important { &.label-important {
background-color: #B94A48; background-color: #B94A48;
} }
&.label-issue {
background-color: #eee;
border: 1px solid #ccc;
padding:4px 6px;
color:#444;
text-shadow:0 0 1px #fff;
}
} }
.nav-tabs > li > a, .nav-pills > li > a { .nav-tabs > li > a, .nav-pills > li > a {

View file

@ -139,6 +139,7 @@ class IssuesController < ApplicationController
@issues = @issues.where(:assignee_id => params[:assignee_id]) if params[:assignee_id].present? @issues = @issues.where(:assignee_id => params[:assignee_id]) if params[:assignee_id].present?
@issues = @issues.where(:milestone_id => params[:milestone_id]) if params[:milestone_id].present? @issues = @issues.where(:milestone_id => params[:milestone_id]) if params[:milestone_id].present?
@issues = @issues.tagged_with(params[:label_name]) if params[:label_name].present?
@issues = @issues.includes(:author, :project).order("critical, updated_at") @issues = @issues.includes(:author, :project).order("critical, updated_at")
@issues @issues
end end

View file

@ -33,4 +33,8 @@ module IssuesHelper
classes << " today" if issue.today? classes << " today" if issue.today?
classes classes
end end
def issue_tags
@project.issues.tag_counts_on(:labels).map(&:name)
end
end end

View file

@ -1,6 +1,8 @@
class Issue < ActiveRecord::Base class Issue < ActiveRecord::Base
include Upvote include Upvote
acts_as_taggable_on :labels
belongs_to :project belongs_to :project
belongs_to :milestone belongs_to :milestone
belongs_to :author, :class_name => "User" belongs_to :author, :class_name => "User"

View file

@ -35,6 +35,12 @@
= f.text_area :description, :maxlength => 2000, :class => "xxlarge", :rows => 14 = f.text_area :description, :maxlength => 2000, :class => "xxlarge", :rows => 14
%p.hint Markdown is enabled. %p.hint Markdown is enabled.
.clearfix
= f.label :label_list, "Labels"
.input
= f.text_field :label_list, :maxlength => 2000, :class => "xxlarge"
%p.hint Separate with comma.
.actions .actions
- if @issue.new_record? - if @issue.new_record?
= f.submit 'Submit new issue', :class => "primary btn" = f.submit 'Submit new issue', :class => "primary btn"

View file

@ -2,6 +2,11 @@
.list_legend .list_legend
.icon .icon
.right .right
- issue.labels.each do |label|
%span.label.label-issue
%i.icon-tag
= label.name
&nbsp;
- if issue.notes.any? - if issue.notes.any?
%span.btn.small.disabled.padded %span.btn.small.disabled.padded
%i.icon-comment %i.icon-comment

View file

@ -31,28 +31,29 @@
%div#issues-table-holder.ui-box %div#issues-table-holder.ui-box
.title .title
.row .left
.span4 %ul.nav.nav-pills.left
%ul.nav.nav-pills.left %li{:class => ("active" if (params[:f] == "0" || !params[:f]))}
%li{:class => ("active" if (params[:f] == "0" || !params[:f]))} = link_to project_issues_path(@project, :f => 0, :milestone_id => params[:milestone_id]) do
= link_to project_issues_path(@project, :f => 0, :milestone_id => params[:milestone_id]) do Open
Open %li{:class => ("active" if params[:f] == "2")}
%li{:class => ("active" if params[:f] == "2")} = link_to project_issues_path(@project, :f => 2, :milestone_id => params[:milestone_id]) do
= link_to project_issues_path(@project, :f => 2, :milestone_id => params[:milestone_id]) do Closed
Closed %li{:class => ("active" if params[:f] == "3")}
%li{:class => ("active" if params[:f] == "3")} = link_to project_issues_path(@project, :f => 3, :milestone_id => params[:milestone_id]) do
= link_to project_issues_path(@project, :f => 3, :milestone_id => params[:milestone_id]) do To Me
To Me %li{:class => ("active" if params[:f] == "1")}
%li{:class => ("active" if params[:f] == "1")} = link_to project_issues_path(@project, :f => 1, :milestone_id => params[:milestone_id]) do
= link_to project_issues_path(@project, :f => 1, :milestone_id => params[:milestone_id]) do All
All
.span6.right
= form_tag project_issues_path(@project), :method => :get, :class => :right do
= select_tag(:assignee_id, options_from_collection_for_select(@project.users.all, "id", "name", params[:assignee_id]), :prompt => "Assignee")
= select_tag(:milestone_id, options_from_collection_for_select(@project.milestones.order("id desc").all, "id", "title", params[:milestone_id]), :prompt => "Milestone")
= hidden_field_tag :f, params[:f]
.right
= form_tag project_issues_path(@project), :method => :get, :class => :right do
= select_tag(:label_name, options_for_select(issue_tags, params[:label_name]), :prompt => "Labels")
= select_tag(:assignee_id, options_from_collection_for_select(@project.users.all, "id", "name", params[:assignee_id]), :prompt => "Assignee")
= select_tag(:milestone_id, options_from_collection_for_select(@project.milestones.order("id desc").all, "id", "title", params[:milestone_id]), :prompt => "Milestone")
= hidden_field_tag :f, params[:f]
.clearfix
%ul#issues-table.unstyled.issues_table %ul#issues-table.unstyled.issues_table
= render "issues" = render "issues"
@ -60,9 +61,10 @@
$(function(){ $(function(){
initIssuesSearch(); initIssuesSearch();
setSortable(); setSortable();
$("#label_name").chosen();
$("#assignee_id").chosen(); $("#assignee_id").chosen();
$("#milestone_id").chosen(); $("#milestone_id").chosen();
$("#milestone_id, #assignee_id").live("change", function(){ $("#milestone_id, #assignee_id, #label_name").live("change", function(){
$(this).closest("form").submit(); $(this).closest("form").submit();
}); });
}) })

View file

@ -51,9 +51,11 @@
= truncate(milestone.title, :length => 20) = truncate(milestone.title, :length => 20)
.right .right
- if @issue.critical - @issue.labels.each do |label|
%span.label.label-important %span.label.label-issue
Critical %i.icon-tag
= label.name
&nbsp;
- if @issue.description.present? - if @issue.description.present?
.bottom_box_content .bottom_box_content

View file

@ -0,0 +1,12 @@
Feature: Issues
Background:
Given I signin as a user
And I own project "Shop"
And project "Shop" have "Release 0.4" open issue
And project "Shop" have "Release 0.3" closed issue
And I visit project "Shop" issues page
Scenario: I should see open issues
Given I should see "Release 0.4" open issue
And I should not see "Release 0.3" closed issue

View file

@ -0,0 +1,22 @@
Given /^project "(.*?)" have "(.*?)" open issue$/ do |arg1, arg2|
project = Project.find_by_name(arg1)
Factory.create(:issue, :title => arg2, :project => project, :author => project.users.first)
end
Given /^project "(.*?)" have "(.*?)" closed issue$/ do |arg1, arg2|
project = Project.find_by_name(arg1)
Factory.create(:issue, :title => arg2, :project => project, :author => project.users.first, :closed => true)
end
Given /^I visit project "(.*?)" issues page$/ do |arg1|
visit project_issues_path(Project.find_by_name(arg1))
end
Given /^I should see "(.*?)" open issue$/ do |arg1|
page.should have_content arg1
end
Given /^I should not see "(.*?)" closed issue$/ do |arg1|
page.should_not have_content arg1
end