From fb4210b6d969c50de2c4f676124d26820a337377 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Thu, 4 Oct 2012 04:48:20 +0000 Subject: [PATCH] move CustomFieldsHelper tabs variable to model constant for common use (#12018) git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10554 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/custom_fields_helper.rb | 11 +---------- app/models/custom_field.rb | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index c55943b32..48485249d 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -20,16 +20,7 @@ module CustomFieldsHelper def custom_fields_tabs - tabs = [{:name => 'IssueCustomField', :partial => 'custom_fields/index', :label => :label_issue_plural}, - {:name => 'TimeEntryCustomField', :partial => 'custom_fields/index', :label => :label_spent_time}, - {:name => 'ProjectCustomField', :partial => 'custom_fields/index', :label => :label_project_plural}, - {:name => 'VersionCustomField', :partial => 'custom_fields/index', :label => :label_version_plural}, - {:name => 'UserCustomField', :partial => 'custom_fields/index', :label => :label_user_plural}, - {:name => 'GroupCustomField', :partial => 'custom_fields/index', :label => :label_group_plural}, - {:name => 'TimeEntryActivityCustomField', :partial => 'custom_fields/index', :label => TimeEntryActivity::OptionName}, - {:name => 'IssuePriorityCustomField', :partial => 'custom_fields/index', :label => IssuePriority::OptionName}, - {:name => 'DocumentCategoryCustomField', :partial => 'custom_fields/index', :label => DocumentCategory::OptionName} - ] + CustomField::CUSTOM_FIELDS_TABS end # Return custom field html tag corresponding to its format diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 115333581..a934cc877 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -30,6 +30,27 @@ class CustomField < ActiveRecord::Base validate :validate_custom_field before_validation :set_searchable + CUSTOM_FIELDS_TABS = [ + {:name => 'IssueCustomField', :partial => 'custom_fields/index', + :label => :label_issue_plural}, + {:name => 'TimeEntryCustomField', :partial => 'custom_fields/index', + :label => :label_spent_time}, + {:name => 'ProjectCustomField', :partial => 'custom_fields/index', + :label => :label_project_plural}, + {:name => 'VersionCustomField', :partial => 'custom_fields/index', + :label => :label_version_plural}, + {:name => 'UserCustomField', :partial => 'custom_fields/index', + :label => :label_user_plural}, + {:name => 'GroupCustomField', :partial => 'custom_fields/index', + :label => :label_group_plural}, + {:name => 'TimeEntryActivityCustomField', :partial => 'custom_fields/index', + :label => TimeEntryActivity::OptionName}, + {:name => 'IssuePriorityCustomField', :partial => 'custom_fields/index', + :label => IssuePriority::OptionName}, + {:name => 'DocumentCategoryCustomField', :partial => 'custom_fields/index', + :label => DocumentCategory::OptionName} + ] + def set_searchable # make sure these fields are not searchable self.searchable = false if %w(int float date bool).include?(field_format)