bullet_train-super_scaffolding 1.0.30 → 1.0.33

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ade9510dad6e37f1400c6d5a934f76aadd00dcf0f8d31ee4bf94a22b335db337
4
- data.tar.gz: 8c6cbfd05ae88e622ba92cdbe0b7692c5d543c272fd17ed244ec039c77b0155c
3
+ metadata.gz: ee19e6fc0bb1ffec6e2d8b6f23ddf3ed1726c8aec64d07cdfa76f9a74e39f05e
4
+ data.tar.gz: a631eeed51759f3ec6590ed6e6b76ff598415a17376e44dc7229757cff73fcc9
5
5
  SHA512:
6
- metadata.gz: 175dfb1b7ba5d85c3d6f50910b96b9759f6b850f747a848a87d66afc865b6fd58f917fc9ea78d43d601f80a9366ff6517bb67850c2c26ddea48cf0d3f9d53822
7
- data.tar.gz: b52ffae0b1fd6cb1bc67c053f53b89bacd9ef6165a59d034fd6b67603c3cfd7eba0a8a8896bd47a5e7923da9d1ec708626622a69e8c074addd961f4e4cf635d6
6
+ metadata.gz: 4ca5dfe3b131cea16d618966715bf85cdd954904d8651ef9496e783927950b799c7fd5673d5eb26c180b67cc14cf6593c8b19e9997d1b72594cde5311380968b
7
+ data.tar.gz: 6b5d0ec8f81e1f5e5b94abc01229543e1bd6bbeefc56723ddcf74709040c18d1109f8798597ed4b5c65478b8bd2336783088df8dd1b2ec64919631ef77f4007c
@@ -0,0 +1,10 @@
1
+ module SuperScaffoldingHelper
2
+ unless defined?(BulletTrain::ActionModels)
3
+ def action_model_select_controller
4
+ # TODO I don't know why if I just call `yield` I get duplicate content on the page.
5
+ tag.div do
6
+ yield
7
+ end
8
+ end
9
+ end
10
+ end
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
  </div>
19
19
 
20
- <%= render 'shared/fields/color_picker', method: :color_picker_value, options: t('scaffolding/completely_concrete/tangible_things.fields.color_picker_value.options') %>
20
+ <%= render 'shared/fields/color_picker', method: :color_picker_value, options: {color_picker_options: t('scaffolding/completely_concrete/tangible_things.fields.color_picker_value.options')} %>
21
21
  <%= render 'shared/fields/cloudinary_image', method: :cloudinary_image_value %>
22
22
  <%= render 'shared/fields/date_field', method: :date_field_value %>
23
23
  <%= render 'shared/fields/date_and_time_field', method: :date_and_time_field_value %>
@@ -7,69 +7,83 @@
7
7
  <% tangible_things = tangible_things.order(:id) unless has_order?(tangible_things) %>
8
8
  <% pagy, tangible_things = pagy(tangible_things, page_param: :tangible_things_page) %>
9
9
 
10
- <%= render 'account/shared/box', pagy: pagy do |p| %>
11
- <% p.content_for :title, t(".contexts.#{context.class.name.underscore}.header") %>
12
- <% p.content_for :description do %>
13
- <%= t(".contexts.#{context.class.name.underscore}.description#{"_empty" unless tangible_things.any?}") %>
14
- <% end %>
10
+ <%= action_model_select_controller do %>
11
+ <%= updates_for context, collection do %>
12
+ <%= render 'account/shared/box', pagy: pagy do |p| %>
13
+ <% p.content_for :title, t(".contexts.#{context.class.name.underscore}.header") %>
14
+ <% p.content_for :description do %>
15
+ <%= t(".contexts.#{context.class.name.underscore}.description#{"_empty" unless tangible_things.any?}") %>
16
+ <% end %>
15
17
 
16
- <% p.content_for :table do %>
17
- <% if tangible_things.any? %>
18
- <table class="table">
19
- <thead>
20
- <tr>
21
- <%# 🚅 skip this section when scaffolding. %>
22
- <th><%= t('.fields.text_field_value.heading') %></th>
23
- <th><%= t('.fields.boolean_button_value.heading') %></th>
24
- <th><%= t('.fields.button_value.heading') %></th>
25
- <th><%= t('.fields.multiple_button_values.heading') %></th>
26
- <%# 🚅 stop any skipping we're doing now. %>
27
- <%# 🚅 super scaffolding will insert new field headers above this line. %>
28
- <th><%= t('.fields.created_at.heading') %></th>
29
- <th class="text-right"></th>
30
- </tr>
31
- </thead>
32
- <tbody>
33
- <% tangible_things.each do |tangible_thing| %>
34
- <% with_attribute_settings object: tangible_thing do %>
35
- <tr data-id="<%= tangible_thing.id %>">
18
+ <% p.content_for :table do %>
19
+ <% if tangible_things.any? %>
20
+ <table class="table">
21
+ <thead>
22
+ <tr>
23
+ <%= render "shared/tables/select_all" %>
36
24
  <%# 🚅 skip this section when scaffolding. %>
37
- <td><%= render 'shared/attributes/text', attribute: :text_field_value, url: [:account, tangible_thing] %></td>
38
- <td><%= render 'shared/attributes/boolean', attribute: :boolean_button_value %></td>
39
- <td><%= render 'shared/attributes/option', attribute: :button_value %></td>
40
- <td><%= render 'shared/attributes/options', attribute: :multiple_button_values %></td>
25
+ <th><%= t('.fields.text_field_value.heading') %></th>
26
+ <th><%= t('.fields.boolean_button_value.heading') %></th>
27
+ <th><%= t('.fields.button_value.heading') %></th>
28
+ <th><%= t('.fields.multiple_button_values.heading') %></th>
41
29
  <%# 🚅 stop any skipping we're doing now. %>
42
- <%# 🚅 super scaffolding will insert new fields above this line. %>
43
- <td><%= render 'shared/attributes/date_and_time', attribute: :created_at %></td>
44
- <td class="buttons">
45
- <% unless hide_actions %>
46
- <% if can? :edit, tangible_thing %>
47
- <%= link_to t('.buttons.shorthand.edit'), [:edit, :account, tangible_thing], class: 'button-secondary button-smaller' %>
48
- <% end %>
49
- <% if can? :destroy, tangible_thing %>
50
- <%= button_to t('.buttons.shorthand.destroy'), [:account, tangible_thing], method: :delete, data: { confirm: t('.buttons.confirmations.destroy', model_locales(tangible_thing)) }, class: 'button-secondary button-smaller' %>
51
- <% end %>
52
- <% end %>
53
- </td>
30
+ <%# 🚅 super scaffolding will insert new field headers above this line. %>
31
+ <th><%= t('.fields.created_at.heading') %></th>
32
+ <th class="text-right"></th>
54
33
  </tr>
34
+ </thead>
35
+ <tbody>
36
+ <% tangible_things.each do |tangible_thing| %>
37
+ <% with_attribute_settings object: tangible_thing do %>
38
+ <tr data-id="<%= tangible_thing.id %>">
39
+ <%= render "shared/tables/checkbox", object: tangible_thing %>
40
+ <%# 🚅 skip this section when scaffolding. %>
41
+ <td><%= render 'shared/attributes/text', attribute: :text_field_value, url: [:account, tangible_thing] %></td>
42
+ <td><%= render 'shared/attributes/boolean', attribute: :boolean_button_value %></td>
43
+ <td><%= render 'shared/attributes/option', attribute: :button_value %></td>
44
+ <td><%= render 'shared/attributes/options', attribute: :multiple_button_values %></td>
45
+ <%# 🚅 stop any skipping we're doing now. %>
46
+ <%# 🚅 super scaffolding will insert new fields above this line. %>
47
+ <td><%= render 'shared/attributes/date_and_time', attribute: :created_at %></td>
48
+ <td class="buttons">
49
+ <% unless hide_actions %>
50
+ <% if can? :edit, tangible_thing %>
51
+ <%= link_to t('.buttons.shorthand.edit'), [:edit, :account, tangible_thing], class: 'button-secondary button-smaller' %>
52
+ <% end %>
53
+ <% if can? :destroy, tangible_thing %>
54
+ <%= button_to t('.buttons.shorthand.destroy'), [:account, tangible_thing], method: :delete, data: { confirm: t('.buttons.confirmations.destroy', model_locales(tangible_thing)) }, class: 'button-secondary button-smaller' %>
55
+ <% end %>
56
+ <%# 🚅 super scaffolding will insert new action model buttons above this line. %>
57
+ <% end %>
58
+ </td>
59
+ </tr>
60
+ <% end %>
61
+ <% end %>
62
+ </tbody>
63
+ </table>
64
+ <% end %>
65
+ <% end %>
66
+
67
+ <% p.content_for :actions do %>
68
+ <% unless hide_actions %>
69
+ <% if context == absolutely_abstract_creative_concept %>
70
+ <% if can? :create, Scaffolding::CompletelyConcrete::TangibleThing.new(absolutely_abstract_creative_concept: absolutely_abstract_creative_concept) %>
71
+ <%= link_to t('.buttons.new'), [:new, :account, absolutely_abstract_creative_concept, :completely_concrete_tangible_thing], class: "#{first_button_primary(:completely_concrete_tangible_thing)} new" %>
55
72
  <% end %>
56
73
  <% end %>
57
- </tbody>
58
- </table>
59
- <% end %>
60
- <% end %>
61
74
 
62
- <% p.content_for :actions do %>
63
- <% unless hide_actions %>
64
- <% if context == absolutely_abstract_creative_concept %>
65
- <% if can? :create, Scaffolding::CompletelyConcrete::TangibleThing.new(absolutely_abstract_creative_concept: absolutely_abstract_creative_concept) %>
66
- <%= link_to t('.buttons.new'), [:new, :account, absolutely_abstract_creative_concept, :completely_concrete_tangible_thing], class: "#{first_button_primary(:completely_concrete_tangible_thing)} new" %>
75
+ <%# 🚅 super scaffolding will insert new bulk action model buttons above this line. %>
76
+ <%= render "shared/bulk_action_select" %>
77
+
78
+ <% unless hide_back %>
79
+ <%= link_to t('global.buttons.back'), [:account, context], class: "#{first_button_primary(:completely_concrete_tangible_thing)} back" %>
80
+ <% end %>
67
81
  <% end %>
68
82
  <% end %>
69
83
 
70
- <% unless hide_back %>
71
- <%= link_to t('global.buttons.back'), [:account, context], class: "#{first_button_primary(:completely_concrete_tangible_thing)} back" %>
84
+ <% p.content_for :raw_footer do %>
85
+ <%# 🚅 super scaffolding will insert new action model index views above this line. %>
72
86
  <% end %>
73
87
  <% end %>
74
88
  <% end %>
75
- <% end %>
89
+ <% end %>
@@ -1,42 +1,49 @@
1
1
  <%= render 'account/shared/page' do |p| %>
2
2
  <% p.content_for :title, t('.section') %>
3
3
  <% p.content_for :body do %>
4
- <%= render 'account/shared/box', divider: true do |p| %>
5
- <% p.content_for :title, t('.header') %>
6
- <% p.content_for :description do %>
7
- <%= t('.description') %>
8
- <%= t('.manage_description') if can? :manage, @tangible_thing %>
9
- <% end %>
4
+ <%= updates_for @tangible_thing do %>
5
+ <%= render 'account/shared/box', divider: true do |p| %>
6
+ <% p.content_for :title, t('.header') %>
7
+ <% p.content_for :description do %>
8
+ <%= t('.description') %>
9
+ <%= t('.manage_description') if can? :manage, @tangible_thing %>
10
+ <% end %>
10
11
 
11
- <% p.content_for :body do %>
12
- <% with_attribute_settings object: @tangible_thing, strategy: :label do %>
13
- <%# 🚅 skip this section when scaffolding. %>
14
- <%= render 'shared/attributes/text', attribute: :text_field_value %>
15
- <%= render 'shared/attributes/boolean', attribute: :boolean_button_value %>
16
- <%= render 'shared/attributes/option', attribute: :button_value %>
17
- <%= render 'shared/attributes/options', attribute: :multiple_button_values %>
18
- <%= render 'shared/attributes/code', attribute: :color_picker_value %>
19
- <%= render 'shared/attributes/text', attribute: :cloudinary_image_value %>
20
- <%= render 'shared/attributes/date', attribute: :date_field_value %>
21
- <%= render 'shared/attributes/date_and_time', attribute: :date_and_time_field_value %>
22
- <%= render 'shared/attributes/email', attribute: :email_field_value %>
23
- <%= render 'shared/attributes/text', attribute: :password_field_value %>
24
- <%= render 'shared/attributes/phone_number', attribute: :phone_field_value %>
25
- <%= render 'shared/attributes/option', attribute: :option_value %>
26
- <%= render 'shared/attributes/options', attribute: :multiple_option_values %>
27
- <%= render 'shared/attributes/option', attribute: :super_select_value %>
28
- <%= render 'shared/attributes/options', attribute: :multiple_super_select_values %>
29
- <%= render 'shared/attributes/block', attribute: :text_area_value %>
30
- <%= render 'shared/attributes/html', attribute: :action_text_value %>
31
- <%# 🚅 stop any skipping we're doing now. %>
32
- <%# 🚅 super scaffolding will insert new fields above this line. %>
12
+ <% p.content_for :body do %>
13
+ <% with_attribute_settings object: @tangible_thing, strategy: :label do %>
14
+ <%# 🚅 skip this section when scaffolding. %>
15
+ <%= render 'shared/attributes/text', attribute: :text_field_value %>
16
+ <%= render 'shared/attributes/boolean', attribute: :boolean_button_value %>
17
+ <%= render 'shared/attributes/option', attribute: :button_value %>
18
+ <%= render 'shared/attributes/options', attribute: :multiple_button_values %>
19
+ <%= render 'shared/attributes/code', attribute: :color_picker_value %>
20
+ <%= render 'shared/attributes/text', attribute: :cloudinary_image_value %>
21
+ <%= render 'shared/attributes/date', attribute: :date_field_value %>
22
+ <%= render 'shared/attributes/date_and_time', attribute: :date_and_time_field_value %>
23
+ <%= render 'shared/attributes/email', attribute: :email_field_value %>
24
+ <%= render 'shared/attributes/text', attribute: :password_field_value %>
25
+ <%= render 'shared/attributes/phone_number', attribute: :phone_field_value %>
26
+ <%= render 'shared/attributes/option', attribute: :option_value %>
27
+ <%= render 'shared/attributes/options', attribute: :multiple_option_values %>
28
+ <%= render 'shared/attributes/option', attribute: :super_select_value %>
29
+ <%= render 'shared/attributes/options', attribute: :multiple_super_select_values %>
30
+ <%= render 'shared/attributes/block', attribute: :text_area_value %>
31
+ <%= render 'shared/attributes/html', attribute: :action_text_value %>
32
+ <%# 🚅 stop any skipping we're doing now. %>
33
+ <%# 🚅 super scaffolding will insert new fields above this line. %>
34
+ <% end %>
33
35
  <% end %>
34
- <% end %>
35
36
 
36
- <% p.content_for :actions do %>
37
- <%= link_to t('.buttons.edit'), [:edit, :account, @tangible_thing], class: first_button_primary if can? :edit, @tangible_thing %>
38
- <%= button_to t('.buttons.destroy'), [:account, @tangible_thing], method: :delete, class: first_button_primary, data: { confirm: t('.buttons.confirmations.destroy', model_locales(@tangible_thing)) } if can? :destroy, @tangible_thing %>
39
- <%= link_to t('global.buttons.back'), [:account, @absolutely_abstract_creative_concept, :completely_concrete_tangible_things], class: first_button_primary %>
37
+ <% p.content_for :actions do %>
38
+ <%= link_to t('.buttons.edit'), [:edit, :account, @tangible_thing], class: first_button_primary if can? :edit, @tangible_thing %>
39
+ <%# 🚅 super scaffolding will insert new action model buttons above this line. %>
40
+ <%= button_to t('.buttons.destroy'), [:account, @tangible_thing], method: :delete, class: first_button_primary, data: { confirm: t('.buttons.confirmations.destroy', model_locales(@tangible_thing)) } if can? :destroy, @tangible_thing %>
41
+ <%= link_to t('global.buttons.back'), [:account, @absolutely_abstract_creative_concept, :completely_concrete_tangible_things], class: first_button_primary %>
42
+ <% end %>
43
+
44
+ <% p.content_for :raw_footer do %>
45
+ <%# 🚅 super scaffolding will insert new action model index views above this line. %>
46
+ <% end %>
40
47
  <% end %>
41
48
  <% end %>
42
49
 
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.0.30"
3
+ VERSION = "1.0.33"
4
4
  end
5
5
  end
@@ -7,16 +7,16 @@ class Scaffolding::BlockManipulator
7
7
  end
8
8
 
9
9
  #
10
- # Wrap a block of ruby code inside another block
10
+ # Wrap a block of ruby code with another block on the outside.
11
11
  #
12
- # @param [String] starting A string to search for at the start of the block. Eg "<%= updates_for context, collection do"
13
- # @param [Array] with An array with two String elements. The text that should wrap the block. Eg ["<%= action_model_select_controller do %>", "<% end %>"]
12
+ # @param [String] `starting` A string to search for at the start of the block. Eg "<%= updates_for context, collection do"
13
+ # @param [Array] `with` An array with two String elements. The text that should wrap the block. Eg ["<%= action_model_select_controller do %>", "<% end %>"]
14
14
  #
15
15
  def wrap_block(starting:, with:)
16
16
  with[0] += "\n" unless with[0].match?(/\n$/)
17
17
  with[1] += "\n" unless with[1].match?(/\n$/)
18
18
  starting_line = find_block_start(starting)
19
- end_line = find_block_end(starting_from: starting_line)
19
+ end_line = find_block_end(starting_from: starting_line, lines: @lines)
20
20
 
21
21
  final = []
22
22
  block_indent = ""
@@ -55,13 +55,13 @@ class Scaffolding::BlockManipulator
55
55
  end_line = @lines.count - 1
56
56
  if within.present?
57
57
  start_line = find_block_start(within)
58
- end_line = find_block_end(starting_from: start_line)
58
+ end_line = find_block_end(starting_from: start_line, lines: @lines)
59
59
  # start_line += 1 # ensure we actually insert the content _within_ the given block
60
60
  # end_line += 1 if end_line == start_line
61
61
  end
62
62
  if after_block.present?
63
63
  block_start = find_block_start(after_block)
64
- block_end = find_block_end(starting_from: block_start)
64
+ block_end = find_block_end(starting_from: block_start, lines: @lines)
65
65
  start_line = block_end
66
66
  end_line = @lines.count - 1
67
67
  end
@@ -102,7 +102,7 @@ class Scaffolding::BlockManipulator
102
102
 
103
103
  def insert_block(block_content, after_block:)
104
104
  block_start = find_block_start(after_block)
105
- block_end = find_block_end(starting_from: block_start)
105
+ block_end = find_block_end(starting_from: block_start, lines: @lines)
106
106
  insert_line(block_content[0], block_end)
107
107
  insert_line(block_content[1], block_end + 1)
108
108
  end
@@ -111,6 +111,18 @@ class Scaffolding::BlockManipulator
111
111
  File.write(@filepath, @lines.join)
112
112
  end
113
113
 
114
+ def find_block_parent(starting_line_number, lines)
115
+ return nil unless indentation_of(starting_line_number, lines)
116
+ cursor = starting_line_number
117
+ while cursor >= 0
118
+ unless lines[cursor].match?(/^#{indentation_of(starting_line_number, lines)}/) || !lines[cursor].present?
119
+ return cursor
120
+ end
121
+ cursor -= 1
122
+ end
123
+ nil
124
+ end
125
+
114
126
  def find_block_start(starting_string)
115
127
  matcher = Regexp.escape(starting_string)
116
128
  starting_line = 0
@@ -124,7 +136,15 @@ class Scaffolding::BlockManipulator
124
136
  starting_line
125
137
  end
126
138
 
127
- def find_block_end(starting_from:)
139
+ def find_block_end(starting_from:, lines:)
140
+ # This loop was previously in the RoutesFileManipulator.
141
+ lines.each_with_index do |line, line_number|
142
+ next unless line_number > starting_from
143
+ if /^#{indentation_of(starting_from, lines)}end\s+/.match?(line)
144
+ return line_number
145
+ end
146
+ end
147
+
128
148
  depth = 0
129
149
  current_line = starting_from
130
150
  @lines[starting_from..@lines.count].each_with_index do |line, index|
@@ -138,7 +158,12 @@ class Scaffolding::BlockManipulator
138
158
  current_line
139
159
  end
140
160
 
141
- def block_indentation_size(line_number)
142
- lines[line_number].scan(/^\s+/).first.size
161
+ # TODO: We shouldn't need this second argument, but since
162
+ # we have `lines` here and in the RoutesFileManipulator,
163
+ # the lines diverge from one another when we edit them individually.
164
+ def indentation_of(line_number, lines)
165
+ lines[line_number].match(/^( +)/)[1]
166
+ rescue
167
+ nil
143
168
  end
144
169
  end
@@ -1,3 +1,5 @@
1
+ require "scaffolding/block_manipulator"
2
+
1
3
  class Scaffolding::RoutesFileManipulator
2
4
  attr_accessor :child, :parent, :lines, :transformer_options, :block_manipulator
3
5
 
@@ -66,7 +68,7 @@ class Scaffolding::RoutesFileManipulator
66
68
  def find_namespaces(namespaces, within = nil)
67
69
  namespaces = namespaces.dup
68
70
  results = {}
69
- block_end = find_block_end(within) if within
71
+ block_end = block_manipulator.find_block_end(starting_from: within, lines: lines) if within
70
72
  lines.each_with_index do |line, line_number|
71
73
  if within
72
74
  next unless line_number > within
@@ -80,39 +82,10 @@ class Scaffolding::RoutesFileManipulator
80
82
  results
81
83
  end
82
84
 
83
- def indentation_of(line_number)
84
- lines[line_number].match(/^( +)/)[1]
85
- rescue
86
- nil
87
- end
88
-
89
- def find_block_parent(starting_line_number)
90
- return nil unless indentation_of(starting_line_number)
91
- cursor = starting_line_number
92
- while cursor >= 0
93
- unless lines[cursor].match?(/^#{indentation_of(starting_line_number)}/) || !lines[cursor].present?
94
- return cursor
95
- end
96
- cursor -= 1
97
- end
98
- nil
99
- end
100
-
101
- def find_block_end(starting_line_number)
102
- return nil unless indentation_of(starting_line_number)
103
- lines.each_with_index do |line, line_number|
104
- next unless line_number > starting_line_number
105
- if /^#{indentation_of(starting_line_number)}end\s+/.match?(line)
106
- return line_number
107
- end
108
- end
109
- nil
110
- end
111
-
112
85
  def insert_before(new_lines, line_number, options = {})
113
86
  options[:indent] ||= false
114
87
  before = lines[0..(line_number - 1)]
115
- new_lines = new_lines.map { |line| (indentation_of(line_number) + (options[:indent] ? " " : "") + line).gsub(/\s+$/, "") + "\n" }
88
+ new_lines = new_lines.map { |line| (block_manipulator.indentation_of(line_number, lines) + (options[:indent] ? " " : "") + line).gsub(/\s+$/, "") + "\n" }
116
89
  after = lines[line_number..]
117
90
  self.lines = before + (options[:prepend_newline] ? ["\n"] : []) + new_lines + after
118
91
  end
@@ -120,7 +93,7 @@ class Scaffolding::RoutesFileManipulator
120
93
  def insert_after(new_lines, line_number, options = {})
121
94
  options[:indent] ||= false
122
95
  before = lines[0..line_number]
123
- new_lines = new_lines.map { |line| (indentation_of(line_number) + (options[:indent] ? " " : "") + line).gsub(/\s+$/, "") + "\n" }
96
+ new_lines = new_lines.map { |line| (block_manipulator.indentation_of(line_number, lines) + (options[:indent] ? " " : "") + line).gsub(/\s+$/, "") + "\n" }
124
97
  after = lines[(line_number + 1)..]
125
98
  self.lines = before + new_lines + (options[:append_newline] ? ["\n"] : []) + after
126
99
  end
@@ -129,7 +102,7 @@ class Scaffolding::RoutesFileManipulator
129
102
  namespace_lines = find_namespaces(namespaces, within)
130
103
  if namespace_lines[namespaces.last]
131
104
  block_start = namespace_lines[namespaces.last]
132
- insertion_point = find_block_end(block_start)
105
+ insertion_point = block_manipulator.find_block_end(starting_from: block_start, lines: lines)
133
106
  insert_before(new_lines, insertion_point, indent: true, prepend_newline: (insertion_point > block_start + 1))
134
107
  else
135
108
  raise "we weren't able to insert the following lines into the namespace block for #{namespaces.join(" -> ")}:\n\n#{new_lines.join("\n")}"
@@ -269,7 +242,7 @@ class Scaffolding::RoutesFileManipulator
269
242
  namespace_name = match_data[2]
270
243
  local_namespace = find_namespaces([namespace_name], within)
271
244
  starting_line_number = local_namespace[namespace_name]
272
- local_namespace_block = ((starting_line_number + 1)..(find_block_end(starting_line_number) + 1))
245
+ local_namespace_block = ((starting_line_number + 1)..(block_manipulator.find_block_end(starting_from: starting_line_number, lines: lines) + 1))
273
246
 
274
247
  if local_namespace_blocks.empty?
275
248
  local_namespace_blocks << local_namespace_block
@@ -296,11 +269,11 @@ class Scaffolding::RoutesFileManipulator
296
269
  def namespace_blocks_directly_under_parent(within)
297
270
  blocks = []
298
271
  if lines[within].match?(/do$/)
299
- parent_indentation_size = block_manipulator.block_indentation_size(within)
300
- within_block_end = find_block_end(within)
272
+ parent_indentation_size = block_manipulator.indentation_of(within, lines).length
273
+ within_block_end = block_manipulator.find_block_end(starting_from: within, lines: lines)
301
274
  within.upto(within_block_end) do |line_number|
302
275
  if lines[line_number].match?(/^#{" " * (parent_indentation_size + 2)}namespace/)
303
- namespace_block_lines = line_number..find_block_end(line_number)
276
+ namespace_block_lines = line_number..block_manipulator.find_block_end(starting_from: line_number, lines: lines)
304
277
  blocks << namespace_block_lines
305
278
  end
306
279
  end
@@ -315,7 +288,7 @@ class Scaffolding::RoutesFileManipulator
315
288
 
316
289
  def lines_within(within)
317
290
  return lines unless within
318
- lines[(within + 1)..(find_block_end(within) + 1)]
291
+ lines[(within + 1)..(block_manipulator.find_block_end(starting_from: within, lines: lines) + 1)]
319
292
  end
320
293
 
321
294
  def find_or_convert_resource_block(parent_resource, options = {})
@@ -338,7 +311,7 @@ class Scaffolding::RoutesFileManipulator
338
311
  end
339
312
 
340
313
  def insert(lines_to_add, within)
341
- insertion_line = find_block_end(within)
314
+ insertion_line = block_manipulator.find_block_end(starting_from: within, lines: lines)
342
315
  result_line = insertion_line
343
316
  unless insertion_line == within + 1
344
317
  # only put the extra space if we're adding this line after a block
@@ -382,7 +355,7 @@ class Scaffolding::RoutesFileManipulator
382
355
 
383
356
  # We want to see if there are any namespaces one level above the parent itself,
384
357
  # because namespaces with the same name as the resource can exist on the same level.
385
- parent_block_start = find_block_parent(parent_within)
358
+ parent_block_start = block_manipulator.find_block_parent(parent_within, lines)
386
359
  namespace_line_within = find_or_create_namespaces(child_namespaces, parent_block_start)
387
360
  find_or_create_resource([child_resource], options: "except: collection_actions", within: namespace_line_within)
388
361
  unless find_namespaces(child_namespaces, within)[child_namespaces.last]
@@ -401,7 +374,7 @@ class Scaffolding::RoutesFileManipulator
401
374
  # resources :projects_deliverables, path: 'projects/deliverables' do
402
375
  # resources :objectives
403
376
  # end
404
- block_parent_within = find_block_parent(top_parent_namespace)
377
+ block_parent_within = block_manipulator.find_block_parent(top_parent_namespace, lines)
405
378
  parent_namespaces_and_resource = (parent_namespaces + [parent_resource]).join("_")
406
379
  parent_within = find_or_create_resource_block([parent_namespaces_and_resource], options: "path: '#{parent_namespaces_and_resource.tr("_", "/")}'", within: block_parent_within)
407
380
  find_or_create_resource(child_namespaces + [child_resource], within: parent_within)
@@ -775,6 +775,10 @@ class Scaffolding::Transformer
775
775
  # add_additional_step :yellow, transform_string("We've added a reference to a `placeholder` to the form for the select or super_select field, but unfortunately earlier versions of the scaffolded locales Yaml don't include a reference to `fields: *fields` under `form`. Please add it, otherwise your form won't be able to locate the appropriate placeholder label.")
776
776
  end
777
777
 
778
+ if type == "color_picker"
779
+ field_options[:color_picker_options] = "t('#{child.pluralize.underscore}.fields.color_picker_value.options')"
780
+ end
781
+
778
782
  # TODO: This feels incorrect.
779
783
  # Should we adjust the partials to only use `{multiple: true}` or `html_options: {multiple_true}`?
780
784
  if is_multiple
@@ -1347,7 +1351,7 @@ class Scaffolding::Transformer
1347
1351
  end
1348
1352
 
1349
1353
  unless cli_options["skip-table"]
1350
- scaffold_replace_line_in_file("./app/views/account/scaffolding/completely_concrete/tangible_things/_index.html.erb", transform_string("<tbody data-reorder=\"<%= url_for [:reorder, :account, context, collection] %>\">"), "<tbody>")
1354
+ scaffold_replace_line_in_file("./app/views/account/scaffolding/completely_concrete/tangible_things/_index.html.erb", transform_string("<tbody data-controller=\"sortable\" data-sortable-reorder-path-value=\"<%= url_for [:reorder, :account, context, collection] %>\">"), "<tbody>")
1351
1355
  end
1352
1356
 
1353
1357
  unless cli_options["skip-controller"]
data/lib/scaffolding.rb CHANGED
@@ -2,7 +2,7 @@ module Scaffolding
2
2
  def self.valid_attribute_type?(type)
3
3
  [
4
4
  "boolean",
5
- "button",
5
+ "buttons",
6
6
  "cloudinary_image",
7
7
  "color_picker",
8
8
  "date_and_time_field",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-super_scaffolding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.30
4
+ version: 1.0.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-15 00:00:00.000000000 Z
11
+ date: 2022-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard
@@ -89,6 +89,7 @@ files:
89
89
  - app/controllers/api/v1/scaffolding/completely_concrete.rb
90
90
  - app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint.rb
91
91
  - app/controllers/concerns/scaffolding/absolutely_abstract/creative_concepts/controller_support.rb
92
+ - app/helpers/super_scaffolding_helper.rb
92
93
  - app/models/scaffolding.rb
93
94
  - app/models/scaffolding/absolutely_abstract.rb
94
95
  - app/models/scaffolding/absolutely_abstract/creative_concept.rb
@@ -133,6 +134,9 @@ files:
133
134
  - app/views/account/scaffolding/completely_concrete/tangible_things/new.html.erb
134
135
  - app/views/account/scaffolding/completely_concrete/tangible_things/show.html.erb
135
136
  - app/views/account/scaffolding/completely_concrete/tangible_things/show.json.jbuilder
137
+ - app/views/shared/_bulk_action_select.html.erb
138
+ - app/views/shared/tables/_checkbox.html.erb
139
+ - app/views/shared/tables/_select_all.html.erb
136
140
  - config/locales/en/scaffolding/absolutely_abstract/creative_concepts.en.yml
137
141
  - config/locales/en/scaffolding/absolutely_abstract/creative_concepts/collaborators.en.yml
138
142
  - config/locales/en/scaffolding/completely_concrete/tangible_things.en.yml
@@ -188,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
192
  - !ruby/object:Gem::Version
189
193
  version: '0'
190
194
  requirements: []
191
- rubygems_version: 3.3.7
195
+ rubygems_version: 3.2.22
192
196
  signing_key:
193
197
  specification_version: 4
194
198
  summary: Bullet Train Super Scaffolding