active_scaffold 3.1.11 → 3.1.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -148,7 +148,7 @@ $(document).ready(function() {
148
148
  return true;
149
149
  } else return false;
150
150
  });
151
- $('input.update_form, textarea.update_form, select.update_form').live('change', function(event) {
151
+ $('input.update_form:not(.recordselect), textarea.update_form, select.update_form').live('change', function(event) {
152
152
  var element = $(this);
153
153
  var value = element.is("input:checkbox:not(:checked)") ? null : element.val();
154
154
  ActiveScaffold.update_column(element, element.attr('data-update_url'), element.attr('data-update_send_form'), element.attr('id'), value);
@@ -72,7 +72,8 @@ $(document).ready(function() {
72
72
 
73
73
  if (action_link) {
74
74
  var cancel_url = as_cancel.attr('href');
75
- if (typeof(cancel_url) == 'undefined' || cancel_url.length == 0) {
75
+ var refresh_data = as_cancel.attr('data-refresh');
76
+ if (refresh_data !== 'true' || !cancel_url) {
76
77
  action_link.close();
77
78
  return false;
78
79
  }
@@ -147,12 +148,17 @@ $(document).ready(function() {
147
148
  return true;
148
149
  } else return false;
149
150
  });
150
- $('input.update_form, text_area.update_form, select.update_form').live('change', function(event) {
151
+ $('input.update_form, textarea.update_form, select.update_form').live('change', function(event) {
151
152
  var element = $(this);
152
153
  var value = element.is("input:checkbox:not(:checked)") ? null : element.val();
153
154
  ActiveScaffold.update_column(element, element.attr('data-update_url'), element.attr('data-update_send_form'), element.attr('id'), value);
154
155
  return true;
155
156
  });
157
+ $('input.recordselect.update_form').live('recordselect:change', function(event, id, label) {
158
+ var element = $(this);
159
+ ActiveScaffold.update_column(element, element.attr('data-update_url'), element.attr('data-update_send_form'), element.attr('id'), id);
160
+ return true;
161
+ });
156
162
 
157
163
  $('select.as_search_range_option').live('change', function(event) {
158
164
  ActiveScaffold[$(this).val() == 'BETWEEN' ? 'show' : 'hide']($(this).parent().find('.as_search_range_between'));
@@ -1,20 +1,18 @@
1
- <% new_row = render :partial => 'list_record', :locals => {:record => @record}%>
2
- ActiveScaffold.create_record_row('#{active_scaffold_id}','#{escape_javascript(new_row)}', #{{:insert_at => :top}.to_json.html_safe});
3
- <%%>
1
+ <% new_row = render :partial => 'list_record', :locals => {:record => @record} %>
2
+ ActiveScaffold.create_record_row('<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {:insert_at => :top}.to_json.html_safe %>);
3
+
4
4
  <% if active_scaffold_config.list.columns.any? {|c| c.calculation?} %>
5
- ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
5
+ ActiveScaffold.replace('<%= active_scaffold_calculations_id %>', '<%= escape_javascript(render(:partial => 'list_calculations')) %>');
6
6
  <%end%>
7
- <%%>
8
- <% if(form_stays_open == true)%>
7
+
8
+ <% if form_stays_open ||= true %>
9
9
  <%# why not just re-render the form? that wouldn't utilize a possible do_new override which sets default values.%>
10
- ActiveScaffold.reset_form('<%element_form_id%>');
11
- ActiveScaffold.replace_html('<%element_messages_id(:action => :add_existing)%>', '<%=escape_javascript(render(:partial => 'form_messages'))%>');
10
+ ActiveScaffold.reset_form('<%= element_form_id %>');
11
+ ActiveScaffold.replace_html('<%= element_messages_id(:action => :add_existing) %>', '<%= escape_javascript(render(:partial => 'form_messages')) %>');
12
12
  <%# have to delay the focus, because there's no "firstElement" in prototype until at least one element is not disabled%>
13
- <%if ActiveScaffold.js_framework == :prototype%>
14
- page.delay 0.1 do
15
- page << "ActiveScaffold.focus_first_element_of_form('#{element_form_id}');"
16
- end
17
- <%end%>
18
- <%else%>
19
- ActiveScaffold.find_action_link('<%element_form_id(:action => :new_existing)%>').close();
20
- <%end%>
13
+ <% if ActiveScaffold.js_framework == :prototype %>
14
+ ActiveScaffold.focus_first_element_of_form.defer('<%= element_form_id %>');
15
+ <% end %>
16
+ <% else %>
17
+ ActiveScaffold.find_action_link('<%= element_form_id(:action => :new_existing) %>').close();
18
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <% new_row = render :partial => 'list_record', :locals => {:record => @record} %>
2
+ ActiveScaffold.create_record_row('<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {:insert_at => :top}.to_json.html_safe %>);
3
+
4
+ <% if active_scaffold_config.list.columns.any? {|c| c.calculation?} %>
5
+ ActiveScaffold.replace('<%= active_scaffold_calculations_id %>', '<%= escape_javascript(render(:partial => 'list_calculations')) %>');
6
+ <%end%>
7
+
8
+ <% if form_stays_open ||= true %>
9
+ <%# why not just re-render the form? that wouldn't utilize a possible do_new override which sets default values.%>
10
+ ActiveScaffold.reset_form('<%= element_form_id %>');
11
+ ActiveScaffold.replace_html('<%= element_messages_id(:action => :add_existing) %>', '<%= escape_javascript(render(:partial => 'form_messages')) %>');
12
+ <%# have to delay the focus, because there's no "firstElement" in prototype until at least one element is not disabled%>
13
+ <% if ActiveScaffold.js_framework == :prototype %>
14
+ ActiveScaffold.focus_first_element_of_form.defer('<%= element_form_id %>');
15
+ <% end %>
16
+ <% else %>
17
+ ActiveScaffold.find_action_link('<%element_form_id(:action => :new_existing)%>').close();
18
+ <% end %>
@@ -103,6 +103,8 @@ module ActiveScaffold::Actions
103
103
  create_save
104
104
  end
105
105
  rescue ActiveRecord::RecordInvalid
106
+ flash[:error] = $!.message
107
+ self.successful = false
106
108
  end
107
109
  end
108
110
 
@@ -2,9 +2,6 @@ module ActiveScaffold::Actions
2
2
  module Create
3
3
  def self.included(base)
4
4
  base.before_filter :create_authorized_filter, :only => [:new, :create]
5
- base.verify :method => :post,
6
- :only => :create,
7
- :redirect_to => { :action => :index }
8
5
  end
9
6
 
10
7
  def new
@@ -106,6 +103,8 @@ module ActiveScaffold::Actions
106
103
  create_save
107
104
  end
108
105
  rescue ActiveRecord::RecordInvalid
106
+ self.successful = false
107
+ flash[:error] = $!.messages
109
108
  end
110
109
  end
111
110
 
@@ -92,9 +92,11 @@ module ActiveScaffold::Actions
92
92
  end
93
93
  end
94
94
  rescue ActiveRecord::RecordInvalid
95
+ flash[:error] = $!.message
96
+ self.successful = false
95
97
  rescue ActiveRecord::StaleObjectError
96
98
  @record.errors.add(:base, as_(:version_inconsistency))
97
- self.successful=false
99
+ self.successful = false
98
100
  rescue ActiveRecord::RecordNotSaved
99
101
  @record.errors.add(:base, as_(:record_not_saved)) if @record.errors.empty?
100
102
  self.successful = false
@@ -18,7 +18,7 @@ module ActiveScaffold::Actions
18
18
  # for inline (inlist) editing
19
19
  def update_column
20
20
  do_update_column
21
- render :action => 'update_column', :locals => {:column_span_id => params[:editor_id] || params[:editorId]}
21
+ @column_span_id = params[:editor_id] || params[:editorId]
22
22
  end
23
23
 
24
24
  protected
@@ -92,9 +92,11 @@ module ActiveScaffold::Actions
92
92
  end
93
93
  end
94
94
  rescue ActiveRecord::RecordInvalid
95
+ self.successful = false
96
+ flash[:error] = $!.message
95
97
  rescue ActiveRecord::StaleObjectError
96
98
  @record.errors.add(:base, as_(:version_inconsistency))
97
- self.successful=false
99
+ self.successful = false
98
100
  rescue ActiveRecord::RecordNotSaved
99
101
  @record.errors.add(:base, as_(:record_not_saved)) if @record.errors.empty?
100
102
  self.successful = false
@@ -28,6 +28,10 @@ module ActiveScaffold::DataStructures
28
28
  @parent_scaffold = session_info[:parent_scaffold]
29
29
  end
30
30
 
31
+ def to_params
32
+ {:parent_scaffold => parent_scaffold.controller_path}
33
+ end
34
+
31
35
  def new_instance?
32
36
  result = @new_instance.nil?
33
37
  @new_instance = false
@@ -94,6 +98,10 @@ module ActiveScaffold::DataStructures
94
98
  association.options[:order]
95
99
  end
96
100
 
101
+ def to_params
102
+ super.merge(:association => @association.name, :assoc_id => parent_id)
103
+ end
104
+
97
105
  protected
98
106
 
99
107
  def iterate_model_associations(model)
@@ -119,5 +127,9 @@ module ActiveScaffold::DataStructures
119
127
  @scope = session_info[:name]
120
128
  @constrained_fields = []
121
129
  end
130
+
131
+ def to_params
132
+ super.merge(:named_scope => @scope)
133
+ end
122
134
  end
123
135
  end
@@ -6,7 +6,6 @@ module ActiveScaffold::DataStructures
6
6
  else
7
7
  session_info = session_storage[:nested].clone
8
8
  begin
9
- debugger
10
9
  session_info[:parent_scaffold] = "#{session_info[:parent_scaffold].to_s.camelize}Controller".constantize
11
10
  session_info[:parent_model] = session_info[:parent_scaffold].active_scaffold_config.model
12
11
  session_info[:association] = session_info[:parent_model].reflect_on_association(session_info[:name])
@@ -29,6 +28,10 @@ module ActiveScaffold::DataStructures
29
28
  @parent_scaffold = session_info[:parent_scaffold]
30
29
  end
31
30
 
31
+ def to_params
32
+ {:parent_scaffold => parent_scaffold.controller_path}
33
+ end
34
+
32
35
  def new_instance?
33
36
  result = @new_instance.nil?
34
37
  @new_instance = false
@@ -95,6 +98,10 @@ module ActiveScaffold::DataStructures
95
98
  association.options[:order]
96
99
  end
97
100
 
101
+ def to_params
102
+ super.merge(:association => @association, :assoc_id => parent_id)
103
+ end
104
+
98
105
  protected
99
106
 
100
107
  def iterate_model_associations(model)
@@ -120,5 +127,9 @@ module ActiveScaffold::DataStructures
120
127
  @scope = session_info[:name]
121
128
  @constrained_fields = []
122
129
  end
130
+
131
+ def to_params
132
+ super.merge(:named_scope => @scope)
133
+ end
123
134
  end
124
135
  end
@@ -32,10 +32,7 @@ module ActiveScaffold
32
32
  parameters[:controller] = params[:parent_controller]
33
33
  parameters[:eid] = params[:parent_controller]
34
34
  end
35
- if nested?
36
- parameters[:controller] = nested.parent_scaffold.controller_path
37
- parameters[:eid] = nil
38
- end
35
+ parameters.merge! nested.to_params if nested?
39
36
  if params[:parent_sti]
40
37
  parameters[:controller] = params[:parent_sti]
41
38
  parameters[:eid] = nil
@@ -33,8 +33,7 @@ module ActiveScaffold
33
33
  parameters[:eid] = params[:parent_controller]
34
34
  end
35
35
  if nested?
36
- parameters[:controller] = nested.parent_scaffold.controller_path
37
- parameters[:eid] = nil
36
+ parameters.merge! nested.to_params
38
37
  end
39
38
  if params[:parent_sti]
40
39
  parameters[:controller] = params[:parent_sti]
@@ -84,17 +83,11 @@ module ActiveScaffold
84
83
  end
85
84
 
86
85
  def build_associated(column, record)
87
- child = column.singular_association? ? record.send(:"build_#{column.name}") : record.send(column.name).build
88
- if record.new_record? && (reflection = record.class.reflect_on_association(column.name)).try(:reverse)
89
- reverse_macro = child.class.reflect_on_association(reflection.reverse).macro
90
- if [:has_one, :belongs_to].include?(reverse_macro) # singular
91
- child.send(:"#{reflection.reverse}=", record)
92
- # TODO: Might want to extend with this branch in the future
93
- # else # plural
94
- # child.send(:"#{reflection.reverse}") << record
95
- end
86
+ if column.singular_association?
87
+ record.send(:"build_#{column.name}")
88
+ else
89
+ record.send(column.name).build
96
90
  end
97
- child
98
91
  end
99
92
  end
100
93
  end
@@ -78,7 +78,9 @@ module ActiveScaffold
78
78
  select_options = options_for_association(column.association, true)
79
79
  else
80
80
  method = column.name
81
- select_options = Array(column.options[:options])
81
+ select_options = column.options[:options].collect do |text, value|
82
+ active_scaffold_translated_option(column, text, value)
83
+ end
82
84
  end
83
85
 
84
86
  options = { :selected => associated }.merge! column.options
@@ -88,7 +88,7 @@ module ActiveScaffold
88
88
  else
89
89
  options[:include_blank] ||= as_(:_select_)
90
90
  end
91
- select(:record, method, options_for_select, options, html_options)
91
+ select(:record, method, select_options, options, html_options)
92
92
  end
93
93
 
94
94
  def active_scaffold_search_text(column, options)
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- PATCH = 11
5
+ PATCH = 12
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: 21
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 11
10
- version: 3.1.11
9
+ - 12
10
+ version: 3.1.12
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: 2011-12-12 00:00:00 Z
18
+ date: 2011-12-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -144,9 +144,9 @@ files:
144
144
  - frontends/default/views/_list_pagination_links.html.erb
145
145
  - frontends/default/views/_list_record.html.erb
146
146
  - frontends/default/views/_action_group.html.erb
147
- - frontends/default/views/_list_messages.html.erb
148
- - frontends/default/views/_row.html.erb
149
147
  - frontends/default/views/_messages.html.erb
148
+ - frontends/default/views/_base_form.html.erb
149
+ - frontends/default/views/_render_field.js.erb
150
150
  - frontends/default/views/_search.html.erb
151
151
  - frontends/default/views/_show.html.erb
152
152
  - frontends/default/views/list.html.erb
@@ -155,24 +155,24 @@ files:
155
155
  - frontends/default/views/_update_form.html.erb
156
156
  - frontends/default/views/_vertical_subform.html.erb
157
157
  - frontends/default/views/_vertical_subform_record.html.erb
158
- - frontends/default/views/_base_form.html.erb
158
+ - frontends/default/views/_row.html.erb
159
159
  - frontends/default/views/delete.html.erb
160
160
  - frontends/default/views/add_existing_form.html.erb
161
161
  - frontends/default/views/create.html.erb
162
+ - frontends/default/views/_horizontal_subform_footer.html.erb
162
163
  - frontends/default/views/_human_conditions.html.erb
163
- - frontends/default/views/_list_with_header.html.erb
164
164
  - frontends/default/views/field_search.html.erb
165
- - frontends/default/views/_render_field.js.erb
166
- - frontends/default/views/search.html.erb
167
165
  - frontends/default/views/add_existing.js.erb
166
+ - frontends/default/views/search.html.erb
167
+ - frontends/default/views/destroy.js.erb
168
168
  - frontends/default/views/update.html.erb
169
+ - frontends/default/views/_list_messages.html.erb
169
170
  - frontends/default/views/_list_pagination.html.erb
170
- - frontends/default/views/_list_record_columns.html.erb
171
171
  - frontends/default/views/show.html.erb
172
- - frontends/default/views/destroy.js.erb
172
+ - frontends/default/views/_list_record_columns.html.erb
173
+ - frontends/default/views/_list_with_header.html.erb
173
174
  - frontends/default/views/_search_attribute.html.erb
174
175
  - frontends/default/views/action_confirmation.html.erb
175
- - frontends/default/views/_horizontal_subform_footer.html.erb
176
176
  - frontends/default/views/edit_associated.js.erb
177
177
  - frontends/default/views/form_messages.js.erb
178
178
  - frontends/default/views/on_action_update.js.erb
@@ -181,8 +181,8 @@ files:
181
181
  - frontends/default/views/on_update.js.erb
182
182
  - frontends/default/views/refresh_list.js.erb
183
183
  - frontends/default/views/render_field.js.erb
184
- - frontends/default/views/update_column.js.erb
185
184
  - frontends/default/views/_base_form.html.erb~
185
+ - frontends/default/views/update_column.js.erb
186
186
  - frontends/default/views/update_row.js.erb
187
187
  - frontends/default/views/_form.html.erb~
188
188
  - frontends/default/views/_row.html.erb~
@@ -207,6 +207,7 @@ files:
207
207
  - frontends/default/views/_horizontal_subform_record.html.erb~
208
208
  - frontends/default/views/_list_with_header.html.erb~
209
209
  - frontends/default/views/_update_form.html.erb~
210
+ - frontends/default/views/add_existing.js.erb~
210
211
  - lib/active_scaffold.rb
211
212
  - lib/active_scaffold_env.rb
212
213
  - lib/active_scaffold/actions/core.rb
@@ -218,9 +219,9 @@ files:
218
219
  - lib/active_scaffold/actions/show.rb
219
220
  - lib/active_scaffold/actions/nested.rb
220
221
  - lib/active_scaffold/actions/search.rb
221
- - lib/active_scaffold/actions/mark.rb
222
222
  - lib/active_scaffold/actions/subform.rb
223
223
  - lib/active_scaffold/actions/update.rb
224
+ - lib/active_scaffold/actions/mark.rb
224
225
  - lib/active_scaffold/actions/core.rb~
225
226
  - lib/active_scaffold/actions/nested.rb~
226
227
  - lib/active_scaffold/actions/update.rb~
@@ -256,8 +257,8 @@ files:
256
257
  - lib/active_scaffold/data_structures/error_message.rb
257
258
  - lib/active_scaffold/data_structures/set.rb
258
259
  - lib/active_scaffold/data_structures/sorting.rb
259
- - lib/active_scaffold/data_structures/nested_info.rb
260
260
  - lib/active_scaffold/data_structures/bridge.rb
261
+ - lib/active_scaffold/data_structures/nested_info.rb
261
262
  - lib/active_scaffold/data_structures/action_columns.rb~
262
263
  - lib/active_scaffold/data_structures/action_link.rb~
263
264
  - lib/active_scaffold/data_structures/nested_info.rb~
@@ -323,13 +324,14 @@ files:
323
324
  - lib/active_scaffold/bridges/shared/date_bridge.rb~
324
325
  - lib/active_scaffold/bridges/tiny_mce.rb
325
326
  - lib/active_scaffold/bridges/tiny_mce/helpers.rb
326
- - lib/active_scaffold/version.rb
327
+ - lib/active_scaffold/engine.rb
327
328
  - lib/active_scaffold/marked_model.rb
328
329
  - lib/active_scaffold/extensions/action_controller_rendering.rb
329
330
  - lib/active_scaffold/extensions/action_view_rendering.rb
330
331
  - lib/active_scaffold/extensions/active_association_reflection.rb
331
332
  - lib/active_scaffold/extensions/active_record_offset.rb
332
333
  - lib/active_scaffold/extensions/array.rb
334
+ - lib/active_scaffold/extensions/cache_association.rb
333
335
  - lib/active_scaffold/extensions/localize.rb
334
336
  - lib/active_scaffold/extensions/name_option_for_datetime.rb
335
337
  - lib/active_scaffold/extensions/nil_id_in_url_params.rb
@@ -340,7 +342,6 @@ files:
340
342
  - lib/active_scaffold/extensions/unsaved_associated.rb
341
343
  - lib/active_scaffold/extensions/unsaved_record.rb
342
344
  - lib/active_scaffold/extensions/usa_state.rb
343
- - lib/active_scaffold/extensions/cache_association.rb
344
345
  - lib/active_scaffold/extensions/action_controller_rendering.rb~
345
346
  - lib/active_scaffold/extensions/action_view_rendering.rb~
346
347
  - lib/active_scaffold/extensions/cache_association.rb~
@@ -349,7 +350,7 @@ files:
349
350
  - lib/active_scaffold/extensions/unsaved_associated.rb~
350
351
  - lib/active_scaffold/paginator.rb
351
352
  - lib/active_scaffold/responds_to_parent.rb
352
- - lib/active_scaffold/engine.rb
353
+ - lib/active_scaffold/version.rb
353
354
  - lib/active_scaffold/attribute_params.rb~
354
355
  - lib/active_scaffold/finder.rb~
355
356
  - lib/active_scaffold/constraints.rb~