usefull_filter 0.0.4 → 1.0.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +7 -3
- data/README.rdoc +6 -1
- data/app/helpers/usefull_filter_helper.rb +34 -6
- data/lib/generators/usefull_filter/install/install_generator.rb +3 -3
- data/lib/generators/usefull_filter/install/templates/config/locales/usefull_filter.it.yml +29 -0
- data/lib/generators/usefull_filter/install/templates/public/javascripts/usefull_filter_date_select.js +2420 -0
- data/lib/generators/usefull_filter/install/templates/public/stylesheets/usefull_filter.css +67 -0
- data/lib/generators/usefull_filter/install/templates/public/stylesheets/usefull_filter_date_select.css +247 -0
- data/lib/usefull_filter/filter_form_builder.rb +60 -35
- data/lib/usefull_filter/version.rb +1 -1
- metadata +22 -43
@@ -0,0 +1,67 @@
|
|
1
|
+
/* Filter bar personalizzata */
|
2
|
+
.usefull_filter_container {
|
3
|
+
width: 946px;
|
4
|
+
margin-top: 8px;
|
5
|
+
margin-bottom: 8px;
|
6
|
+
background: #E6E6E6;
|
7
|
+
cursor: default;
|
8
|
+
border: 2px solid #C8C8C8;
|
9
|
+
}
|
10
|
+
|
11
|
+
.usefull_filter_container h3 {
|
12
|
+
display: inline-block !important;
|
13
|
+
margin-bottom: 1.0em !important;
|
14
|
+
}
|
15
|
+
|
16
|
+
/* self-clearing method: */
|
17
|
+
.usefull_filter_container li {
|
18
|
+
display: inline;
|
19
|
+
font-weight:bold;
|
20
|
+
float: left;
|
21
|
+
margin-right:5px;
|
22
|
+
width: 49%;
|
23
|
+
color: #105cb6;
|
24
|
+
}
|
25
|
+
|
26
|
+
/* input del container: */
|
27
|
+
.usefull_filter_container input {
|
28
|
+
width: 40%;
|
29
|
+
display: inline;
|
30
|
+
float: right;
|
31
|
+
background: white
|
32
|
+
}
|
33
|
+
/* input del container btw_date: */
|
34
|
+
.usefull_filter_container input.btw_date {
|
35
|
+
width: 50%;
|
36
|
+
float: right;
|
37
|
+
background: white
|
38
|
+
}
|
39
|
+
/* select del container dati: */
|
40
|
+
.usefull_filter_container select {
|
41
|
+
width: 40%;
|
42
|
+
float: right;
|
43
|
+
}
|
44
|
+
/* select del container filtri: */
|
45
|
+
.usefull_filter_container select.select_dati {
|
46
|
+
float: left;
|
47
|
+
width: 45%;
|
48
|
+
}
|
49
|
+
|
50
|
+
.usefull_filter_container .apply_filter_btn {
|
51
|
+
position:relative;
|
52
|
+
float:left;
|
53
|
+
background: none repeat scroll 0 0 orange;
|
54
|
+
margin-bottom: 5px;
|
55
|
+
margin-top: 3px;
|
56
|
+
min-width: 100px;
|
57
|
+
z-index: 3;
|
58
|
+
}
|
59
|
+
.usefull_filter_container .remove_filter_btn {
|
60
|
+
position:relative;
|
61
|
+
float:right;
|
62
|
+
background: none repeat scroll 0 0 orange;
|
63
|
+
margin-bottom: 5px;
|
64
|
+
margin-top: 3px;
|
65
|
+
min-width: 100px;
|
66
|
+
z-index: 3;
|
67
|
+
}
|
@@ -0,0 +1,247 @@
|
|
1
|
+
/** Base container **/
|
2
|
+
.kalendae {
|
3
|
+
display: inline-block;zoom:1;*display:inline;
|
4
|
+
background:#eee;
|
5
|
+
padding:10px;
|
6
|
+
margin:5px;
|
7
|
+
border-radius:5px;
|
8
|
+
-moz-border-radius: 5px;
|
9
|
+
-webkit-border-radius: 5px;
|
10
|
+
font-size:11px;
|
11
|
+
font-family:'Helvetica Neue', 'Helvetica';
|
12
|
+
cursor:default;
|
13
|
+
position:relative;
|
14
|
+
}
|
15
|
+
|
16
|
+
/** Popup Container for Kalendae.Input **/
|
17
|
+
.kalendae.k-floating {
|
18
|
+
position:absolute;
|
19
|
+
top:0;
|
20
|
+
left:0;
|
21
|
+
z-index:100000;
|
22
|
+
margin:0;
|
23
|
+
box-shadow:0 1px 3px rgba(0,0,0,0.75);
|
24
|
+
-moz-box-shadow:0 1px 3px rgba(0,0,0,0.75);
|
25
|
+
-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.75);
|
26
|
+
}
|
27
|
+
|
28
|
+
/** Kalendae.Input's popup close button **/
|
29
|
+
.kalendae .k-btn-close {
|
30
|
+
position:absolute;
|
31
|
+
top:-8px;
|
32
|
+
right:-8px;
|
33
|
+
width:16px;
|
34
|
+
height:16px;
|
35
|
+
background:white;
|
36
|
+
border:2px solid #ccc;
|
37
|
+
color:#999;
|
38
|
+
line-height:17px;
|
39
|
+
text-align:center;
|
40
|
+
font-size:13px;
|
41
|
+
border-radius:10px;
|
42
|
+
box-shadow:0 1px 3px rgba(0,0,0,0.75);
|
43
|
+
cursor:pointer;
|
44
|
+
text-decoration:none;
|
45
|
+
}
|
46
|
+
.kalendae .k-btn-close:after {content:"\2716";}
|
47
|
+
.kalendae .k-btn-close:hover {
|
48
|
+
color:#7EA0E2;
|
49
|
+
background:white;
|
50
|
+
border-color:#7EA0E2;
|
51
|
+
}
|
52
|
+
|
53
|
+
/** Month Container **/
|
54
|
+
.kalendae .k-calendar {display: inline-block;zoom:1;*display:inline;width:155px;vertical-align:top;}
|
55
|
+
|
56
|
+
/** Month Separator **/
|
57
|
+
.kalendae .k-separator {display: inline-block;zoom:1;*display:inline;width:2px;vertical-align:top;background:#ddd;height:155px;margin:0px 10px;}
|
58
|
+
|
59
|
+
/** Month Title Row **/
|
60
|
+
.kalendae .k-title {text-align:center;white-space:nowrap;position:relative;height:18px;}
|
61
|
+
.kalendae .k-caption {font-size:12px;line-height:18px;}
|
62
|
+
|
63
|
+
|
64
|
+
/** Month and Year Buttons **/
|
65
|
+
.kalendae .k-btn-previous-month,
|
66
|
+
.kalendae .k-btn-next-month,
|
67
|
+
.kalendae .k-btn-previous-year,
|
68
|
+
.kalendae .k-btn-next-year {
|
69
|
+
width:16px;
|
70
|
+
height:16px;
|
71
|
+
cursor:pointer;
|
72
|
+
position:absolute;
|
73
|
+
top:-3px;
|
74
|
+
color:#777;
|
75
|
+
font-size:26px;
|
76
|
+
line-height: 18px;
|
77
|
+
font-weight: bold;
|
78
|
+
font-family: arial;
|
79
|
+
text-decoration:none;
|
80
|
+
}
|
81
|
+
|
82
|
+
.kalendae .k-btn-previous-year {left:0;}
|
83
|
+
.kalendae .k-btn-previous-month {left:16px;}
|
84
|
+
.kalendae .k-btn-next-month {right:16px;}
|
85
|
+
.kalendae .k-btn-next-year {right:0;}
|
86
|
+
|
87
|
+
.kalendae .k-btn-previous-month:after {content:"\2039";}
|
88
|
+
.kalendae .k-btn-next-month:after {content:"\203A";}
|
89
|
+
|
90
|
+
.kalendae .k-btn-previous-year:after {content:"\00AB";}
|
91
|
+
.kalendae .k-btn-next-year:after {content:"\00BB";}
|
92
|
+
|
93
|
+
.kalendae .k-btn-previous-month:hover,
|
94
|
+
.kalendae .k-btn-next-month:hover {color:#7EA0E2;}
|
95
|
+
|
96
|
+
.kalendae .k-btn-previous-year:hover,
|
97
|
+
.kalendae .k-btn-next-year:hover {color:#6FDF81;}
|
98
|
+
|
99
|
+
/** Remove extra buttons when calendar shows multiple months **/
|
100
|
+
.kalendae .k-first-month .k-btn-next-month,
|
101
|
+
.kalendae .k-middle-month .k-btn-next-month,
|
102
|
+
.kalendae .k-middle-month .k-btn-previous-month,
|
103
|
+
.kalendae .k-last-month .k-btn-previous-month,
|
104
|
+
.kalendae .k-first-month .k-btn-next-year,
|
105
|
+
.kalendae .k-middle-month .k-btn-next-year,
|
106
|
+
.kalendae .k-middle-month .k-btn-previous-year,
|
107
|
+
.kalendae .k-last-month .k-btn-previous-year {display:none;}
|
108
|
+
|
109
|
+
/** Disable year nav option **/
|
110
|
+
.kalendae .k-title.k-disable-year-nav .k-btn-next-year,
|
111
|
+
.kalendae .k-title.k-disable-year-nav .k-btn-previous-year { display: none; }
|
112
|
+
.kalendae .k-title.k-disable-year-nav .k-btn-next-month { right: 0; }
|
113
|
+
.kalendae .k-title.k-disable-year-nav .k-btn-previous-month { left: 0; }
|
114
|
+
|
115
|
+
/** Force specific width for month container contents **/
|
116
|
+
.kalendae .k-title,
|
117
|
+
.kalendae .k-header,
|
118
|
+
.kalendae .k-days {
|
119
|
+
width:154px;
|
120
|
+
display:block;
|
121
|
+
overflow:hidden;
|
122
|
+
}
|
123
|
+
|
124
|
+
|
125
|
+
/** Hide unusable buttons **/
|
126
|
+
.kalendae.k-disable-next-month-btn .k-btn-next-month,
|
127
|
+
.kalendae.k-disable-previous-month-btn .k-btn-previous-month,
|
128
|
+
.kalendae.k-disable-next-year-btn .k-btn-next-year,
|
129
|
+
.kalendae.k-disable-previous-year-btn .k-btn-previous-year {
|
130
|
+
display:none;
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
/** Week columns and day cells **/
|
135
|
+
.kalendae .k-header span,
|
136
|
+
.kalendae .k-days span {
|
137
|
+
float:left;
|
138
|
+
margin:1px 1px;
|
139
|
+
}
|
140
|
+
|
141
|
+
.kalendae .k-header span {
|
142
|
+
text-align:center;
|
143
|
+
font-weight:bold;
|
144
|
+
width:20px;
|
145
|
+
padding:1px 0;
|
146
|
+
color:#666;
|
147
|
+
}
|
148
|
+
|
149
|
+
.kalendae .k-days span {
|
150
|
+
text-align:right;
|
151
|
+
width:13px;
|
152
|
+
height:1.1em;
|
153
|
+
line-height:1em;
|
154
|
+
padding:2px 3px 2px 2px;
|
155
|
+
border:1px solid transparent;
|
156
|
+
border-radius:3px;
|
157
|
+
-moz-border-radius: 3px;
|
158
|
+
-webkit-border-radius: 3px;
|
159
|
+
color:#999;
|
160
|
+
}
|
161
|
+
|
162
|
+
/** Today **/
|
163
|
+
.kalendae .k-today {
|
164
|
+
text-decoration:underline;
|
165
|
+
}
|
166
|
+
|
167
|
+
/** Days inside of the month view **/
|
168
|
+
.kalendae .k-days span.k-in-month.k-active {
|
169
|
+
border-color:#ddd;
|
170
|
+
background-color:#fff;
|
171
|
+
color:#333;
|
172
|
+
}
|
173
|
+
/** Days outside of the month view (before the first day of the month, after the last day of the month) **/
|
174
|
+
.kalendae .k-days span.k-out-of-month {color:#ddd;}
|
175
|
+
|
176
|
+
/** Selectable **/
|
177
|
+
.kalendae .k-days span.k-active {
|
178
|
+
cursor:pointer;
|
179
|
+
}
|
180
|
+
|
181
|
+
/** Selected day, when outside the selectable area **/
|
182
|
+
.kalendae .k-days span.k-selected {
|
183
|
+
border-color:#1072A5;
|
184
|
+
color:#1072A5;
|
185
|
+
}
|
186
|
+
|
187
|
+
/** Selected day, when inside the selectable area **/
|
188
|
+
.kalendae .k-days span.k-selected.k-active {
|
189
|
+
background:#7EA0E2;
|
190
|
+
color:white;
|
191
|
+
}
|
192
|
+
|
193
|
+
/** Days between the start and end points on a range, outside of the selectable area **/
|
194
|
+
.kalendae .k-days span.k-range {
|
195
|
+
background:none;
|
196
|
+
border-color:#6DD4FE;
|
197
|
+
}
|
198
|
+
|
199
|
+
/** Days between the start and end points on a range, inside of the selectable area **/
|
200
|
+
.kalendae .k-days span.k-range.k-in-month {
|
201
|
+
background:#C4D4F1;
|
202
|
+
border-color:#19AEFE;
|
203
|
+
color:#333;
|
204
|
+
}
|
205
|
+
|
206
|
+
/** Selectable day, hovered **/
|
207
|
+
.kalendae .k-days span.k-active:hover {
|
208
|
+
border-color:#666;
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
/*-------------------------------------IE8 ONLY CODE BELOW THIS LINE--------------------------------------------*/
|
213
|
+
|
214
|
+
.kalendae.ie8.k-floating {
|
215
|
+
border:1px solid #ccc;
|
216
|
+
}
|
217
|
+
|
218
|
+
.kalendae.ie8 .k-btn-close {
|
219
|
+
width:20px;
|
220
|
+
height:20px;
|
221
|
+
border:none;
|
222
|
+
background:url('close.png') no-repeat top left;
|
223
|
+
}
|
224
|
+
.kalendae.ie8 .k-btn-close:after {display:none;}
|
225
|
+
|
226
|
+
.kalendae.ie8 .k-btn-previous-month,
|
227
|
+
.kalendae.ie8 .k-btn-next-month,
|
228
|
+
.kalendae.ie8 .k-btn-previous-year,
|
229
|
+
.kalendae.ie8 .k-btn-next-year {width:16px;height:16px;cursor:pointer;background:#777 url('arrows.png') no-repeat center left;position:absolute;top:0;}
|
230
|
+
|
231
|
+
.kalendae.ie8 .k-btn-next-month,
|
232
|
+
.kalendae.ie8 .k-btn-next-year {background-position:center right;}
|
233
|
+
|
234
|
+
.kalendae.ie8 .k-btn-previous-month:hover,
|
235
|
+
.kalendae.ie8 .k-btn-next-month:hover {background-color:#7EA0E2;}
|
236
|
+
|
237
|
+
.kalendae.ie8 .k-btn-previous-year,
|
238
|
+
.kalendae.ie8 .k-btn-next-year {background-color:#333;}
|
239
|
+
|
240
|
+
.kalendae.ie8 .k-btn-previous-year:hover,
|
241
|
+
.kalendae.ie8 .k-btn-next-year:hover {background-color:#6FDF81;}
|
242
|
+
|
243
|
+
.kalendae.ie8 .k-btn-previous-month:after,
|
244
|
+
.kalendae.ie8 .k-btn-next-month:after,
|
245
|
+
.kalendae.ie8 .k-btn-previous-year:after,
|
246
|
+
.kalendae.ie8 .k-btn-next-year:after {display:none;}
|
247
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module UsefullFilter
|
2
2
|
class FilterFormBuilder < ActionView::Helpers::FormBuilder
|
3
3
|
|
4
|
-
DEFAULT_TYPES=["equals", "does_not_equal", "in", "not_in"]
|
4
|
+
DEFAULT_TYPES=["equals", "does_not_equal", "in", "not_in", "is_blank", "is_not_null"]
|
5
5
|
STRING_TYPES=["contains", "does_not_contain", "starts_with", "does_not_start_with", "ends_with", "does_not_end_with"]
|
6
6
|
NUMBER_TYPES=["greater_than", "greater_than_or_equal_to", "less_than", "less_than_or_equal_to"]
|
7
7
|
BOOLEAN_TYPES=["is_true", "is_false"]
|
@@ -16,19 +16,44 @@ module UsefullFilter
|
|
16
16
|
#* :ART
|
17
17
|
#* "document.activity.id" (come per la tabelle)
|
18
18
|
def text_field(object_name, *args)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
19
|
+
opt = define_args(args, object_name)
|
20
|
+
name = object_name.to_s.gsub(/\./, "_")
|
21
|
+
opt.merge!(@options[:html_1][:input])
|
22
|
+
@template.content_tag(:li) do
|
23
|
+
#@template.concat filter_list(name, opt[:default_filter], opt)
|
24
|
+
@template.concat filter_list(object_name, opt[:default_filter], opt)
|
25
|
+
@template.concat " "
|
26
|
+
@template.concat super(default(name, opt[:default_filter]), opt)
|
27
|
+
#@template.concat attribute_type(object_name) == :Date ? @template.link_to(@template.image_tag('calendar16.png'), '#', :onclick => "show_calendar('search_data_prevista_equals')") : ''
|
28
|
+
end
|
30
29
|
end
|
31
30
|
|
31
|
+
def between_dates(object_name, *args)
|
32
|
+
opt = args.extract_options!
|
33
|
+
name = object_name.to_s.gsub(/\./, "_") + "_my_between_dates"
|
34
|
+
opt.merge!(@options[:html_1][:input])
|
35
|
+
opt.merge!({:field_type => :text_field})
|
36
|
+
opt[:class].blank? ? opt[:class]="btw_date auto-kal" : opt[:class] << " btw_date auto-kal"
|
37
|
+
if opt[:format].blank?
|
38
|
+
opt['data-kal']="format: '" + I18n.t("date.formats.between_dates_default_js") + "'"
|
39
|
+
else
|
40
|
+
_format = opt.delete(:format)
|
41
|
+
opt['data-kal']="format: '#{_format}'"
|
42
|
+
end
|
43
|
+
@template.content_tag(:li) do
|
44
|
+
@template.concat I18n.t(:my_between_dates, :scope =>"meta_search.predicates", :attribute => human(object_name))
|
45
|
+
@template.concat multiparameter_field(name, opt.dup, opt.dup, :size => 10)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def date_select(object_name, *args)
|
50
|
+
# Richiamo il metodo "text_field" facendogli utilizzare la classe "auto-kal" utilizzata da un JS per mostrare il calendario.
|
51
|
+
options = args.extract_options!
|
52
|
+
options[:class].blank? ? options[:class]="auto-kal" : options[:class] << " auto-kal"
|
53
|
+
options['data-kal'] = "format: '" + I18n.t("date.formats.date_select_default_js") + "'"
|
54
|
+
text_field(object_name, options)
|
55
|
+
end
|
56
|
+
|
32
57
|
#Utilizza come filtro una combo, con i valori passati nell'array
|
33
58
|
def select(object_name, array, *args)
|
34
59
|
opt = define_args(args, object_name)
|
@@ -48,20 +73,10 @@ module UsefullFilter
|
|
48
73
|
#def checks(object_name, array, *args, &block)
|
49
74
|
# super.to_s.html_safe
|
50
75
|
#end
|
51
|
-
|
52
|
-
|
53
|
-
#Genera una doppia text_box per gestire i filtri tra due
|
54
|
-
def between_field(object_name, *args)
|
55
|
-
opt = define_args(args, object_name)
|
56
|
-
name = object_name.to_s.gsub(/\./, "_")
|
57
|
-
@template.content_tag(:li,
|
58
|
-
multiparameter_field(name.to_s + "_between",
|
59
|
-
{:field_type => :text_field}, {:field_type => :text_field}, :size => 5))
|
60
|
-
end
|
61
|
-
|
76
|
+
|
62
77
|
def submit
|
63
78
|
applay_filter_label = I18n.t(:applay_filter, :scope => "meta_search.buttons")
|
64
|
-
super(applay_filter_label, :class => "
|
79
|
+
super(applay_filter_label, :class => "apply_filter_btn")
|
65
80
|
end
|
66
81
|
|
67
82
|
private
|
@@ -76,7 +91,7 @@ module UsefullFilter
|
|
76
91
|
opt = args.extract_options!
|
77
92
|
#Il filtro di default e _equals che deve essere presente su tutti i campi
|
78
93
|
opt[:filters] ||= DEFAULT_TYPES + type(object_name)
|
79
|
-
opt[:default_filter] ||= opt[:filters].include?("
|
94
|
+
opt[:default_filter] ||= opt[:filters].include?("contains") ? "contains" : opt[:filters].first
|
80
95
|
opt[:filters_only] ||= []
|
81
96
|
opt[:filters_except] ||= []
|
82
97
|
case opt[:filters_type]
|
@@ -89,7 +104,6 @@ module UsefullFilter
|
|
89
104
|
when :other
|
90
105
|
opt[:filters] |= OTHER_TYPES
|
91
106
|
end
|
92
|
-
|
93
107
|
opt[:filters] -= opt[:filters_except]
|
94
108
|
opt[:filters] = opt[:filters_only] unless opt[:filters_only] .blank?
|
95
109
|
opt
|
@@ -99,9 +113,10 @@ module UsefullFilter
|
|
99
113
|
#seleziona come selected il parametro trovato in params[] per garantire coerenza dopo il reload
|
100
114
|
def options_list(object_name, args, default_filter="equals")
|
101
115
|
filters = args[:filters].dup
|
116
|
+
name = object_name.to_s.gsub(/\./, "_")
|
102
117
|
filters.map! {|o|
|
103
|
-
"<option value = '" +
|
104
|
-
(default(
|
118
|
+
"<option value = '" + name.to_s + "_" + o + "'" +
|
119
|
+
(default(name,default_filter) == name.to_s + "_" + o ? " selected = 'selected'" : "") +
|
105
120
|
" >" +
|
106
121
|
I18n.t(o, :scope =>"meta_search.predicates", :attribute => human(object_name)) +
|
107
122
|
"</option>"}
|
@@ -110,12 +125,13 @@ module UsefullFilter
|
|
110
125
|
|
111
126
|
#Crea una lista dei filtri disponibili per il campo
|
112
127
|
def filter_list(object_name, default_filter, args)
|
128
|
+
#mylog("filter_list: #{object_name}")
|
113
129
|
list = options_list(object_name, args,default_filter)
|
114
|
-
|
115
|
-
#UserSession.log("
|
130
|
+
name = object_name.to_s.gsub(/\./, "_")
|
131
|
+
#UserSession.log("FilterHelper#filter_list:object_name=#{object_name.inspect}")
|
116
132
|
#@template.select_tag(object_name, list.html_safe, :onchange => "document.getElementById('search_' + #{object_name.to_s}).name = 'search[' + this + ']'")
|
117
133
|
@options[:html_1][:select][:onchange] = "$(#{'search_' + default(object_name,default_filter)}).name = 'search[' + this.value + ']'; $(#{'search_' + default(object_name, default_filter)}).id = 'search_' + this.value "
|
118
|
-
@options[:html_1][:select][:id] =
|
134
|
+
@options[:html_1][:select][:id] = name.to_s
|
119
135
|
@options[:html_1][:select][:class] = "select_dati"
|
120
136
|
##UserSession.log("FilterHelper#filter_list:options(before select_tag)=#{@options.inspect}")
|
121
137
|
@template.select_tag("", list, @options[:html_1][:select])
|
@@ -138,11 +154,11 @@ module UsefullFilter
|
|
138
154
|
end
|
139
155
|
end
|
140
156
|
|
141
|
-
#Restituisce il tipo
|
157
|
+
#Restituisce il tipo dell'attributo
|
142
158
|
#gestendo i multilivello document.activity.data_prevista => :Date
|
143
159
|
#==Nota:
|
144
160
|
#* non testata con le relazioni polimorfiche...
|
145
|
-
#* con metodi
|
161
|
+
#* con metodi definiti all'utente, restiuisce nil
|
146
162
|
def attribute_type(attribute_name)
|
147
163
|
#UserSession.log("FilterFormBuilder#attribute_type attribute_name=#{attribute_name}, base=#{@object.base.name}")
|
148
164
|
#Aggiungo self. daventi in quanto i campi tipo ART vengono confusi per costanti se non specifico il contesto. SIGH!
|
@@ -162,9 +178,18 @@ module UsefullFilter
|
|
162
178
|
end
|
163
179
|
|
164
180
|
#Restituisce il nome del campo preso da ActiveRecord
|
165
|
-
def human(object_name)
|
181
|
+
def human(object_name)
|
182
|
+
#mylog("human: #{object_name.inspect}")
|
166
183
|
##UserSession.log("FilterFormBuilder#human classe=#{@object.class.name}")
|
167
|
-
|
184
|
+
#@object.base.human_attribute_name(object_name.to_s)
|
185
|
+
associations = object_name.to_s.split(".")
|
186
|
+
klass = @object.base
|
187
|
+
while associations.size > 1
|
188
|
+
klass = klass.reflect_on_association(associations.shift.to_sym).klass
|
189
|
+
end
|
190
|
+
#ass= associations.shift
|
191
|
+
#klass = klass.reflect_on_association(ass).klass
|
192
|
+
klass.human_attribute_name(associations)
|
168
193
|
end
|
169
194
|
|
170
195
|
#Restituisce il valore di default prelevato da params[]
|