active_scaffold 4.0.0.rc1 → 4.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +6 -1
  3. data/README.md +5 -15
  4. data/app/assets/config/active_scaffold/manifest.js +3 -0
  5. data/app/assets/javascripts/jquery/active_scaffold.js +6 -0
  6. data/app/assets/stylesheets/active_scaffold.scss +2 -2
  7. data/app/assets/stylesheets/active_scaffold_colors.scss +7 -0
  8. data/app/assets/stylesheets/active_scaffold_layout.css +21 -0
  9. data/app/views/active_scaffold_overrides/_list.html.erb +1 -8
  10. data/app/views/active_scaffold_overrides/_list_messages.html.erb +1 -10
  11. data/app/views/active_scaffold_overrides/_list_messages_content.html.erb +8 -0
  12. data/app/views/active_scaffold_overrides/_new_record.js.erb +15 -0
  13. data/app/views/active_scaffold_overrides/_refresh_create_form.js.erb +12 -0
  14. data/app/views/active_scaffold_overrides/destroy.js.erb +6 -3
  15. data/app/views/active_scaffold_overrides/on_create.js.erb +2 -30
  16. data/lib/active_scaffold/bridges/date_picker/ext.rb +1 -1
  17. data/lib/active_scaffold/config/core.rb +5 -0
  18. data/lib/active_scaffold/data_structures/action_link_separator.rb +13 -0
  19. data/lib/active_scaffold/data_structures/action_links.rb +12 -6
  20. data/lib/active_scaffold/helpers/action_link_helpers.rb +29 -13
  21. data/lib/active_scaffold/version.rb +1 -1
  22. data/lib/generators/active_scaffold/install_generator.rb +93 -21
  23. data/vendor/assets/stylesheets/jquery-ui-theme.css.erb +0 -17
  24. metadata +35 -17
  25. data/app/assets/config/active_scaffold_manifest.js +0 -3
  26. /data/{app → vendor}/assets/images/jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  27. /data/{app → vendor}/assets/images/jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  28. /data/{app → vendor}/assets/images/jquery-ui/ui-bg_flat_10_000000_40x100.png +0 -0
  29. /data/{app → vendor}/assets/images/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  30. /data/{app → vendor}/assets/images/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  31. /data/{app → vendor}/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  32. /data/{app → vendor}/assets/images/jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  33. /data/{app → vendor}/assets/images/jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  34. /data/{app → vendor}/assets/images/jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  35. /data/{app → vendor}/assets/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
  36. /data/{app → vendor}/assets/images/jquery-ui/ui-icons_228ef1_256x240.png +0 -0
  37. /data/{app → vendor}/assets/images/jquery-ui/ui-icons_ef8c08_256x240.png +0 -0
  38. /data/{app → vendor}/assets/images/jquery-ui/ui-icons_ffd27a_256x240.png +0 -0
  39. /data/{app → vendor}/assets/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ecbb34d72c3f80ed59d3e2375baf713458478c1721a7cbbd869fc9f07969b3b
4
- data.tar.gz: 5608a6c738c0c00906b693948666324ed69e3de0edd4484d46a74c9974dabe6d
3
+ metadata.gz: 4bccfcf8d4c225ac40c3065df81306ddd3dd481c730c8154ba9f3c739a5521c0
4
+ data.tar.gz: 52eeca24fb5823cb0be1c6e9996ea5cde658902956158177e9175623d018426e
5
5
  SHA512:
6
- metadata.gz: 2197a3ce4b166d648d48afb8530f6bc9d34e3acc64b3a2eb05e09242888093d7298920dcd8ca890bb8c936495e0a743b5d4fc9bd0ccef263a4e02fe331aea770
7
- data.tar.gz: 375ce3cda4d6d08ee694b7ccb529a02ddde1e4982e641f15eea47e283e38b435c95a93a48e075174c7cf13d9ac805935e9e270d54909c34e95d5a7c6bdccf50a
6
+ metadata.gz: 06a2c2bf3b3e7f1dc622ec0f7ddb678156d61e6ade22d60ba30bd33c1b9843e310b6e2424af1f016e8bb9b6099926986f7882ebec17190173e69f29372dcdbbc
7
+ data.tar.gz: 90641599e80840772a26f2249819474cca3153927c30d20c69980d95343ebfed3fca3c2c599ee935c67859440caf53d59b3c35a47d9cac43bae1156e01f3d8f6
data/CHANGELOG.rdoc CHANGED
@@ -5,8 +5,13 @@
5
5
  - Action links can't be changed, added or removed, add all links and use ignore_method to control when they are displayed
6
6
  - Require using active_scaffold_config.override_columns to exclude or add columns
7
7
  - Thread safety enabled by default, can't be disabled, deprecate ActiveScaffold.threadsafe!
8
+ - Support separators in action links
8
9
 
9
- = 3.7.9 (not released yet)
10
+ = 3.7.10
11
+ - Move code from on_create.js.erb to partials, so it's easier to change parts, e.g. how new record is rendered
12
+ - Don't reload after deleting last record if pagination is disabled
13
+
14
+ = 3.7.9
10
15
  - Add css_class to action links, to avoid changing name, it may result confusing, deprecate name setter.
11
16
  - Add buttons to check all and uncheck all on :select form ui for collection associations, and draggable lists (active_scaffold_checkbox_list).
12
17
  - Add hidden field with locking column in base_form partial for persisted records automatically, if model uses optimistic locking.
data/README.md CHANGED
@@ -32,25 +32,17 @@ Added to Gemfile
32
32
  gem 'active_scaffold'
33
33
  ```
34
34
 
35
- For rails >= 5.1, add jquery-rails to Gemfile, and install generator will jquery to application.js before rails-ujs. Also it's possible to load jquery in your layout before application.js using CDN (e.g. jquery-rails-cdn). You can replace rails-ujs with jquery_ujs, although rails-ujs should work (never load both).
35
+ Add jquery-rails to Gemfile, or handle jquery with other tools like webpack or importmap. Also it's possible to load jquery in your layout before application.js using CDN (e.g. jquery-rails-cdn). You can replace @rails/ujs with jquery_ujs, although @rails/ujs should work (never load both).
36
36
 
37
37
  ```ruby
38
38
  gem 'jquery-rails'
39
39
  ```
40
40
 
41
- For rails >= 6.0, installer generator will create app/assets/javascripts/application.js, add it to assets.precompile array and add javascript_include_tag in layout, as ActiveScaffold doesn't work with webpack yet. Jquery may be loaded by packs or assets pipeline.
41
+ For rails 7.x, install generator will add active_scaffold to config/importmap.rb, app/javascript/application.js, and active_scaffold/manifest.js to app/assets/config/manifest.js. It will add jquery and jquery_ujs to all the 3 files if jquery-rails gem is available.
42
42
 
43
- Run the following commands, for rails 4.2
43
+ For rails 6.1, install generator will create app/assets/javascripts/application.js, add it, and active_scaffold/manifest.js, to app/assets/config/manifest.js and add javascript_include_tag in layout, as ActiveScaffold doesn't work with webpack. It will add jquery to app/assets/javascripts/application.js too if query-rails gem is available, although Jquery may be loaded by packs too and it will work, it won't add jquery_ujs or @rails/ujs as it's added to app/javascript/packs/application.js by default.
44
44
 
45
- ```console
46
- bundle install
47
- rails g active_scaffold:install
48
- bundle exec rake db:create
49
- rails g active_scaffold:resource Model [attrs]
50
- bundle exec rake db:migrate
51
- ```
52
-
53
- Or run the following commands, for rails >= 5
45
+ Run the following commands
54
46
 
55
47
  ```console
56
48
  bundle install
@@ -67,9 +59,7 @@ It's recommended to call `clear_helpers` in ApplicationController, as some helpe
67
59
  Threadsafe
68
60
  ----------
69
61
 
70
- Threadsafe can be enabled calling ActiveScaffold.threadsafe! in an initializer.
71
- It should be enabled on app start and it can't be disabled. Threadsafety is a
72
- new feature and not well tested yet.
62
+ Threadsafe is enabled always since 4.0, and it can't be disabled.
73
63
 
74
64
  Configuration
75
65
  -------------
@@ -0,0 +1,3 @@
1
+ //= link_tree ../../images
2
+ //= link_directory ../../javascripts .js
3
+ //= link_directory ../../stylesheets .css
@@ -647,6 +647,11 @@
647
647
  jQuery(tbody).parent().find('tbody.messages p.empty-message').hide();
648
648
  }
649
649
  },
650
+ show_empty_message: function(tbody) {
651
+ if (this.records_for(tbody).length != 0) {
652
+ jQuery(tbody).parent().find('tbody.messages p.empty-message').hide();
653
+ }
654
+ },
650
655
  reload_if_empty: function(tbody, url) {
651
656
  if (this.records_for(tbody).length == 0) {
652
657
  this.reload(url);
@@ -849,6 +854,7 @@
849
854
  ActiveScaffold.stripe(tbody);
850
855
  ActiveScaffold.decrement_record_count(tbody.closest('div.active-scaffold'));
851
856
  if (page_reload_url) ActiveScaffold.reload_if_empty(tbody, page_reload_url);
857
+ else ActiveScaffold.show_empty_message(tbody);
852
858
  });
853
859
  },
854
860
 
@@ -6,9 +6,9 @@
6
6
 
7
7
  For details, see the ActiveScaffold web site: https://github.com/activescaffold/active_scaffold
8
8
  */
9
+ //= require "active_scaffold_jquery_ui"
10
+ //= require "active_scaffold_extensions"
9
11
 
10
12
  @import 'active_scaffold_layout';
11
13
  @import 'active_scaffold_images';
12
- @import 'active_scaffold_jquery_ui';
13
- @import 'active_scaffold_extensions';
14
14
  @import 'active_scaffold_colors';
@@ -110,6 +110,9 @@ color: $column_color;
110
110
  color: $header_color;
111
111
  }
112
112
 
113
+ .active-scaffold div.actions a.separator {
114
+ border-color: $action_group_border_color;
115
+ }
113
116
  .active-scaffold-header div.actions a.disabled {
114
117
  color: $actions_disabled_color;
115
118
  }
@@ -191,6 +194,10 @@ color: $column_empty_color;
191
194
  border-color: $column_actions_border_color;
192
195
  }
193
196
 
197
+ .active-scaffold tr.record td.actions table td.separator {
198
+ border-color: $column_actions_border_color;
199
+ }
200
+
194
201
  .active-scaffold tr.record td.actions a.disabled {
195
202
  color: $actions_disabled_color;
196
203
  }
@@ -110,6 +110,12 @@ top: 14px;
110
110
  top: -3px;
111
111
  }
112
112
 
113
+ .active-scaffold div.actions a.separator {
114
+ border-right: 1px solid;
115
+ padding-right: 0;
116
+ padding-left: 0;
117
+ }
118
+
113
119
  .active-scaffold div.actions a.disabled {
114
120
  opacity: 0.5;
115
121
  }
@@ -251,6 +257,11 @@ text-align: right;
251
257
  padding: 0 2px;
252
258
  }
253
259
 
260
+ .active-scaffold tr.record td.actions table td.separator {
261
+ border-right: solid 1px;
262
+ padding: 0;
263
+ }
264
+
254
265
  .active-scaffold tr.record td.actions a,
255
266
  .active-scaffold tr.record td.actions div {
256
267
  font-weight: bold;
@@ -304,6 +315,16 @@ width: auto;
304
315
  text-align: left;
305
316
  }
306
317
 
318
+ .active-scaffold .actions .action_group ul li.separator {
319
+ border-top-width: 1px;
320
+ border-top-style: solid;
321
+ height: 0;
322
+ }
323
+
324
+ .active-scaffold .actions .action_group ul li.separator + li {
325
+ border-top: none;
326
+ }
327
+
307
328
  .active-scaffold .actions .action_group ul li div {
308
329
  margin: 0;
309
330
  padding: 5px 5px 5px 25px;
@@ -3,14 +3,7 @@
3
3
  <tbody>
4
4
  <tr>
5
5
  <td class="messages-container">
6
- <p class="error-message message server-error" style="display:none;">
7
- <%= as_(:internal_error).html_safe %>
8
- <span class="error-500"><%= as_(:error_500).html_safe %></span>
9
- <a href="#" class="close" title="<%= as_(:close).html_safe %>"><%= as_(:close).html_safe %></a>
10
- </p>
11
- <div id="<%= active_scaffold_messages_id -%>" class="action-messages">
12
- <%= render 'messages' %>
13
- </div>
6
+ <%= render 'list_messages_content' %>
14
7
  </td>
15
8
  </tr>
16
9
  </tbody>
@@ -2,16 +2,7 @@
2
2
  <tbody class="messages">
3
3
  <tr class="record even-record">
4
4
  <td colspan="<%= column_count -%>" class="messages-container">
5
- <% unless active_scaffold_config.list.messages_above_header %>
6
- <p class="error-message message server-error" style="display:none;">
7
- <%= as_(:internal_error).html_safe %>
8
- <span class="error-500"><%= as_(:error_500).html_safe %></span>
9
- <a href="#" class="close" title="<%= as_(:close).html_safe %>"><%= as_(:close).html_safe %></a>
10
- </p>
11
- <div id="<%= active_scaffold_messages_id -%>" class="action-messages">
12
- <%= render 'messages' %>
13
- </div>
14
- <% end %>
5
+ <%= render 'list_messages_content' unless active_scaffold_config.list.messages_above_header %>
15
6
  <%= content_tag :div, class: 'filtered-message',
16
7
  style: ('display:none;' unless @filtered),
17
8
  data: ({search: search_params || ''} if active_scaffold_config.store_user_settings && respond_to?(:search_params)) do %>
@@ -0,0 +1,8 @@
1
+ <p class="error-message message server-error" style="display:none;">
2
+ <%= as_(:internal_error).html_safe %>
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">
7
+ <%= render 'messages' %>
8
+ </div>
@@ -0,0 +1,15 @@
1
+ <% if render_parent? %>
2
+ <% if nested_singular_association? %>
3
+ if (action_link) action_link.close(true);
4
+ <% elsif params[:parent_sti] && render_parent_action == :row %>
5
+ ActiveScaffold.create_record_row_from_url(action_link, '<%= url_for(render_parent_options) %>', <%= {insert_at: insert_at}.to_json.html_safe %>);
6
+ <% else %>
7
+ ActiveScaffold.reload('<%= url_for render_parent_options %>');
8
+ <% end %>
9
+ <% elsif active_scaffold_config.create.refresh_list %>
10
+ <%= render 'refresh_list', no_history: true %>
11
+ <% elsif params[:parent_controller].nil? %>
12
+ <% new_row = render 'list_record', record: @saved_record || @record %>
13
+ ActiveScaffold.create_record_row(action_link ? action_link.scaffold() : '<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {insert_at: insert_at}.to_json.html_safe %>);
14
+ <%= render 'update_calculations' %>
15
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <% if always_show_create %>
2
+ ActiveScaffold.reset_form('<%= form_selector %>');
3
+ <% elsif params[:dont_close] %>
4
+ ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render('create_form', xhr: true)) %>');
5
+ ActiveScaffold.focus_first_element_of_form('<%= form_selector %>');
6
+ <% else %>
7
+ if (action_link) action_link.close();
8
+ <% end %>
9
+ <% if active_scaffold_config.create.action_after_create %>
10
+ var link = ActiveScaffold.find_action_link('<%= action_link_id active_scaffold_config.create.action_after_create, @record.id || @saved_record.id %>');
11
+ if (link) link.open();
12
+ <% end %>
@@ -17,10 +17,13 @@
17
17
  <%= render 'refresh_list', no_history: true %>
18
18
  <% else %>
19
19
  <%
20
- url = main_path_to_return
21
- url[:page] = [active_scaffold_config.list.user.page.to_i - 1, 1].max if url.is_a?(Hash) && active_scaffold_config.actions.include?(:list)
20
+ if active_scaffold_config.actions.exclude?(:list) || active_scaffold_config.list.pagination
21
+ url = main_path_to_return
22
+ url[:page] = [active_scaffold_config.list.user.page.to_i - 1, 1].max if url.is_a?(Hash) && active_scaffold_config.actions.include?(:list)
23
+ url = url_for(url)
24
+ end
22
25
  %>
23
- ActiveScaffold.delete_record_row('<%= element_row_id(action: 'list', id: params[:id]) %>', '<%= url_for(url) %>');
26
+ ActiveScaffold.delete_record_row('<%= element_row_id(action: 'list', id: params[:id]) %>', '<%= url %>');
24
27
  <%= render 'update_calculations' %>
25
28
  <% end %>
26
29
  <% else %>
@@ -12,36 +12,8 @@ action_link = ActiveScaffold.find_action_link('<%= form_selector %>');
12
12
  if (action_link) action_link.update_flash_messages('<%= escape_javascript(render('messages')) %>');
13
13
  <% end -%>
14
14
  <% if successful? -%>
15
- <% if render_parent? %>
16
- <% if nested_singular_association? %>
17
- if (action_link) action_link.close(true);
18
- <% elsif params[:parent_sti] && render_parent_action == :row %>
19
- ActiveScaffold.create_record_row_from_url(action_link,'<%= url_for(render_parent_options) %>', <%= {insert_at: insert_at}.to_json.html_safe %>);
20
- <% else %>
21
- ActiveScaffold.reload('<%= url_for render_parent_options %>');
22
- <% end %>
23
- <% elsif active_scaffold_config.create.refresh_list %>
24
- <%= render 'refresh_list', no_history: true %>
25
- <% elsif params[:parent_controller].nil? %>
26
- <% new_row = render 'list_record', record: @saved_record || @record %>
27
- ActiveScaffold.create_record_row(action_link ? action_link.scaffold() : '<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {insert_at: insert_at}.to_json.html_safe %>);
28
- <%= render 'update_calculations' %>
29
- <% end %>
30
-
31
- <% unless render_parent? %>
32
- <% if always_show_create %>
33
- ActiveScaffold.reset_form('<%= form_selector %>');
34
- <% elsif params[:dont_close] %>
35
- ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render('create_form', xhr: true)) %>');
36
- ActiveScaffold.focus_first_element_of_form('<%= form_selector %>');
37
- <% else %>
38
- if (action_link) action_link.close();
39
- <% end %>
40
- <% if active_scaffold_config.create.action_after_create %>
41
- var link = ActiveScaffold.find_action_link('<%= action_link_id active_scaffold_config.create.action_after_create, @record.id || @saved_record.id %>');
42
- if (link) link.open();
43
- <% end %>
44
- <% end %>
15
+ <%= render 'new_record', insert_at: insert_at %>
16
+ <%= render 'refresh_create_form', always_show_create: always_show_create, form_selector: form_selector unless render_parent? %>
45
17
  <% else %>
46
18
  ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render('create_form', xhr: true)) %>');
47
19
  ActiveScaffold.scroll_to('<%= form_selector %>', true);
@@ -4,7 +4,7 @@ class ActiveScaffold::Bridges::DatePicker
4
4
  super
5
5
  return unless ActiveScaffold::Bridges::DatePicker.default_ui
6
6
 
7
- types = %i[date datetime]
7
+ types = %i[date datetime timestamp timestamptz]
8
8
  date_picker_fields = _columns.filter_map { |c| {name: c.name.to_sym, type: c.type} if types.include?(c.type) }
9
9
  # check to see if file column was used on the model
10
10
  return if date_picker_fields.empty?
@@ -305,6 +305,11 @@ module ActiveScaffold::Config
305
305
  include ActiveScaffold::Configurable
306
306
  user_attr :cache_action_link_urls, :cache_association_options, :conditional_get_support,
307
307
  :timestamped_messages, :highlight_messages
308
+ attr_writer :label
309
+
310
+ def label(options = {})
311
+ @label ? as_(@label, options) : @conf.label(options)
312
+ end
308
313
 
309
314
  def method_missing(name, *args)
310
315
  value = @conf.actions.include?(name) ? @conf.send(name) : super
@@ -0,0 +1,13 @@
1
+ class ActionLinkSeparator
2
+ def initialize(weight)
3
+ @weight = weight
4
+ end
5
+
6
+ attr_reader :weight
7
+
8
+ def ==(other)
9
+ other == :separator
10
+ end
11
+
12
+ def name_to_cache; end # :nodoc:
13
+ end
@@ -34,6 +34,12 @@ module ActiveScaffold::DataStructures
34
34
  end
35
35
  alias << add
36
36
 
37
+ def add_separator(weight = 0)
38
+ raise 'Call add_separator on a group' if name == :root
39
+
40
+ add_to_set ActionLinkSeparator.new(weight)
41
+ end
42
+
37
43
  def add_to_set(link)
38
44
  @set << link
39
45
  end
@@ -51,6 +57,8 @@ module ActiveScaffold::DataStructures
51
57
  def [](val)
52
58
  links = []
53
59
  @set.each do |item|
60
+ next if item == :separator
61
+
54
62
  if item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
55
63
  collected = item[val]
56
64
  links << collected unless collected.nil?
@@ -64,6 +72,8 @@ module ActiveScaffold::DataStructures
64
72
  def find_duplicate(link)
65
73
  links = []
66
74
  @set.each do |item|
75
+ next if item == :separator
76
+
67
77
  if item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
68
78
  collected = item.find_duplicate(link)
69
79
  links << collected unless collected.nil?
@@ -76,6 +86,8 @@ module ActiveScaffold::DataStructures
76
86
 
77
87
  def delete(val)
78
88
  each(include_set: true) do |link, set|
89
+ next if link == :separator
90
+
79
91
  if link.action.to_s == val.to_s
80
92
  set.delete link
81
93
  break
@@ -110,12 +122,6 @@ module ActiveScaffold::DataStructures
110
122
  end
111
123
  end
112
124
 
113
- def collect_by_type(type = nil)
114
- links = []
115
- subgroup(type).each(type) { |link| links << link }
116
- links
117
- end
118
-
119
125
  def collect
120
126
  @set
121
127
  end
@@ -35,33 +35,49 @@ module ActiveScaffold
35
35
  options[:level] ||= 0
36
36
  options[:first_action] = true
37
37
  output = ActiveSupport::SafeBuffer.new
38
+ prev_link = separator = nil
38
39
 
39
40
  action_links.each(reverse: options.delete(:reverse), groups: true) do |link|
41
+ if link == :separator
42
+ separator = true if prev_link
43
+ next
44
+ end
45
+ content = nil
40
46
  if link.is_a? ActiveScaffold::DataStructures::ActionLinks
41
- unless link.empty?
42
- options[:level] += 1
43
- content = display_action_links(link, record, options, &block)
44
- options[:level] -= 1
45
- if content.present?
46
- output << display_action_link(link, content, record, options)
47
- options[:first_action] = false
48
- end
49
- end
47
+ content = display_action_link_group(link, record, options, &block) unless link.empty?
50
48
  elsif !skip_action_link?(link, *Array(options[:for]))
51
49
  authorized, reason = action_link_authorized?(link, *Array(options[:for]))
52
50
  next if !authorized && options[:skip_unauthorized]
53
51
 
54
- output << display_action_link(link, nil, record, options.merge(authorized: authorized, not_authorized_reason: reason))
52
+ content = display_action_link(link, nil, record, options.merge(authorized: authorized, not_authorized_reason: reason))
55
53
  options[:first_action] = false
56
54
  end
55
+ next if content.blank?
56
+
57
+ prev_link = true
58
+ output << display_action_link_separator(options) if separator
59
+ output << content
60
+ separator = false
57
61
  end
58
62
  output
59
63
  end
60
64
 
65
+ def display_action_link_group(link, record, options, &block)
66
+ options[:level] += 1
67
+ content = display_action_links(link, record, options, &block)
68
+ options[:level] -= 1
69
+ display_action_link(link, content, record, options).tap { options[:first_action] = false } if content.present?
70
+ end
71
+
72
+ def display_action_link_separator(options)
73
+ tag = options[:level_0_tag] || :a if options[:level].zero?
74
+ content_tag(tag || :li, '&nbsp;'.html_safe, class: 'separator')
75
+ end
76
+
61
77
  def display_action_link(link, content, record, options)
62
78
  if content
63
79
  html_classes = hover_via_click? ? 'hover_click ' : ''
64
- if (options[:level]).zero?
80
+ if options[:level].zero?
65
81
  html_classes << 'action_group'
66
82
  group_tag = :div
67
83
  else
@@ -73,9 +89,9 @@ module ActiveScaffold
73
89
  end
74
90
  else
75
91
  content = render_action_link(link, record, options)
76
- content = content_tag(:li, content, class: ('top' if options[:first_action])) unless (options[:level]).zero?
92
+ content = content_tag(:li, content, class: ('top' if options[:first_action])) unless options[:level].zero?
77
93
  end
78
- content = content_tag(options[:level_0_tag], content, options[:options_level_0_tag]) if (options[:level]).zero? && options[:level_0_tag]
94
+ content = content_tag(options[:level_0_tag], content, options[:options_level_0_tag]) if options[:level].zero? && options[:level_0_tag]
79
95
  content
80
96
  end
81
97
 
@@ -3,7 +3,7 @@ module ActiveScaffold
3
3
  MAJOR = 4
4
4
  MINOR = 0
5
5
  PATCH = 0
6
- FIX = 'rc1'
6
+ FIX = 'rc2'.freeze
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, FIX].compact.join('.')
9
9
  end
@@ -11,21 +11,29 @@ module ActiveScaffold
11
11
  route 'concern :active_scaffold_association, ActiveScaffold::Routing::Association.new'
12
12
  end
13
13
 
14
- def add_to_javascript_manifest
15
- file = 'app/assets/javascripts/application.js'
16
- unless File.exist?(file)
17
- create_javascript_manifest file
18
- return
19
- end
20
- original_js = File.binread(file)
21
- if original_js.include?('require active_scaffold')
22
- say_status('skipped', "insert into #{file}", :yellow)
23
- else
24
- insert_into_file file, after: %r{//= require +.*ujs['"]?\n} do
25
- "//= require active_scaffold\n"
14
+ IMPORTMAP = 'config/importmap.rb'.freeze
15
+ JS_ASSET = 'app/assets/javascripts/application.js'.freeze
16
+ JS_APP = 'app/javascript/application.js'.freeze
17
+ MANIFEST = 'app/assets/config/manifest.js'.freeze
18
+
19
+ def add_javascript
20
+ if File.exist?(IMPORTMAP)
21
+ add_to_importmap
22
+ add_to_js_app
23
+ elsif File.exist?(JS_ASSET) # rails 6.1
24
+ original_js = File.binread(JS_ASSET)
25
+ if original_js.include?('require active_scaffold')
26
+ say_status('skipped', "insert into #{JS_ASSET}", :yellow)
27
+ else
28
+ insert_into_file JS_ASSET, after: %r{//= require +.*ujs['"]?\n} do
29
+ "//= require active_scaffold\n"
30
+ end
31
+ add_to_manifest 'active_scaffold/manifest.js'
26
32
  end
33
+ setup_jquery JS_ASSET, original_js
34
+ else
35
+ create_javascript_manifest JS_ASSET
27
36
  end
28
- setup_jquery file, original_js
29
37
  end
30
38
 
31
39
  def add_to_stylesheet_manifest
@@ -44,10 +52,70 @@ module ActiveScaffold
44
52
 
45
53
  protected
46
54
 
55
+ def add_to_importmap
56
+ original_js = File.binread(IMPORTMAP)
57
+ if original_js.match?(/^pin +['"]active_scaffold['"](?=,|$)/)
58
+ say_status('skipped', "append active_scaffold to #{IMPORTMAP}", :yellow)
59
+ else
60
+ append_to_file IMPORTMAP do
61
+ "pin 'active_scaffold'\n"
62
+ end
63
+ end
64
+ if Object.const_defined?(:Jquery)
65
+ if original_js.match?(/^pin +['"]jquery['"](?=,|$)/)
66
+ say_status('skipped', "append jquery to #{IMPORTMAP}", :yellow)
67
+ else
68
+ append_to_file IMPORTMAP do
69
+ "pin 'jquery'\n"
70
+ end
71
+ end
72
+ if original_js.match?(%r{^pin +['"](jquery_ujs|@rails/ujs)['"](?=,|$)})
73
+ say_status('skipped', "append jquery_ujs to #{IMPORTMAP}", :yellow)
74
+ else
75
+ append_to_file IMPORTMAP do
76
+ "pin 'jquery_ujs'\n"
77
+ end
78
+ end
79
+ else
80
+ say_status('missing', 'no jquery-rails gem, load jquery, and jquery_ujs or @rails/ujs, in your layout, or add jquery-rails ' \
81
+ "to Gemfile and add pin \"jquery\" and pin \"jquery_ujs\" or pin \"@rails/ujs\", to #{IMPORTMAP}", :red)
82
+ end
83
+ end
84
+
85
+ def add_to_js_app
86
+ original_js = File.binread(JS_APP)
87
+ if original_js.match?(/^import +['"]active_scaffold['"]/)
88
+ say_status('skipped', "append active_scaffold to #{JS_APP}", :yellow)
89
+ else
90
+ append_to_file JS_APP do
91
+ "import 'active_scaffold'\n"
92
+ end
93
+ end
94
+ manifest = ['active_scaffold/manifest.js']
95
+ if Object.const_defined?(:Jquery)
96
+ if original_js.match?(/^import +['"]jquery['"]/)
97
+ say_status('skipped', "append jquery to #{JS_APP}", :yellow)
98
+ else
99
+ manifest << 'jquery.js'
100
+ insert_into_file JS_APP, before: /import +['"]active_scaffold['"]\n/ do
101
+ "import 'jquery'\n"
102
+ end
103
+ end
104
+ if original_js.match?(%r{^import +(['"]jquery_ujs['"]|Rails from ['"]@rails/ujs['"])})
105
+ say_status('skipped', "append jquery_ujs to #{JS_APP}", :yellow)
106
+ else
107
+ manifest << 'jquery_ujs.js'
108
+ insert_into_file JS_APP, before: /import +['"]active_scaffold['"]\n/ do
109
+ "import 'jquery_ujs'\n"
110
+ end
111
+ end
112
+ end
113
+ add_to_manifest(*manifest)
114
+ end
115
+
47
116
  def create_javascript_manifest(file)
48
117
  FileUtils.mkdir_p File.dirname(file)
49
- File.open(file, 'w') do |f|
50
- f << "// This is a manifest file that'll be compiled into application.js, which will include all the files
118
+ js_content = "// This is a manifest file that'll be compiled into application.js, which will include all the files
51
119
  // listed below.
52
120
  //
53
121
  // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
@@ -61,20 +129,24 @@ module ActiveScaffold
61
129
  //
62
130
  //= require active_scaffold
63
131
  "
64
- say_status('create', file)
65
- end
132
+ File.open(file, 'w') { |f| f << js_content } unless options[:pretend]
133
+ say_status('create', file)
66
134
  insert_into_file 'app/views/layouts/application.html.erb', after: /javascript_pack_tag 'application'.*\n/ do
67
135
  " <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload', 'data-turbo-track': 'reload' %>\n"
68
136
  end
69
- append_to_file 'config/initializers/assets.rb' do
70
- "Rails.application.config.assets.precompile += %w( application.js )\n"
137
+ add_to_manifest 'application.js', 'active_scaffold/manifest.js'
138
+ setup_jquery file, js_content, where: 'active_scaffold'
139
+ end
140
+
141
+ def add_to_manifest(*files)
142
+ append_to_file MANIFEST do
143
+ files.map { |file| "//= link #{file}\n" }.join
71
144
  end
72
- setup_jquery file, where: 'active_scaffold'
73
145
  end
74
146
 
75
147
  def setup_jquery(file, original_js = nil, where: 'ujs')
76
148
  original_js ||= File.binread(file)
77
- if defined? Jquery
149
+ if Object.const_defined?(:Jquery)
78
150
  unless original_js.include?('require jquery')
79
151
  insert_into_file file, before: %r{//= require +.*#{where}['"]?\n} do
80
152
  "//= require jquery\n"
@@ -1,20 +1,3 @@
1
- /*
2
- *= depend_on_asset "jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png"
3
- *= depend_on_asset "jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png"
4
- *= depend_on_asset "jquery-ui/ui-bg_flat_10_000000_40x100.png"
5
- *= depend_on_asset "jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png"
6
- *= depend_on_asset "jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png"
7
- *= depend_on_asset "jquery-ui/ui-bg_glass_65_ffffff_1x400.png"
8
- *= depend_on_asset "jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png"
9
- *= depend_on_asset "jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png"
10
- *= depend_on_asset "jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png"
11
- *= depend_on_asset "jquery-ui/ui-icons_222222_256x240.png"
12
- *= depend_on_asset "jquery-ui/ui-icons_228ef1_256x240.png"
13
- *= depend_on_asset "jquery-ui/ui-icons_ef8c08_256x240.png"
14
- *= depend_on_asset "jquery-ui/ui-icons_ffd27a_256x240.png"
15
- *= depend_on_asset "jquery-ui/ui-icons_ffffff_256x240.png"
16
- */
17
-
18
1
  /* Component containers
19
2
  ----------------------------------*/
20
3
  .ui-widget-content { border: 1px solid #dddddd; background: #eeeeee url(<%= image_path('jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png') %>) 50% top repeat-x; color: #333333; }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.rc1
4
+ version: 4.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Many, see README
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-03 00:00:00.000000000 Z
11
+ date: 2024-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sassc-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
55
69
  description: Save time and headaches, and create a more easily maintainable set of
56
70
  pages, with ActiveScaffold. ActiveScaffold handles all your CRUD (create, read,
57
71
  update, delete) user interface needs, leaving you more time to focus on more challenging
@@ -65,7 +79,7 @@ files:
65
79
  - CHANGELOG.rdoc
66
80
  - LICENSE.md
67
81
  - README.md
68
- - app/assets/config/active_scaffold_manifest.js
82
+ - app/assets/config/active_scaffold/manifest.js
69
83
  - app/assets/images/active_scaffold/add.png
70
84
  - app/assets/images/active_scaffold/arrow_down.png
71
85
  - app/assets/images/active_scaffold/arrow_up.png
@@ -80,20 +94,6 @@ files:
80
94
  - app/assets/images/active_scaffold/indicator.gif
81
95
  - app/assets/images/active_scaffold/magnifier.png
82
96
  - app/assets/images/active_scaffold/refresh.png
83
- - app/assets/images/jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png
84
- - app/assets/images/jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png
85
- - app/assets/images/jquery-ui/ui-bg_flat_10_000000_40x100.png
86
- - app/assets/images/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png
87
- - app/assets/images/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png
88
- - app/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png
89
- - app/assets/images/jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png
90
- - app/assets/images/jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png
91
- - app/assets/images/jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png
92
- - app/assets/images/jquery-ui/ui-icons_222222_256x240.png
93
- - app/assets/images/jquery-ui/ui-icons_228ef1_256x240.png
94
- - app/assets/images/jquery-ui/ui-icons_ef8c08_256x240.png
95
- - app/assets/images/jquery-ui/ui-icons_ffd27a_256x240.png
96
- - app/assets/images/jquery-ui/ui-icons_ffffff_256x240.png
97
97
  - app/assets/javascripts/active_scaffold.js.erb
98
98
  - app/assets/javascripts/jquery/active_scaffold.js
99
99
  - app/assets/javascripts/jquery/active_scaffold_chosen.js
@@ -129,11 +129,14 @@ files:
129
129
  - app/views/active_scaffold_overrides/_list_header.html.erb
130
130
  - app/views/active_scaffold_overrides/_list_inline_adapter.html.erb
131
131
  - app/views/active_scaffold_overrides/_list_messages.html.erb
132
+ - app/views/active_scaffold_overrides/_list_messages_content.html.erb
132
133
  - app/views/active_scaffold_overrides/_list_pagination.html.erb
133
134
  - app/views/active_scaffold_overrides/_list_pagination_links.html.erb
134
135
  - app/views/active_scaffold_overrides/_list_record.html.erb
135
136
  - app/views/active_scaffold_overrides/_list_with_header.html.erb
136
137
  - app/views/active_scaffold_overrides/_messages.html.erb
138
+ - app/views/active_scaffold_overrides/_new_record.js.erb
139
+ - app/views/active_scaffold_overrides/_refresh_create_form.js.erb
137
140
  - app/views/active_scaffold_overrides/_refresh_list.js.erb
138
141
  - app/views/active_scaffold_overrides/_render_field.js.erb
139
142
  - app/views/active_scaffold_overrides/_row.html.erb
@@ -269,6 +272,7 @@ files:
269
272
  - lib/active_scaffold/core.rb
270
273
  - lib/active_scaffold/data_structures/action_columns.rb
271
274
  - lib/active_scaffold/data_structures/action_link.rb
275
+ - lib/active_scaffold/data_structures/action_link_separator.rb
272
276
  - lib/active_scaffold/data_structures/action_links.rb
273
277
  - lib/active_scaffold/data_structures/actions.rb
274
278
  - lib/active_scaffold/data_structures/association.rb
@@ -324,6 +328,20 @@ files:
324
328
  - lib/tasks/brakeman.rake
325
329
  - public/blank.html
326
330
  - shoulda_macros/macros.rb
331
+ - vendor/assets/images/jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png
332
+ - vendor/assets/images/jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png
333
+ - vendor/assets/images/jquery-ui/ui-bg_flat_10_000000_40x100.png
334
+ - vendor/assets/images/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png
335
+ - vendor/assets/images/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png
336
+ - vendor/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png
337
+ - vendor/assets/images/jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png
338
+ - vendor/assets/images/jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png
339
+ - vendor/assets/images/jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png
340
+ - vendor/assets/images/jquery-ui/ui-icons_222222_256x240.png
341
+ - vendor/assets/images/jquery-ui/ui-icons_228ef1_256x240.png
342
+ - vendor/assets/images/jquery-ui/ui-icons_ef8c08_256x240.png
343
+ - vendor/assets/images/jquery-ui/ui-icons_ffd27a_256x240.png
344
+ - vendor/assets/images/jquery-ui/ui-icons_ffffff_256x240.png
327
345
  - vendor/assets/javascripts/jquery-ui-timepicker-addon.js
328
346
  - vendor/assets/javascripts/jquery.ba-throttle-debounce.js
329
347
  - vendor/assets/javascripts/jquery.visible.min.js
@@ -1,3 +0,0 @@
1
- //= link_tree ../images
2
- //= link_directory ../javascripts .js
3
- //= link active_scaffold.scss