Skip to content

Commit

Permalink
Merge branch '3-7-stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
scambra committed Dec 13, 2024
2 parents d46d393 + eaa62d5 commit 8d65b3d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 35 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
- Action links can't be changed, added or removed, add all links and use ignore_method to control when they are displayed
- Require using active_scaffold_config.override_columns to exclude or add columns
- Thread safety enabled by default, can't be disabled, deprecate ActiveScaffold.threadsafe!
- Support separators in action links

= 3.7.10
- Move code from on_create.js.erb to partials, so it's easier to change parts, e.g. how new record is rendered
- Don't reload after deleting last record if pagination is disabled

= 3.7.9 (not released yet)
= 3.7.9
- Add css_class to action links, to avoid changing name, it may result confusing, deprecate name setter.
- Add buttons to check all and uncheck all on :select form ui for collection associations, and draggable lists (active_scaffold_checkbox_list).
- Add hidden field with locking column in base_form partial for persisted records automatically, if model uses optimistic locking.
- Add on_stale_object_error when StaleObjectError is rescued, to allow customization.
- Fix search_ui :select_multiple, which was broken when operator select was added.
- Support separators in action links
- Deprecate ActiveScaffold.js_framework as will be removed in 4.0

= 3.7.8
Expand Down
6 changes: 6 additions & 0 deletions app/assets/javascripts/jquery/active_scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,11 @@
jQuery(tbody).parent().find('tbody.messages p.empty-message').hide();
}
},
show_empty_message: function(tbody) {
if (this.records_for(tbody).length != 0) {
jQuery(tbody).parent().find('tbody.messages p.empty-message').hide();
}
},
reload_if_empty: function(tbody, url) {
if (this.records_for(tbody).length == 0) {
this.reload(url);
Expand Down Expand Up @@ -849,6 +854,7 @@
ActiveScaffold.stripe(tbody);
ActiveScaffold.decrement_record_count(tbody.closest('div.active-scaffold'));
if (page_reload_url) ActiveScaffold.reload_if_empty(tbody, page_reload_url);
else ActiveScaffold.show_empty_message(tbody);
});
},

Expand Down
15 changes: 15 additions & 0 deletions app/views/active_scaffold_overrides/_new_record.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% if render_parent? %>
<% if nested_singular_association? %>
if (action_link) action_link.close(true);
<% elsif params[:parent_sti] && render_parent_action == :row %>
ActiveScaffold.create_record_row_from_url(action_link, '<%= url_for(render_parent_options) %>', <%= {insert_at: insert_at}.to_json.html_safe %>);
<% else %>
ActiveScaffold.reload('<%= url_for render_parent_options %>');
<% end %>
<% elsif active_scaffold_config.create.refresh_list %>
<%= render 'refresh_list', no_history: true %>
<% elsif params[:parent_controller].nil? %>
<% new_row = render 'list_record', record: @saved_record || @record %>
ActiveScaffold.create_record_row(action_link ? action_link.scaffold() : '<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {insert_at: insert_at}.to_json.html_safe %>);
<%= render 'update_calculations' %>
<% end %>
12 changes: 12 additions & 0 deletions app/views/active_scaffold_overrides/_refresh_create_form.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% if always_show_create %>
ActiveScaffold.reset_form('<%= form_selector %>');
<% elsif params[:dont_close] %>
ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render('create_form', xhr: true)) %>');
ActiveScaffold.focus_first_element_of_form('<%= form_selector %>');
<% else %>
if (action_link) action_link.close();
<% end %>
<% if active_scaffold_config.create.action_after_create %>
var link = ActiveScaffold.find_action_link('<%= action_link_id active_scaffold_config.create.action_after_create, @record.id || @saved_record.id %>');
if (link) link.open();
<% end %>
9 changes: 6 additions & 3 deletions app/views/active_scaffold_overrides/destroy.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
<%= render 'refresh_list', no_history: true %>
<% else %>
<%
url = main_path_to_return
url[:page] = [active_scaffold_config.list.user.page.to_i - 1, 1].max if url.is_a?(Hash) && active_scaffold_config.actions.include?(:list)
if active_scaffold_config.actions.exclude?(:list) || active_scaffold_config.list.pagination
url = main_path_to_return
url[:page] = [active_scaffold_config.list.user.page.to_i - 1, 1].max if url.is_a?(Hash) && active_scaffold_config.actions.include?(:list)
url = url_for(url)
end
%>
ActiveScaffold.delete_record_row('<%= element_row_id(action: 'list', id: params[:id]) %>', '<%= url_for(url) %>');
ActiveScaffold.delete_record_row('<%= element_row_id(action: 'list', id: params[:id]) %>', '<%= url %>');
<%= render 'update_calculations' %>
<% end %>
<% else %>
Expand Down
32 changes: 2 additions & 30 deletions app/views/active_scaffold_overrides/on_create.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,8 @@ action_link = ActiveScaffold.find_action_link('<%= form_selector %>');
if (action_link) action_link.update_flash_messages('<%= escape_javascript(render('messages')) %>');
<% end -%>
<% if successful? -%>
<% if render_parent? %>
<% if nested_singular_association? %>
if (action_link) action_link.close(true);
<% elsif params[:parent_sti] && render_parent_action == :row %>
ActiveScaffold.create_record_row_from_url(action_link,'<%= url_for(render_parent_options) %>', <%= {insert_at: insert_at}.to_json.html_safe %>);
<% else %>
ActiveScaffold.reload('<%= url_for render_parent_options %>');
<% end %>
<% elsif active_scaffold_config.create.refresh_list %>
<%= render 'refresh_list', no_history: true %>
<% elsif params[:parent_controller].nil? %>
<% new_row = render 'list_record', record: @saved_record || @record %>
ActiveScaffold.create_record_row(action_link ? action_link.scaffold() : '<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {insert_at: insert_at}.to_json.html_safe %>);
<%= render 'update_calculations' %>
<% end %>

<% unless render_parent? %>
<% if always_show_create %>
ActiveScaffold.reset_form('<%= form_selector %>');
<% elsif params[:dont_close] %>
ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render('create_form', xhr: true)) %>');
ActiveScaffold.focus_first_element_of_form('<%= form_selector %>');
<% else %>
if (action_link) action_link.close();
<% end %>
<% if active_scaffold_config.create.action_after_create %>
var link = ActiveScaffold.find_action_link('<%= action_link_id active_scaffold_config.create.action_after_create, @record.id || @saved_record.id %>');
if (link) link.open();
<% end %>
<% end %>
<%= render 'new_record', insert_at: insert_at %>
<%= render 'refresh_create_form', always_show_create: always_show_create, form_selector: form_selector unless render_parent? %>
<% else %>
ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render('create_form', xhr: true)) %>');
ActiveScaffold.scroll_to('<%= form_selector %>', true);
Expand Down

0 comments on commit 8d65b3d

Please sign in to comment.