active_scaffold 3.0.5 → 3.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/.document +5 -0
  2. data/Gemfile +11 -2
  3. data/Gemfile.lock +20 -0
  4. data/Rakefile +33 -4
  5. data/active_scaffold.gemspec +378 -17
  6. data/frontends/default/images/config.png +0 -0
  7. data/frontends/default/images/gears.png +0 -0
  8. data/frontends/default/javascripts/jquery/active_scaffold.js +34 -33
  9. data/frontends/default/javascripts/jquery/jquery.editinplace.js +21 -4
  10. data/frontends/default/javascripts/prototype/active_scaffold.js +43 -38
  11. data/frontends/default/stylesheets/stylesheet.css +110 -35
  12. data/frontends/default/views/_action_group.html.erb +20 -0
  13. data/frontends/default/views/_base_form.html.erb +7 -3
  14. data/frontends/default/views/_create_form.html.erb +5 -3
  15. data/frontends/default/views/_create_form_on_list.html.erb +2 -1
  16. data/frontends/default/views/_field_search.html.erb +2 -2
  17. data/frontends/default/views/_form.html.erb +2 -2
  18. data/frontends/default/views/_form_messages.html.erb +1 -1
  19. data/frontends/default/views/_horizontal_subform.html.erb +1 -1
  20. data/frontends/default/views/_list_actions.html.erb +6 -14
  21. data/frontends/default/views/_list_header.html.erb +4 -6
  22. data/frontends/default/views/_list_with_header.html.erb +2 -2
  23. data/frontends/default/views/_messages.html.erb +2 -2
  24. data/frontends/default/views/_search.html.erb +2 -2
  25. data/frontends/default/views/_show.html.erb +1 -1
  26. data/frontends/default/views/_update_form.html.erb +2 -1
  27. data/frontends/default/views/_vertical_subform.html.erb +1 -1
  28. data/frontends/default/views/action_confirmation.html.erb +13 -0
  29. data/frontends/default/views/add_existing.js.rjs +1 -1
  30. data/frontends/default/views/destroy.js.rjs +21 -3
  31. data/frontends/default/views/on_action_update.js.rjs +1 -1
  32. data/frontends/default/views/on_create.js.rjs +30 -13
  33. data/frontends/default/views/on_update.js.rjs +19 -6
  34. data/init.rb +6 -0
  35. data/lib/active_scaffold/actions/core.rb +32 -12
  36. data/lib/active_scaffold/actions/create.rb +4 -11
  37. data/lib/active_scaffold/actions/delete.rb +16 -13
  38. data/lib/active_scaffold/actions/list.rb +58 -2
  39. data/lib/active_scaffold/actions/mark.rb +1 -1
  40. data/lib/active_scaffold/actions/nested.rb +24 -15
  41. data/lib/active_scaffold/actions/show.rb +10 -3
  42. data/lib/active_scaffold/actions/update.rb +10 -3
  43. data/lib/{active_record_permissions.rb → active_scaffold/active_record_permissions.rb} +0 -0
  44. data/lib/active_scaffold/bridges/ancestry/lib/ancestry_bridge.rb +9 -8
  45. data/lib/active_scaffold/bridges/bridge.rb +1 -1
  46. data/lib/active_scaffold/bridges/calendar_date_select/lib/as_cds_bridge.rb +8 -4
  47. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +1 -1
  48. data/lib/active_scaffold/bridges/paperclip/bridge.rb +1 -1
  49. data/lib/active_scaffold/bridges/paperclip/lib/list_ui.rb +1 -1
  50. data/lib/active_scaffold/config/base.rb +8 -0
  51. data/lib/active_scaffold/config/core.rb +2 -15
  52. data/lib/active_scaffold/config/create.rb +8 -0
  53. data/lib/active_scaffold/config/delete.rb +10 -1
  54. data/lib/active_scaffold/config/field_search.rb +1 -0
  55. data/lib/active_scaffold/config/form.rb +2 -1
  56. data/lib/active_scaffold/config/nested.rb +3 -2
  57. data/lib/active_scaffold/config/search.rb +1 -0
  58. data/lib/active_scaffold/config/show.rb +1 -0
  59. data/lib/active_scaffold/config/update.rb +8 -0
  60. data/lib/active_scaffold/constraints.rb +9 -4
  61. data/lib/active_scaffold/data_structures/action_columns.rb +1 -1
  62. data/lib/active_scaffold/data_structures/action_link.rb +10 -1
  63. data/lib/active_scaffold/data_structures/action_links.rb +62 -22
  64. data/lib/active_scaffold/data_structures/column.rb +17 -13
  65. data/lib/active_scaffold/data_structures/nested_info.rb +21 -6
  66. data/lib/active_scaffold/finder.rb +2 -1
  67. data/lib/active_scaffold/helpers/association_helpers.rb +2 -2
  68. data/lib/active_scaffold/helpers/controller_helpers.rb +57 -10
  69. data/lib/active_scaffold/helpers/form_column_helpers.rb +12 -8
  70. data/lib/active_scaffold/helpers/id_helpers.rb +5 -9
  71. data/lib/active_scaffold/helpers/list_column_helpers.rb +26 -28
  72. data/lib/active_scaffold/helpers/search_column_helpers.rb +8 -3
  73. data/lib/active_scaffold/helpers/view_helpers.rb +60 -19
  74. data/lib/active_scaffold/locale/de.rb +13 -6
  75. data/lib/active_scaffold/locale/en.rb +2 -1
  76. data/lib/active_scaffold/locale/es.yml +3 -0
  77. data/lib/active_scaffold/locale/fr.rb +5 -2
  78. data/lib/active_scaffold/locale/ru.yml +77 -20
  79. data/lib/active_scaffold/marked_model.rb +5 -5
  80. data/lib/{paginator.rb → active_scaffold/paginator.rb} +0 -0
  81. data/lib/{responds_to_parent.rb → active_scaffold/responds_to_parent.rb} +0 -0
  82. data/lib/active_scaffold/version.rb +9 -0
  83. data/lib/active_scaffold.rb +60 -84
  84. data/lib/active_scaffold_assets.rb +45 -0
  85. data/lib/active_scaffold_env.rb +14 -0
  86. data/lib/active_scaffold_vho.rb +2 -0
  87. data/lib/extensions/active_association_reflection.rb +13 -0
  88. data/lib/extensions/paginator_extensions.rb +1 -1
  89. data/lib/extensions/routing_mapper.rb +1 -1
  90. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +12 -4
  91. metadata +85 -68
  92. data/lib/dhtml_confirm.rb +0 -54
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Helpers
3
3
  module ControllerHelpers
4
4
  def self.included(controller)
5
- controller.class_eval { helper_method :params_for, :main_path_to_return }
5
+ controller.class_eval { helper_method :params_for, :main_path_to_return, :render_parent?, :render_parent_options, :render_parent_action, :nested_singular_association?}
6
6
  end
7
7
 
8
8
  include ActiveScaffold::Helpers::IdHelpers
@@ -26,16 +26,63 @@ module ActiveScaffold
26
26
  # ActiveScaffold is used as a component on another controllers
27
27
  # page)
28
28
  def main_path_to_return
29
- parameters = {}
30
- if params[:parent_controller]
31
- parameters[:controller] = params[:parent_controller]
32
- parameters[:eid] = params[:parent_controller]
29
+ if params[:return_to]
30
+ params[:return_to]
31
+ else
32
+ parameters = {}
33
+ if params[:parent_controller]
34
+ parameters[:controller] = params[:parent_controller]
35
+ parameters[:eid] = params[:parent_controller]
36
+ end
37
+ if nested?
38
+ parameters[:controller] = nested.parent_scaffold.controller_path
39
+ parameters[:eid] = nil
40
+ end
41
+ if params[:parent_sti]
42
+ parameters[:controller] = params[:parent_sti]
43
+ parameters[:eid] = nil
44
+ end
45
+ parameters[:parent_column] = nil
46
+ parameters[:parent_id] = nil
47
+ parameters[:action] = "index"
48
+ parameters[:id] = nil
49
+ parameters[:associated_id] = nil
50
+ parameters[:utf8] = nil
51
+ params_for(parameters)
33
52
  end
34
- parameters[:parent_column] = nil
35
- parameters[:parent_id] = nil
36
- parameters[:action] = "index"
37
- parameters[:id] = nil
38
- params_for(parameters)
53
+ end
54
+
55
+ def nested_singular_association?
56
+ nested? && (nested.belongs_to? || nested.has_one?)
57
+ end
58
+
59
+ def render_parent?
60
+ nested_singular_association? || params[:parent_sti]
61
+ end
62
+
63
+ def render_parent_options
64
+ if nested_singular_association?
65
+ {:controller => nested.parent_scaffold.controller_path, :action => :row, :id => nested.parent_id}
66
+ elsif params[:parent_sti]
67
+ options = {:controller => params[:parent_sti], :action => render_parent_action(params[:parent_sti])}
68
+ if render_parent_action(params[:parent_sti]) == :index
69
+ options.merge(params.slice(:eid))
70
+ else
71
+ options.merge({:id => @record.id})
72
+ end
73
+ end
74
+ end
75
+
76
+ def render_parent_action(controller_path = nil)
77
+ begin
78
+ @parent_action = :row
79
+ parent_controller = "#{controller_path.to_s.camelize}Controller".constantize
80
+ @parent_action = :index if action_name == 'create' && parent_controller.active_scaffold_config.actions.include?(:create) && parent_controller.active_scaffold_config.create.refresh_list == true
81
+ @parent_action = :index if action_name == 'update' && parent_controller.active_scaffold_config.actions.include?(:update) && parent_controller.active_scaffold_config.update.refresh_list == true
82
+ @parent_action = :index if action_name == 'destroy' && parent_controller.active_scaffold_config.actions.include?(:delete) && parent_controller.active_scaffold_config.delete.refresh_list == true
83
+ rescue ActiveScaffold::ControllerNotFound
84
+ end if @parent_action.nil?
85
+ @parent_action
39
86
  end
40
87
  end
41
88
  end
@@ -139,19 +139,23 @@ module ActiveScaffold
139
139
  [(text.is_a?(Symbol) ? column.active_record_class.human_attribute_name(text) : text), value]
140
140
  end
141
141
 
142
+ def active_scaffold_input_enum(column, html_options)
143
+ options = { :selected => @record.send(column.name) }
144
+ options_for_select = column.options[:options].collect do |text, value|
145
+ active_scaffold_translated_option(column, text, value)
146
+ end
147
+ html_options.update(column.options[:html_options] || {})
148
+ options.update(column.options)
149
+ select(:record, column.name, options_for_select, options, html_options)
150
+ end
151
+
142
152
  def active_scaffold_input_select(column, html_options)
143
153
  if column.singular_association?
144
154
  active_scaffold_input_singular_association(column, html_options)
145
155
  elsif column.plural_association?
146
156
  active_scaffold_input_plural_association(column, html_options)
147
157
  else
148
- options = { :selected => @record.send(column.name) }
149
- options_for_select = column.options[:options].collect do |text, value|
150
- active_scaffold_translated_option(column, text, value)
151
- end
152
- html_options.update(column.options[:html_options] || {})
153
- options.update(column.options)
154
- select(:record, column.name, options_for_select, options, html_options)
158
+ active_scaffold_input_enum(column, html_options)
155
159
  end
156
160
  end
157
161
 
@@ -160,7 +164,7 @@ module ActiveScaffold
160
164
  column.options[:options].inject('') do |html, (text, value)|
161
165
  text, value = active_scaffold_translated_option(column, text, value)
162
166
  html << content_tag(:label, radio_button(:record, column.name, value, html_options.merge(:id => html_options[:id] + '-' + value.to_s)) + text)
163
- end
167
+ end.html_safe
164
168
  end
165
169
 
166
170
  # requires RecordSelect plugin to be installed and configured.
@@ -6,8 +6,8 @@ module ActiveScaffold
6
6
  controller.to_s.gsub("/", "__")
7
7
  end
8
8
 
9
- def controller_id
10
- controller_id ||= 'as_' + id_from_controller(params[:eid] || params[:parent_controller] || params[:controller])
9
+ def controller_id(controller = (params[:eid] || params[:parent_controller] || params[:controller]))
10
+ controller_id ||= 'as_' + id_from_controller(controller)
11
11
  end
12
12
 
13
13
  def active_scaffold_id
@@ -22,8 +22,8 @@ module ActiveScaffold
22
22
  "#{controller_id}-tbody"
23
23
  end
24
24
 
25
- def active_scaffold_messages_id
26
- "#{controller_id}-messages"
25
+ def active_scaffold_messages_id(options = {})
26
+ "#{options[:controller_id] || controller_id}-messages"
27
27
  end
28
28
 
29
29
  def active_scaffold_calculations_id(column = nil)
@@ -38,10 +38,6 @@ module ActiveScaffold
38
38
  "#{controller_id}-search-container"
39
39
  end
40
40
 
41
- def search_form_id
42
- "#{controller_id}-search-form"
43
- end
44
-
45
41
  def search_input_id
46
42
  "#{controller_id}-search-input"
47
43
  end
@@ -63,7 +59,7 @@ module ActiveScaffold
63
59
  options[:action] ||= params[:action]
64
60
  options[:id] ||= params[:id]
65
61
  options[:id] ||= params[:parent_id]
66
- clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-row"
62
+ clean_id "#{options[:controller_id] || controller_id}-#{options[:action]}-#{options[:id]}-row"
67
63
  end
68
64
 
69
65
  def element_cell_id(options = {})
@@ -43,23 +43,11 @@ module ActiveScaffold
43
43
  url_options[:link] = as_(:create_new) if link.crud_type == :create
44
44
  end
45
45
 
46
- # check authorization
47
- if column.association
48
- associated_for_authorized = if associated.nil? || (associated.respond_to?(:empty?) && associated.empty?)
49
- column.association.klass
50
- elsif column.plural_association?
51
- associated.first
52
- else
53
- associated
54
- end
55
- authorized = associated_for_authorized.authorized_for?(:crud_type => link.crud_type)
56
- authorized = authorized and record.authorized_for?(:crud_type => :update, :column => column.name) if link.crud_type == :create
46
+ if column_link_authorized?(link, column, record, associated)
47
+ render_action_link(link, url_options, record)
57
48
  else
58
- authorized = record.authorized_for?(:crud_type => link.crud_type)
49
+ "<a class='disabled'>#{text}</a>".html_safe
59
50
  end
60
- # to make html render properly
61
- return "<a class='disabled'>#{text}</a>".html_safe unless authorized
62
- render_action_link(link, url_options, record)
63
51
  else
64
52
  text = active_scaffold_inplace_edit(record, column, {:formatted_column => text}) if inplace_edit?(record, column)
65
53
  text
@@ -70,36 +58,46 @@ module ActiveScaffold
70
58
  def action_link_to_inline_form(column, record, associated)
71
59
  link = column.link.clone
72
60
  if column.polymorphic_association?
73
- polymorphic_controller = polymorphic_controller_for_nested_link(column, record)
61
+ polymorphic_controller = controller_path_for_activerecord(record.send(column.association.name).class)
74
62
  return link if polymorphic_controller.nil?
75
63
  link.controller = polymorphic_controller
76
64
  end
65
+ configure_column_link(link, associated, column.actions_for_association_links)
66
+ end
77
67
 
68
+ def configure_column_link(link, associated, actions)
78
69
  if column_empty?(associated) # if association is empty, we only can link to create form
79
- if column.actions_for_association_links.include?(:new)
70
+ if actions.include?(:new)
80
71
  link.action = 'new'
81
72
  link.crud_type = :create
82
73
  end
83
- elsif column.actions_for_association_links.include?(:edit)
74
+ elsif actions.include?(:edit)
84
75
  link.action = 'edit'
85
76
  link.crud_type = :update
86
- elsif column.actions_for_association_links.include?(:show)
77
+ elsif actions.include?(:show)
87
78
  link.action = 'show'
88
79
  link.crud_type = :read
89
- elsif column.actions_for_association_links.include?(:list)
90
- link.parameters[:id] = record.send(column.association.name).id
80
+ elsif actions.include?(:list)
91
81
  link.action = 'index'
92
82
  link.crud_type = :read
93
83
  end
94
84
  link
95
85
  end
96
86
 
97
- def polymorphic_controller_for_nested_link(column, record)
98
- begin
99
- controller = active_scaffold_controller_for(record.send(column.association.name).class)
100
- controller.controller_path
101
- rescue ActiveScaffold::ControllerNotFound
102
- controller = nil
87
+ def column_link_authorized?(link, column, record, associated)
88
+ if column.association
89
+ associated_for_authorized = if associated.nil? || (associated.respond_to?(:empty?) && associated.empty?)
90
+ column.association.klass
91
+ elsif [:has_many, :has_and_belongs_to_many].include? column.association.macro
92
+ associated.first
93
+ else
94
+ associated
95
+ end
96
+ authorized = associated_for_authorized.authorized_for?(:crud_type => link.crud_type)
97
+ authorized = authorized and record.authorized_for?(:crud_type => :update, :column => column.name) if link.crud_type == :create
98
+ authorized
99
+ else
100
+ record.authorized_for?(:crud_type => link.crud_type)
103
101
  end
104
102
  end
105
103
 
@@ -347,7 +345,7 @@ module ActiveScaffold
347
345
 
348
346
  def render_nested_view(action_links, url_options, record)
349
347
  rendered = []
350
- action_links.each do |link|
348
+ action_links.member.each do |link|
351
349
  if link.nested_link? && link.column && @nested_auto_open[link.column.name] && @records.length <= @nested_auto_open[link.column.name] && respond_to?(:render_component)
352
350
  link_url_options = {:adapter => '_list_inline_adapter', :format => :js}.merge(action_link_url_options(link, url_options, record, options = {:reuse_eid => true}))
353
351
  link_id = get_action_link_id(link_url_options, record, link.column)
@@ -123,8 +123,13 @@ module ActiveScaffold
123
123
 
124
124
  def active_scaffold_search_range(column, options)
125
125
  opt_value, from_value, to_value = field_search_params_range_values(column)
126
+
127
+ text_field_size = 10
126
128
  select_options = ActiveScaffold::Finder::NumericComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
127
- select_options.unshift *ActiveScaffold::Finder::StringComparators.collect {|title, comp| [as_(title), comp]} if column.column && column.column.text?
129
+ if column.column && column.column.text?
130
+ select_options.unshift *ActiveScaffold::Finder::StringComparators.collect {|title, comp| [as_(title), comp]}
131
+ text_field_size = 15
132
+ end
128
133
  from_value = controller.class.condition_value_for_numeric(column, from_value)
129
134
  to_value = controller.class.condition_value_for_numeric(column, to_value)
130
135
  from_value = format_number_value(from_value, column.options) if from_value.is_a?(Numeric)
@@ -133,9 +138,9 @@ module ActiveScaffold
133
138
  options_for_select(select_options, opt_value),
134
139
  :id => "#{options[:id]}_opt",
135
140
  :class => "as_search_range_option")
136
- html << ' ' << text_field_tag("#{options[:name]}[from]", from_value, active_scaffold_input_text_options(:id => options[:id], :size => 10))
141
+ html << ' ' << text_field_tag("#{options[:name]}[from]", from_value, active_scaffold_input_text_options(:id => options[:id], :size => text_field_size))
137
142
  html << ' ' << content_tag(:span, (' - ' + text_field_tag("#{options[:name]}[to]", to_value,
138
- active_scaffold_input_text_options(:id => "#{options[:id]}_to", :size => 10))).html_safe,
143
+ active_scaffold_input_text_options(:id => "#{options[:id]}_to", :size => text_field_size))).html_safe,
139
144
  :id => "#{options[:id]}_between", :class => "as_search_range_between", :style => "display:#{(opt_value == 'BETWEEN') ? '' : 'none'}")
140
145
  html
141
146
  end
@@ -34,6 +34,15 @@ module ActiveScaffold
34
34
  ## Uncategorized
35
35
  ##
36
36
 
37
+ def controller_path_for_activerecord(klass)
38
+ begin
39
+ controller = active_scaffold_controller_for(klass)
40
+ controller.controller_path
41
+ rescue ActiveScaffold::ControllerNotFound
42
+ controller = nil
43
+ end
44
+ end
45
+
37
46
  def generate_temporary_id
38
47
  (Time.now.to_f*1000).to_i.to_s
39
48
  end
@@ -128,6 +137,14 @@ module ActiveScaffold
128
137
  action_link_html(link, url_options, html_options)
129
138
  end
130
139
 
140
+ def render_group_action_link(link, url_options, options, record = nil)
141
+ if link.type == :member && !options[:authorized]
142
+ action_link_html(link, nil, {:class => "disabled #{link.action}#{link.html_options[:class].blank? ? '' : (' ' + link.html_options[:class])}"})
143
+ else
144
+ render_action_link(link, url_options, record)
145
+ end
146
+ end
147
+
131
148
  def action_link_url_options(link, url_options, record, options = {})
132
149
  url_options = url_options.clone
133
150
  url_options[:action] = link.action
@@ -135,7 +152,8 @@ module ActiveScaffold
135
152
  url_options.delete(:search) if link.controller and link.controller.to_s != params[:controller]
136
153
  url_options.merge! link.parameters if link.parameters
137
154
  url_options_for_nested_link(link.column, record, link, url_options, options) if link.nested_link?
138
- url_options[:_method] = link.method if link.inline? && link.method != :get
155
+ url_options_for_sti_link(link.column, record, link, url_options, options) unless record.nil? || active_scaffold_config.sti_children.nil?
156
+ url_options[:_method] = link.method if !link.confirm? && link.inline? && link.method != :get
139
157
  url_options
140
158
  end
141
159
 
@@ -144,14 +162,17 @@ module ActiveScaffold
144
162
  html_options.reverse_merge! link.html_options.merge(:class => link.action)
145
163
 
146
164
  # Needs to be in html_options to as the adding _method to the url is no longer supported by Rails
147
- html_options[:method] = link.method if !link.inline? && link.method != :get
165
+ html_options[:method] = link.method if link.method != :get
148
166
 
149
167
  html_options['data-confirm'] = link.confirm(record.try(:to_label)) if link.confirm?
150
168
  html_options['data-position'] = link.position if link.position and link.inline?
151
169
  html_options[:class] += ' as_action' if link.inline?
152
- html_options[:popup] = true if link.popup?
170
+ if link.popup?
171
+ html_options['data-popup'] = true
172
+ html_options[:target] = '_blank'
173
+ end
153
174
  html_options[:id] = link_id
154
- html_options[:remote] = true unless link.page?
175
+ html_options[:remote] = true unless link.page? || link.popup?
155
176
  if link.dhtml_confirm?
156
177
  html_options[:class] += ' as_action' if !link.inline?
157
178
  html_options[:page_link] = 'true' if !link.inline?
@@ -161,6 +182,7 @@ module ActiveScaffold
161
182
  html_options[:class] += " #{link.html_options[:class]}" unless link.html_options[:class].blank?
162
183
  html_options
163
184
  end
185
+
164
186
  def get_action_link_id(url_options, record = nil, column = nil)
165
187
  id = url_options[:id] || url_options[:parent_id]
166
188
  id = "#{column.association.name}-#{record.id}" if column && column.plural_association?
@@ -199,6 +221,16 @@ module ActiveScaffold
199
221
  end
200
222
  end
201
223
 
224
+ def url_options_for_sti_link(column, record, link, url_options, options = {})
225
+ #need to find out controller of current record type
226
+ #and set parameters
227
+ sti_controller_path = controller_path_for_activerecord(record.class)
228
+ if sti_controller_path
229
+ url_options[:controller] = sti_controller_path
230
+ url_options[:parent_sti] = controller_path
231
+ end
232
+ end
233
+
202
234
  def column_class(column, column_value, record)
203
235
  classes = []
204
236
  classes << "#{column.name}-column"
@@ -219,7 +251,7 @@ module ActiveScaffold
219
251
  classes = []
220
252
  classes << "#{column.name}-column_heading"
221
253
  classes << "sorted #{sorting.direction_of(column).downcase}" if sorting.sorts_on? column
222
- classes << column.css_class unless column.css_class.nil?
254
+ classes << column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc)
223
255
  classes.join(' ')
224
256
  end
225
257
 
@@ -231,11 +263,15 @@ module ActiveScaffold
231
263
  end
232
264
 
233
265
  def column_calculation(column)
234
- conditions = controller.send(:all_conditions)
235
- includes = active_scaffold_config.list.count_includes
236
- includes ||= controller.send(:active_scaffold_includes) unless conditions.nil?
237
- calculation = beginning_of_chain.calculate(column.calculate, column.name, :conditions => conditions,
238
- :joins => controller.send(:joins_for_collection), :include => includes)
266
+ unless column.calculate.instance_of? Proc
267
+ conditions = controller.send(:all_conditions)
268
+ includes = active_scaffold_config.list.count_includes
269
+ includes ||= controller.send(:active_scaffold_includes) unless conditions.nil?
270
+ calculation = beginning_of_chain.calculate(column.calculate, column.name, :conditions => conditions,
271
+ :joins => controller.send(:joins_for_collection), :include => includes)
272
+ else
273
+ column.calculate.call(@records)
274
+ end
239
275
  end
240
276
 
241
277
  def render_column_calculation(column)
@@ -243,7 +279,7 @@ module ActiveScaffold
243
279
  override_formatter = "render_#{column.name}_#{column.calculate}"
244
280
  calculation = send(override_formatter, calculation) if respond_to? override_formatter
245
281
 
246
- "#{as_(column.calculate)}: #{format_column_value nil, column, calculation}"
282
+ "#{"#{as_(column.calculate)}: " unless column.calculate.is_a? Proc}#{format_column_value nil, column, calculation}"
247
283
  end
248
284
 
249
285
  def column_show_add_existing(column)
@@ -256,8 +292,9 @@ module ActiveScaffold
256
292
  value
257
293
  end
258
294
 
259
- def error_messages_for(*params)
295
+ def active_scaffold_error_messages_for(*params)
260
296
  options = params.extract_options!.symbolize_keys
297
+ options.reverse_merge!(:container_tag => :div, :list_type => :ul)
261
298
 
262
299
  objects = Array.wrap(options.delete(:object) || params).map do |object|
263
300
  object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
@@ -295,17 +332,21 @@ module ActiveScaffold
295
332
 
296
333
  error_messages = objects.sum do |object|
297
334
  object.errors.full_messages.map do |msg|
298
- content_tag(:li, msg)
335
+ options[:list_type] != :br ? content_tag(:li, msg) : msg
299
336
  end
300
- end.join.html_safe
337
+ end
338
+ error_messages = if options[:list_type] == :br
339
+ error_messages.join('<br/>').html_safe
340
+ else
341
+ content_tag(options[:list_type], error_messages.join.html_safe)
342
+ end
301
343
 
302
- contents = ''
344
+ contents = []
303
345
  contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank?
304
346
  contents << content_tag(:p, message) unless message.blank?
305
- contents << content_tag(:ul, error_messages)
306
-
307
- content_tag(:div, contents.html_safe, html)
308
-
347
+ contents << error_messages
348
+ contents = contents.join.html_safe
349
+ options[:container_tag] ? content_tag(options[:container_tag], contents, html) : contents
309
350
  else
310
351
  ''
311
352
  end
@@ -7,13 +7,14 @@
7
7
  :are_you_sure_to_delete => 'Sind Sie sicher?',
8
8
  :cancel => 'Abbrechen',
9
9
  :click_to_edit => 'Zum Editieren anklicken',
10
+ :click_to_reset => 'Reset',
10
11
  :close => 'Schliessen',
11
12
  :config_list => 'Konfigurieren',
12
13
  :config_list_model => 'Konfiguriere Spalten für %{model}',
13
14
  :create => 'Anlegen',
14
15
  :create_model => 'Lege %{model} an',
15
16
  :create_another => 'Weitere anlegen',
16
- :created_model => '%{model} anlegen',
17
+ :created_model => '%{model} angelegt',
17
18
  :create_new => 'Neu anlegen',
18
19
  :customize => 'Anpassen',
19
20
  :delete => 'Löschen',
@@ -60,6 +61,9 @@
60
61
  :'<' => '<',
61
62
  :'!=' => '!=',
62
63
  :between => 'Zwischen',
64
+ :contains => 'Enthält',
65
+ :begins_with => 'Beginnt',
66
+ :ends_with => 'Ended',
63
67
  :today => 'Heute',
64
68
  :yesterday => 'Gestern',
65
69
  :tomorrow => 'Morgen',
@@ -74,7 +78,7 @@
74
78
  :next_year => 'Nächstes Jahr',
75
79
  :past => 'Letzten',
76
80
  :future => 'Nächsten',
77
- :range => 'Spanne',
81
+ :range => 'Zeitraum',
78
82
  :seconds => 'Sekunden',
79
83
  :minutes => 'Minuten',
80
84
  :hours => 'Stunden',
@@ -83,8 +87,8 @@
83
87
  :months => 'Monate',
84
88
  :years => 'Jahre',
85
89
  :optional_attributes => 'Weitere',
86
- :null => 'Undefiniert',
87
- :not_null => 'Definiert',
90
+ :null => 'Null',
91
+ :not_null => 'Nicht Null',
88
92
  :date_picker_options => {
89
93
  :weekHeader => 'Wo',
90
94
  :firstDay => 1,
@@ -92,7 +96,9 @@
92
96
  :showMonthAfterYear => false
93
97
  },
94
98
  :datetime_picker_options => {
95
- :timeText => 'Uhrzeit'
99
+ :timeText => 'Uhrzeit',
100
+ :currentText => 'Jetzt',
101
+ :closeText => 'Schließen'
96
102
  },
97
103
  :errors => {
98
104
  :template => {
@@ -107,7 +113,8 @@
107
113
  :cant_destroy_record => "%{record} kann nicht gelöscht werden",
108
114
  :internal_error => 'Fehler bei der Verarbeitung (code 500, Interner Fehler)',
109
115
  :version_inconsistency => 'Inkonsistente Versionen - dieser Eintrag wurde verändert nachdem Sie mit der Bearbeitung begonnen haben.',
110
- :record_not_saved => 'Eintrag kann nicht gespeichert werden. Ursache unbekannt.'
116
+ :record_not_saved => 'Eintrag kann nicht gespeichert werden. Ursache unbekannt.',
117
+ :no_authorization_for_action => "Keine Berechtigung für Aktion %{action}"
111
118
  }
112
119
  }
113
120
  }
@@ -112,7 +112,8 @@
112
112
  :cant_destroy_record => "%{record} can't be destroyed",
113
113
  :internal_error => 'Request Failed (code 500, Internal Error)',
114
114
  :version_inconsistency => 'Version inconsistency - this record has been modified since you started editing it.',
115
- :record_not_saved => 'Failed to save record cause of an unknown error'
115
+ :record_not_saved => 'Failed to save record cause of an unknown error',
116
+ :no_authorization_for_action => "No Authorization for action %{action}"
116
117
  }
117
118
  }
118
119
  }
@@ -99,6 +99,8 @@ es:
99
99
  showMonthAfterYear: false
100
100
  datetime_picker_options:
101
101
  timeText: 'Hora'
102
+ currentText: 'Ahora'
103
+ closeText: 'Cerrar'
102
104
  errors:
103
105
  template:
104
106
  header:
@@ -110,3 +112,4 @@ es:
110
112
  cant_destroy_record: "No se pudo borrar %{record}"
111
113
  internal_error: 'Petición fallida (código 500, error interno)'
112
114
  version_inconsistency: 'Inconsistencia de versiones - este registro se ha modificado después de que empezó a editarlo.'
115
+ no_authorization_for_action: "No Authorization for action %{action}"
@@ -92,7 +92,9 @@
92
92
  :showMonthAfterYear => false,
93
93
  },
94
94
  :datetime_picker_options => {
95
- :timeText => 'Heure'
95
+ :timeText => 'Heure',
96
+ :currentText => 'Maintenant',
97
+ :closeText => 'Fermer'
96
98
  },
97
99
  :errors => {
98
100
  :template => {
@@ -107,7 +109,8 @@
107
109
  :cant_destroy_record => "%{record} can't be destroyed",
108
110
  :internal_error => 'Erreur de la requête (code 500, Erreur interne)',
109
111
  :version_inconsistency => "Version incomplète - Cet enregistrement a été modifié depuis que vous avez commencé à l'éditer.",
110
- :record_not_saved => 'Failed to save record cause of an unknown error'
112
+ :record_not_saved => 'Failed to save record cause of an unknown error',
113
+ :no_authorization_for_action => "No Authorization for action %{action}"
111
114
  }
112
115
  }
113
116
  }