active_scaffold 4.3.2 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +19 -0
  3. data/README.md +1 -1
  4. data/app/assets/javascripts/active_scaffold/active_scaffold.js +98 -11
  5. data/app/assets/javascripts/active_scaffold/draggable_lists.js +4 -3
  6. data/app/assets/javascripts/active_scaffold/load.js +20 -5
  7. data/app/assets/stylesheets/active_scaffold/_images.scss +53 -1
  8. data/app/assets/stylesheets/active_scaffold/_layout.scss +1 -66
  9. data/app/views/active_scaffold_overrides/_add_existing_form.html.erb +17 -11
  10. data/app/views/active_scaffold_overrides/_base_form.html.erb +29 -19
  11. data/app/views/active_scaffold_overrides/_field_search.html.erb +9 -9
  12. data/app/views/active_scaffold_overrides/_field_search_columns.html.erb +29 -33
  13. data/app/views/active_scaffold_overrides/_form.html.erb +43 -34
  14. data/app/views/active_scaffold_overrides/_form_association.html.erb +3 -3
  15. data/app/views/active_scaffold_overrides/_form_association_footer.html.erb +20 -16
  16. data/app/views/active_scaffold_overrides/_form_association_record.html.erb +3 -4
  17. data/app/views/active_scaffold_overrides/_horizontal_subform_header.html.erb +2 -1
  18. data/app/views/active_scaffold_overrides/_list.html.erb +6 -4
  19. data/app/views/active_scaffold_overrides/_list_calculations.html.erb +1 -1
  20. data/app/views/active_scaffold_overrides/_list_header.html.erb +3 -3
  21. data/app/views/active_scaffold_overrides/_list_messages.html.erb +19 -19
  22. data/app/views/active_scaffold_overrides/_list_messages_content.html.erb +5 -5
  23. data/app/views/active_scaffold_overrides/_list_pagination.html.erb +7 -5
  24. data/app/views/active_scaffold_overrides/_list_pagination_links.html.erb +5 -3
  25. data/app/views/active_scaffold_overrides/_list_record.html.erb +13 -8
  26. data/app/views/active_scaffold_overrides/_list_with_header.html.erb +8 -8
  27. data/app/views/active_scaffold_overrides/_messages.html.erb +3 -3
  28. data/app/views/active_scaffold_overrides/_render_field.js.erb +8 -11
  29. data/app/views/active_scaffold_overrides/_search.html.erb +7 -6
  30. data/app/views/active_scaffold_overrides/_show.html.erb +4 -4
  31. data/app/views/active_scaffold_overrides/_show_actions.html.erb +2 -2
  32. data/app/views/active_scaffold_overrides/_show_columns.html.erb +28 -30
  33. data/app/views/active_scaffold_overrides/add_existing.js.erb +7 -4
  34. data/app/views/active_scaffold_overrides/render_field.js.erb +1 -1
  35. data/config/locales/de.yml +2 -1
  36. data/config/locales/en.yml +33 -32
  37. data/config/locales/es.yml +15 -14
  38. data/config/locales/fr.yml +3 -2
  39. data/config/locales/hu.yml +3 -2
  40. data/config/locales/ja.yml +2 -1
  41. data/config/locales/ro.yml +169 -0
  42. data/config/locales/ru.yml +8 -7
  43. data/config/locales/ta.yml +7 -6
  44. data/config/locales/zh_Hans.yml +14 -13
  45. data/lib/active_scaffold/actions/common_search.rb +1 -14
  46. data/lib/active_scaffold/actions/core.rb +55 -16
  47. data/lib/active_scaffold/actions/field_search.rb +2 -2
  48. data/lib/active_scaffold/actions/list.rb +35 -13
  49. data/lib/active_scaffold/actions/nested.rb +31 -7
  50. data/lib/active_scaffold/actions/show.rb +1 -1
  51. data/lib/active_scaffold/active_record_permissions.rb +1 -1
  52. data/lib/active_scaffold/attribute_params.rb +2 -1
  53. data/lib/active_scaffold/bridges/date_picker/helper.rb +14 -0
  54. data/lib/active_scaffold/bridges/date_picker.rb +10 -0
  55. data/lib/active_scaffold/config/list.rb +10 -1
  56. data/lib/active_scaffold/core.rb +9 -6
  57. data/lib/active_scaffold/data_structures/action_columns.rb +2 -0
  58. data/lib/active_scaffold/data_structures/column.rb +27 -6
  59. data/lib/active_scaffold/data_structures/filter.rb +4 -0
  60. data/lib/active_scaffold/data_structures/nested_info.rb +8 -1
  61. data/lib/active_scaffold/data_structures/sorting.rb +1 -1
  62. data/lib/active_scaffold/extensions/action_view_rendering.rb +1 -1
  63. data/lib/active_scaffold/finder.rb +66 -21
  64. data/lib/active_scaffold/helpers/action_link_helpers.rb +43 -18
  65. data/lib/active_scaffold/helpers/assets_helpers.rb +4 -4
  66. data/lib/active_scaffold/helpers/filter_helpers.rb +3 -3
  67. data/lib/active_scaffold/helpers/form_column_helpers.rb +34 -22
  68. data/lib/active_scaffold/helpers/form_ui_helpers.rb +15 -10
  69. data/lib/active_scaffold/helpers/framework_ui_helpers.rb +22 -0
  70. data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -0
  71. data/lib/active_scaffold/helpers/list_column_helpers.rb +19 -0
  72. data/lib/active_scaffold/helpers/pagination_helpers.rb +28 -7
  73. data/lib/active_scaffold/helpers/search_column_helpers.rb +32 -5
  74. data/lib/active_scaffold/helpers/tabs_helpers.rb +3 -5
  75. data/lib/active_scaffold/helpers/view_helpers.rb +12 -0
  76. data/lib/active_scaffold/tableless.rb +11 -8
  77. data/lib/active_scaffold/version.rb +2 -2
  78. data/lib/active_scaffold.rb +169 -0
  79. data/lib/tasks/bundle.rake +2 -1
  80. data/lib/tasks/mock_app.rake +43 -0
  81. metadata +20 -7
  82. data/shoulda_macros/macros.rb +0 -145
@@ -1,40 +1,36 @@
1
+ <%
2
+ ol_attrs = {}
3
+ ol_attrs[:id] = subsection_id unless local_assigns[:subsection_id].nil?
4
+ ol_attrs[:style] = 'display: none;' if columns.collapsed
5
+ %>
1
6
  <% if columns.layout == :multiple -%>
2
- <div class="form-columns"<%= " id=#{subsection_id}" if local_assigns.key? :subsection_id %><%= ' style="display: none;"'.html_safe if columns.collapsed %>>
3
- <% columns.each do |group| %>
4
- <%= render 'field_search_columns', local_assigns.merge(columns: group, subsection_id: nil) %>
7
+ <%= as_element :field_search_fields_columns, **ol_attrs do %>
8
+ <% columns.each do |group| %>
9
+ <%= render 'field_search_columns', local_assigns.merge(columns: group) %>
10
+ <% end %>
5
11
  <% end %>
6
- </div>
7
12
  <% else -%>
8
- <ol class="form" <%= "id=#{subsection_id}" unless local_assigns[:subsection_id].nil? %> <%= 'style="display: none;"'.html_safe if columns.collapsed %>>
9
- <% visibles, hiddens = visibles_and_hiddens(active_scaffold_config.field_search, columns) %>
10
- <% visibles.each do |column| -%>
11
- <% if column.respond_to? :each_column %>
12
- <li class="sub-section <%= column.css_class unless column.css_class.is_a?(Proc) %>">
13
- <%= render_subsection column, @record, nil, :field_search, partial: 'field_search_columns' %>
14
- </li>
15
- <% else %>
16
- <li class="form-element <%= column.css_class unless column.css_class.is_a?(Proc) %>"><%= search_attribute(column, @record) %></li>
17
- <% end %>
18
- <% end -%>
19
- <% unless hiddens.empty? -%>
20
- <li class="sub-section">
21
- <% further_options_id = sub_section_id(sub_section: 'further_options') %>
22
- <h5>
23
- <%= as_(:optional_attributes) %>
24
- <%= link_to_visibility_toggle(further_options_id, default_visible: false) %>
25
- </h5>
26
- <ol id="<%= further_options_id %>" class="form" style="display:none;">
27
- <% hiddens.each do |column| -%>
28
- <% if column.respond_to? :each_column %>
29
- <li class="sub-section <%= column.css_class unless column.css_class.is_a?(Proc) %>">
30
- <%= render_subsection column, @record, nil, :field_search, partial: 'field_search_columns' %>
31
- </li>
32
- <% else %>
33
- <li class="form-element <%= column.css_class unless column.css_class.is_a?(Proc) %>"><%= search_attribute(column, @record) %></li>
13
+ <%= as_element :field_search_fields_container, class: 'form', **ol_attrs do %>
14
+ <% visibles, hiddens = visibles_and_hiddens(active_scaffold_config.field_search, columns) %>
15
+ <% visibles.each do |column| -%>
16
+ <%= render_field_search_column(column, @record) %>
17
+ <% end -%>
18
+ <% unless hiddens.empty? -%>
19
+ <%
20
+ @hidden_section ||= ActiveScaffold::DataStructures::ActionColumns.new.tap do |group|
21
+ group.label = :optional_attributes
22
+ group.collapsed = true
23
+ end
24
+ %>
25
+ <%= as_element :field_search_subsection do %>
26
+ <%= render_subsection(@hidden_section, @record, nil, :field_search, subsection_id: sub_section_id(sub_section: 'further_options')) do |further_options_id| %>
27
+ <%= as_element :field_search_fields_container, id: further_options_id, class: 'form', style: 'display:none;' do %>
28
+ <% hiddens.each do |column| -%>
29
+ <%= render_field_search_column(column, @record) %>
30
+ <% end -%>
31
+ <% end %>
32
+ <% end %>
34
33
  <% end %>
35
34
  <% end -%>
36
- </ol>
37
- </li>
38
35
  <% end -%>
39
- </ol>
40
36
  <% end -%>
@@ -1,47 +1,56 @@
1
- <% if columns.layout == :multiple %>
2
- <div class="form-columns"<%= " id=#{subsection_id}" if local_assigns.key? :subsection_id %><%= ' style="display: none;"'.html_safe if columns.collapsed %>>
1
+ <%
2
+ ol_attrs = {}
3
+ ol_attrs[:id] = subsection_id unless local_assigns[:subsection_id].nil?
4
+ ol_attrs[:style] = 'display: none;' if columns.collapsed
5
+ %>
6
+ <% if columns.layout == :multiple -%>
7
+ <%= as_element :form_fields_columns, **ol_attrs do %>
3
8
  <% columns.each do |group| %>
4
9
  <%= render 'form', local_assigns.merge(columns: group, subsection_id: nil) %>
5
10
  <% end %>
6
- </div>
11
+ <% end %>
7
12
  <% else %>
8
13
  <%
9
14
  scope ||= nil
10
- subsection_id ||= nil
11
- tab_value ||= nil
12
15
  tabbed_by ||= nil
13
16
  tab_id ||= nil
14
17
  show_unauthorized_columns = active_scaffold_config.send(form_action).show_unauthorized_columns if active_scaffold_config.actions.include? form_action
15
18
  %>
16
- <ol class="form" <%= "id=#{subsection_id}" unless subsection_id.nil? %> <%= 'style="display: none;"'.html_safe if columns.collapsed %>>
19
+ <%= as_element :fields_container, class: 'form', **ol_attrs do %>
17
20
  <% columns.each_column(for: @record, crud_type: (:read if show_unauthorized_columns)) do |column| %>
18
- <% column_css_class = column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc) %>
19
- <% renders_as = column_renders_as(column) %>
20
- <% authorized = show_unauthorized_columns || renders_as == :subsection ? @record.authorized_for?(crud_type: form_action, column: column.name) : true %>
21
- <% if renders_as == :subsection -%>
22
- <% next unless authorized %>
23
- <li class="sub-section <%= column_css_class %>">
24
- <%= render_subsection(column, @record, scope, form_action) %>
25
- </li>
26
- <% elsif renders_as == :subform && (authorized || column.show_ui) -%>
27
- <%
28
- subform_attrs = active_scaffold_subform_attributes(column, column_css_class, tab_id: tab_id)
29
- subform_attrs[:class] = "#{subform_attrs[:class]} read-only".strip unless authorized
30
- tab_options = local_assigns.slice(:tabbed_by, :tab_id, :tab_value)
31
- tab_options[:tabbed_by] = column.options[:tabbed_by] if tabbed_by && column.options[:tabbed_by]
32
- %>
33
- <%= content_tag :li, subform_attrs do %>
34
- <% if authorized %>
35
- <%= render_column(column, @record, renders_as, scope, **tab_options) %>
36
- <% else %>
37
- <%= show_column_value(@record, column, **tab_options) %>
38
- <% end %>
39
- <% end %>
40
- <% else -%>
41
- <li class="form-element <%= 'required' if column.required?(action_for_validation(@record)) %> <%= column.form_ui %> <%= column_css_class %>">
42
- <%= render_column(column, @record, renders_as, scope, only_value: !authorized) %>
43
- </li>
44
- <% end -%>
21
+ <% column_css_class = column.css_class unless column.css_class.is_a?(Proc) %>
22
+ <% renders_as = column_renders_as(column) %>
23
+ <% authorized = show_unauthorized_columns || renders_as == :subsection ? @record.authorized_for?(crud_type: form_action, column: column.name) : true %>
24
+ <% if renders_as == :subsection -%>
25
+ <% next unless authorized %>
26
+ <%= as_element :form_subsection, class: column_css_class do %>
27
+ <%= render_subsection(column, @record, scope, form_action) %>
28
+ <% end %>
29
+ <% elsif renders_as == :subform && (authorized || column.show_ui) -%>
30
+ <%
31
+ subform_attrs = active_scaffold_subform_attributes(column, column_css_class, tab_id: tab_id)
32
+ subform_attrs[:class] = "#{subform_attrs[:class]} read-only".strip unless authorized
33
+ tab_options = local_assigns.slice(:tabbed_by, :tab_id, :tab_value)
34
+ tab_options[:tabbed_by] = column.options[:tabbed_by] if tabbed_by && column.options[:tabbed_by]
35
+ %>
36
+ <%= as_element :subform, **subform_attrs do %>
37
+ <% if authorized %>
38
+ <%= render_column(column, @record, renders_as, scope, **tab_options) %>
39
+ <% else %>
40
+ <%= show_column_value(@record, column, **tab_options) %>
41
+ <% end %>
42
+ <% end %>
43
+ <% else -%>
44
+ <%
45
+ classes = ['form-element']
46
+ classes << 'required' if column.required?(action_for_validation(@record))
47
+ classes << form_ui_class(column.form_ui)
48
+ classes << column.css_class
49
+ %>
50
+ <%= as_element :form_element, class: classes.compact.join(' ') do %>
51
+ <%= render_column(column, @record, renders_as, scope, only_value: !authorized) %>
52
+ <% end -%>
53
+ <% end -%>
45
54
  <% end -%>
46
- </ol>
55
+ <% end -%>
47
56
  <% end %>
@@ -22,12 +22,12 @@
22
22
  columns = (column.form_ui_options || column.options)[:subform_columns]
23
23
  columns = active_scaffold_config_for(column.association.klass).subform.build_action_columns(columns) if columns
24
24
  -%>
25
- <h5>
25
+ <%= as_element :subform_header do %>
26
26
  <%= column.label -%>
27
27
  <%= link_to_visibility_toggle(subform_div_id, default_visible: !column.collapsed) -%>
28
- </h5>
28
+ <% end %>
29
29
  <%= content_tag :span, column.description, class: 'description' if column.description.present? %>
30
- <div id ="<%= subform_div_id %>" <%= 'style="display: none;"'.html_safe if column.collapsed -%>>
30
+ <div id="<%= subform_div_id %>" <%= 'style="display: none;"'.html_safe if column.collapsed -%>>
31
31
  <%# HACK: to be able to delete all associated records %>
32
32
  <%= hidden_field_tag "#{(opts = active_scaffold_input_options(column, scope, object: parent_record))[:name]}[0]", '', id: "#{opts[:id]}_0" if column.association.collection? %>
33
33
  <%= render subform_partial_for_column(column), column: column, parent_record: parent_record, columns: columns, associated: associated, show_blank_record: show_blank_record, scope: scope, tab_id: tab_id %>
@@ -28,17 +28,19 @@ end
28
28
 
29
29
  -%>
30
30
  <div class="footer-wrapper">
31
- <div class="footer">
31
+ <%= as_element :subform_footer do %>
32
32
  <% if show_add_new -%>
33
- <% if column.association.collection?
34
- add_label = as_(:create_another, model: column.association.klass.model_name.human)
35
- add_class = 'as_create_another'
36
- else
37
- add_label = as_(:replace_with_new)
38
- add_class = 'as_replace_with_new'
39
- end
40
- create_another_id = "#{subform_div_id}-create-another" %>
41
- <%= link_to add_label, add_new_url, id: create_another_id, remote: true, class: "as-js-button #{add_class}", style: 'display: none;' %>
33
+ <%
34
+ if column.association.collection?
35
+ add_label = as_(:create_another, model: column.association.klass.model_name.human)
36
+ add_class = 'create_another'
37
+ else
38
+ add_label = as_(:replace_with_new)
39
+ add_class = 'replace_with_new'
40
+ end
41
+ add_button_attrs = {id: "#{subform_div_id}-create-another", remote: true, class: "as-js-button as_#{add_class}", style: 'display: none;'}
42
+ %>
43
+ <%= link_to add_label, add_new_url, as_element_attributes(:"subform_#{add_class}", **add_button_attrs) %>
42
44
  <% end -%>
43
45
 
44
46
  <%= '|' if show_add_new && show_add_existing %>
@@ -47,13 +49,15 @@ end
47
49
  <% if remote_controller.respond_to?(:uses_record_select?) && remote_controller.uses_record_select? -%>
48
50
  <%= link_to_record_select as_(:add_existing), remote_controller.controller_path, record_select_params_for_add_existing(column.association, edit_associated_url, parent_record) -%>
49
51
  <% else -%>
50
- <% helper_method = association_helper_method(column.association, :sorted_association_options_find)
51
- select_options = options_from_collection_for_select(send(helper_method, column.association, nil, parent_record), :to_param, :to_label)
52
- add_existing_id = "#{subform_div_id}-add-existing"
53
- add_existing_label = column.association.collection? ? :add_existing : :replace_existing %>
52
+ <%
53
+ helper_method = association_helper_method(column.association, :sorted_association_options_find)
54
+ select_options = options_from_collection_for_select(send(helper_method, column.association, nil, parent_record), :to_param, :to_label)
55
+ add_existing_label = column.association.collection? ? :add_existing : :replace_existing
56
+ add_existing_attrs = {id: "#{subform_div_id}-add-existing", remote: true, class: "as-js-button as_#{add_existing_label}", style: 'display: none;'}
57
+ %>
54
58
  <%= select_tag 'associated_id', content_tag(:option, as_(:_select_), value: '') + select_options %>
55
- <%= link_to as_(add_existing_label), edit_associated_url, id: add_existing_id, remote: true, class: "as-js-button as_#{add_existing_label}", style: 'display: none;' %>
59
+ <%= link_to as_(add_existing_label), edit_associated_url, as_element_attributes(:subform_add_existing, **add_existing_attrs) %>
56
60
  <% end -%>
57
61
  <% end -%>
58
- </div>
62
+ <% end %>
59
63
  </div>
@@ -1,6 +1,6 @@
1
1
  <%
2
2
  record_column = column
3
- ui_options = record_column.form_ui_options || record_column.options
3
+ ui_options = record_column.form_ui_options || record_column.options if record_column
4
4
  readonly = record.readonly? || !record.authorized_for?(crud_type: :update)
5
5
  crud_type = record.new_record? ? :create : (readonly ? :read : :update)
6
6
  show_actions = false
@@ -8,7 +8,7 @@
8
8
  config = active_scaffold_config_for(record.class)
9
9
  columns ||= config.subform.columns
10
10
  column_names = columns.visible_columns_names
11
- scope = column_scope(record_column, scope, record)
11
+ scope = column_scope(record_column, scope, record) if record_column
12
12
  options = active_scaffold_input_options(config.columns[record.class.primary_key], scope, object: record)
13
13
  tr_id = "association-#{options[:id]}"
14
14
  layout ||= ui_options[:layout] || config.subform.layout
@@ -30,14 +30,13 @@
30
30
  default_col_class = ['form-element']
31
31
  flatten ||= false
32
32
  end
33
- index ||= form_association_record_counter ||= nil
34
33
 
35
34
  columns_length = 0
36
35
  columns_groups = []
37
36
  -%>
38
37
  <%= content_tag record_tag, class: 'sub-form-record' do %>
39
38
  <% unless record.errors.empty? -%>
40
- <%= content_tag error_tag, class: 'association-record-errors', id: element_messages_id(action: record.class.name.underscore, id: "#{parent_record.id}-#{index}") do %>
39
+ <%= content_tag error_tag, class: 'association-record-errors', id: element_messages_id(action: record.class.name.underscore) do %>
41
40
  <% errors = active_scaffold_error_messages_for(:record, object: record) %>
42
41
  <%= error_inner_tag ? content_tag(error_inner_tag, errors, colspan: (active_scaffold_config_for(record.class).subform.columns.length + 1 if error_inner_tag == :td)) : errors %>
43
42
  <% end %>
@@ -2,7 +2,8 @@
2
2
  <tr>
3
3
  <%
4
4
  columns ||= active_scaffold_config_for(record_class).subform.columns
5
- columns.each_column(for: record_class, crud_type: :read) do |column|
5
+ crud_type ||= :read
6
+ columns.each_column(for: record_class, crud_type: crud_type) do |column|
6
7
  next unless column.is_a? ActiveScaffold::DataStructures::Column
7
8
  next unless in_subform?(column, parent_record, parent_column)
8
9
  hidden = column_renders_as(column) == :hidden
@@ -9,15 +9,16 @@
9
9
  </tbody>
10
10
  </table>
11
11
  <% end %>
12
- <table>
13
- <thead>
14
- <tr>
12
+ <%= list_table_html do %>
13
+ <table <%= as_element_attributes :list_table, class: "list-table #{'local-sorting' if local_sorting?}" %>>
14
+ <thead <%= as_element_attributes :list_table_head %>>
15
+ <tr <%= as_element_attributes :list_table_head_row %>>
15
16
  <% columns = list_columns %>
16
17
  <%= render 'list_column_headings', columns: columns %>
17
18
  </tr>
18
19
  </thead>
19
20
  <%= render 'list_messages', columns: columns %>
20
- <tbody class="records" id="<%= active_scaffold_tbody_id %>" data-refresh-record="<%= url_for(params_for(action: :index, id: '--ID--')) %>">
21
+ <tbody <%= as_element_attributes :list_records, class: 'records', id: active_scaffold_tbody_id, data: {refresh_record: url_for(params_for(action: :index, id: '--ID--'))} %>>
21
22
  <% if !@page.empty? -%>
22
23
  <%= render partial: list_record_view, collection: @page.items, locals: {hidden: false, columns: columns, action_links: active_scaffold_config.action_links.member} %>
23
24
  <% end -%>
@@ -28,4 +29,5 @@
28
29
  </tfoot>
29
30
  <% end -%>
30
31
  </table>
32
+ <% end %>
31
33
  <%= render 'list_pagination' %>
@@ -1,5 +1,5 @@
1
1
  <% columns ||= list_columns -%>
2
- <tr id="<%= active_scaffold_calculations_id %>" class="active-scaffold-calculations">
2
+ <tr <%= as_element_attributes :list_calculations, id: active_scaffold_calculations_id, class: 'active-scaffold-calculations' %>>
3
3
  <% columns.each do |column| -%>
4
4
  <% if column.calculation? %>
5
5
  <td id="<%= active_scaffold_calculations_id(column: column) %>"><%= render_column_calculation(column) %></td>
@@ -1,8 +1,8 @@
1
1
  <% action_links = active_scaffold_config.action_links.collection -%>
2
2
  <% filters = active_scaffold_config.list.filters %>
3
- <div class="actions">
3
+ <%= as_element :list_actions, class: 'actions' do %>
4
4
  <%= display_filters(filters) %>
5
5
  <%= display_action_links(action_links, nil, skip_unauthorized: true) unless action_links.empty? %>
6
6
  <%= loading_indicator_tag(action: :table) %>
7
- </div>
8
- <h2><%= active_scaffold_config.list.user.label %></h2>
7
+ <% end %>
8
+ <%= as_element :list_title, active_scaffold_config.list.user.label %>
@@ -1,33 +1,33 @@
1
1
  <% column_count ||= columns.length + (grouped_search? ? 0 : 1) -%>
2
- <tbody class="messages">
2
+ <tbody <%= as_element_attributes :list_messages %>>
3
3
  <tr class="record even-record">
4
- <td colspan="<%= column_count -%>" class="messages-container">
4
+ <td <%= as_element_attributes :list_messages_container, colspan: column_count, class: 'messages-container' %>>
5
5
  <%= render 'list_messages_content' unless active_scaffold_config.list.messages_above_header %>
6
- <%= content_tag :div, class: 'filtered-message',
7
- style: ('display:none;' unless @filtered),
8
- data: ({search: search_params || ''} if active_scaffold_config.store_user_settings && respond_to?(:search_params)) do %>
6
+ <%= as_element :filtered_message,
7
+ style: ('display:none;' unless @filtered),
8
+ data: ({search: search_params || ''} if active_scaffold_config.store_user_settings && respond_to?(:search_params)) do %>
9
9
  <div><%= @filtered.is_a?(Array) ? render('human_conditions', columns: @filtered) : as_(active_scaffold_config.list.filtered_message) %></div>
10
10
  <% if active_scaffold_config.list.show_search_reset && @filtered -%>
11
- <div class="reset">
12
- <%= loading_indicator_tag(action: :record, id: nil) %>
13
- <%= render_action_link(active_scaffold_config.list.reset_link) %>
14
- </div>
15
- <% end -%>
11
+ <%= as_element :message_reset do %>
12
+ <%= loading_indicator_tag(action: :record, id: nil) %>
13
+ <%= render_action_link(active_scaffold_config.list.reset_link) %>
14
+ <% end -%>
15
+ <% end %>
16
16
  <% end %>
17
- <%= content_tag :div, class: 'filtered-message applied-filters',
18
- style: ('display:none;' unless active_scaffold_config.list.filter_human_message && @applied_filters.present?),
19
- data: ({search: search_params || ''} if active_scaffold_config.store_user_settings && respond_to?(:search_params)) do %>
20
- <div><%= render('human_filters', filters: @applied_filters) if active_scaffold_config.list.filter_human_message && @applied_filters.present? %></div>
21
- <% if active_scaffold_config.list.show_filter_reset && @applied_filters.present? -%>
22
- <div class="reset">
17
+ <% applied_filters = (@filter_states || {}).values.filter_map { |filter| filter[:option] if filter[:status] == :applied && !filter[:default] } %>
18
+ <%= as_element :applied_filters_message,
19
+ style: ('display:none;' unless active_scaffold_config.list.filter_human_message && applied_filters.present?) do %>
20
+ <div><%= render('human_filters', filters: applied_filters) if active_scaffold_config.list.filter_human_message && applied_filters.present? %></div>
21
+ <% if active_scaffold_config.list.show_filter_reset && applied_filters.present? -%>
22
+ <%= as_element :message_reset do %>
23
23
  <%= loading_indicator_tag(action: :record, id: nil) %>
24
24
  <%= render_action_link(active_scaffold_config.list.reset_filter_link) %>
25
- </div>
25
+ <% end -%>
26
26
  <% end -%>
27
27
  <% end %>
28
- <p id="<%= empty_message_id %>" class="empty-message" <%= ' style="display:none;" '.html_safe unless @page.empty? %>>
28
+ <%= as_element :empty_message, id: empty_message_id, class: 'empty-message', style: ('display:none;' unless @page.empty?) do %>
29
29
  <%= as_(active_scaffold_config.list.no_entries_message) %>
30
- </p>
30
+ <% end %>
31
31
  </td>
32
32
  </tr>
33
33
  </tbody>
@@ -1,8 +1,8 @@
1
- <p class="error-message message server-error" style="display:none;">
1
+ <%= server_error_msg class: 'as-msg', style: 'display:none;' do %>
2
2
  <%= as_(:internal_error).html_safe %>
3
3
  <span class="error-500"><%= as_(:error_500).html_safe %></span>
4
- <a href="#" class="close" title="<%= as_(:close).html_safe %>"><%= as_(:close).html_safe %></a>
5
- </p>
6
- <div id="<%= active_scaffold_messages_id -%>" class="action-messages">
4
+ <%= as_element :message_close, as_(:close), class: 'msg-close', title: as_(:close) %>
5
+ <% end %>
6
+ <%= as_element :list_action_messages, id: active_scaffold_messages_id, class: 'action-messages' do %>
7
7
  <%= render 'messages' %>
8
- </div>
8
+ <% end %>
@@ -1,11 +1,13 @@
1
- <div class="active-scaffold-footer">
1
+ <%= as_element :list_footer do %>
2
2
  <% if active_scaffold_config.list.pagination != :infinite -%>
3
- <div class="active-scaffold-found"><span class="active-scaffold-records"><%= @page.pager.count -%></span> <%= as_(:found, count: @page.pager.count) %></div>
3
+ <%= as_element :list_found, class: 'active-scaffold-found' do %>
4
+ <%= as_element :list_found_count, @page.pager.count, class: 'active-scaffold-records' -%> <%= as_(:found, count: @page.pager.count) %>
5
+ <% end %>
4
6
  <% end -%>
5
7
  <% if active_scaffold_config.list.pagination -%>
6
- <div class="active-scaffold-pagination<%= ' auto-paginate' if active_scaffold_config.list.auto_pagination %>">
8
+ <%= as_element :pagination_links, class: "active-scaffold-pagination #{'auto-paginate' if active_scaffold_config.list.auto_pagination}" do %>
7
9
  <%= render 'list_pagination_links', current_page: @page if @page.pager.infinite? || @page.pager.number_of_pages > 1 %>
8
- </div>
10
+ <% end -%>
9
11
  <% end -%>
10
12
  <br /><!-- to clear this block -->
11
- </div>
13
+ <% end -%>
@@ -3,7 +3,9 @@
3
3
  <% options = {'data-page-history' => controller_id, remote: true, method: :get} -%>
4
4
 
5
5
  <%= loading_indicator_tag action: :pagination %>
6
- <%= link_to as_(:previous), url_options.merge(page: current_page.number - 1), options.merge(class: 'as_paginate previous') if current_page.prev? %>
7
- <%= pagination_ajax_links current_page, url_options, options, active_scaffold_config.list.page_links_inner_window, active_scaffold_config.list.page_links_outer_window %>
8
- <%= link_to as_(:next), url_options.merge(page: current_page.number + 1), options.merge(class: 'as_paginate next') if current_page.next? %>
6
+ <%= pagination_html do %>
7
+ <%= pagination_ajax_link current_page.number - 1, url_options, options.merge(class: 'previous'), text: :previous if current_page.prev? %>
8
+ <%= pagination_ajax_links current_page, url_options, options, active_scaffold_config.list.page_links_inner_window, active_scaffold_config.list.page_links_outer_window %>
9
+ <%= pagination_ajax_link current_page.number + 1, url_options, options.merge(class: 'next'), text: :next if current_page.next? %>
10
+ <% end %>
9
11
  <% end -%>
@@ -11,18 +11,23 @@ data_refresh ||= record.to_param
11
11
  <% authorized = record.authorized_for?(crud_type: :read, column: column.name) -%>
12
12
  <% column_value = authorized ? get_column_value(record, column) : empty_field_text -%>
13
13
  <% attrs = column_attributes(column, record).merge(class: column_class(column, column_value, record)) %>
14
+ <% if local_sorting? && column.sortable? && attrs&.dig(:data, :sort_value).nil? && !column.text? && column.column %>
15
+ <% (attrs[:data] ||= {})[:sort_value] = column_sort_value(record, column) %>
16
+ <% end %>
14
17
 
15
18
  <%= content_tag :td, authorized ? render_list_column(column_value, column, record) : column_value, attrs %>
16
19
  <% end -%>
17
20
 
18
21
  <% unless grouped_search? -%>
19
- <td class="actions"><table>
20
- <tr>
21
- <td class="indicator-container">
22
- <%= loading_indicator_tag(action: :record, id: record.id) %>
23
- </td>
24
- <%= display_action_links(action_links, record, level_0_tag: :td, for: record.persisted? ? record : record.class) %>
25
- </tr>
26
- </table></td>
22
+ <td <%= as_element_attributes :record_actions_cell, class: 'actions' %>>
23
+ <table <%= as_element_attributes :record_action_links %>>
24
+ <tr>
25
+ <td class="indicator-container">
26
+ <%= loading_indicator_tag(action: :record, id: record.id) %>
27
+ </td>
28
+ <%= display_action_links(action_links, record, level_0_tag: :td, for: record.persisted? ? record : record.class) %>
29
+ </tr>
30
+ </table>
31
+ </td>
27
32
  <% end -%>
28
33
  <% end %>
@@ -1,8 +1,8 @@
1
- <%= content_tag(:div, id: active_scaffold_id, class: as_main_div_class, data: as_main_div_data) do %>
2
- <div class="active-scaffold-header">
1
+ <%= as_element(:list, id: active_scaffold_id, class: as_main_div_class, data: as_main_div_data) do %>
2
+ <%= as_element :list_header, class: 'active-scaffold-header' do %>
3
3
  <%= render 'list_header' %>
4
- </div>
5
- <table>
4
+ <% end %>
5
+ <%= as_element :before_header_table do %>
6
6
  <tbody class="before-header" id="<%= before_header_id -%>">
7
7
  <% if active_scaffold_config.list.always_show_search %>
8
8
  <% old_record, @record = @record, active_scaffold_config.model.new %>
@@ -21,7 +21,7 @@
21
21
  <% old_record, @record = @record, new_model %>
22
22
  <tr>
23
23
  <td>
24
- <div class="active-scaffold create-view <%= "#{id_from_controller params[:controller]}-view" %> view">
24
+ <div class="active-scaffold create-view <%= "#{id_from_controller params[:controller]}-view" %> view">
25
25
  <%= render 'create_form_on_list' %>
26
26
  </div>
27
27
  </td>
@@ -29,8 +29,8 @@
29
29
  <% @record = old_record %>
30
30
  <% end %>
31
31
  </tbody>
32
- </table>
33
- <div id="<%= active_scaffold_content_id-%>" class="as_content">
32
+ <% end %>
33
+ <%= as_element :list_content, id: active_scaffold_content_id, class: 'as_content' do %>
34
34
  <%= render 'list' %>
35
- </div>
35
+ <% end %>
36
36
  <% end %>
@@ -1,11 +1,11 @@
1
1
  <% for name in %i[info warning error] %>
2
2
  <% if flash[name].present? %>
3
- <div class="<%= "#{name}-message message" %>">
3
+ <%= as_element :"#{name}_message", class: 'as-msg' do %>
4
4
  <%= display_message flash[name] %>
5
5
  <% flash.delete name %>
6
6
  <% if request.xhr? %>
7
- <a href="#" class="close" title="<%= as_(:close) %>"><%= as_(:close) %></a>
7
+ <%= as_element :message_close, as_(:close), class: 'msg-close', title: as_(:close) %>
8
8
  <% end %>
9
- </div>
9
+ <% end %>
10
10
  <% end %>
11
11
  <% end %>
@@ -1,9 +1,11 @@
1
1
  <%
2
2
  record ||= @record
3
3
  active_scaffold_config ||= self.active_scaffold_config
4
- if render_field.is_a?(Hash)
4
+ ActiveScaffold.deprecator.warn "use `as: :column` when rendering render_field partial" if local_assigns[:render_field]
5
+ column ||= render_field
6
+ if column.is_a?(Hash)
5
7
  traverse ||= []
6
- render_field.each do |assoc_name, columns|
8
+ column.each do |assoc_name, columns|
7
9
  if assoc_name == :__root__
8
10
  config = params[:parent_controller] ? active_scaffold_config_for(params[:parent_controller].singularize.camelize) : controller.active_scaffold_config
9
11
  value = @form_record
@@ -24,17 +26,12 @@
24
26
  step = traverse_by_record ? "#{sub_form}:has([id$=\"#{assoc_name}_#{r.id || temp_id}\"])" : sub_form
25
27
  next_scope = column_scope(assoc_column, scope, r, temp_id) unless assoc_name == :__root__
26
28
  %>
27
- <%= render(partial: 'render_field', collection: columns, locals: {source_id: source_id, scope: next_scope, record: r, active_scaffold_config: config, traverse: traverse + [step]}) %>
29
+ <%= render(partial: 'render_field', collection: columns, as: :column, locals: {source_id: source_id, scope: next_scope, record: r, active_scaffold_config: config, traverse: traverse + [step]}) %>
28
30
  <%
29
31
  end
30
32
  end
31
33
  else
32
- column =
33
- if render_field.is_a? ActiveScaffold::DataStructures::Column
34
- render_field
35
- else
36
- active_scaffold_config.columns[render_field]
37
- end
34
+ column = active_scaffold_config.columns[column] unless column.is_a? ActiveScaffold::DataStructures::Column
38
35
  return if column.nil? # using hash may include __root__ to update parent columns when used as subform, and fail if it can be in different model's form, or when edited without subform
39
36
  return if local_assigns[:traverse].nil? && @main_columns.exclude?(column.name)
40
37
  rendered = (@rendered ||= {})[record] ||= Set.new
@@ -54,7 +51,7 @@
54
51
  if renders_as == :subform
55
52
  active_scaffold_subform_attributes(column, column_css_class)
56
53
  else
57
- {class: "form-element #{:required if column.required?(@form_action)} #{column.form_ui} #{column_css_class}", id: ''}
54
+ as_element_attributes(:form_element, class: "form-element #{:required if column.required?(@form_action)} #{form_ui_class column.form_ui} #{column_css_class}", id: '')
58
55
  end
59
56
  options[:traverse] = traverse if local_assigns[:traverse]
60
57
  html =
@@ -71,5 +68,5 @@
71
68
  -%>
72
69
 
73
70
  ActiveScaffold.render_form_field('<%= source_id %>','<%= escape_javascript(html) %>', <%= options.to_json.html_safe %>);
74
- <%= render(partial: 'render_field', collection: column.update_columns, locals: local_assigns) if column.update_columns.present? %>
71
+ <%= render(partial: 'render_field', collection: column.update_columns, as: :column, locals: local_assigns) if column.update_columns.present? %>
75
72
  <% end %>
@@ -3,13 +3,14 @@
3
3
  url_options = params_for(action: :index, id: nil, search: nil)
4
4
  submit_text ||= :search
5
5
  xhr ||= request.xhr?
6
- options = {
6
+ options = as_element_attributes(
7
+ :search_form,
7
8
  id: element_form_id(action: 'search'),
8
9
  class: "as_form search#{' live' if live_search}",
9
10
  remote: xhr,
10
11
  data: {loading: true},
11
12
  method: :get
12
- }
13
+ )
13
14
 
14
15
  hidden_params = url_options.except(:controller, :action, :id, :search).to_query.split(Rack::Utils::DEFAULT_SEP)
15
16
  -%>
@@ -20,16 +21,16 @@
20
21
  <%= hidden_field_tag(key, value) %>
21
22
  <% end -%>
22
23
  <% field_placeholder = as_(live_search ? :live_search : :search_terms) %>
23
- <%= search_field_tag :search, (search_params if search_params.is_a? String), class: 'text-input', id: search_input_id, size: 50, autocomplete: :off, placeholder: field_placeholder %>
24
- <%= submit_tag as_(submit_text), class: 'submit', style: ('display:none;' if live_search) %>
24
+ <%= search_field_tag :search, (search_params if search_params.is_a? String), as_element_attributes(:search_field, id: search_input_id, placeholder: field_placeholder) %>
25
+ <%= submit_tag as_(submit_text), as_element_attributes(:search_submit, style: ('display:none;' if live_search)) %>
25
26
  <%
26
- reset_attrs = {class: 'as_cancel reset'}
27
+ reset_attrs = {class: 'as_cancel'}
27
28
  if active_scaffold_config.search.reset_form
28
29
  reset_attrs[:data] = {reset: true}
29
30
  else
30
31
  reset_attrs.merge! remote: true, data: {refresh: true}
31
32
  end
32
33
  %>
33
- <%= link_to as_(:reset), url_for(url_options.merge(search: '')), reset_attrs unless local_assigns[:skip_reset] %>
34
+ <%= link_to as_(:reset), url_for(url_options.merge(search: '')), as_element_attributes(:search_reset, **reset_attrs) unless local_assigns[:skip_reset] %>
34
35
  <%= loading_indicator_tag(action: :search) %>
35
36
  <% end %>