From 412f9be7c96c22beb42317adcea182334cfdcf49 Mon Sep 17 00:00:00 2001 From: Akiko Takano Date: Mon, 31 Mar 2014 05:49:07 +0900 Subject: [PATCH] Remove is_default from global template. --- app/models/global_issue_template.rb | 12 ------------ app/views/global_issue_templates/_form.html.erb | 8 +------- app/views/global_issue_templates/index.html.erb | 8 +++----- ..._remove_is_default_from_global_issue_templates.rb | 9 +++++++++ 4 files changed, 13 insertions(+), 24 deletions(-) create mode 100644 db/migrate/20140330155030_remove_is_default_from_global_issue_templates.rb diff --git a/app/models/global_issue_template.rb b/app/models/global_issue_template.rb index f91e79a..5783f47 100644 --- a/app/models/global_issue_template.rb +++ b/app/models/global_issue_template.rb @@ -3,7 +3,6 @@ class GlobalIssueTemplate < ActiveRecord::Base unloadable belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' belongs_to :tracker - before_save :check_default validates :title, :presence => true validates :tracker, :presence => true validates_uniqueness_of :title, :scope => :tracker_id @@ -18,7 +17,6 @@ class GlobalIssueTemplate < ActiveRecord::Base 'note', 'enabled', 'issue_title', - 'is_default', 'project_ids' def enabled? @@ -28,14 +26,4 @@ class GlobalIssueTemplate < ActiveRecord::Base def <=>(issue_template) position <=> global_issue_template.position end - - # - # In case set is_default and updated, others are also updated. - # - def check_default - if is_default? && is_default_changed? - GlobalIssueTemplate.update_all({:is_default => false}, - ['racker_id = ?', tracker_id]) - end - end end diff --git a/app/views/global_issue_templates/_form.html.erb b/app/views/global_issue_templates/_form.html.erb index e0ea792..51c4e51 100644 --- a/app/views/global_issue_templates/_form.html.erb +++ b/app/views/global_issue_templates/_form.html.erb @@ -36,12 +36,6 @@ :label => l(:issue_template_note), :style => "overflow:auto;" %>

-

<%= f.check_box :is_default, :label => l(:field_is_default) %> - <%= l(:help_for_this_field) %> -
- -

<%= f.check_box :enabled, :label => l(:label_enabled) %> <%= l(:help_for_this_field) %> @@ -52,7 +46,7 @@ -<%= wikitoolbar_for 'issue_template_description' %> +<%= wikitoolbar_for 'global_issue_template_description' %>

<%= preview_link url_for(:controller => 'global_issue_templates', :action => 'preview', diff --git a/app/views/global_issue_templates/index.html.erb b/app/views/global_issue_templates/index.html.erb index 80d4170..3a55c19 100644 --- a/app/views/global_issue_templates/index.html.erb +++ b/app/views/global_issue_templates/index.html.erb @@ -1,4 +1,4 @@ -

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

+

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

<%= link_to(l(:label_new_templates), @@ -22,7 +22,6 @@ <%= l(:field_tracker) %> <%= l(:field_author) %> <%= l(:field_updated_on) %> - <%= l(:field_is_default) %> <%= l(:label_enabled) %> <% if authorize_for("global_issue_templates", "edit") %> <%=l(:button_sort)%> @@ -33,13 +32,12 @@ <% @global_issue_templates.each do |issue_template| %> issue_template issue"> <%= link_to h(issue_template.id), {:controller => 'global_issue_templates', - :id => issue_template.id, :action => 'show'}, {:title => issue_template.note } %> + :id => issue_template.id, :action => 'show'}, title: issue_template.title, tooltip: issue_template.note %> <%= link_to h(issue_template.title), {:controller => 'global_issue_templates', - :id => issue_template.id, :action => 'show'}, {:title => issue_template.note } %> + :id => issue_template.id, :action => 'show'}, title: issue_template.note, class: "tooltip" %> <%=h issue_template.tracker.name %> <%=h issue_template.author %> <%= format_time(issue_template.updated_on)%> - <%= checked_image issue_template.is_default? %> <%= checked_image issue_template.enabled? %> <% if authorize_for("issue_templates", "edit") %> diff --git a/db/migrate/20140330155030_remove_is_default_from_global_issue_templates.rb b/db/migrate/20140330155030_remove_is_default_from_global_issue_templates.rb new file mode 100644 index 0000000..257cbb5 --- /dev/null +++ b/db/migrate/20140330155030_remove_is_default_from_global_issue_templates.rb @@ -0,0 +1,9 @@ +class RemoveIsDefaultFromGlobalIssueTemplates < ActiveRecord::Migration + def self.up + remove_column :global_issue_templates, :is_default + end + + def self.down + raise IrreversibleMigration + end +end