]> source.dussan.org Git - redmine.git/commitdiff
Removed default values on custom field min and max length.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 14 Dec 2013 10:01:45 +0000 (10:01 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 14 Dec 2013 10:01:45 +0000 (10:01 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12405 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/custom_fields/formats/_regexp.html.erb
app/views/custom_fields/index.api.rsb
db/migrate/20131214094309_remove_custom_fields_min_max_length_default_values.rb [new file with mode: 0644]
lib/redmine/field_format.rb
test/fixtures/custom_fields.yml

index 0b630347a1cbf7550d7a217c7c532bf2b9d44210..9630d5a305967530d58160476d812578013d4e3c 100644 (file)
@@ -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 %>
index 4dbd44c7ad8479c43580baf6fc8460978acee723..902edff164055dec698f4f6b6a099f3d05b6c65f 100644 (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.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
diff --git a/db/migrate/20131214094309_remove_custom_fields_min_max_length_default_values.rb b/db/migrate/20131214094309_remove_custom_fields_min_max_length_default_values.rb
new file mode 100644 (file)
index 0000000..d7111c1
--- /dev/null
@@ -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
index 399f7d150152fd6407da3420ccdd42fdd122e932..ac27831be37734ee3678f8f4811ca813275b85af 100644 (file)
@@ -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
index 976c19c2623ee91eaf604db0f9ba42785a8e04ee..510e3a41c47acd2c98e4d64ac9c4bf221eb44796 100644 (file)
@@ -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