Commit 9afee5ad5298dc4c89ec74c5fda44adfc91de1b2

Authored by gitlabhq
1 parent afe98ae7

Add critical status to issues

app/assets/stylesheets/projects.css.scss
@@ -647,3 +647,37 @@ tbody tr:nth-child(2n) td, tbody tr.even td { @@ -647,3 +647,37 @@ tbody tr:nth-child(2n) td, tbody tr.even td {
647 background: none repeat scroll 0 0 #FFBBBB 647 background: none repeat scroll 0 0 #FFBBBB
648 } 648 }
649 } 649 }
  650 +
  651 +.tag {
  652 + @include round-borders-all(4px);
  653 + padding:2px 4px;
  654 + border:none;
  655 +
  656 + &.high {
  657 + background: #D12F19;
  658 + color:white;
  659 + }
  660 +
  661 + &.today {
  662 + background: #44aa22;
  663 + color:white;
  664 + }
  665 +
  666 + &.yours {
  667 + background: #4466cc;
  668 + color:white;
  669 + }
  670 + &.notes {
  671 + background: #2c5c66;
  672 + color:white;
  673 + }
  674 +}
  675 +
  676 +#issues-table .issue {
  677 + &.critical {
  678 + td {
  679 + //background: #D12F19;
  680 + //color:#fff;
  681 + }
  682 + }
  683 +}
app/controllers/issues_controller.rb
@@ -12,7 +12,7 @@ class IssuesController < ApplicationController @@ -12,7 +12,7 @@ class IssuesController < ApplicationController
12 12
13 def index 13 def index
14 @issues = case params[:f].to_i 14 @issues = case params[:f].to_i
15 - when 1 then @project.issues.all 15 + when 1 then @project.issues
16 when 2 then @project.issues.closed 16 when 2 then @project.issues.closed
17 when 3 then @project.issues.opened.assigned(current_user) 17 when 3 then @project.issues.opened.assigned(current_user)
18 else @project.issues.opened 18 else @project.issues.opened
app/models/issue.rb
@@ -18,11 +18,22 @@ class Issue < ActiveRecord::Base @@ -18,11 +18,22 @@ class Issue < ActiveRecord::Base
18 :presence => true, 18 :presence => true,
19 :length => { :within => 0..2000 } 19 :length => { :within => 0..2000 }
20 20
  21 + scope :critical, where(:critical => true)
  22 + scope :non_critical, where(:critical => false)
  23 +
21 scope :opened, where(:closed => false) 24 scope :opened, where(:closed => false)
22 scope :closed, where(:closed => true) 25 scope :closed, where(:closed => true)
23 scope :assigned, lambda { |u| where(:assignee_id => u.id)} 26 scope :assigned, lambda { |u| where(:assignee_id => u.id)}
24 27
25 acts_as_list 28 acts_as_list
  29 +
  30 + def today?
  31 + Date.today == created_at.to_date
  32 + end
  33 +
  34 + def new?
  35 + today? && created_at == updated_at
  36 + end
26 end 37 end
27 # == Schema Information 38 # == Schema Information
28 # 39 #
app/views/issues/_form.html.haml
@@ -5,17 +5,21 @@ @@ -5,17 +5,21 @@
5 - @issue.errors.full_messages.each do |msg| 5 - @issue.errors.full_messages.each do |msg|
6 %li= msg 6 %li= msg
7 7
8 - .span-6 8 + .span-8
9 = f.label :title 9 = f.label :title
10 = f.text_field :title, :style => "width:450px" 10 = f.text_field :title, :style => "width:450px"
11 - .span-6 11 + .span-8
12 = f.label :content 12 = f.label :content
13 = f.text_area :content, :style => "width:450px; height:130px" 13 = f.text_area :content, :style => "width:450px; height:130px"
14 - .span-6.append-bottom 14 + .span-8.append-bottom
15 = f.label :assignee_id 15 = f.label :assignee_id
16 = f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }) 16 = f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" })
  17 + .span-1
  18 + = f.label :critical, "Critical"
  19 + %br
  20 + = f.check_box :critical
17 - unless @issue.new_record? 21 - unless @issue.new_record?
18 - .span-3.right 22 + .span-2.right
19 = f.label :closed 23 = f.label :closed
20 %br 24 %br
21 = f.check_box :closed 25 = f.check_box :closed
app/views/issues/_issues.html.haml
1 %table.round-borders#issues-table 1 %table.round-borders#issues-table
2 %tr 2 %tr
  3 + - if can?(current_user, :admin_issue, @project) && !params[:f] || params[:f] == "0"
  4 + %th
3 %th Assignee 5 %th Assignee
4 %th ID 6 %th ID
5 %th Title 7 %th Title
6 %th Closed? 8 %th Closed?
7 %th 9 %th
8 10
9 - - @issues.each do |issue| 11 + - @issues.critical.each do |issue|
  12 + = render(:partial => 'show', :locals => {:issue => issue})
  13 +
  14 + - @issues.non_critical.each do |issue|
10 = render(:partial => 'show', :locals => {:issue => issue}) 15 = render(:partial => 'show', :locals => {:issue => issue})
app/views/issues/_show.html.haml
1 -%tr{ :id => dom_id(issue), :class => "issue", :url => project_issue_path(@project, issue) } 1 +%tr{ :id => dom_id(issue), :class => "issue #{issue.critical ? "critical" : ""}", :url => project_issue_path(@project, issue) }
  2 + - if can?(current_user, :admin_issue, @project) && !params[:f] || params[:f] == "0"
  3 + %td
  4 + = image_tag "move.png" , :class => [:handle, :left]
2 %td 5 %td
3 - = image_tag "move.png" , :class => [:handle, :left]  
4 = image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" 6 = image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;"
5 = truncate issue.assignee.name, :lenght => 20 7 = truncate issue.assignee.name, :lenght => 20
6 %td ##{issue.id} 8 %td ##{issue.id}
7 - %td= html_escape issue.title 9 + %td
  10 + = html_escape issue.title
  11 + %br
  12 + - if issue.critical
  13 + %span.tag.high critical
  14 + - if issue.today?
  15 + %span.tag.today today
  16 + -#- if issue.author == current_user
  17 + -#%span.tag.yours yours
  18 + -#- if issue.notes.count > 0
  19 + -#%span.tag.notes
  20 + -#= issue.notes.count
  21 + -#notes
8 %td 22 %td
9 - if can? current_user, :write_issue, @project 23 - if can? current_user, :write_issue, @project
10 = form_for([@project, issue], :remote => true) do |f| 24 = form_for([@project, issue], :remote => true) do |f|
db/migrate/20111025134235_add_high_label_to_issue.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +class AddHighLabelToIssue < ActiveRecord::Migration
  2 + def change
  3 + add_column :issues, :critical, :boolean, :default => false, :null => false
  4 + end
  5 +end
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 # 11 #
12 # It's strongly recommended to check this file into your version control system. 12 # It's strongly recommended to check this file into your version control system.
13 13
14 -ActiveRecord::Schema.define(:version => 20111021101550) do 14 +ActiveRecord::Schema.define(:version => 20111025134235) do
15 15
16 create_table "issues", :force => true do |t| 16 create_table "issues", :force => true do |t|
17 t.string "title" 17 t.string "title"
@@ -23,6 +23,7 @@ ActiveRecord::Schema.define(:version =&gt; 20111021101550) do @@ -23,6 +23,7 @@ ActiveRecord::Schema.define(:version =&gt; 20111021101550) do
23 t.datetime "updated_at" 23 t.datetime "updated_at"
24 t.boolean "closed", :default => false, :null => false 24 t.boolean "closed", :default => false, :null => false
25 t.integer "position", :default => 0 25 t.integer "position", :default => 0
  26 + t.boolean "critical", :default => false, :null => false
26 end 27 end
27 28
28 create_table "keys", :force => true do |t| 29 create_table "keys", :force => true do |t|