erp_forms 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/erp_forms/dynamic_form_field.rb +4 -1
- data/lib/erp_forms/dynamic_grid_column.rb +16 -40
- data/lib/erp_forms/version.rb +1 -1
- data/spec/dummy/db/schema.rb +858 -0
- data/spec/dummy/db/spec.sqlite3 +0 -0
- data/spec/dummy/log/spec.log +629 -0
- metadata +31 -10
@@ -161,9 +161,11 @@ class DynamicFormField
|
|
161
161
|
field[:extraParams] = options[:extraParams] unless options[:extraParams].blank?
|
162
162
|
field[:url] = options[:url] unless options[:url].blank?
|
163
163
|
field[:fields] = options[:fields] unless options[:fields].blank?
|
164
|
-
|
165
164
|
field[:mapping] = options[:mapping] unless options[:mapping].blank?
|
165
|
+
field[:minLength] = options[:minLength] unless options[:minLength].nil?
|
166
166
|
field[:maxLength] = options[:maxLength] unless options[:maxLength].nil?
|
167
|
+
field[:minValue] = options[:minValue] unless options[:minValue].nil?
|
168
|
+
field[:maxValue] = options[:maxValue] unless options[:maxValue].nil?
|
167
169
|
|
168
170
|
if selections and selections != []
|
169
171
|
field[:store] = selections
|
@@ -191,6 +193,7 @@ class DynamicFormField
|
|
191
193
|
options[:allowBlank] = true if options[:allowBlank].nil?
|
192
194
|
options[:value] = '' if options[:value].nil?
|
193
195
|
options[:readOnly] = false if options[:readOnly].nil?
|
196
|
+
options[:minLength] = nil if options[:minLength].nil?
|
194
197
|
options[:maxLength] = nil if options[:maxLength].nil?
|
195
198
|
options[:width] = 200 if options[:width].nil?
|
196
199
|
options[:height] = nil if options[:height].nil?
|
@@ -2,52 +2,28 @@ class DynamicGridColumn
|
|
2
2
|
|
3
3
|
def self.build_column(field_hash, options={})
|
4
4
|
field_hash.symbolize_keys!
|
5
|
-
header = field_hash[:fieldLabel]
|
6
|
-
type = DynamicGridColumn.convert_xtype_to_column_type(field_hash[:xtype])
|
5
|
+
header = (field_hash[:header] ? field_hash[:header] : field_hash[:fieldLabel])
|
6
|
+
type = (field_hash[:type] ? field_hash[:type] : DynamicGridColumn.convert_xtype_to_column_type(field_hash[:xtype]))
|
7
7
|
data_index = (field_hash[:dataIndex] ? field_hash[:dataIndex] : field_hash[:name])
|
8
|
+
sortable = (field_hash[:sortable].nil? ? true : field_hash[:sortable])
|
9
|
+
renderer = (type == 'date' ? "Ext.util.Format.dateRenderer('m/d/Y')" : '')
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
col = "{
|
16
|
-
\"header\":\"#{header}\",
|
17
|
-
\"type\":\"#{type}\",
|
18
|
-
\"dataIndex\":\"#{data_index}\""
|
11
|
+
col = {
|
12
|
+
:header => header,
|
13
|
+
:type => type,
|
14
|
+
:dataIndex => data_index,
|
15
|
+
:sortable => sortable
|
16
|
+
}
|
19
17
|
|
20
|
-
|
21
|
-
col
|
18
|
+
col[:width] = field_hash[:width] if field_hash[:width]
|
19
|
+
col[:renderer] = renderer unless renderer.blank?
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
col += ",
|
27
|
-
\"renderer\": #{renderer}" if renderer != ''
|
28
|
-
|
29
|
-
if options[:editor]
|
30
|
-
readonly = field_hash[:readOnly].blank? ? false : field_hash[:readOnly]
|
31
|
-
col += ",
|
32
|
-
{
|
33
|
-
\"xtype\": \"#{field_hash[:xtype]}\",
|
34
|
-
\"readOnly\": \"#{readonly}\""
|
35
|
-
|
36
|
-
if field_hash[:validation_regex] and field_hash[:validation_regex] != ''
|
37
|
-
col += ",
|
38
|
-
\"validateOnBlur\": true,
|
39
|
-
\"validator\": function(v){
|
40
|
-
var pattern = /#{field_hash[:validation_regex]}/;
|
41
|
-
var regex = new RegExp(pattern);
|
42
|
-
return regex.test(v);
|
43
|
-
}"
|
44
|
-
end
|
45
|
-
col += "}"
|
21
|
+
if field_hash[:editor]
|
22
|
+
selections = (field_hash[:editor][:store] ? field_hash[:editor][:store] : [])
|
23
|
+
col[:editor] = DynamicFormField.basic_field(field_hash[:editor][:xtype], field_hash[:editor], selections)
|
46
24
|
end
|
47
|
-
|
48
|
-
col += "}"
|
49
25
|
|
50
|
-
col
|
26
|
+
col.to_json
|
51
27
|
end
|
52
28
|
|
53
29
|
def self.build_delete_column(action='')
|