Removed default values on custom field min and max length.

git-svn-id: http://svn.redmine.org/redmine/trunk@12405 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-12-14 10:01:45 +00:00
parent 3e5f1e326a
commit e715c4b847
5 changed files with 19 additions and 23 deletions

View File

@ -2,7 +2,6 @@
<label for="custom_field_min_length"><%=l(:label_min_max_length)%></label> <label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
<%= f.text_field :min_length, :size => 5, :no_label => true %> - <%= f.text_field :min_length, :size => 5, :no_label => true %> -
<%= f.text_field :max_length, :size => 5, :no_label => true %> <%= f.text_field :max_length, :size => 5, :no_label => true %>
<em class="info"><%= l(:text_min_max_length_info) %></em>
</p> </p>
<p> <p>
<%= f.text_field :regexp, :size => 50 %> <%= f.text_field :regexp, :size => 50 %>

View File

@ -6,8 +6,8 @@ api.array :custom_fields do
api.customized_type field.class.customized_class.name.underscore if field.class.customized_class api.customized_type field.class.customized_class.name.underscore if field.class.customized_class
api.field_format field.field_format api.field_format field.field_format
api.regexp field.regexp api.regexp field.regexp
api.min_length (field.min_length == 0 ? nil : field.min_length) api.min_length field.min_length
api.max_length (field.max_length == 0 ? nil : field.max_length) api.max_length field.max_length
api.is_required field.is_required? api.is_required field.is_required?
api.is_filter field.is_filter? api.is_filter field.is_filter?
api.searchable field.searchable api.searchable field.searchable

View File

@ -0,0 +1,15 @@
class RemoveCustomFieldsMinMaxLengthDefaultValues < ActiveRecord::Migration
def up
change_column :custom_fields, :min_length, :int, :default => nil, :null => true
change_column :custom_fields, :max_length, :int, :default => nil, :null => true
CustomField.where(:min_length => 0).update_all(:min_length => nil)
CustomField.where(:max_length => 0).update_all(:max_length => nil)
end
def self.down
CustomField.where(:min_length => nil).update_all(:min_length => 0)
CustomField.where(:max_length => nil).update_all(:max_length => 0)
change_column :custom_fields, :min_length, :int, :default => 0, :null => false
change_column :custom_fields, :max_length, :int, :default => 0, :null => false
end
end

View File

@ -218,10 +218,10 @@ module Redmine
unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
errs << ::I18n.t('activerecord.errors.messages.invalid') errs << ::I18n.t('activerecord.errors.messages.invalid')
end end
if custom_field.min_length > 0 and value.length < custom_field.min_length if custom_field.min_length && value.length < custom_field.min_length
errs << ::I18n.t('activerecord.errors.messages.too_short', :count => custom_field.min_length) errs << ::I18n.t('activerecord.errors.messages.too_short', :count => custom_field.min_length)
end end
if custom_field.max_length > 0 and value.length > custom_field.max_length if custom_field.max_length && custom_field.max_length > 0 && value.length > custom_field.max_length
errs << ::I18n.t('activerecord.errors.messages.too_long', :count => custom_field.max_length) errs << ::I18n.t('activerecord.errors.messages.too_long', :count => custom_field.max_length)
end end
end end

View File

@ -1,12 +1,10 @@
--- ---
custom_fields_001: custom_fields_001:
name: Database name: Database
min_length: 0
regexp: "" regexp: ""
is_for_all: true is_for_all: true
is_filter: true is_filter: true
type: IssueCustomField type: IssueCustomField
max_length: 0
possible_values: possible_values:
- MySQL - MySQL
- PostgreSQL - PostgreSQL
@ -35,12 +33,10 @@ custom_fields_002:
position: 1 position: 1
custom_fields_003: custom_fields_003:
name: Development status name: Development status
min_length: 0
regexp: "" regexp: ""
is_for_all: false is_for_all: false
is_filter: true is_filter: true
type: ProjectCustomField type: ProjectCustomField
max_length: 0
possible_values: possible_values:
- Stable - Stable
- Beta - Beta
@ -54,11 +50,9 @@ custom_fields_003:
position: 1 position: 1
custom_fields_004: custom_fields_004:
name: Phone number name: Phone number
min_length: 0
regexp: "" regexp: ""
is_for_all: false is_for_all: false
type: UserCustomField type: UserCustomField
max_length: 0
possible_values: "" possible_values: ""
id: 4 id: 4
is_required: false is_required: false
@ -68,11 +62,9 @@ custom_fields_004:
position: 1 position: 1
custom_fields_005: custom_fields_005:
name: Money name: Money
min_length: 0
regexp: "" regexp: ""
is_for_all: false is_for_all: false
type: UserCustomField type: UserCustomField
max_length: 0
possible_values: "" possible_values: ""
id: 5 id: 5
is_required: false is_required: false
@ -82,11 +74,9 @@ custom_fields_005:
position: 2 position: 2
custom_fields_006: custom_fields_006:
name: Float field name: Float field
min_length: 0
regexp: "" regexp: ""
is_for_all: true is_for_all: true
type: IssueCustomField type: IssueCustomField
max_length: 0
possible_values: "" possible_values: ""
id: 6 id: 6
is_required: false is_required: false
@ -96,12 +86,10 @@ custom_fields_006:
position: 3 position: 3
custom_fields_007: custom_fields_007:
name: Billable name: Billable
min_length: 0
regexp: "" regexp: ""
is_for_all: false is_for_all: false
is_filter: true is_filter: true
type: TimeEntryActivityCustomField type: TimeEntryActivityCustomField
max_length: 0
possible_values: "" possible_values: ""
id: 7 id: 7
is_required: false is_required: false
@ -111,12 +99,10 @@ custom_fields_007:
position: 1 position: 1
custom_fields_008: custom_fields_008:
name: Custom date name: Custom date
min_length: 0
regexp: "" regexp: ""
is_for_all: true is_for_all: true
is_filter: false is_filter: false
type: IssueCustomField type: IssueCustomField
max_length: 0
possible_values: "" possible_values: ""
id: 8 id: 8
is_required: false is_required: false
@ -126,12 +112,10 @@ custom_fields_008:
position: 4 position: 4
custom_fields_009: custom_fields_009:
name: Project 1 cf name: Project 1 cf
min_length: 0
regexp: "" regexp: ""
is_for_all: false is_for_all: false
is_filter: true is_filter: true
type: IssueCustomField type: IssueCustomField
max_length: 0
possible_values: "" possible_values: ""
id: 9 id: 9
is_required: false is_required: false
@ -141,12 +125,10 @@ custom_fields_009:
position: 5 position: 5
custom_fields_010: custom_fields_010:
name: Overtime name: Overtime
min_length: 0
regexp: "" regexp: ""
is_for_all: false is_for_all: false
is_filter: false is_filter: false
type: TimeEntryCustomField type: TimeEntryCustomField
max_length: 0
possible_values: "" possible_values: ""
id: 10 id: 10
is_required: false is_required: false