active_scaffold 3.2.7 → 3.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/CHANGELOG +16 -1
  2. data/app/assets/javascripts/jquery/active_scaffold.js +50 -16
  3. data/app/assets/javascripts/jquery/jquery.editinplace.js +6 -6
  4. data/app/assets/javascripts/prototype/active_scaffold.js +39 -15
  5. data/app/assets/stylesheets/active_scaffold_layout.css +24 -1
  6. data/frontends/default/views/_base_form.html.erb +9 -10
  7. data/frontends/default/views/_form.html.erb +8 -7
  8. data/frontends/default/views/_form_attribute.html.erb +6 -3
  9. data/frontends/default/views/_form_messages.html.erb +3 -3
  10. data/frontends/default/views/_horizontal_subform_record.html.erb +1 -1
  11. data/frontends/default/views/_list_calculations.html.erb +1 -1
  12. data/frontends/default/views/_list_messages.html.erb +10 -13
  13. data/frontends/default/views/_list_record_columns.html.erb +2 -2
  14. data/frontends/default/views/_messages.html.erb +1 -1
  15. data/frontends/default/views/_refresh_list.js.erb +1 -0
  16. data/frontends/default/views/_row.html.erb +2 -2
  17. data/frontends/default/views/_search.html.erb +2 -2
  18. data/frontends/default/views/_update_calculations.js.erb +4 -0
  19. data/frontends/default/views/_update_messages.js.erb +2 -0
  20. data/frontends/default/views/_vertical_subform_record.html.erb +1 -1
  21. data/frontends/default/views/add_existing.js.erb +2 -6
  22. data/frontends/default/views/destroy.js.erb +25 -23
  23. data/frontends/default/views/on_action_update.js.erb +21 -12
  24. data/frontends/default/views/on_create.js.erb +24 -21
  25. data/frontends/default/views/on_update.js.erb +19 -18
  26. data/frontends/default/views/refresh_list.js.erb +2 -1
  27. data/frontends/default/views/row.js.erb +1 -0
  28. data/frontends/default/views/update_column.js.erb +14 -15
  29. data/lib/active_scaffold.rb +1 -1
  30. data/lib/active_scaffold/actions/core.rb +6 -2
  31. data/lib/active_scaffold/actions/create.rb +9 -12
  32. data/lib/active_scaffold/actions/delete.rb +1 -4
  33. data/lib/active_scaffold/actions/list.rb +15 -12
  34. data/lib/active_scaffold/actions/mark.rb +1 -2
  35. data/lib/active_scaffold/actions/nested.rb +2 -1
  36. data/lib/active_scaffold/actions/update.rb +5 -8
  37. data/lib/active_scaffold/config/list.rb +18 -0
  38. data/lib/active_scaffold/constraints.rb +2 -12
  39. data/lib/active_scaffold/data_structures/column.rb +5 -2
  40. data/lib/active_scaffold/data_structures/nested_info.rb +6 -5
  41. data/lib/active_scaffold/finder.rb +11 -7
  42. data/lib/active_scaffold/helpers/controller_helpers.rb +16 -6
  43. data/lib/active_scaffold/helpers/form_column_helpers.rb +10 -20
  44. data/lib/active_scaffold/helpers/id_helpers.rb +2 -2
  45. data/lib/active_scaffold/helpers/list_column_helpers.rb +15 -20
  46. data/lib/active_scaffold/helpers/search_column_helpers.rb +15 -27
  47. data/lib/active_scaffold/helpers/show_column_helpers.rb +9 -20
  48. data/lib/active_scaffold/helpers/view_helpers.rb +20 -1
  49. data/lib/active_scaffold/version.rb +1 -1
  50. metadata +8 -4
@@ -26,8 +26,8 @@ module ActiveScaffold
26
26
  "#{options[:controller_id] || controller_id}-messages"
27
27
  end
28
28
 
29
- def active_scaffold_calculations_id(column = nil)
30
- "#{controller_id}-calculations#{'-' + column.name.to_s if column}"
29
+ def active_scaffold_calculations_id(options = {})
30
+ "#{options[:controller_id] || controller_id}-calculations#{'-' + options[:column].name.to_s if options[:column]}"
31
31
  end
32
32
 
33
33
  def empty_message_id
@@ -6,16 +6,16 @@ module ActiveScaffold
6
6
  def get_column_value(record, column)
7
7
  begin
8
8
  # check for an override helper
9
- value = if column_override? column
9
+ value = if (method = column_override(column))
10
10
  # we only pass the record as the argument. we previously also passed the formatted_value,
11
11
  # but mike perham pointed out that prohibited the usage of overrides to improve on the
12
12
  # performance of our default formatting. see issue #138.
13
- send(column_override(column), record)
13
+ send(method, record)
14
14
  # second, check if the dev has specified a valid list_ui for this column
15
- elsif column.list_ui and override_column_ui?(column.list_ui)
16
- send(override_column_ui(column.list_ui), column, record)
17
- elsif column.column and override_column_ui?(column.column.type)
18
- send(override_column_ui(column.column.type), column, record)
15
+ elsif column.list_ui and (method = override_column_ui(column.list_ui))
16
+ send(method, column, record)
17
+ elsif column.column and (method = override_column_ui(column.column.type))
18
+ send(method, column, record)
19
19
  else
20
20
  format_column_value(record, column)
21
21
  end
@@ -49,8 +49,11 @@ module ActiveScaffold
49
49
  else
50
50
  "<a class='disabled'>#{text}</a>".html_safe
51
51
  end
52
+ elsif inplace_edit?(record, column)
53
+ active_scaffold_inplace_edit(record, column, {:formatted_column => text})
54
+ elsif active_scaffold_config.list.wrap_tag
55
+ content_tag active_scaffold_config.list.wrap_tag, text
52
56
  else
53
- text = active_scaffold_inplace_edit(record, column, {:formatted_column => text}) if inplace_edit?(record, column)
54
57
  text
55
58
  end
56
59
  end
@@ -128,26 +131,17 @@ module ActiveScaffold
128
131
  check_box(:record, column.name, options)
129
132
  end
130
133
 
131
- def column_override_name(column, class_prefix = false)
132
- "#{clean_class_name(column.active_record_class.name) + '_' if class_prefix}#{clean_column_name(column.name)}_column"
133
- end
134
-
135
134
  def column_override(column)
136
- method_with_class = column_override_name(column, true)
137
- return method_with_class if respond_to?(method_with_class)
138
- method = column_override_name(column)
139
- method if respond_to?(method)
135
+ override_helper column, 'column'
140
136
  end
141
137
  alias_method :column_override?, :column_override
142
138
 
143
- def override_column_ui?(list_ui)
144
- respond_to?(override_column_ui(list_ui))
145
- end
146
-
147
139
  # the naming convention for overriding column types with helpers
148
140
  def override_column_ui(list_ui)
149
- "active_scaffold_column_#{list_ui}"
141
+ method = "active_scaffold_column_#{list_ui}"
142
+ method if respond_to? method
150
143
  end
144
+ alias_method :override_column_ui?, :override_column_ui
151
145
 
152
146
  ##
153
147
  ## Formatting
@@ -262,6 +256,7 @@ module ActiveScaffold
262
256
  tag_options = {:id => element_cell_id(id_options), :class => "in_place_editor_field",
263
257
  :title => as_(:click_to_edit), 'data-ie_id' => record.id.to_s}
264
258
 
259
+ content_tag(:span, as_(:click_to_edit), :class => 'handle') <<
265
260
  content_tag(:span, formatted_column, tag_options)
266
261
  end
267
262
 
@@ -8,20 +8,20 @@ module ActiveScaffold
8
8
  options = active_scaffold_search_options(column)
9
9
 
10
10
  # first, check if the dev has created an override for this specific field for search
11
- if override_search_field?(column)
12
- send(override_search_field(column), @record, options)
11
+ if (method = override_search_field(column))
12
+ send(method, @record, options)
13
13
 
14
14
  # second, check if the dev has specified a valid search_ui for this column, using specific ui for searches
15
- elsif column.search_ui and override_search?(column.search_ui)
16
- send(override_search(column.search_ui), column, options)
15
+ elsif column.search_ui and (method = override_search(column.search_ui))
16
+ send(method, column, options)
17
17
 
18
18
  # third, check if the dev has specified a valid search_ui for this column, using generic ui for forms
19
- elsif column.search_ui and override_input?(column.search_ui)
20
- send(override_input(column.search_ui), column, options)
19
+ elsif column.search_ui and (method = override_input(column.search_ui))
20
+ send(method, column, options)
21
21
 
22
22
  # fourth, check if the dev has created an override for this specific field
23
- elsif override_form_field?(column)
24
- send(override_form_field(column), @record, options)
23
+ elsif (method = override_form_field(column))
24
+ send(method, @record, options)
25
25
 
26
26
  # fallback: we get to make the decision
27
27
  else
@@ -30,11 +30,11 @@ module ActiveScaffold
30
30
 
31
31
  else # regular model attribute column
32
32
  # if we (or someone else) have created a custom render option for the column type, use that
33
- if override_search?(column.column.type)
34
- send(override_search(column.column.type), column, options)
33
+ if (method = override_search(column.column.type))
34
+ send(method, column, options)
35
35
  # if we (or someone else) have created a custom render option for the column type, use that
36
- elsif override_input?(column.column.type)
37
- send(override_input(column.column.type), column, options)
36
+ elsif (method = override_input(column.column.type))
37
+ send(method, column, options)
38
38
  # final ultimate fallback: use rails' generic input method
39
39
  else
40
40
  # for textual fields we pass different options
@@ -216,25 +216,13 @@ module ActiveScaffold
216
216
  ##
217
217
 
218
218
  def override_search_field(column)
219
- method_with_class = override_search_field_name(column, true)
220
- return method_with_class if respond_to?(method_with_class)
221
- method = override_search_field_name(column)
222
- method if respond_to?(method)
223
- end
224
- alias_method :override_search_field?, :override_search_field
225
-
226
- # the naming convention for overriding form fields with helpers
227
- def override_search_field_name(column, class_prefix = false)
228
- "#{clean_class_name(column.active_record_class.name) + '_' if class_prefix}#{clean_column_name(column.name)}_search_column"
229
- end
230
-
231
- def override_search?(search_ui)
232
- respond_to?(override_search(search_ui))
219
+ override_helper column, 'search_column'
233
220
  end
234
221
 
235
222
  # the naming convention for overriding search input types with helpers
236
223
  def override_search(form_ui)
237
- "active_scaffold_search_#{form_ui}"
224
+ method = "active_scaffold_search_#{form_ui}"
225
+ method if respond_to? method
238
226
  end
239
227
 
240
228
  def visibles_and_hiddens(search_config)
@@ -4,17 +4,17 @@ module ActiveScaffold
4
4
  module ShowColumnHelpers
5
5
  def show_column_value(record, column)
6
6
  # check for an override helper
7
- if show_column_override? column
7
+ if (method = show_column_override(column))
8
8
  # we only pass the record as the argument. we previously also passed the formatted_value,
9
9
  # but mike perham pointed out that prohibited the usage of overrides to improve on the
10
10
  # performance of our default formatting. see issue #138.
11
- send(show_column_override(column), record)
11
+ send(method, record)
12
12
  # second, check if the dev has specified a valid list_ui for this column
13
- elsif column.list_ui and override_show_column_ui?(column.list_ui)
14
- send(override_show_column_ui(column.list_ui), column, record)
13
+ elsif column.list_ui and (method = override_show_column_ui(column.list_ui))
14
+ send(method, column, record)
15
15
  else
16
- if column.column and override_show_column_ui?(column.column.type)
17
- send(override_show_column_ui(column.column.type), column, record)
16
+ if column.column and (method = override_show_column_ui(column.column.type))
17
+ send(method, column, record)
18
18
  else
19
19
  get_column_value(record, column)
20
20
  end
@@ -25,25 +25,14 @@ module ActiveScaffold
25
25
  simple_format(clean_column_value(record.send(column.name)))
26
26
  end
27
27
 
28
- def show_column_override_name(column, class_prefix = false)
29
- "#{clean_class_name(column.active_record_class.name) + '_' if class_prefix}#{clean_column_name(column.name)}_show_column"
30
- end
31
-
32
28
  def show_column_override(column)
33
- method_with_class = show_column_override_name(column, true)
34
- return method_with_class if respond_to?(method_with_class)
35
- method = show_column_override_name(column)
36
- method if respond_to?(method)
37
- end
38
- alias_method :show_column_override?, :show_column_override
39
-
40
- def override_show_column_ui?(list_ui)
41
- respond_to?(override_show_column_ui(list_ui))
29
+ override_helper column, 'show_column'
42
30
  end
43
31
 
44
32
  # the naming convention for overriding show types with helpers
45
33
  def override_show_column_ui(list_ui)
46
- "active_scaffold_show_#{list_ui}"
34
+ method = "active_scaffold_show_#{list_ui}"
35
+ method if respond_to? method
47
36
  end
48
37
  end
49
38
  end
@@ -217,7 +217,13 @@ module ActiveScaffold
217
217
  class_override_helper = :"#{clean_class_name(record.class.name)}_list_row_class"
218
218
  respond_to?(class_override_helper) ? send(class_override_helper, record) : ''
219
219
  end
220
-
220
+
221
+ def column_attributes(column, record)
222
+ method = override_helper column, 'column_attributes'
223
+ return send(method, record) if method
224
+ {}
225
+ end
226
+
221
227
  def column_class(column, column_value, record)
222
228
  classes = []
223
229
  classes << "#{column.name}-column"
@@ -231,6 +237,7 @@ module ActiveScaffold
231
237
  classes << 'empty' if column_empty? column_value
232
238
  classes << 'sorted' if active_scaffold_config.list.user.sorting.sorts_on?(column)
233
239
  classes << 'numeric' if column.column and [:decimal, :float, :integer].include?(column.column.type)
240
+ classes << 'in_place_editor_field' if inplace_edit?(record, column)
234
241
  classes.join(' ').rstrip
235
242
  end
236
243
 
@@ -293,6 +300,18 @@ module ActiveScaffold
293
300
  name.underscore.gsub('/', '_')
294
301
  end
295
302
 
303
+ # the naming convention for overriding with helpers
304
+ def override_helper_name(column, suffix, class_prefix = false)
305
+ "#{clean_class_name(column.active_record_class.name) + '_' if class_prefix}#{clean_column_name(column.name)}_#{suffix}"
306
+ end
307
+
308
+ def override_helper(column, suffix)
309
+ method_with_class = override_helper_name(column, suffix, true)
310
+ return method_with_class if respond_to?(method_with_class)
311
+ method = override_helper_name(column, suffix)
312
+ method if respond_to?(method)
313
+ end
314
+
296
315
  def active_scaffold_error_messages_for(*params)
297
316
  options = params.extract_options!.symbolize_keys
298
317
  options.reverse_merge!(:container_tag => :div, :list_type => :ul)
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 2
5
- PATCH = 7
5
+ PATCH = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 2
9
- - 7
10
- version: 3.2.7
9
+ - 8
10
+ version: 3.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Many, see README
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-08 00:00:00 Z
18
+ date: 2012-05-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :development
@@ -152,6 +152,7 @@ files:
152
152
  - frontends/default/views/_list_record_columns.html.erb
153
153
  - frontends/default/views/_list_with_header.html.erb
154
154
  - frontends/default/views/_messages.html.erb
155
+ - frontends/default/views/_refresh_list.js.erb
155
156
  - frontends/default/views/_render_field.js.erb
156
157
  - frontends/default/views/_row.html.erb
157
158
  - frontends/default/views/_search.html.erb
@@ -159,7 +160,9 @@ files:
159
160
  - frontends/default/views/_show.html.erb
160
161
  - frontends/default/views/_show_columns.html.erb
161
162
  - frontends/default/views/_update_actions.html.erb
163
+ - frontends/default/views/_update_calculations.js.erb
162
164
  - frontends/default/views/_update_form.html.erb
165
+ - frontends/default/views/_update_messages.js.erb
163
166
  - frontends/default/views/_vertical_subform.html.erb
164
167
  - frontends/default/views/_vertical_subform_record.html.erb
165
168
  - frontends/default/views/action_confirmation.html.erb
@@ -178,6 +181,7 @@ files:
178
181
  - frontends/default/views/on_update.js.erb
179
182
  - frontends/default/views/refresh_list.js.erb
180
183
  - frontends/default/views/render_field.js.erb
184
+ - frontends/default/views/row.js.erb
181
185
  - frontends/default/views/search.html.erb
182
186
  - frontends/default/views/show.html.erb
183
187
  - frontends/default/views/update.html.erb