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