Ver código fonte

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
tags/2.5.0
Jean-Philippe Lang 10 anos atrás
pai
commit
e715c4b847

+ 0
- 1
app/views/custom_fields/formats/_regexp.html.erb Ver arquivo

@@ -2,7 +2,6 @@
<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 :max_length, :size => 5, :no_label => true %>
<em class="info"><%= l(:text_min_max_length_info) %></em>
</p>
<p>
<%= f.text_field :regexp, :size => 50 %>

+ 2
- 2
app/views/custom_fields/index.api.rsb Ver arquivo

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

+ 15
- 0
db/migrate/20131214094309_remove_custom_fields_min_max_length_default_values.rb Ver arquivo

@@ -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

+ 2
- 2
lib/redmine/field_format.rb Ver arquivo

@@ -218,10 +218,10 @@ module Redmine
unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
errs << ::I18n.t('activerecord.errors.messages.invalid')
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)
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)
end
end

+ 0
- 18
test/fixtures/custom_fields.yml Ver arquivo

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

Carregando…
Cancelar
Salvar