active_scaffold 3.3.0.rc3 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/CHANGELOG +16 -4
  2. data/README.md +67 -0
  3. data/app/assets/javascripts/jquery/active_scaffold.js +9 -9
  4. data/app/views/active_scaffold_overrides/_form.html.erb +4 -4
  5. data/app/views/active_scaffold_overrides/_form_association.html.erb +3 -2
  6. data/app/views/active_scaffold_overrides/_form_association_footer.html.erb +6 -4
  7. data/app/views/active_scaffold_overrides/_horizontal_subform.html.erb +1 -1
  8. data/app/views/active_scaffold_overrides/_list.html.erb +1 -1
  9. data/app/views/active_scaffold_overrides/_list_messages.html.erb +1 -1
  10. data/app/views/active_scaffold_overrides/_refresh_list.js.erb +4 -0
  11. data/app/views/active_scaffold_overrides/_render_field.js.erb +3 -2
  12. data/app/views/active_scaffold_overrides/_vertical_subform.html.erb +1 -1
  13. data/app/views/active_scaffold_overrides/edit_associated.js.erb +1 -1
  14. data/app/views/active_scaffold_overrides/on_create.js.erb +2 -1
  15. data/app/views/active_scaffold_overrides/render_field_inplace.html.erb +6 -1
  16. data/config/locales/ru.yml +6 -6
  17. data/lib/active_scaffold/actions/core.rb +2 -2
  18. data/lib/active_scaffold/actions/create.rb +1 -0
  19. data/lib/active_scaffold/actions/field_search.rb +4 -5
  20. data/lib/active_scaffold/actions/list.rb +13 -13
  21. data/lib/active_scaffold/actions/mark.rb +1 -1
  22. data/lib/active_scaffold/actions/search.rb +2 -2
  23. data/lib/active_scaffold/actions/show.rb +3 -3
  24. data/lib/active_scaffold/actions/subform.rb +2 -1
  25. data/lib/active_scaffold/actions/update.rb +1 -0
  26. data/lib/active_scaffold/attribute_params.rb +6 -2
  27. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +4 -1
  28. data/lib/active_scaffold/bridges/calendar_date_select.rb +1 -1
  29. data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +2 -2
  30. data/lib/active_scaffold/bridges/date_picker/helper.rb +1 -1
  31. data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +2 -2
  32. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +1 -1
  33. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +2 -2
  34. data/lib/active_scaffold/bridges/file_column.rb +1 -1
  35. data/lib/active_scaffold/bridges/paperclip/form_ui.rb +2 -2
  36. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +1 -1
  37. data/lib/active_scaffold/bridges/paperclip.rb +1 -1
  38. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +1 -1
  39. data/lib/active_scaffold/config/list.rb +9 -1
  40. data/lib/active_scaffold/constraints.rb +2 -2
  41. data/lib/active_scaffold/data_structures/action_columns.rb +2 -2
  42. data/lib/active_scaffold/data_structures/action_links.rb +3 -3
  43. data/lib/active_scaffold/data_structures/column.rb +16 -1
  44. data/lib/active_scaffold/extensions/action_view_rendering.rb +17 -5
  45. data/lib/active_scaffold/extensions/left_outer_joins.rb +33 -0
  46. data/lib/active_scaffold/extensions/paginator_extensions.rb +8 -0
  47. data/lib/active_scaffold/extensions/unsaved_associated.rb +4 -4
  48. data/lib/active_scaffold/finder.rb +13 -7
  49. data/lib/active_scaffold/helpers/controller_helpers.rb +11 -1
  50. data/lib/active_scaffold/helpers/form_column_helpers.rb +50 -27
  51. data/lib/active_scaffold/helpers/list_column_helpers.rb +9 -3
  52. data/lib/active_scaffold/helpers/view_helpers.rb +8 -8
  53. data/lib/active_scaffold/tableless.rb +8 -0
  54. data/lib/active_scaffold/version.rb +1 -1
  55. data/lib/active_scaffold.rb +1 -0
  56. data/lib/generators/active_scaffold_controller/templates/controller.rb +7 -1
  57. metadata +7 -10
  58. data/README +0 -66
  59. data/app/views/active_scaffold_overrides/_form_attribute.html.erb +0 -27
  60. data/app/views/active_scaffold_overrides/_form_hidden_attribute.html.erb +0 -7
data/CHANGELOG CHANGED
@@ -1,6 +1,6 @@
1
- = master
1
+ = 3.3.0
2
2
  - Unify field overrides and list_ui method signatures
3
- - Improve performance removing some partials and adding some caching for helper overrides and UIs, and caching url generation for lists (optional)
3
+ - Improve performance removing some partials and adding some caching for helper overrides and UIs, and caching url generation for lists (caching url is optional)
4
4
  - Drop support for rails 3.1
5
5
  - Add HTML5 form fields
6
6
  - Add :chosen form_ui, and :chosen and :multi_chosen search_ui
@@ -26,8 +26,20 @@
26
26
  - Fix multipart persistent update form
27
27
  - Support jquery 1.9 (jquery-rails 2.2.0 gem)
28
28
  - Reduce usage of session
29
-
30
- = 3.2.19 (not released yet)
29
+ - Allow to include header on list refreshing
30
+ - Add search_joins to columns, so it's possible to do left joins without loading associations only for searching
31
+ - Fix set focus for inplace edit clone and ajax
32
+ - Allow to override label for list column headings with a new helper method column_heading_label
33
+ - Keep focus on last field when render_field is called
34
+ - Add empty create and update methods to tableless
35
+ - Allow multiple subform levels
36
+
37
+ = 3.2.20
38
+ - Some fixes for ruby 1.9
39
+ - Some fixes for rails 3.1
40
+ - Fix detection of empty for has_and_belongs_to_many on subforms
41
+
42
+ = 3.2.19
31
43
  - Avoid crashing when between is chosen and from or to is not filled
32
44
 
33
45
  = 3.2.18
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ Overview
2
+ ========
3
+ ActiveScaffold provides a quick and powerful user interfaces for CRUD (create, read, update, delete) operations for Rails applications. It offers additonal features including searching, pagination & layout control.
4
+
5
+ Branch Details
6
+ --------------
7
+ rails-3.2 branch on Github supports Rails 3.1 & 3.2, and is the current source of the 3.2.x line of gems. The master branch (3.3.x) has dropped support for Rails 3.1
8
+
9
+ Quick Start
10
+ -----------
11
+ To get started with a new Rails project
12
+
13
+ Added to Gemfile
14
+
15
+ gem 'active_scaffold'
16
+
17
+ Run the following commands
18
+
19
+ bundle install
20
+ bundle exec rake db:create
21
+ rails g active_scaffold User name:string
22
+ bundle exec rake db:migrate
23
+
24
+ Add the following line to app/assets/javascripts/application.js
25
+
26
+ //= require active_scaffold
27
+
28
+ Add the following line to /app/assets/stylesheets/application.css
29
+
30
+ *= require active_scaffold
31
+
32
+ Run the app and visit localhost:3000/teams
33
+
34
+ Configuration
35
+ -------------
36
+ See Wiki for instructions on customising ActiveScaffold and to find the full API details.
37
+
38
+ Compatability Issues
39
+ --------------------
40
+ jQuery 1.9 deprecates some methods that rails-3.2 branch still uses (NB: jQuery 1.9 is supported in 3.3.x, the master branch). You'll therefore need to ensure you use jQuery 1.8. You can do this by fixing version in your Gemfile:
41
+
42
+ gem 'jquery-rails', '2.1.4'
43
+
44
+ active_scaffold_batch plugin gem (versions 3.2.x) require 3.3.x (master branch). Therefore if you wish to try using active_scaffold_batch with this branch, you'll need to fork the project and edit the runtime dependency in the gemspec file (use at your own discretion)
45
+
46
+ Credits
47
+ -------
48
+ ActiveScaffold grew out of a project named Ajaxscaffold dating back to 2006. It has had numerous contributors including:
49
+
50
+ ActiveScaffold Gem/Plugin by Scott Rutherford (scott@caronsoftware.com), Richard White (rrwhite@gmail.com), Lance Ivy (lance@cainlevy.net), Ed Moss, Tim Harper and Sergio Cambra (sergio@entrecables.com)
51
+
52
+ Uses DhtmlHistory by Brad Neuberg (bkn3@columbia.edu)
53
+ http://codinginparadise.org
54
+
55
+ Uses Querystring by Adam Vandenberg
56
+ http://adamv.com/dev/javascript/querystring
57
+
58
+ Uses Paginator by Bruce Williams
59
+ http://paginator.rubyforge.org/
60
+
61
+ Supports RecordSelect by Lance Ivy
62
+ http://code.google.com/p/recordselect/
63
+
64
+
65
+ License
66
+ =======
67
+ Released under the MIT license (included)
@@ -5,6 +5,7 @@ jQuery(document).ready(function($) {
5
5
  else alert(error);
6
6
  }
7
7
 
8
+ jQuery(document).on('focus', ':input', function() { ActiveScaffold.last_focus = this; });
8
9
  jQuery(document).click(function(event) {
9
10
  jQuery('.action_group.dyn ul').remove();
10
11
  });
@@ -364,6 +365,7 @@ if (typeof(jQuery.fn.delayedObserver) === 'undefined') {
364
365
  */
365
366
 
366
367
  var ActiveScaffold = {
368
+ last_focus: null,
367
369
  records_for: function(tbody_id) {
368
370
  if (typeof(tbody_id) == 'string') tbody_id = '#' + tbody_id;
369
371
  return jQuery(tbody_id).children('.record');
@@ -441,7 +443,7 @@ var ActiveScaffold = {
441
443
  replace: function(element, html) {
442
444
  if (typeof(element) == 'string') element = '#' + element;
443
445
  element = jQuery(element);
444
- var new_element = typeof(html) == 'string' ? jQuery.parseHTML(html.trim()) : html;
446
+ var new_element = typeof(html) == 'string' ? jQuery.parseHTML(html.trim(), true) : html;
445
447
  new_element = jQuery(new_element);
446
448
  element.replaceWith(new_element);
447
449
  new_element.trigger('as:element_updated');
@@ -554,13 +556,10 @@ var ActiveScaffold = {
554
556
  row = jQuery(row);
555
557
  var tbody = row.closest('tbody.records');
556
558
 
557
- var current_action_node = row.find('td.actions a.disabled').first();
558
- if (current_action_node) {
559
- var action_link = ActiveScaffold.ActionLink.get(current_action_node);
560
- if (action_link) {
561
- action_link.close_previous_adapter();
562
- }
563
- }
559
+ row.find('a.disabled').each(function() {;
560
+ var action_link = ActiveScaffold.ActionLink.get(this);
561
+ if (action_link) action_link.close();
562
+ });
564
563
 
565
564
  ActiveScaffold.remove(row, function() {
566
565
  ActiveScaffold.stripe(tbody);
@@ -678,7 +677,7 @@ var ActiveScaffold = {
678
677
  content = jQuery(content);
679
678
  if (options.singular == false) {
680
679
  if (!(options.id && jQuery('#' + options.id).size() > 0)) {
681
- var tfoot = element.find('tfoot');
680
+ var tfoot = element.children('tfoot');
682
681
  if (tfoot.length) tfoot.before(content);
683
682
  else element.append(content);
684
683
  content.trigger('as:element_created');
@@ -860,6 +859,7 @@ var ActiveScaffold = {
860
859
  complete: function(event) {
861
860
  element.nextAll('img.loading-indicator').css('visibility','hidden');
862
861
  ActiveScaffold.enable_form(as_form);
862
+ if (ActiveScaffold.last_focus) $(ActiveScaffold.last_focus).focus().select();
863
863
  },
864
864
  error: function (xhr, status, error) {
865
865
  var as_div = element.closest("div.active-scaffold");
@@ -1,7 +1,7 @@
1
1
  <%
2
2
  scope ||= nil
3
3
  subsection_id ||= nil
4
- show_unauthorized_columns = active_scaffold_config.send(form_action).show_unauthorized_columns
4
+ show_unauthorized_columns = active_scaffold_config.send(form_action).show_unauthorized_columns if active_scaffold_config.actions.include? form_action
5
5
  %>
6
6
  <ol class="form" <%= "id=#{subsection_id}" unless subsection_id.nil? %> <%= "style=\"display: none;\"".html_safe if columns.collapsed %>>
7
7
  <% columns.each :for => @record, :crud_type => (:read if show_unauthorized_columns) do |column| %>
@@ -15,13 +15,13 @@
15
15
  <%= render :partial => 'form', :locals => { :columns => column, :subsection_id => subsection_id, :form_action => form_action, :scope => scope } %>
16
16
  <%= link_to_visibility_toggle(subsection_id, {:default_visible => !column.collapsed}) -%>
17
17
  </li>
18
- <% elsif renders_as == :subform and !override_form_field?(column) and authorized -%>
18
+ <% elsif renders_as == :subform and authorized -%>
19
19
  <li class="sub-form <%= active_scaffold_config_for(column.association.klass).subform.layout %>-sub-form <%= column_css_class %> <%=column.name%>-sub-form" id="<%= sub_form_id(:association => column.name) %>">
20
- <%=raw render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column, :scope => scope } -%>
20
+ <%= render_column(column, @record, renders_as, scope) %>
21
21
  </li>
22
22
  <% else -%>
23
23
  <li class="form-element <%= 'required' if column.required? %> <%= column_css_class %>">
24
- <%=raw render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column, :only_value => !authorized, :scope => scope } -%>
24
+ <%= render_column(column, @record, renders_as, scope, !authorized) %>
25
25
  </li>
26
26
  <% end -%>
27
27
  <% end -%>
@@ -5,8 +5,9 @@ associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless
5
5
  if show_blank_record = column.show_blank_record?(associated)
6
6
  associated << build_associated(column, parent_record)
7
7
  end
8
+ disable_required_for_new = @disable_required_for_new
8
9
  @disable_required_for_new = show_blank_record unless (column.singular_association? && column.required?)
9
- subform_div_id = "#{sub_form_id({:association => column.name, :id => parent_record.id || 99999999999})}-div"
10
+ subform_div_id = "#{sub_form_id(:association => column.name, :id => parent_record.id || generated_id(parent_record) || 99999999999)}-div"
10
11
  -%>
11
12
  <h5><%= column.label -%></h5>
12
13
  <div id ="<%= subform_div_id %>" <%= 'style="display: none;"'.html_safe if column.collapsed -%>>
@@ -18,5 +19,5 @@ subform_div_id = "#{sub_form_id({:association => column.name, :id => parent_reco
18
19
  <%= link_to_visibility_toggle(subform_div_id, {:default_visible => !column.collapsed}) -%>
19
20
  <%
20
21
  @record = parent_record
21
- @disable_required_for_new = nil
22
+ @disable_required_for_new = disable_required_for_new
22
23
  -%>
@@ -11,8 +11,10 @@ show_add_new = column_show_add_new(column, associated, @record)
11
11
 
12
12
  return unless show_add_new or show_add_existing
13
13
 
14
- edit_associated_url = params_for(:action => 'edit_associated', :child_association => column.name, :associated_id => '--ID--', :scope => scope) if show_add_existing
15
- add_new_url = params_for(:action => 'edit_associated', :child_association => column.name, :scope => scope) if show_add_new
14
+ temporary_id = generated_id(parent_record) if parent_record.new_record?
15
+ controller_path = active_scaffold_controller_for(parent_record.class).controller_path
16
+ edit_associated_url = params_for(:controller => controller_path, :action => 'edit_associated', :child_association => column.name, :associated_id => '--ID--', :scope => scope, :id => parent_record.id, :generated_id => temporary_id, :parent_controller => controller.controller_path) if show_add_existing
17
+ add_new_url = params_for(:controller => controller_path, :action => 'edit_associated', :child_association => column.name, :scope => scope, :id => parent_record.id, :generated_id => temporary_id, :parent_controller => controller.controller_path) if show_add_new
16
18
 
17
19
  -%>
18
20
  <div class="footer-wrapper">
@@ -25,7 +27,7 @@ add_new_url = params_for(:action => 'edit_associated', :child_association => col
25
27
  add_label = as_(:replace_with_new)
26
28
  add_class = 'as_replace_with_new'
27
29
  end
28
- create_another_id = "#{sub_form_id(:association => column.name)}-create-another" %>
30
+ create_another_id = "#{sub_form_id(:association => column.name, :id => parent_record.id || temporary_id || 99999999999)}-create-another" %>
29
31
  <%= link_to add_label, add_new_url, :id => create_another_id, :remote => true, :class => add_class, :style=> "display: none;" %>
30
32
  <%= javascript_tag("ActiveScaffold.show('#{create_another_id}');") %>
31
33
  <% end -%>
@@ -37,7 +39,7 @@ add_new_url = params_for(:action => 'edit_associated', :child_association => col
37
39
  <%= link_to_record_select as_(:add_existing), remote_controller.controller_path, :onselect => "ActiveScaffold.record_select_onselect(#{url_for(edit_associated_url).to_json}, #{active_scaffold_id.to_json}, id);" -%>
38
40
  <% else -%>
39
41
  <% select_options = options_from_collection_for_select(sorted_association_options_find(column.association), :id, :to_label)
40
- add_existing_id = "#{sub_form_id(:association => column.name)}-add-existing"
42
+ add_existing_id = "#{sub_form_id(:association => column.name, :id => parent_record.id || temporary_id || 99999999999)}-add-existing"
41
43
  add_existing_label = column.plural_association? ? :add_existing : :replace_existing %>
42
44
  <%= select_tag 'associated_id', '<option value="">'.html_safe + as_(:_select_) + '</option>'.html_safe + select_options %>
43
45
  <%= link_to as_(add_existing_label), edit_associated_url, :id => add_existing_id, :remote => true, :class=> "as_#{add_existing_label}", :style => "display: none;" %>
@@ -1,4 +1,4 @@
1
- <table cellpadding="0" cellspacing="0" id="<%= sub_form_list_id(:association => column.name) %>">
1
+ <table cellpadding="0" cellspacing="0" id="<%= sub_form_list_id(:association => column.name, :id => parent_record.try(:id) || generated_id(parent_record) || 99999999999) %>">
2
2
  <% @record = associated.empty? ? build_associated(column, parent_record) : associated.last -%>
3
3
  <%= render :partial => 'horizontal_subform_header', :locals => {:parent_record => parent_record, :record => @record} %>
4
4
 
@@ -24,7 +24,7 @@
24
24
  </thead>
25
25
  <%= render :partial => 'list_messages', :locals => {:columns => columns} %>
26
26
  <tbody class="records" id="<%= active_scaffold_tbody_id %>">
27
- <% if !@records.empty? -%>
27
+ <% if !@page.empty? -%>
28
28
  <%= render :partial => 'list_record', :collection => @page.items, :locals => {:hidden => false, :columns => columns, :action_links => active_scaffold_config.action_links.member, :data_refresh => url_for(params_for(:action => :row, :id => '--ID--', :_method => :get))} %>
29
29
  <% end -%>
30
30
  <% if columns.any? {|c| c.calculation?} -%>
@@ -20,7 +20,7 @@
20
20
  </div>
21
21
  <% end -%>
22
22
  </div>
23
- <p id="<%= empty_message_id %>" class="empty-message" <%= ' style="display:none;" '.html_safe unless @page.items.empty? %>>
23
+ <p id="<%= empty_message_id %>" class="empty-message" <%= ' style="display:none;" '.html_safe unless @page.empty? %>>
24
24
  <%= as_(active_scaffold_config.list.no_entries_message) %>
25
25
  </p>
26
26
  </td>
@@ -1 +1,5 @@
1
+ <% if active_scaffold_config.list.refresh_with_header -%>
2
+ ActiveScaffold.replace('<%= active_scaffold_id %>', '<%= escape_javascript(render('list_with_header')) %>');
3
+ <% else -%>
1
4
  ActiveScaffold.replace_html('<%= active_scaffold_content_id %>', '<%= escape_javascript(render('list')) %>');
5
+ <% end -%>
@@ -8,7 +8,8 @@
8
8
  @rendered ||= Set.new
9
9
  return if @rendered.include? column.name
10
10
  @rendered << column.name
11
- if column_renders_as(column) == :subform
11
+ renders_as = column_renders_as(column)
12
+ if renders_as == :subform
12
13
  options = {:is_subform => true, :field_class => "#{column.name}-sub-form"}
13
14
  else
14
15
  options = {:is_subform => false, :field_class => "#{column.name}-input"}
@@ -18,7 +19,7 @@
18
19
  crud_type = @record.new_record? ? :create : (readonly ? :read : :update)
19
20
  active_scaffold_render_subform_column(column, scope, crud_type, readonly, !active_scaffold_config.subform.columns.names_without_auth_check.include?(column.name))
20
21
  else
21
- render(:partial => form_partial_for_column(column), :locals => { :column => column, :scope => scope })
22
+ render_column(column, @record, renders_as, scope)
22
23
  end
23
24
  -%>
24
25
 
@@ -1,4 +1,4 @@
1
- <div id="<%= sub_form_list_id(:association => column.name) %>">
1
+ <div id="<%= sub_form_list_id(:association => column.name, :id => parent_record.id || generated_id(parent_record) || 99999999999) %>">
2
2
  <% associated.each_index do |index| %>
3
3
  <% @record = associated[index] -%>
4
4
  <%= render :partial => 'form_association_record', :locals => {:scope => column_scope(column, scope), :parent_record => parent_record, :column => column, :locked => show_blank_record && @record.new_record? && @record == associated.last, :index => index} %>
@@ -9,4 +9,4 @@ else
9
9
  options[:id] = active_scaffold_input_options(column, @scope)[:id]
10
10
  end
11
11
  end %>
12
- ActiveScaffold.create_associated_record_form('<%=sub_form_list_id(:association => @column.name)%>','<%=escape_javascript(associated_form)%>', <%= options.to_json.html_safe %>);
12
+ ActiveScaffold.create_associated_record_form('<%=sub_form_list_id(:association => @column.name, :id => @parent_record.id || generated_id(@parent_record) || 99999999999)%>','<%=escape_javascript(associated_form)%>', <%= options.to_json.html_safe %>);
@@ -1,10 +1,11 @@
1
1
  try {
2
+ var action_link;
2
3
  <% form_selector = "#{element_form_id(:action => :create)}"
3
4
  insert_at ||= :top -%>
4
5
  <% if active_scaffold_config.list.always_show_create -%>
5
6
  <%= render :partial => 'update_messages' %>
6
7
  <% else -%>
7
- var action_link = ActiveScaffold.find_action_link('<%= form_selector %>');
8
+ action_link = ActiveScaffold.find_action_link('<%= form_selector %>');
8
9
  action_link.update_flash_messages('<%= escape_javascript(render(:partial => 'messages')) %>');
9
10
  <% end -%>
10
11
  <% if controller.send :successful? -%>
@@ -1 +1,6 @@
1
- <%= active_scaffold_input_for(active_scaffold_config.columns[@column.name]) %>
1
+ <%
2
+ column = active_scaffold_config.columns[@column.name]
3
+ options = active_scaffold_input_options(column)
4
+ options[:class] = "#{options[:class]} inplace_field"
5
+ -%>
6
+ <%= active_scaffold_input_for(column, nil, options) %>
@@ -6,7 +6,7 @@ ru:
6
6
  add: 'Добавить запись'
7
7
  add_existing: 'Добавить существующую запись'
8
8
  add_existing_model: '%{model}: добавить существующую запись'
9
- apply: 'Apply'
9
+ apply: 'Применить'
10
10
  are_you_sure_to_delete: 'Удалить %{label}?'
11
11
  cancel: 'Отмена'
12
12
  click_to_edit: 'Нажмите для редактирования'
@@ -30,7 +30,7 @@ ru:
30
30
  nested_of_model: '%{nested_model} @ %{parent_model}'
31
31
  'false': 'Нет'
32
32
  filtered: '(Найденное)'
33
- found:
33
+ found:
34
34
  one: 'запись'
35
35
  few: 'записи'
36
36
  many: 'записей'
@@ -56,7 +56,7 @@ ru:
56
56
  refresh: 'Обновить'
57
57
  remove: 'Удалить'
58
58
  remove_file: 'Удалить или заменить файл'
59
- replace_existing: 'Replace existing'
59
+ replace_existing: 'Заменить существующим'
60
60
  replace_with_new: 'Заменить новым'
61
61
  revisions_for_model: '%{model}: редакции'
62
62
  reset: 'Сброс'
@@ -111,13 +111,13 @@ ru:
111
111
  firstDay: 1
112
112
  isRTL: false
113
113
  showMonthAfterYear: false
114
-
114
+
115
115
  datetime_picker_options:
116
-
116
+
117
117
  human_conditions:
118
118
  boolean: "%{column} = %{value}"
119
119
  association: "%{column} = %{value}"
120
-
120
+
121
121
  errors:
122
122
  template:
123
123
  header:
@@ -8,7 +8,7 @@ module ActiveScaffold::Actions
8
8
  rescue_from ActiveScaffold::RecordNotAllowed, ActiveScaffold::ActionNotAllowed, :with => :deny_access
9
9
  end
10
10
  base.helper_method :nested?
11
- base.helper_method :calculate
11
+ base.helper_method :calculate_query
12
12
  base.helper_method :new_model
13
13
  end
14
14
  def render_field
@@ -185,7 +185,7 @@ module ActiveScaffold::Actions
185
185
  respond_to do |type|
186
186
  action_formats.each do |format|
187
187
  type.send(format) do
188
- if respond_to?(method_name = "#{action}_respond_to_#{format}")
188
+ if respond_to?(method_name = "#{action}_respond_to_#{format}", true)
189
189
  send(method_name)
190
190
  end
191
191
  end
@@ -33,6 +33,7 @@ module ActiveScaffold::Actions
33
33
 
34
34
  def create_respond_to_html
35
35
  if params[:iframe]=='true' # was this an iframe post ?
36
+ do_refresh_list if successful? && active_scaffold_config.create.refresh_list && !render_parent?
36
37
  responds_to_parent do
37
38
  render :action => 'on_create', :formats => [:js], :layout => false
38
39
  end
@@ -48,19 +48,18 @@ module ActiveScaffold::Actions
48
48
  columns = active_scaffold_config.field_search.columns
49
49
  search_params.each do |key, value|
50
50
  next unless columns.include? key
51
- search_condition = self.class.condition_for_column(active_scaffold_config.columns[key], value, text_search)
51
+ column = active_scaffold_config.columns[key]
52
+ search_condition = self.class.condition_for_column(column, value, text_search)
52
53
  unless search_condition.blank?
54
+ self.active_scaffold_outer_joins << column.search_joins unless column.includes.present? && list_columns.include?(column)
53
55
  self.active_scaffold_conditions << search_condition
54
- filtered_columns << active_scaffold_config.columns[key]
56
+ filtered_columns << column
55
57
  end
56
58
  end
57
59
  unless filtered_columns.blank?
58
60
  @filtered = active_scaffold_config.field_search.human_conditions ? filtered_columns : true
59
61
  end
60
62
 
61
- includes_for_search_columns = columns.collect{ |column| column.includes}.flatten.uniq.compact
62
- self.active_scaffold_includes.concat includes_for_search_columns
63
-
64
63
  active_scaffold_config.list.user.page = nil
65
64
  end
66
65
  end
@@ -24,7 +24,7 @@ module ActiveScaffold::Actions
24
24
  @nested_auto_open = active_scaffold_config.list.nested_auto_open
25
25
  respond_to_action(:list)
26
26
  end
27
-
27
+
28
28
  protected
29
29
  def list_respond_to_html
30
30
  if embedded?
@@ -49,11 +49,11 @@ module ActiveScaffold::Actions
49
49
  def list_respond_to_yaml
50
50
  render :text => Hash.from_xml(response_object.to_xml(:only => list_columns_names)).to_yaml, :content_type => Mime::YAML, :status => response_status
51
51
  end
52
-
52
+
53
53
  def row_respond_to_html
54
54
  render(:partial => 'row', :locals => {:record => @record})
55
55
  end
56
-
56
+
57
57
  def row_respond_to_js
58
58
  render :action => 'row'
59
59
  end
@@ -61,10 +61,10 @@ module ActiveScaffold::Actions
61
61
  # The actual algorithm to prepare for the list view
62
62
  def set_includes_for_columns(action = :list)
63
63
  @cache_associations = true
64
- includes_for_list_columns = active_scaffold_config.send(action).columns.collect{ |c| c.includes }.flatten.uniq.compact
64
+ includes_for_list_columns = active_scaffold_config.send(action).columns.collect_visible(:flatten => true){ |c| c.includes }.flatten.uniq.compact
65
65
  self.active_scaffold_includes.concat includes_for_list_columns
66
66
  end
67
-
67
+
68
68
  def get_row
69
69
  set_includes_for_columns
70
70
  klass = beginning_of_chain.includes(active_scaffold_includes)
@@ -97,23 +97,23 @@ module ActiveScaffold::Actions
97
97
  end
98
98
  @page, @records = page, page.items
99
99
  end
100
-
100
+
101
101
  def do_refresh_list
102
102
  params.delete(:id)
103
- do_search if respond_to? :do_search
103
+ do_search if respond_to? :do_search, true
104
104
  do_list
105
105
  end
106
106
 
107
107
  def each_record_in_page
108
108
  _page = active_scaffold_config.list.user.page
109
- do_search if respond_to? :do_search
109
+ do_search if respond_to? :do_search, true
110
110
  active_scaffold_config.list.user.page = _page
111
111
  do_list
112
112
  @page.items.each {|record| yield record}
113
113
  end
114
114
 
115
115
  def each_record_in_scope
116
- do_search if respond_to? :do_search
116
+ do_search if respond_to? :do_search, true
117
117
  append_to_query(beginning_of_chain, finder_options).all.each {|record| yield record}
118
118
  end
119
119
 
@@ -133,11 +133,11 @@ module ActiveScaffold::Actions
133
133
  def process_action_link_action(render_action = :action_update, crud_type = nil)
134
134
  if request.get?
135
135
  # someone has disabled javascript, we have to show confirmation form first
136
- @record = find_if_allowed(params[:id], :read) if params[:id] && params[:id] && params[:id].to_i > 0
136
+ @record = find_if_allowed(params[:id], :read) if params[:id] && params[:id].to_i > 0
137
137
  respond_to_action(:action_confirmation)
138
138
  else
139
139
  @action_link = active_scaffold_config.action_links[action_name]
140
- if params[:id] && params[:id] && params[:id].to_i > 0
140
+ if params[:id] && params[:id].to_i > 0
141
141
  crud_type ||= (request.post? || request.put?) ? :update : :delete
142
142
  set_includes_for_columns
143
143
  klass = beginning_of_chain.includes(active_scaffold_includes)
@@ -180,7 +180,7 @@ module ActiveScaffold::Actions
180
180
  def action_update_respond_to_yaml
181
181
  render :text => successful? ? "" : Hash.from_xml(response_object.to_xml(:only => list_columns_names)).to_yaml, :content_type => Mime::YAML, :status => response_status
182
182
  end
183
-
183
+
184
184
  private
185
185
  def list_authorized_filter
186
186
  raise ActiveScaffold::ActionNotAllowed unless list_authorized?
@@ -204,7 +204,7 @@ module ActiveScaffold::Actions
204
204
  end
205
205
 
206
206
  def list_columns
207
- active_scaffold_config.list.columns.collect_visible
207
+ @list_columns ||= active_scaffold_config.list.columns.collect_visible
208
208
  end
209
209
 
210
210
  def list_columns_names
@@ -28,7 +28,7 @@ module ActiveScaffold::Actions
28
28
 
29
29
  def mark_respond_to_js
30
30
  if params[:id]
31
- do_search if respond_to? :do_search
31
+ do_search if respond_to? :do_search, true
32
32
  set_includes_for_columns if active_scaffold_config.actions.include? :list
33
33
  @page = find_page(:pagination => active_scaffold_config.mark.mark_all_mode != :page)
34
34
  render :action => 'on_mark'
@@ -29,8 +29,8 @@ module ActiveScaffold::Actions
29
29
  @filtered = !search_conditions.blank?
30
30
  self.active_scaffold_conditions.concat search_conditions if @filtered
31
31
 
32
- includes_for_search_columns = columns.collect{ |column| column.includes}.flatten.uniq.compact
33
- self.active_scaffold_includes.concat includes_for_search_columns
32
+ outer_joins = columns.collect{ |column| column.search_joins unless column.includes.present? && list_columns.include?(column)}
33
+ self.active_scaffold_outer_joins.concat outer_joins.flatten.uniq.compact
34
34
 
35
35
  active_scaffold_config.list.user.page = nil
36
36
  end
@@ -11,13 +11,13 @@ module ActiveScaffold::Actions
11
11
  do_show
12
12
  respond_to_action(:show)
13
13
  else
14
- @record = find_if_allowed(params[:id], :read) if params[:id] && params[:id] && params[:id].to_i > 0
14
+ @record = find_if_allowed(params[:id], :read) if params[:id] && params[:id].to_i > 0
15
15
  action_confirmation_respond_to_html(:destroy)
16
16
  end
17
17
  end
18
18
 
19
19
  protected
20
-
20
+
21
21
  def show_respond_to_json
22
22
  render :text => response_object.to_json(:only => active_scaffold_config.show.columns.names), :content_type => Mime::JSON, :status => response_status
23
23
  end
@@ -53,7 +53,7 @@ module ActiveScaffold::Actions
53
53
  def show_ignore?(record = nil)
54
54
  !self.send(:authorized_for?, :crud_type => :read)
55
55
  end
56
- private
56
+ private
57
57
  def show_authorized_filter
58
58
  link = active_scaffold_config.show.link || active_scaffold_config.show.class.link
59
59
  raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
@@ -9,6 +9,7 @@ module ActiveScaffold::Actions
9
9
 
10
10
  def do_edit_associated
11
11
  @parent_record = params[:id].nil? ? new_model : find_if_allowed(params[:id], :update)
12
+ generate_temporary_id(@parent_record, params[:generated_id]) if @parent_record.new_record? && params[:generated_id]
12
13
  @column = active_scaffold_config.columns[params[:child_association]]
13
14
 
14
15
  # NOTE: we don't check whether the user is allowed to update this record, because if not, we'll still let them associate the record. we'll just refuse to do more than associate, is all.
@@ -16,7 +17,7 @@ module ActiveScaffold::Actions
16
17
  @record ||= build_associated(@column, @parent_record)
17
18
 
18
19
  @scope = "#{params[:scope]}[#{@column.name}]"
19
- @scope += (@record.new_record?) ? "[#{(Time.now.to_f*1000).to_i.to_s}]" : "[#{@record.id}]" if @column.plural_association?
20
+ @scope += "[#{@record.id || generate_temporary_id(@record)}]" if @column.plural_association?
20
21
  end
21
22
 
22
23
  end
@@ -34,6 +34,7 @@ module ActiveScaffold::Actions
34
34
  end
35
35
  def update_respond_to_html
36
36
  if params[:iframe]=='true' # was this an iframe post ?
37
+ do_refresh_list if successful? && active_scaffold_config.create.refresh_list && !render_parent?
37
38
  responds_to_parent do
38
39
  render :action => 'on_update', :formats => [:js], :layout => false
39
40
  end
@@ -212,16 +212,20 @@ module ActiveScaffold
212
212
  next true if column and ignore_column_types.include?(column.type)
213
213
 
214
214
  # defaults are pre-filled on the form. we can't use them to determine if the user intends a new row.
215
- next true if column and value == column.default.to_s
215
+ next true if value == column_default_value(column_name, klass, column)
216
216
 
217
217
  if value.is_a?(Hash)
218
218
  attributes_hash_is_empty?(value, klass)
219
219
  elsif value.is_a?(Array)
220
- value.any? {|id| id.respond_to?(:empty?) ? !id.empty? : true}
220
+ value.all?(&:blank?)
221
221
  else
222
222
  value.respond_to?(:empty?) ? value.empty? : false
223
223
  end
224
224
  end
225
225
  end
226
+
227
+ def column_default_value(column_name, klass, column)
228
+ column.default.to_s if column
229
+ end
226
230
  end
227
231
  end
@@ -19,7 +19,10 @@ module ActiveScaffold
19
19
  self.model.bitfields.each do |column_name, options|
20
20
  columns = options.keys.sort_by { |column| self.columns[column].weight }
21
21
  [:create, :update, :show, :subform].each do |action|
22
- self.send(action).columns.add_subgroup(column_name) { |group| group.add *columns } if self.actions.included? action
22
+ if self.actions.include? action
23
+ self.send(action).columns.exclude column_name
24
+ self.send(action).columns.add_subgroup(column_name) { |group| group.add *columns }
25
+ end
23
26
  end
24
27
  end if self.model.respond_to?(:bitfields) and self.model.bitfields.present?
25
28
 
@@ -3,7 +3,7 @@ class ActiveScaffold::Bridges::CalendarDateSelect < ActiveScaffold::DataStructur
3
3
  # check to see if the old bridge was installed. If so, warn them
4
4
  # we can detect this by checking to see if the bridge was installed before calling this code
5
5
 
6
- if ActiveScaffold::Config::Core.instance_methods.include?("initialize_with_calendar_date_select")
6
+ if ActiveScaffold::Config::Core.instance_methods.include?("initialize_with_calendar_date_select".send(::ActiveScaffold::METHOD_CONVERSION))
7
7
  raise RuntimeError, "We've detected that you have active_scaffold_calendar_date_select_bridge installed. This plugin has been moved to core. Please remove active_scaffold_calendar_date_select_bridge to prevent any conflicts"
8
8
  end
9
9