bullet_train 1.6.23 → 1.6.25

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: 7c5688d90e9ae12f444c775df68efc7853c33c280f6759494f2c08d0bcd64353
4
- data.tar.gz: 868a0282a864a22d7219d3f41e5e3e98e1ded8cda5bcc26bfed02c6cb84ca358
3
+ metadata.gz: 5f81b52d6132ac315898b8d8bf2130637b61403f706121737e801b3b434b62cb
4
+ data.tar.gz: 0e9cbc8a0898ee1d9055b5874d99884e344ecd9adabfa0805e29747a551e4e03
5
5
  SHA512:
6
- metadata.gz: 0c0b78150f0fb9bf2e4ef109f5ae9c5d7a6840d5a55d301e8ee65ffe08f991fce408fb464530107bea7aa7b0a138b363921463761f2d33cafcd7a54b26cf4151
7
- data.tar.gz: a333d9dd09a487ff5db181a7cbf412177099aeb9362e537718b5dc7f1d597a35629efb126be9bda6d8feccf1aab4db248a88e2fb877bfd80c6058f883ea8f683
6
+ metadata.gz: 76d8b82d7b66f719ee155bd6029970ac5725a627e1d3d55cee6926ca339cae4cd8ad6aea0eab36841514da14c206a34c74ee995c297afd99cba1711637cd8319
7
+ data.tar.gz: 633025d258e12c22ec1f2054416cf3bf52a2827cde8ee12e0285a1ec22529fa86e9db771d1ab5c06192d661ae1f23452806615b22c8dd78e23062ed9cf19dde7
@@ -30,7 +30,7 @@
30
30
  <div class="sm:col-span-2">
31
31
  <%= render 'shared/fields/super_select', form: f, method: :time_zone,
32
32
  choices: time_zone_options_for_select(@user.time_zone, nil, ActiveSupport::TimeZone),
33
- other_options: {search: true, required: true} %>
33
+ other_options: {search: true, required: true, use_browser_time_zone: true} %>
34
34
  </div>
35
35
  </div>
36
36
 
@@ -60,14 +60,18 @@
60
60
  // figure out the rails timezone value.
61
61
  var railsValue = jsTimezoneMapping[jstz.determine().name()];
62
62
 
63
- // set the form accordingly.
64
- var $option = $("#user_time_zone option[value=\"" + railsValue + "\"]")
65
- $option.prop('selected', true);
63
+ var useBrowserTimeZone = $("#user_time_zone")[0].dataset.useBrowserTimeZone
66
64
 
67
- // update the select2 as well. is there a better way to handle this?
68
- // why don't _they_ handle this for us?
69
- $("#select2-user_time_zone-container").attr('title', $option.text());
70
- $("#select2-user_time_zone-container").text($option.text());
65
+ if (useBrowserTimeZone == "true") {
66
+ // set the form accordingly.
67
+ var $option = $("#user_time_zone option[value=\"" + railsValue + "\"]")
68
+ $option.prop('selected', true);
69
+
70
+ // update the select2 as well. is there a better way to handle this?
71
+ // why don't _they_ handle this for us?
72
+ $("#select2-user_time_zone-container").attr('title', $option.text());
73
+ $("#select2-user_time_zone-container").text($option.text());
74
+ }
71
75
 
72
76
  });
73
77
  </script>
@@ -143,10 +143,15 @@
143
143
  <% end %>
144
144
  <% end %>
145
145
 
146
- <%= render 'account/shared/menu/item', url: 'https://github.com/bullet-train-co/magic_test', label: 'Magic Test' do |p| %>
146
+ <%= render 'account/shared/menu/item', url: 'https://github.com/bullet-train-co/magic_test' do |p| %>
147
147
  <% p.icon do %>
148
148
  <i class="fal fa-check ti ti-video-camera"></i>
149
149
  <% end %>
150
+ <% p.label do %>
151
+ <span>
152
+ Magic Test <i class="ti ti-new-window ml-1"></i>
153
+ </span>
154
+ <% end %>
150
155
  <% end %>
151
156
 
152
157
  <%= render 'account/shared/menu/item', url: '/docs/application-options', label: 'Application Options' do |p| %>
@@ -207,16 +212,26 @@
207
212
  <% end %>
208
213
  <% end %>
209
214
 
210
- <%= render 'account/shared/menu/item', url: 'https://github.com/bullet-train-co/nice_partials', label: 'Nice Partials' do |p| %>
215
+ <%= render 'account/shared/menu/item', url: 'https://github.com/bullet-train-co/nice_partials' do |p| %>
211
216
  <% p.icon do %>
212
217
  <i class="fal fa-swatchbook ti ti-widget"></i>
213
218
  <% end %>
219
+ <% p.label do %>
220
+ <span>
221
+ Nice Partials <i class="ti ti-new-window ml-1"></i>
222
+ </span>
223
+ <% end %>
214
224
  <% end %>
215
225
 
216
- <%= render 'account/shared/menu/item', url: 'https://github.com/bullet-train-co/showcase', label: 'Showcase' do |p| %>
226
+ <%= render 'account/shared/menu/item', url: 'https://github.com/bullet-train-co/showcase' do |p| %>
217
227
  <% p.icon do %>
218
228
  <i class="fal fa-swatchbook ti ti-panel"></i>
219
229
  <% end %>
230
+ <% p.label do %>
231
+ <span>
232
+ Showcase <i class="ti ti-new-window ml-1"></i>
233
+ </span>
234
+ <% end %>
220
235
  <% end %>
221
236
  <% end %>
222
237
 
@@ -63,9 +63,9 @@ Don't forget to run `bundle install` and `rails restart`.
63
63
  You can get detailed information about using Super Scaffolding to generate different types of Action Models like so:
64
64
 
65
65
  ```
66
- bin/super-scaffold action-model:targets-many
67
- bin/super-scaffold action-model:targets-one
68
- bin/super-scaffold action-model:targets-one-parent
66
+ rails generate super_scaffold:action_model:targets_many
67
+ rails generate super_scaffold:action_model:targets_one
68
+ rails generate super_scaffold:action_model:targets_one_parent
69
69
  ```
70
70
 
71
71
  ## Basic Example
@@ -73,13 +73,13 @@ bin/super-scaffold action-model:targets-one-parent
73
73
  ### 1. Generate and scaffold an example `Project` model.
74
74
 
75
75
  ```
76
- bin/super-scaffold crud Project Team name:text_field
76
+ rails generate super_scaffold Project Team name:text_field
77
77
  ```
78
78
 
79
79
  ### 2. Generate and scaffold an archive action for projects.
80
80
 
81
81
  ```
82
- bin/super-scaffold action-model:targets-many Archive Project Team
82
+ rails generate super_scaffold:action_model:targets_many Archive Project Team
83
83
  ```
84
84
 
85
85
  ### 3. Implement the action logic.
@@ -61,6 +61,21 @@ Here is the same example, with search enabled:
61
61
  html_options: {multiple: true}, other_options: {search: true} %>
62
62
  </code></pre>
63
63
 
64
+ ## Overriding Browser Time Zone
65
+
66
+ When using super-select with Time Zone options, passing `use_browser_time_zone:
67
+ false` will override the automatic setting of the timezone value from the
68
+ browser.
69
+
70
+
71
+ Here is the an example setting the selected value to `@user.time_zone` which
72
+ will not be overridden by the browser time zone.
73
+
74
+ <pre><code><%= render 'shared/fields/super_select', form: f, method: :time_zone,
75
+ choices: time_zone_options_for_select(@user.time_zone, nil, ActiveSupport::TimeZone),
76
+ other_options: {search: true, required: true, use_browser_time_zone: false } %>
77
+ </code></pre>
78
+
64
79
  ## Accepting New Entries
65
80
 
66
81
  Here is an example allowing a new option to be entered by the user:
@@ -43,6 +43,14 @@ rails generate super_scaffold
43
43
  | `rails generate super_scaffold:join_model` | Scaffolds a join model (must have two existing models to join before scaffolding) |
44
44
  | `rails generate super_scaffold:oauth_provider` | Scaffolds logic to use OAuth2 with the provider of your choice |
45
45
 
46
+ The following commands are for use specifically with [Action Models](action-models).
47
+
48
+ | `rails generate` Command | Scaffolding Type |
49
+ |--------------------------|------------------|
50
+ | `rails generate super_scaffold:action_models:targets_many` | Generates an action that targets many records |
51
+ | `rails generate super_scaffold:action_models:targets_one` | Generates an action that targets one record |
52
+ | `rails generate super_scaffold:action_models:targets_one_parent` | Generates an action that targets the parent of the specified model |
53
+
46
54
  ## Examples
47
55
 
48
56
  ### 1. Basic CRUD Scaffolding
@@ -281,7 +281,39 @@ git add -A
281
281
  git commit -m "Upgrading Bullet Train gems."
282
282
  ```
283
283
 
284
- ### 5. Run Tests.
284
+ ### 5. Update `package.json``
285
+
286
+ Likewise, we'll need to manually update the version of the `@bullet_train/*` JavaScript packages in
287
+ `package.json`, by looking for these lines:
288
+
289
+ ```json
290
+ "@bullet-train/bullet-train": "1.3.0",
291
+ "@bullet-train/bullet-train-sortable": "1.3.0",
292
+ "@bullet-train/fields": "1.3.0",
293
+ ```
294
+
295
+ And upgrading the version numbers like this:
296
+
297
+ ```json
298
+ "@bullet-train/bullet-train": "1.3.1",
299
+ "@bullet-train/bullet-train-sortable": "1.3.1",
300
+ "@bullet-train/fields": "1.3.1",
301
+ ```
302
+
303
+ (As with the Gemfile, we have to do this since we didn't start explicitly tracking versions until
304
+ `1.4.0` and want to make sure that our gem versions match what the starter repo expects.)
305
+
306
+ Then run `yarn install`
307
+
308
+ Then go ahead and commit the changes.
309
+
310
+ ```
311
+ git diff
312
+ git add -A
313
+ git commit -m "Upgrading Bullet Train js packages."
314
+ ```
315
+
316
+ ### 6. Run Tests.
285
317
 
286
318
  ```
287
319
  rails test
@@ -290,7 +322,7 @@ rails test:system
290
322
 
291
323
  If anything fails, investigate the failures and get things working again, and commit those changes.
292
324
 
293
- ### 6. Merge into `main` and delete the branch.
325
+ ### 7. Merge into `main` and delete the branch.
294
326
 
295
327
  ```
296
328
  git checkout main
@@ -113,7 +113,7 @@ module BulletTrain
113
113
  package_name: nil,
114
114
  }
115
115
 
116
- result[:absolute_path] = file_path || class_path || locale_path || partial_path
116
+ result[:absolute_path] = file_path || class_path || locale_path || js_or_stylesheet_path || partial_path
117
117
 
118
118
  # If we get the partial resolver template itself, that means we couldn't find the file.
119
119
  if result[:absolute_path].match?("app/views/bullet_train/partial_resolver.html.erb") || result[:absolute_path].nil?
@@ -251,10 +251,47 @@ module BulletTrain
251
251
  nil
252
252
  end
253
253
 
254
+ # In this search, we prioritize files in local themes
255
+ # and then look in theme gems if nothing is found.
256
+ def js_or_stylesheet_path
257
+ file_name = @needle.split("/").last
258
+
259
+ # Prioritize the current theme and fall back to
260
+ # the default `light` theme if nothing is found locally.
261
+ puts "Searching under current theme: #{current_theme.blue}"
262
+
263
+ asset_globs = [
264
+ "*.js", # Include JavaScript files under the app's root directory.
265
+ "app/assets/javascript/**/*.#{current_theme}.js",
266
+ "app/assets/javascript/#{current_theme}/**/*.js",
267
+ "app/assets/stylesheets/**/*.#{current_theme}.css",
268
+ "app/assets/stylesheets/#{current_theme}/**/*.css",
269
+ ]
270
+
271
+ files = Dir.glob(asset_globs).reject { |file| file.match?("/builds/") }
272
+ absolute_file_path = files.find { |file| file.end_with?(file_name) }
273
+
274
+ if absolute_file_path
275
+ absolute_file_path
276
+ else
277
+ # Search for the file in its respective gem. Fall back to the `light` theme if no gem is available.
278
+ gem_path = [`bundle show bullet_train-themes-#{current_theme}`, `bundle show bullet_train-themes-light`].map(&:chomp).find(&:present?)
279
+ return nil unless gem_path
280
+
281
+ # At this point we can be more generic since we're inside the gem.
282
+ files = Dir.glob(["#{gem_path}/**/*.js", "#{gem_path}/**/*.css"])
283
+ files.find { |file| file.end_with?(file_name) }
284
+ end
285
+ end
286
+
254
287
  def ejected_theme?
255
- current_theme_symbol = File.read("#{Rails.root}/app/helpers/application_helper.rb").split("\n").find { |str| str.match?(/\s+:.*/) }
256
- current_theme = current_theme_symbol.delete(":").strip
257
288
  current_theme != "light" && Dir.exist?("#{Rails.root}/app/assets/stylesheets/#{current_theme}")
258
289
  end
290
+
291
+ def current_theme
292
+ msmn = Masamune::AbstractSyntaxTree.new(Rails.root.join("app/helpers/application_helper.rb").read)
293
+ current_theme_def = msmn.method_definitions.find { |node| node.token_value == "current_theme" }
294
+ msmn.symbols.find { |sym| sym.line_number == current_theme_def.line_number + 1 }.token_value
295
+ end
259
296
  end
260
297
  end
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.6.23"
2
+ VERSION = "1.6.25"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.23
4
+ version: 1.6.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-14 00:00:00.000000000 Z
11
+ date: 2024-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard