From 635cdd8bd08bea651f5c08718f9e0b9ba8d0aeb5 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Fri, 8 Apr 2011 14:32:07 -0700 Subject: [PATCH] [#5072] Add a small counter icon to Kanban --- config/locales/en.yml | 1 + init.rb | 2 ++ .../hooks/view_kanbans_issue_details_hook.rb | 33 +++++++++++++++++++ .../hooks/view_layouts_base_html_head_hook.rb | 20 +++++++++++ .../view_kanbans_issue_details_hook_test.rb | 12 +++++++ .../view_layouts_base_html_head_hook_test.rb | 12 +++++++ 6 files changed, 80 insertions(+) create mode 100644 lib/chiliproject_issue_aging/hooks/view_kanbans_issue_details_hook.rb create mode 100644 lib/chiliproject_issue_aging/hooks/view_layouts_base_html_head_hook.rb create mode 100644 test/integration/chiliproject_issue_aging/hooks/view_kanbans_issue_details_hook_test.rb create mode 100644 test/integration/chiliproject_issue_aging/hooks/view_layouts_base_html_head_hook_test.rb diff --git a/config/locales/en.yml b/config/locales/en.yml index add8503..9ed19b2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3,3 +3,4 @@ en: issue_aging_text_number_of_days_for_error: "Number of days before an issue enters the error state" issue_aging_text_title: "Aging Issues" issue_aging_text_last_status_change: "Last status change" + issue_aging_text_days_ago: "%{count} days ago" diff --git a/init.rb b/init.rb index e242a12..972eb32 100644 --- a/init.rb +++ b/init.rb @@ -22,3 +22,5 @@ require_dependency 'issue' Issue.send(:include, ChiliprojectIssueAging::Patches::IssuePatch) end +require 'chiliproject_issue_aging/hooks/view_kanbans_issue_details_hook' +require 'chiliproject_issue_aging/hooks/view_layouts_base_html_head_hook' diff --git a/lib/chiliproject_issue_aging/hooks/view_kanbans_issue_details_hook.rb b/lib/chiliproject_issue_aging/hooks/view_kanbans_issue_details_hook.rb new file mode 100644 index 0000000..443c8f9 --- /dev/null +++ b/lib/chiliproject_issue_aging/hooks/view_kanbans_issue_details_hook.rb @@ -0,0 +1,33 @@ +module ChiliprojectIssueAging + module Hooks + class ViewKanbansIssueDetailsHook < Redmine::Hook::ViewListener + def view_kanbans_issue_details(context={}) + issue = context[:issue] + + aging_status = issue.aging_status + journal = issue.last_status_change_journal + + if aging_status && journal + time_ago = (Date.today - journal.created_on.to_date).to_i + + if aging_status == :warning + css_class = 'aging warning-state' + elsif aging_status == :error + css_class = 'aging error-state' + end + + return content_tag(:span, + time_ago, + { + :title => l(:issue_aging_text_days_ago, :count => time_ago), + :class => css_class + }) + + else + return '' + end + + end + end + end +end diff --git a/lib/chiliproject_issue_aging/hooks/view_layouts_base_html_head_hook.rb b/lib/chiliproject_issue_aging/hooks/view_layouts_base_html_head_hook.rb new file mode 100644 index 0000000..881ba53 --- /dev/null +++ b/lib/chiliproject_issue_aging/hooks/view_layouts_base_html_head_hook.rb @@ -0,0 +1,20 @@ +module ChiliprojectIssueAging + module Hooks + class ViewLayoutsBaseHtmlHeadHook < Redmine::Hook::ViewListener + def view_layouts_base_html_head(context={}) + return < + + +CSS + end + end + end +end diff --git a/test/integration/chiliproject_issue_aging/hooks/view_kanbans_issue_details_hook_test.rb b/test/integration/chiliproject_issue_aging/hooks/view_kanbans_issue_details_hook_test.rb new file mode 100644 index 0000000..44f4f49 --- /dev/null +++ b/test/integration/chiliproject_issue_aging/hooks/view_kanbans_issue_details_hook_test.rb @@ -0,0 +1,12 @@ +require File.dirname(__FILE__) + '/../../../test_helper' + +class ChiliprojectIssueAging::Hooks::ViewKanbansIssueDetailsTest < ActionController::IntegrationTest + include Redmine::Hook::Helper + + context "#view_kanbans_issue_details" do + setup do + end + + should "be tested" + end +end diff --git a/test/integration/chiliproject_issue_aging/hooks/view_layouts_base_html_head_hook_test.rb b/test/integration/chiliproject_issue_aging/hooks/view_layouts_base_html_head_hook_test.rb new file mode 100644 index 0000000..500ac9d --- /dev/null +++ b/test/integration/chiliproject_issue_aging/hooks/view_layouts_base_html_head_hook_test.rb @@ -0,0 +1,12 @@ +require File.dirname(__FILE__) + '/../../../test_helper' + +class ChiliprojectIssueAging::Hooks::ViewLayoutsBaseHtmlHeadTest < ActionController::IntegrationTest + include Redmine::Hook::Helper + + context "#view_layouts_base_html_head" do + setup do + end + + should "be tested" + end +end