##// END OF EJS Templates
Removed default values on custom field min and max length....
Jean-Philippe Lang -
r12130:e715c4b847a8
parent child
Show More
@@ -0,0 +1,15
1 class RemoveCustomFieldsMinMaxLengthDefaultValues < ActiveRecord::Migration
2 def up
3 change_column :custom_fields, :min_length, :int, :default => nil, :null => true
4 change_column :custom_fields, :max_length, :int, :default => nil, :null => true
5 CustomField.where(:min_length => 0).update_all(:min_length => nil)
6 CustomField.where(:max_length => 0).update_all(:max_length => nil)
7 end
8
9 def self.down
10 CustomField.where(:min_length => nil).update_all(:min_length => 0)
11 CustomField.where(:max_length => nil).update_all(:max_length => 0)
12 change_column :custom_fields, :min_length, :int, :default => 0, :null => false
13 change_column :custom_fields, :max_length, :int, :default => 0, :null => false
14 end
15 end
@@ -2,7 +2,6
2 2 <label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
3 3 <%= f.text_field :min_length, :size => 5, :no_label => true %> -
4 4 <%= f.text_field :max_length, :size => 5, :no_label => true %>
5 <em class="info"><%= l(:text_min_max_length_info) %></em>
6 5 </p>
7 6 <p>
8 7 <%= f.text_field :regexp, :size => 50 %>
@@ -6,8 +6,8 api.array :custom_fields do
6 6 api.customized_type field.class.customized_class.name.underscore if field.class.customized_class
7 7 api.field_format field.field_format
8 8 api.regexp field.regexp
9 api.min_length (field.min_length == 0 ? nil : field.min_length)
10 api.max_length (field.max_length == 0 ? nil : field.max_length)
9 api.min_length field.min_length
10 api.max_length field.max_length
11 11 api.is_required field.is_required?
12 12 api.is_filter field.is_filter?
13 13 api.searchable field.searchable
@@ -218,10 +218,10 module Redmine
218 218 unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
219 219 errs << ::I18n.t('activerecord.errors.messages.invalid')
220 220 end
221 if custom_field.min_length > 0 and value.length < custom_field.min_length
221 if custom_field.min_length && value.length < custom_field.min_length
222 222 errs << ::I18n.t('activerecord.errors.messages.too_short', :count => custom_field.min_length)
223 223 end
224 if custom_field.max_length > 0 and value.length > custom_field.max_length
224 if custom_field.max_length && custom_field.max_length > 0 && value.length > custom_field.max_length
225 225 errs << ::I18n.t('activerecord.errors.messages.too_long', :count => custom_field.max_length)
226 226 end
227 227 end
@@ -1,12 +1,10
1 1 ---
2 2 custom_fields_001:
3 3 name: Database
4 min_length: 0
5 4 regexp: ""
6 5 is_for_all: true
7 6 is_filter: true
8 7 type: IssueCustomField
9 max_length: 0
10 8 possible_values:
11 9 - MySQL
12 10 - PostgreSQL
@@ -35,12 +33,10 custom_fields_002:
35 33 position: 1
36 34 custom_fields_003:
37 35 name: Development status
38 min_length: 0
39 36 regexp: ""
40 37 is_for_all: false
41 38 is_filter: true
42 39 type: ProjectCustomField
43 max_length: 0
44 40 possible_values:
45 41 - Stable
46 42 - Beta
@@ -54,11 +50,9 custom_fields_003:
54 50 position: 1
55 51 custom_fields_004:
56 52 name: Phone number
57 min_length: 0
58 53 regexp: ""
59 54 is_for_all: false
60 55 type: UserCustomField
61 max_length: 0
62 56 possible_values: ""
63 57 id: 4
64 58 is_required: false
@@ -68,11 +62,9 custom_fields_004:
68 62 position: 1
69 63 custom_fields_005:
70 64 name: Money
71 min_length: 0
72 65 regexp: ""
73 66 is_for_all: false
74 67 type: UserCustomField
75 max_length: 0
76 68 possible_values: ""
77 69 id: 5
78 70 is_required: false
@@ -82,11 +74,9 custom_fields_005:
82 74 position: 2
83 75 custom_fields_006:
84 76 name: Float field
85 min_length: 0
86 77 regexp: ""
87 78 is_for_all: true
88 79 type: IssueCustomField
89 max_length: 0
90 80 possible_values: ""
91 81 id: 6
92 82 is_required: false
@@ -96,12 +86,10 custom_fields_006:
96 86 position: 3
97 87 custom_fields_007:
98 88 name: Billable
99 min_length: 0
100 89 regexp: ""
101 90 is_for_all: false
102 91 is_filter: true
103 92 type: TimeEntryActivityCustomField
104 max_length: 0
105 93 possible_values: ""
106 94 id: 7
107 95 is_required: false
@@ -111,12 +99,10 custom_fields_007:
111 99 position: 1
112 100 custom_fields_008:
113 101 name: Custom date
114 min_length: 0
115 102 regexp: ""
116 103 is_for_all: true
117 104 is_filter: false
118 105 type: IssueCustomField
119 max_length: 0
120 106 possible_values: ""
121 107 id: 8
122 108 is_required: false
@@ -126,12 +112,10 custom_fields_008:
126 112 position: 4
127 113 custom_fields_009:
128 114 name: Project 1 cf
129 min_length: 0
130 115 regexp: ""
131 116 is_for_all: false
132 117 is_filter: true
133 118 type: IssueCustomField
134 max_length: 0
135 119 possible_values: ""
136 120 id: 9
137 121 is_required: false
@@ -141,12 +125,10 custom_fields_009:
141 125 position: 5
142 126 custom_fields_010:
143 127 name: Overtime
144 min_length: 0
145 128 regexp: ""
146 129 is_for_all: false
147 130 is_filter: false
148 131 type: TimeEntryCustomField
149 max_length: 0
150 132 possible_values: ""
151 133 id: 10
152 134 is_required: false
General Comments 0
You need to be logged in to leave comments. Login now