From f38c661f51525148a2cc278598934857d334600d Mon Sep 17 00:00:00 2001 From: Akiko Takano Date: Mon, 31 Mar 2014 05:49:56 +0900 Subject: [PATCH] Try to use JQueryUI's tooltip. --- app/controllers/issue_templates_controller.rb | 36 +++++++++---------- app/views/issue_templates/index.html.erb | 7 ++-- assets/javascripts/issue_templates.js | 13 +++++++ assets/stylesheets/issue_templates.css | 10 ++++++ config/locales/en.yml | 3 +- config/locales/ja.yml | 3 +- lib/issue_templates_issues_hook.rb | 3 +- 7 files changed, 51 insertions(+), 24 deletions(-) diff --git a/app/controllers/issue_templates_controller.rb b/app/controllers/issue_templates_controller.rb index d22c0d2..571e4cb 100644 --- a/app/controllers/issue_templates_controller.rb +++ b/app/controllers/issue_templates_controller.rb @@ -97,26 +97,24 @@ class IssueTemplatesController < ApplicationController # update pulldown def set_pulldown + @grouped_options = [] + group = [] + @default_template = nil @setting = IssueTemplateSetting.find_or_create(@project.id) inherit_template = @setting.enabled_inherit_templates? - @default_template = nil - project_ids = inherit_template ? @project.ancestors.collect(&:id) : [@project.id] issue_templates = IssueTemplate.where('project_id = ? AND tracker_id = ? AND enabled = ?', - @project.id, @tracker.id, true).order('position') + @project.id, @tracker.id, true).order('position') project_default_template = IssueTemplate.where('project_id = ? AND tracker_id = ? AND enabled = ? - AND is_default = ?', - @project.id, @tracker.id, true, true).first + AND is_default = ?', + @project.id, @tracker.id, true, true).first unless project_default_template.blank? - @default_template = project_default_template + @default_template = project_default_template end - @grouped_options = [] - group = [] - if issue_templates.size > 0 issue_templates.each { |x| group.push([x.title, x.id]) } end @@ -125,8 +123,8 @@ class IssueTemplatesController < ApplicationController inherit_templates = [] # keep ordering of project tree - # TODO: Add Test code. - project_ids.each do |i| + # TODO: Add Test code. + project_ids.each do |i| inherit_templates.concat(IssueTemplate.where('project_id = ? AND tracker_id = ? AND enabled = ? AND enabled_sharing = ?', i, @tracker.id, true, true).order('position')) end @@ -135,7 +133,7 @@ class IssueTemplatesController < ApplicationController inherit_templates.each do |x| group.push([x.title, x.id, {:class => "inherited"}]) if x.is_default == true - if project_default_template.blank? + if project_default_template.blank? @default_template = x end end @@ -144,16 +142,16 @@ class IssueTemplatesController < ApplicationController end @globalIssueTemplates = GlobalIssueTemplate.find(:all,:include => [:projects], - :conditions => [" tracker_id = ? AND projects.id = ?", @tracker.id, @project.id] ) - + :conditions => [" tracker_id = ? AND projects.id = ?", @tracker.id, @project.id] ) if @globalIssueTemplates.any? @globalIssueTemplates.each do |x| group.push([x.title, x.id, {:class => "global"}]) - if x.is_default == true - if project_default_template.blank? - @default_template = x - end - end + # Using global template as default template is now disabled. + # if x.is_default == true + # if project_default_template.blank? + # @default_template = x + # end + # end end end diff --git a/app/views/issue_templates/index.html.erb b/app/views/issue_templates/index.html.erb index af69f62..15f6dfc 100644 --- a/app/views/issue_templates/index.html.erb +++ b/app/views/issue_templates/index.html.erb @@ -119,7 +119,7 @@ <% end %> <% unless @globalIssueTemplates.blank? %> -

<%=h "#{l(:label_global_templates)}" %>

+

<%=h "#{l(:global_issue_templates)}" %>

@@ -139,7 +139,10 @@ :action => 'show', :id => issue_template.id, }, {:title => issue_template.note } %> - + diff --git a/assets/javascripts/issue_templates.js b/assets/javascripts/issue_templates.js index 3a4359d..c2e89c9 100644 --- a/assets/javascripts/issue_templates.js +++ b/assets/javascripts/issue_templates.js @@ -4,6 +4,19 @@ */ changeType = ""; +$(function () { + $(".tooltip").tooltip({ + position: { + my: "left top", + at: "left bottom" + }, + content: function () { + return $(this).prop('title'); + + } + }); +}); + function checkExpand(ch) { var obj=document.all && document.all(ch) || document.getElementById && document.getElementById(ch); if(obj && obj.style) obj.style.display= diff --git a/assets/stylesheets/issue_templates.css b/assets/stylesheets/issue_templates.css index 6ce3641..df5d584 100644 --- a/assets/stylesheets/issue_templates.css +++ b/assets/stylesheets/issue_templates.css @@ -118,4 +118,14 @@ padding: 6px; } .icon-erase { background-image: url(../images/eraser.png); } + +#admin-menu a.redmine-issue-templates { + background-image: url(../images/issue_templates.png); +} + +label { + display: inline-block; + width: 5em; +} + ​ diff --git a/config/locales/en.yml b/config/locales/en.yml index 84f1c24..1975d95 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -37,4 +37,5 @@ en: label_enabledshaing_help_message: "If true, this template can be shared with descendant projects. (You also have to activate Inherited template option at child project.)" label_should_replaced: "Replace subject and description" label_should_replaced_help_message: "If true, existing subject and description are cleared and replaced with template text.(Default is false, and appended text.)" - label_global_templates: "Global Issue Templates" \ No newline at end of file + global_issue_templates: "Global Issue Templates" + no_issue_templates_for_this_redmine: "No global issue templates are defined for this redmine." \ No newline at end of file diff --git a/config/locales/ja.yml b/config/locales/ja.yml index bfcf4fd..4874bcf 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -37,4 +37,5 @@ ja: label_enabledshaing_help_message: "オプションをチェックすると、子プロジェクトでの利用を許可します。(子プロジェクト側での『テンプレートの継承』を設定した場合)" label_should_replaced: "テンプレート読み込みの際に本文とタイトルを上書き" label_should_replaced_help_message: "オプションをチェックすると、テンプレートを適用する際に、入力済みの本文とタイトルを上書きします。(デフォルトはOFFです)" - label_global_templates: "グローバルテンプレート" + global_issue_templates: "グローバル チケットテンプレート" + no_issue_templates_for_this_redmine: "このRedmineにはグローバルチケットテンプレートは定義されていません。" diff --git a/lib/issue_templates_issues_hook.rb b/lib/issue_templates_issues_hook.rb index f0212f8..3472852 100644 --- a/lib/issue_templates_issues_hook.rb +++ b/lib/issue_templates_issues_hook.rb @@ -8,7 +8,8 @@ class IssueTemplatesIssuesHook < Redmine::Hook::ViewListener o = stylesheet_link_tag('issue_templates', :plugin => 'redmine_issue_templates') if (context[:controller].class.name == 'IssuesController' and context[:controller].action_name != 'index') or - (context[:controller].class.name == 'IssueTemplatesController') + (context[:controller].class.name == 'IssueTemplatesController') or + (context[:controller].class.name == 'GlobalIssueTemplatesController') o << javascript_include_tag('issue_templates', :plugin => 'redmine_issue_templates') end return o
<%= issue_template.title %> + <%= link_to h(issue_template.title), {:controller => 'global_issue_templates', + :id => issue_template.id, :action => 'show'}, title: textilizable(issue_template.description), class: "tooltip" %> + <%=h issue_template.tracker.name %> <%=h issue_template.author %> <%= format_time(issue_template.updated_on)%>