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
@@ -1,13 +1,16 @@
1
- <% scope ||= nil %>
1
+ <%
2
+ scope ||= nil
3
+ column_options = active_scaffold_input_options(column, scope)
4
+ %>
2
5
  <dl>
3
6
  <dt>
4
- <label for="<%= active_scaffold_input_options(column, scope)[:id] %>"><%= column.label %></label>
7
+ <label for="<%= column_options[:id] %>"><%= column.label %></label>
5
8
  </dt>
6
9
  <dd>
7
10
  <% unless local_assigns[:only_value] %>
8
11
  <%=raw active_scaffold_input_for column, scope %>
9
12
  <% else %>
10
- <%= get_column_value(@record, column) %>
13
+ <%= content_tag :span, get_column_value(@record, column), options.except(:name) %>
11
14
  <%= hidden_field :record, column.association ? column.association.foreign_key : column.name, active_scaffold_input_options(column, scope) -%>
12
15
  <% end %>
13
16
  <% if column.update_columns -%>
@@ -1,5 +1,5 @@
1
- <%= render :partial => 'messages' %>
1
+ <%= render :partial => 'messages' unless request.xhr? %>
2
2
 
3
3
  <% unless @record.nil? %>
4
- <%= active_scaffold_error_messages_for :record, :object_name => @record.class.model_name.human.downcase %>
5
- <% end %>
4
+ <%= active_scaffold_error_messages_for :record, :object_name => @record.class.model_name.human.downcase %>
5
+ <% end %>
@@ -24,7 +24,7 @@
24
24
  <% unless readonly and not @record.new_record? or not @record.authorized_for?(:crud_type => crud_type, :column => column.name) -%>
25
25
  <%= render :partial => form_partial_for_column(column), :locals => { :column => column, :scope => scope } -%>
26
26
  <% else -%>
27
- <p><%= get_column_value(@record, column) -%></p>
27
+ <p class="<%= column.name %>-input"><%= get_column_value(@record, column) -%></p>
28
28
  <% end -%>
29
29
  </td>
30
30
  <% end -%>
@@ -2,7 +2,7 @@
2
2
  columns ||= list_columns -%>
3
3
  <tr id="<%= active_scaffold_calculations_id %>" class="active-scaffold-calculations">
4
4
  <% columns.each do |column| -%>
5
- <td <%= "id=#{active_scaffold_calculations_id(column)}" if column.calculation? %>>
5
+ <td <%= "id=#{active_scaffold_calculations_id(:column => column)}" if column.calculation? %>>
6
6
  <% if column.calculation? -%>
7
7
  <%= render_column_calculation(column) %>
8
8
  <% else -%>
@@ -1,29 +1,26 @@
1
1
  <tbody class="messages">
2
2
  <tr class="record even-record">
3
- <td colspan="<%= columns.length -%>" class="messages-container">
3
+ <td colspan="<%= columns.length + 1 -%>" class="messages-container">
4
4
  <p class="error-message message server-error" style="display:none;">
5
5
  <%= as_(:internal_error).html_safe %>
6
- <a href="#" onclick="ActiveScaffold.hide(this.parentNode); return false;" title="<%= as_(:close).html_safe %>"><%= as_(:close).html_safe %></a>
6
+ <a href="#" class="close" title="<%= as_(:close).html_safe %>"><%= as_(:close).html_safe %></a>
7
7
  </p>
8
8
  <div id="<%= active_scaffold_messages_id -%>">
9
9
  <%= render :partial => 'messages' %>
10
10
  </div>
11
- <p class="filtered-message" <%= ' style="display:none;" '.html_safe unless @filtered %>>
11
+ <div class="filtered-message" <%= ' style="display:none;" '.html_safe unless @filtered %>>
12
12
  <%= @filtered.is_a?(Array) ? render(:partial => 'human_conditions', :locals => {:columns => @filtered}) : as_(active_scaffold_config.list.filtered_message) %>
13
- </p>
13
+ <% if active_scaffold_config.list.show_search_reset && @filtered -%>
14
+ <div class="reset">
15
+ <%= loading_indicator_tag(:action => :record, :id => nil) %>
16
+ <%= render_action_link(active_scaffold_config.list.reset_link, params_for(:search => '')) %>
17
+ </div>
18
+ <% end -%>
19
+ </div>
14
20
  <p id="<%= empty_message_id %>" class="empty-message" <%= ' style="display:none;" '.html_safe unless @page.items.empty? %>>
15
21
  <%= as_(active_scaffold_config.list.no_entries_message) %>
16
22
  </p>
17
23
  </td>
18
- <% if active_scaffold_config.list.show_search_reset && @filtered -%>
19
- <% search_link = ActiveScaffold::DataStructures::ActionLink.new('index', :label => :click_to_reset, :type => :member, :position => false)
20
- action_links = ActiveScaffold::DataStructures::ActionLinks.new
21
- action_links.add(search_link) -%>
22
- <%= render :partial => 'list_actions', :locals => {:record => new_model, :url_options => params_for(:search => ''), :action_links => action_links.member} %>
23
- <% else %>
24
- <td class='actions'><%= '<p class="empty-message">&nbsp;</p>'.html_safe if @page.items.empty? %></td>
25
- <% end -%>
26
-
27
24
  </tr>
28
25
  </tbody>
29
26
 
@@ -2,7 +2,7 @@
2
2
  <% authorized = record.authorized_for?(:crud_type => :read, :column => column.name) -%>
3
3
  <% column_value = authorized ? get_column_value(record, column) : active_scaffold_config.list.empty_field_text -%>
4
4
 
5
- <td class="<%= column_class(column, column_value, record) %>" >
5
+ <%= content_tag :td, column_attributes(column, record).merge(:class => column_class(column, column_value, record)) do %>
6
6
  <%= authorized ? render_list_column(column_value, column, record) : column_value %>
7
- </td>
7
+ <% end %>
8
8
  <% end -%>
@@ -3,7 +3,7 @@
3
3
  <div class="<%= "#{name}-message message" %>">
4
4
  <%= h flash[name] %>
5
5
  <% if request.xhr? %>
6
- <a href="#" onclick="ActiveScaffold.remove(this.parentNode); return false;" title="<%= as_(:close) %>"><%= as_(:close) %></a>
6
+ <a href="#" class="close" title="<%= as_(:close) %>"><%= as_(:close) %></a>
7
7
  <% end %>
8
8
  </div>
9
9
  <% end %>
@@ -0,0 +1 @@
1
+ ActiveScaffold.replace_html('<%= active_scaffold_content_id %>', '<%= escape_javascript(render(:partial => 'list', :layout => false)) %>');
@@ -1,6 +1,6 @@
1
1
  <%= render :partial => 'list_record', :locals => {:record => record}%>
2
2
  <%= javascript_tag do %>
3
- ActiveScaffold.replace('<%= active_scaffold_calculations_id %>', '<%= escape_javascript render(:partial => 'list_calculations') %>');
4
- <% end if active_scaffold_config.list.columns.any? {|c| c.calculation?} %>
3
+ <%= render :partial => 'update_calculations', :formats => [:js] %>
4
+ <% end %>
5
5
 
6
6
 
@@ -17,13 +17,13 @@ options['data-loading'] = true unless live_search
17
17
  //<![CDATA[
18
18
  <% if ActiveScaffold.js_framework == :prototype %>
19
19
  new TextFieldWithExample('<%= search_input_id %>', '<%= as_(live_search ? :live_search : :search_terms) %>', {focus: true});
20
- <% end -%>
21
- <% if live_search && ActiveScaffold.js_framework == :prototype -%>
20
+ <% if live_search -%>
22
21
  $(<%= search_input_id.to_json.html_safe %>).next().hide();
23
22
  new Form.Element.DelayedObserver('<%= search_input_id %>', 0.5, function(element, value) {
24
23
  if (!$(element.id)) return false; // because the element may have been destroyed
25
24
  $(element).next().click();
26
25
  });
26
+ <% end -%>
27
27
  <% elsif live_search && ActiveScaffold.js_framework == :jquery %>
28
28
  jQuery(<%= "##{search_input_id}".to_json.html_safe %>).next().hide();
29
29
  jQuery(<%= "##{search_input_id}".to_json.html_safe %>).delayedObserver(0.5, function() {
@@ -0,0 +1,4 @@
1
+ <% calculations_id ||= active_scaffold_calculations_id -%>
2
+ <% if active_scaffold_config.list.columns.any? {|c| c.calculation?} %>
3
+ ActiveScaffold.replace('<%= calculations_id %>', '<%= escape_javascript(render(:partial => 'list_calculations')) %>');
4
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <% messages_id ||= active_scaffold_messages_id -%>
2
+ ActiveScaffold.replace_html('<%= messages_id %>', '<%= escape_javascript(render(:partial => 'messages')) %>');
@@ -24,7 +24,7 @@
24
24
  <% unless readonly and not @record.new_record? or not @record.authorized_for?(:crud_type => crud_type, :column => column.name) -%>
25
25
  <%= render :partial => form_partial_for_column(column), :locals => { :column => column, :scope => scope } -%>
26
26
  <% else -%>
27
- <p><%= get_column_value(@record, column) -%></p>
27
+ <p class="<%= column.name %>-input"><%= get_column_value(@record, column) -%></p>
28
28
  <% end -%>
29
29
  </li>
30
30
  <% end -%>
@@ -1,18 +1,14 @@
1
1
  <% new_row = render :partial => 'list_record', :locals => {:record => @record} %>
2
2
  ActiveScaffold.create_record_row('<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {:insert_at => :top}.to_json.html_safe %>);
3
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%>
4
+ <%= render :partial => 'update_calculations' %>
7
5
 
8
6
  <% if form_stays_open ||= true %>
9
7
  <%# why not just re-render the form? that wouldn't utilize a possible do_new override which sets default values.%>
10
8
  ActiveScaffold.reset_form('<%= element_form_id %>');
11
9
  ActiveScaffold.replace_html('<%= element_messages_id(:action => :add_existing) %>', '<%= escape_javascript(render(:partial => 'form_messages')) %>');
12
10
  <%# 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 %>
11
+ ActiveScaffold.focus_first_element_of_form<%= '.defer' if ActiveScaffold.js_framework == :prototype %>('<%= element_form_id %>');
16
12
  <% else %>
17
13
  ActiveScaffold.find_action_link('<%= element_form_id(:action => :new_existing) %>').close();
18
14
  <% end %>
@@ -1,24 +1,26 @@
1
- <%messages_id = active_scaffold_messages_id%>
2
- <%if controller.send(:successful?)%>
3
- <%if render_parent? && controller.respond_to?(:render_component_into_view)%>
4
- <%render_parent_options%>
5
- <%if render_parent_action == :row%>
6
- <%# TODO: That s not working with delete....%>
7
- ActiveScaffold.delete_record_row('<%=element_row_id(:controller_id => "as_#{id_from_controller(params[:eid] || params[:parent_sti])}", :action => 'list', :id => params[:id])%>', '<%=url_for(params_for(:action => :index, :id => nil, :page => [active_scaffold_config.list.user.page.to_i - 1, 1].max))%>');
8
- <%messages_id = active_scaffold_messages_id(:controller_id => "as_#{id_from_controller(params[:eid] || params[:parent_sti])}")%>
9
- <%elsif render_parent_action == :index%>
10
- <%= escape_javascript(controller.send(:render_component_into_view, render_parent_options))%>
11
- <%end%>
12
- <%#page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
13
- <%elsif (active_scaffold_config.delete.refresh_list)%>
14
- ActiveScaffold.replace('<%=active_scaffold_content_id%>', '<%=escape_javascript(render(:partial => 'list', :layout => false))%>');
15
- <%else%>
16
- ActiveScaffold.delete_record_row('<%=element_row_id(:action => 'list', :id => params[:id])%>', '<%=url_for(params_for(:action => :index, :id => nil, :page => [active_scaffold_config.list.user.page.to_i - 1, 1].max))%>');
17
- <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
18
- ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
1
+ <% messages_id = active_scaffold_messages_id %>
2
+ <% if controller.send(:successful?) %>
3
+ <% if render_parent? %>
4
+ <% if render_parent_action == :row %>
5
+ <%# TODO: That s not working with delete.... %>
6
+ <% current_id = controller_id(params[:eid] || params[:parent_sti]) -%>
7
+ ActiveScaffold.delete_record_row('<%= element_row_id(:controller_id => current_id, :action => 'list', :id => params[:id]) %>', '<%= url_for(params_for(:action => :index, :id => nil, :page => [active_scaffold_config.list.user.page.to_i - 1, 1].max)) %>');
8
+ <% messages_id = active_scaffold_messages_id(:controller_id => current_id) %>
9
+ <%= render :partial => 'update_calculations', :locals => {:calculations_id => active_scaffold_calculations_id(:controller_id => current_id)} %>
10
+ <% elsif render_parent_action == :index %>
11
+ <% if controller.respond_to?(:render_component_into_view) %>
12
+ <%= escape_javascript(controller.send(:render_component_into_view, render_parent_options)) %>
13
+ <% else %>
14
+ ActiveScaffold.reload('<%= url_for render_parent_options %>');
15
+ <% end %>
19
16
  <% end %>
20
- <%end%>
21
- <%else%>
22
- <%flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br)%>
23
- <%end%>
24
- ActiveScaffold.replace_html('<%=messages_id%>', '<%=escape_javascript(render(:partial => 'messages'))%>');
17
+ <% elsif (active_scaffold_config.delete.refresh_list) %>
18
+ <%= render :partial => 'refresh_list' %>
19
+ <% else %>
20
+ ActiveScaffold.delete_record_row('<%= element_row_id(:action => 'list', :id => params[:id]) %>', '<%= url_for(params_for(:action => :index, :id => nil, :page => [active_scaffold_config.list.user.page.to_i - 1, 1].max)) %>');
21
+ <%= render :partial => 'update_calculations' %>
22
+ <% end %>
23
+ <% else %>
24
+ <% flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br) %>
25
+ <% end %>
26
+ <%= render :partial => 'update_messages', :locals => {:messages_id => messages_id} %>
@@ -1,13 +1,22 @@
1
- <%if controller.send :successful?%>
2
- ActiveScaffold.replace_html('<%=active_scaffold_messages_id%>','<%=escape_javascript(render(:partial => 'messages'))%>');
3
- <%if @record%>
4
- ActiveScaffold.update_row('<%=element_row_id(:action => :list, :id => @record.id)%>','<%=escape_javascript(render(:partial => 'list_record', :locals => {:record => @record}))%>');
5
- <%end%>
6
- <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
7
- ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
1
+ <% if controller.send :successful? %>
2
+ <% if @record %>
3
+ <%= render :partial => 'update_messages' %>
4
+ <% row = escape_javascript(render(:partial => 'list_record', :locals => {:record => @record})) -%>
5
+ <% if @action_link.nil? || @action_link.position %>
6
+ ActiveScaffold.find_action_link('<%= element_row_id(:action => :list, :id => @record.id) %>').close('<%= row %>');
7
+ <% else %>
8
+ ActiveScaffold.update_row('<%= element_row_id(:action => :list, :id => @record.id) %>', '<%= row %>');
9
+ ActiveScaffold.scroll_to('<%= element_row_id(:action => :list, :id => @record.id) %>', true);
8
10
  <% end %>
9
- <%else%>
10
- <%flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br)%>
11
- ActiveScaffold.replace_html('<%=active_scaffold_messages_id%>','<%=escape_javascript(render(:partial => 'messages'))%>');
12
- ActiveScaffold.scroll_to('<%=active_scaffold_messages_id%>');
13
- <%end%>
11
+ <%= render :partial => 'update_calculations' %>
12
+ <% else %>
13
+ <% if @action_link.nil? || @action_link.position %>
14
+ ActiveScaffold.find_action_link('<%= element_row_id(:action => action_name) %>').close();
15
+ <% end %>
16
+ <%= render :partial => 'refresh_list' %>
17
+ <% end %>
18
+ <% else %>
19
+ <% flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br) %>
20
+ ActiveScaffold.replace_html('<%= active_scaffold_messages_id %>','<%= escape_javascript(render(:partial => 'messages')) %>');
21
+ ActiveScaffold.scroll_to('<%= active_scaffold_messages_id %>', true);
22
+ <% end %>
@@ -4,29 +4,32 @@ insert_at ||= :top %>
4
4
  var action_link = ActiveScaffold.find_action_link('<%= form_selector%>');
5
5
  action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'messages'))%>');
6
6
  <% if controller.send :successful? %>
7
- <% if render_parent? && controller.respond_to?(:render_component_into_view) %>
8
- <% parent_rendered = controller.send(:render_component_into_view, render_parent_options) %>
9
- <% if nested_singular_association? %>
10
- action_link.close('<%= escape_javascript(parent_rendered)%>');
7
+ <% if render_parent? %>
8
+ <% if controller.respond_to?(:render_component_into_view) %>
9
+ <% parent_rendered = controller.send(:render_component_into_view, render_parent_options) %>
10
+ <% if nested_singular_association? %>
11
+ action_link.close('<%= escape_javascript(parent_rendered)%>');
12
+ <% else %>
13
+ <% if render_parent_action == :row %>
14
+ ActiveScaffold.create_record_row(action_link.scaffold(),'<%= escape_javascript(parent_rendered) %>', <%= {:insert_at => insert_at}.to_json.html_safe %>);
15
+ <% elsif render_parent_action == :index %>
16
+ <%= escape_javascript(parent_rendered) %>
17
+ <% end %>
18
+ action_link.close();
19
+ <% end %>
20
+ <%= render :partial => 'update_calculations', :locals => {:calculations_id => active_scaffold_calculations_id(:controller_id => render_parent_controller)} unless render_parent_action == :index %>
11
21
  <% else %>
12
- <% if render_parent_action == :row %>
13
- ActiveScaffold.create_record_row(action_link.scaffold(),'<%= escape_javascript(parent_rendered)%>', <%= {:insert_at => insert_at}.to_json.html_safe %>);
14
- <% elsif render_parent_action == :index %>
15
- <%= escape_javascript(parent_rendered) %>
22
+ <% if nested_singular_association? || render_parent_action == :row %>
23
+ action_link.close();
16
24
  <% end %>
17
- action_link.close();
18
- <% end %>
19
- <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
20
- ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
25
+ ActiveScaffold.reload('<%= url_for render_parent_options %>');
21
26
  <% end %>
22
27
  <% elsif (active_scaffold_config.create.refresh_list) %>
23
- ActiveScaffold.replace_html('<%= active_scaffold_content_id%>', '<%= escape_javascript(render(:partial => 'list', :layout => false)) %>');
28
+ <%= render :partial => 'refresh_list' %>
24
29
  <% elsif params[:parent_controller].nil? %>
25
30
  <% new_row = render :partial => 'list_record', :locals => {:record => @record} %>
26
- ActiveScaffold.create_record_row(action_link.scaffold(),'<%=escape_javascript(new_row)%>', <%={:insert_at => insert_at}.to_json.html_safe%>);
27
- <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
28
- ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
29
- <% end %>
31
+ ActiveScaffold.create_record_row(action_link.scaffold(),'<%= escape_javascript(new_row) %>', <%= {:insert_at => insert_at}.to_json.html_safe %>);
32
+ <%= render :partial => 'update_calculations' %>
30
33
  <% end %>
31
34
 
32
35
  <% unless render_parent? %>
@@ -36,12 +39,12 @@ action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'mess
36
39
  action_link.close();
37
40
  <% end %>
38
41
  <% if (active_scaffold_config.create.action_after_create) %>
39
- var link = $('<%=action_link_id active_scaffold_config.create.action_after_create, @record.id%>');
40
- if (link) (function() { link.action_link.open() }).defer();
42
+ var link = ActiveScaffold.find_action_link('<%= action_link_id active_scaffold_config.create.action_after_create, @record.id %>');
43
+ if (link) (function() { link.open() })<%= '.defer' if ActiveScaffold.js_framework == :prototype %>();
41
44
  <% end %>
42
45
  <% end %>
43
46
  <% else %>
44
- ActiveScaffold.replace('<%=form_selector%>','<%=escape_javascript(render(:partial => 'create_form', :locals => {:xhr => true}))%>');
45
- ActiveScaffold.scroll_to('<%=form_selector%>');
47
+ ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render(:partial => 'create_form', :locals => {:xhr => true})) %>');
48
+ ActiveScaffold.scroll_to('<%= form_selector %>', true);
46
49
  <% end %>
47
50
  } catch (e) { alert('RJS error:\n\n' + e.toString());}
@@ -1,33 +1,34 @@
1
1
  try {
2
2
  <% form_selector = "#{element_form_id(:action => :update)}" %>
3
- var action_link = ActiveScaffold.find_action_link('<%= form_selector%>');
4
- action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'messages'))%>');
3
+ var action_link = ActiveScaffold.find_action_link('<%= form_selector %>');
4
+ action_link.update_flash_messages('<%= escape_javascript(render(:partial => 'messages')) %>');
5
5
  <% if controller.send :successful? %>
6
6
  <% if !active_scaffold_config.update.persistent %>
7
- <% if render_parent? && controller.respond_to?(:render_component_into_view) %>
8
- <% parent_rendered = controller.send(:render_component_into_view, render_parent_options) %>
9
- <% if nested_singular_association? %>
10
- action_link.close('<%= escape_javascript(parent_rendered)%>');
11
- <% else %>
12
- <% if render_parent_action == :row %>
13
- action_link.close('<%= escape_javascript(parent_rendered)%>');
7
+ <% if render_parent? %>
8
+ <% if controller.respond_to?(:render_component_into_view) %>
9
+ <% parent_rendered = controller.send(:render_component_into_view, render_parent_options) %>
10
+ <% if nested_singular_association? || render_parent_action == :row %>
11
+ action_link.close('<%= escape_javascript(parent_rendered) %>');
12
+ <%= render :partial => 'update_calculations', :locals => {:calculations_id => active_scaffold_calculations_id(:controller_id => render_parent_controller)} %>
14
13
  <% elsif render_parent_action == :index %>
15
14
  <%= escape_javascript(parent_rendered) %>
16
15
  <% end %>
16
+ <% else %>
17
+ <% if nested_singular_association? || render_parent_action == :row %>
18
+ action_link.close();
19
+ <% end %>
20
+ ActiveScaffold.reload('<%= url_for render_parent_options %>');
17
21
  <% end %>
18
- <%#page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
19
22
  <% elsif update_refresh_list? %>
20
- ActiveScaffold.replace_html('<%= active_scaffold_content_id%>', '<%= escape_javascript(render(:partial => 'list', :layout => false))%>');
23
+ <%= render :partial => 'refresh_list' %>
21
24
  <% else %>
22
- <% updated_row = render :partial => 'list_record', :locals => {:record => @record}%>
23
- action_link.close('<%= escape_javascript(updated_row)%>');
24
- <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
25
- ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
26
- <% end %>
25
+ <% updated_row = render :partial => 'list_record', :locals => {:record => @record} %>
26
+ action_link.close('<%= escape_javascript(updated_row) %>');
27
+ <%= render :partial => 'update_calculations' %>
27
28
  <% end %>
28
29
  <% end %>
29
30
  <% else %>
30
- ActiveScaffold.replace('<%=form_selector%>','<%=escape_javascript(render(:partial => 'update_form', :locals => {:xhr => true}))%>');
31
- ActiveScaffold.scroll_to('<%=form_selector%>');
31
+ ActiveScaffold.replace('<%= form_selector %>', '<%= escape_javascript(render(:partial => 'update_form', :locals => {:xhr => true})) %>');
32
+ ActiveScaffold.scroll_to('<%= form_selector %>', true);
32
33
  <% end %>
33
34
  } catch (e) { alert('RJS error:\n\n' + e.toString());}
@@ -1 +1,2 @@
1
- ActiveScaffold.replace_html('<%=active_scaffold_content_id%>','<%=escape_javascript(render(:partial => 'list', :layout => false))%>');
1
+ <% ActiveSupport::Deprecation.warn "You should use render :partial => 'refresh_list' instead of render :action => 'refresh_list'" %>
2
+ <%= render :partial => 'refresh_list' %>
@@ -0,0 +1 @@
1
+ ActiveScaffold.update_row('<%= element_row_id(:action => :list) %>', '<%= escape_javascript render(:partial => 'row', :locals => {:record => @record}) %>');
@@ -1,16 +1,15 @@
1
1
  <% @column_span_id ||= element_cell_id(:id => @record.id.to_s, :action => 'update_column', :name => params[:column]) %>
2
- <% unless controller.send :successful?%>
3
- alert('<%= escape_javascript(@record.errors.full_messages.join("\n"))%>');
4
- <% @record.reload%>
5
- <% end%>
6
- <% column = active_scaffold_config.columns[params[:column]]%>
7
- <% if column.inplace_edit%>
8
- ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(get_column_value(@record, column))%>');
9
- <% else%>
10
- <% formatted_value = get_column_value(@record, column)%>
11
- ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(formatted_value)%>');
12
- <% end%>
13
- <% if column.calculation?%>
14
- ActiveScaffold.replace_html('<%=active_scaffold_calculations_id(column)%>', '<%=escape_javascript(render_column_calculation(column))%>');
15
- <% end%>
16
-
2
+ <% unless controller.send :successful? %>
3
+ alert('<%= escape_javascript(@record.errors.full_messages.join("\n")) %>');
4
+ <% @record.reload %>
5
+ <% end %>
6
+ <% column = active_scaffold_config.columns[params[:column]] %>
7
+ <% formatted_value = get_column_value(@record, column) %>
8
+ <% if column.inplace_edit %>
9
+ ActiveScaffold.update_inplace_edit('<%= @column_span_id %>','<%= escape_javascript(formatted_value) %>', <%= column_empty?(formatted_value).to_json %>);
10
+ <% else %>
11
+ ActiveScaffold.replace_html('<%= @column_span_id %>','<%= escape_javascript(formatted_value) %>');
12
+ <% end %>
13
+ <% if column.calculation? %>
14
+ ActiveScaffold.replace_html('<%= active_scaffold_calculations_id(:column => column) %>', '<%= escape_javascript(render_column_calculation(column)) %>');
15
+ <% end %>
@@ -138,7 +138,7 @@ module ActiveScaffold
138
138
  end
139
139
 
140
140
  def self.js_config
141
- @@js_config ||= {:scroll_on_close => true}
141
+ @@js_config ||= {:scroll_on_close => :checkInViewport}
142
142
  end
143
143
 
144
144
  # exclude bridges you do not need
@@ -27,7 +27,7 @@ module ActiveScaffold::Actions
27
27
  end
28
28
 
29
29
  def render_field_for_inplace_editing
30
- register_constraints_with_action_columns(nested.constrained_fields, active_scaffold_config.update.hide_nested_column ? [] : [:update]) if nested?
30
+ register_constraints_with_action_columns(active_scaffold_config.update.hide_nested_column ? [] : [:update]) if nested?
31
31
  @record = find_if_allowed(params[:id], :update)
32
32
  render :inline => "<%= active_scaffold_input_for(active_scaffold_config.columns[params[:update_column].to_sym]) %>"
33
33
  end
@@ -178,7 +178,11 @@ module ActiveScaffold::Actions
178
178
  def respond_to_action(action)
179
179
  respond_to do |type|
180
180
  action_formats.each do |format|
181
- type.send(format){ send("#{action}_respond_to_#{format}") }
181
+ type.send(format) do
182
+ if respond_to?(method_name = "#{action}_respond_to_#{format}")
183
+ send(method_name)
184
+ end
185
+ end
182
186
  end
183
187
  end
184
188
  end