hot-glue 0.4.9.2 → 0.5.2

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: b96fed7ffa4bfccbe2dbe0d22e4dc784a70304aebf50e0ef672b2fb30c6f4641
4
- data.tar.gz: bb0398bf9529ad73c69c7703209a5888081ba0a629376a82880b726d5d74faa6
3
+ metadata.gz: f420219d9ff451f6fa20c743bef94003726a86c452fba51c8487f4d537d3c258
4
+ data.tar.gz: c031f7ffe2fb832a17ce13bd78051296baec30ed279de3d6b7b73c04dfdfd3c3
5
5
  SHA512:
6
- metadata.gz: 5064b5d5432f0f7f518b70b61a21b7d98a0182efd73a7e8784009f1e8d381edfa5f64cd6222214aefaebc1d9d30fd4adb4be870bf854fc2e8896d7bc77e66120
7
- data.tar.gz: 6d88a66a54966f7179f4c041d61670fb799c6bcdddc5a0fc5b3d984011ebc3cabbb5b8713fa05fa534b68a1f07f912f8c1ad8b955be3d0f1281618e2b04f3429
6
+ metadata.gz: f72f3d5376e8b2ca6c50e3a7c8044b83ed6b62b550a91d1c2e76cf6a4b33eeab882ea760f67ee744e6d8e5c844ba1019a51368325eab5d5f4de56bd2edcbd768
7
+ data.tar.gz: 3299ae7f5aff59f94b65b7fae3af98f31dc935e7aa3c3b132e41c05057ae790c1ee10e8888ef34ebe9d6e8ddf221f5dac7a3d1ce4a8261968bca2b5b59761739
data/.github/FUNDING.yml CHANGED
@@ -1 +1 @@
1
- custom: ["https://jfbcodes.com/p/hot-glue-in-depth-tutorial?utm_source=github.com&utm_campaign=github_hot_glue_repo_funding_link"]
1
+ custom: ["https://heliosdev.shop/p/hot-glue/","https://jfbcodes.com/p/hot-glue-in-depth-tutorial?utm_source=github.com&utm_campaign=github_hot_glue_repo_funding_link"]
data/Gemfile CHANGED
@@ -10,6 +10,7 @@ gem 'sqlite3'
10
10
  gem 'byebug'
11
11
  gem 'rails'
12
12
  gem 'devise', require: true
13
+ # gem 'progress_formatter'
13
14
 
14
15
  # for testing
15
16
  gem "rails-controller-testing", group: [:test]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.4.9.1)
4
+ hot-glue (0.5.2)
5
5
  ffaker (~> 2.16)
6
6
  kaminari (~> 1.2)
7
7
  rails (> 5.1)
data/README.md CHANGED
@@ -34,12 +34,23 @@ Hot Glue generates functionality that is quick and dirty. It lets you be crafty.
34
34
 
35
35
  | | |
36
36
  | ------------- | ------------- |
37
- | ![Teachable-225x225](https://user-images.githubusercontent.com/59002/147857335-a919e095-e6de-4718-8513-736d1f283a0b.png) | Now avaiale on [Teachable](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page) |
37
+ | ![Teachable-225x225](https://user-images.githubusercontent.com/59002/147857335-a919e095-e6de-4718-8513-736d1f283a0b.png) | Now avaiale on [Teachable](https://jfbcodes.com/courses/hot-glue-in-depth-tutorial/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page) |
38
38
 
39
39
 
40
+ ---
41
+
42
+
43
+ ## NEW GETTING STARTED VIDEO
44
+ The getting started video is newly updated with an explanation of the options for **`jsbundling-rails`/`cssbudling-rails`** when creating a new Rails 7 app.
45
+
46
+ Check it out on Youtube at https://www.youtube.com/watch?v=bKjKHMTvzZc
40
47
 
48
+ While you're over there could you give my Youtube channel a 'Subscribe'? (look for the RED SUBSCRIBE BUTTON) Thanks so much!
41
49
 
42
50
 
51
+ ---
52
+
53
+
43
54
  ## HOW EASY?
44
55
 
45
56
  ```
@@ -60,13 +71,13 @@ _If you are on Rails 6, see [LEGACY SETUP FOR RAILS 6](https://github.com/jasonf
60
71
 
61
72
  ## 1. Rails 7 New App
62
73
 
63
- There are two ways to create new apps on Rails 7: With or without ImportMap. These instructions prefer the **without Importmap** method, but to help you choose [see this post](https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-do-i-need-importmap-rails/)
74
+ There are two ways to create new apps on Rails 7: With or Without ImportMap. These instructions prefer the **without Importmap** method using ESBuild as the bundler, but to help you choose [see this post](https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-do-i-need-importmap-rails/)
64
75
 
65
- `rails new --css=bootstrap --javascript=webpack --database=postgresql`
76
+ `rails new --css=bootstrap --javascript=esbuild --database=postgresql`
66
77
 
67
- Confirm that both Stimulus and Turbo are working.
78
+ **If using JSBundling, make sure to use the new `./bin/dev` to start your server instead of the old `rails server` or else your Turbo interactions will not work correctly.**
68
79
 
69
- **If using JSBundling, make sure to use the new `bin/dev rails` instead of the old `rails server` or else your Webpack will not compile.**
80
+ Confirm that both Stimulus and Turbo are working.
70
81
 
71
82
  For the quick step-by-step guide to help you confirm that both Stimulus and Turbo are working for your new JSBundling-Rails/CSSBunlding-Rails setup [see this post](https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-new-app-with-js-bundling-css-bundling/).
72
83
 
@@ -138,18 +149,13 @@ https://github.com/FortAwesome/font-awesome-sass
138
149
 
139
150
 
140
151
  ## 5. Devise
152
+ !!! Warning: as of 2022-03-22, Devise is still not compatible out-of-the-box with Rails 7.
141
153
 
142
- (or only use --gd mode, see below)
143
-
144
- Add to your Gemfile
145
-
146
- As of now, Devise for Rails 7 is still not released so you must use **main branch**, like so:
154
+ please see https://github.com/heartcombo/devise/issues/5478 or check this README for updated information.
147
155
 
148
- `gem 'devise', branch: 'main', git: 'https://github.com/heartcombo/devise.git'`
149
156
 
150
157
  (If you are on Rails 6, you must do ALL of the steps in the Legacy Setup steps. Be sure not to skip **Legacy Step #5** below)
151
158
 
152
- For Rails 7, be sure you are on the main branch of devise above and your logins should work. (The previously necessary step of disabling turbo shown in Legacy Step #5 is no longer needed. )
153
159
 
154
160
  You MUST run the installer FIRST or else you will put your app into a non-workable state:
155
161
  ```
@@ -467,9 +473,49 @@ In this case a controller would be generated that would have NO before_action to
467
473
  Please note that this example would produce non-functional code, so you would need to manually fix your controllers to make sure `current_account` is available to the controller.
468
474
 
469
475
 
476
+ ### `--hawk=`
477
+
478
+ Hawk a foreign key that is not the object's owner to within a specified scope.
479
+
480
+ Assuming a Pet belong_to a :human, when building an Appointments scaffold, you can hawk the `pet_id` to the current human's pets. (Whoever is the authentication object.)
481
+
482
+ `--hawk=pet_id`
483
+
484
+ This is covered in [Example #3 in the Hot Glue Tutorial](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38584014)
485
+
486
+ To hawk to a scope that is not the currently authenticated user, use curly braces `{...}` to specify the scope.
487
+
488
+ `--hawk=user_id{current_user.family}`
489
+
490
+ This would hawk the Appointment's `user_id` key to any users who are within the scope of the current_user's family.
491
+
492
+ This is covered in [Example #4 in the Hot Glue Tutorial](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38787505)
493
+
494
+
470
495
  ### `--plural=`
471
496
 
472
- You don't need this if the pluralized version is just + "s" of the singular version. Only use for non-standard plurlizations, and be sure to pass it as TitleCase (as if you pluralized the model name which is non-standard for Rails)
497
+ You don't need this if the pluralized version is just + "s" of the singular version.
498
+ Only use for non-standard plurlizations, and be sure to pass it as TitleCase (as if you pluralized the model name which is non-standard for Rails)
499
+
500
+ An better alternative is to define the non-standard plurlizations globally in your app.
501
+
502
+ Make a file at `config/initializers/inflections.rb`
503
+
504
+ # Add new inflection rules using the following format
505
+ ActiveSupport::Inflector.inflections do |inflect|
506
+ inflect.irregular 'clothing', 'clothes'
507
+ inflect.irregular 'human', 'humans'
508
+
509
+
510
+ # the standard pluralization is pretty sexist and will pluralize `human` to `humen`
511
+ end
512
+
513
+
514
+ ### `--form-labels-position` (default: `after`; options are **before**, **after**, and **omit**)
515
+ By default form labels appear after the form inputs. To make them appear before or omit them, use this flag.
516
+
517
+ See also `--form-placeholder-labels` to use placeolder labels.
518
+
473
519
 
474
520
 
475
521
  ### `--exclude=`
@@ -673,13 +719,29 @@ Omits list action. Only makes sense to use this if want to create a view where y
673
719
 
674
720
  ### `--no-list-label`
675
721
 
676
- Omits list LABEL itself above the list. (Do not confuse with the field labels.)
722
+ Omits list LABEL itself above the list. (Do not confuse with the list heading which contains the field labels.)
677
723
 
678
724
  (Note that on a per model basis, you can also globally omit the label or set a unique label value using
679
725
  `@@table_label_singular` and `@@table_label_plural` on your model objects.)
680
726
 
681
727
  Note that list labels may be automatically omitted on downnested scaffolds.
682
728
 
729
+ ### `--form-placeholder-labels` (default: false)
730
+
731
+ When set to true, fields, numbers, and text areas will have placeholder labels.
732
+ Will not apply to dates, times, datetimes, dropdowns (enums + foreign keys), or booleans.
733
+
734
+ See also setting `--form-labels-position` to control position or omit normal labels.
735
+
736
+ ### `--inline-list-labels` (before, after, omit; default: omit)
737
+
738
+ Determines if field label will appear on the LIST VIEW. Note that because Hot Glue has no separate show route or page, this affects the `_show` template which is rendered as a partial from the LIST view.
739
+
740
+ Because the labels are already in the heading, this is `omit` by default. (Use with `--no-list-heading` to omit the labels in the list heading.)
741
+
742
+ Use `before` to make the labels come before or `after` to make them come after. See Version 0.5.1 release notes for an example.
743
+
744
+
683
745
  ### `--no-list-heading`
684
746
 
685
747
  Omits the heading of column names that appears above the 1st row of data.
@@ -738,12 +800,41 @@ Child portals have the headings omitted automatically (there is a heading identi
738
800
  - Date: displayed as HTML5 date picker
739
801
  - Time: displayed as HTML5 time picker
740
802
  - Boolean: displayed radio buttons yes/ no
741
- - Enum - displayed as a drop-down list (defined the enum values on your model). For Rails 6 see https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
803
+ - Enum - displayed as a drop-down list (defined the enum values on your model).
804
+ - For Rails 6 see https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
742
805
  - AFAIK, you must specify the enum definition both in your model and also in your database migration for both Rails 6 + Rails 7
743
806
 
744
807
 
745
808
  # VERSION HISTORY
746
809
 
810
+ #### ???? - v0.5.2 - Hawked Foreign Keys
811
+
812
+
813
+
814
+
815
+
816
+ #### 2022-03-12 - v0.5.1 - Inline List Labels
817
+
818
+ `--inline-list-labels` (default: `after`; options are **before**, **after**, and **omit**)
819
+
820
+ Determines if field label will appear on the LIST VIEW. Note that because Hot Glue has no separate show route or page, this affects the `_show` template which is rendered as a partial from the LIST view.
821
+
822
+ Because the labels are already in the heading, this `omit` by default. (Use with `--no-list-heading` to omit the labels in the list heading.)
823
+
824
+ Use `before` to make the labels come before or `after` to make them come after. See Version 0.5.1 release notes for an example.
825
+
826
+ #### 2022-03-06 - v0.5.0 - Label options before or after or with placeholder labels
827
+ `--form-labels-position` (default: `after`; options are **before**, **after**, and **omit**)
828
+ By default, form labels appear after the form inputs. To make them appear before or omit them, use this flag.
829
+
830
+ `--form-placeholder-labels` (default: false)
831
+
832
+ When this flag is set, fields, numbers, and text areas will have placeholder labels.
833
+ Will not apply to dates, times, datetimes, dropdowns (enums + foreign keys), or booleans.
834
+
835
+ For example see the [release notes](https://github.com/jasonfb/hot-glue/releases/tag/v0.5.0)
836
+
837
+
747
838
  #### 2022-02-14 - v0.4.9
748
839
  • Fixed issue building models with namespaced class names (e.g. `Fruits::Apple` and `Fruits::Bannana`).
749
840
  You can now build against these kinds of models natively (be sure to pass the full model name, with double-colon syntax).
@@ -1,50 +1,28 @@
1
1
  module HotGlue
2
2
  module ControllerHelper
3
-
4
3
  def timezonize(tz)
5
4
  tz = tz.to_i
6
5
  (tz >= 0 ? "+" : "-") + sprintf('%02d',tz.abs) + ":00"
7
6
  end
8
7
 
9
-
10
8
  def datetime_field_localized(form_object, field_name, value, label, timezone = nil )
11
- res = form_object.label(label,
12
- field_name,
13
- class: 'small form-text text-muted')
14
-
15
- res << form_object.text_field(field_name, class: 'form-control',
9
+ form_object.text_field(field_name, class: 'form-control',
16
10
  type: 'datetime-local',
17
- value: date_to_current_timezone(value, timezone))
18
-
19
- res << timezonize(timezone)
20
- res
11
+ value: date_to_current_timezone(value, timezone)) + timezonize(timezone)
21
12
  end
22
13
 
23
14
 
24
15
  def date_field_localized(form_object, field_name, value, label, timezone = nil )
25
-
26
- res = form_object.label(label,
27
- field_name,
28
- class: 'small form-text text-muted')
29
-
30
- res << form_object.text_field(field_name, class: 'form-control',
16
+ form_object.text_field(field_name, class: 'form-control',
31
17
  type: 'date',
32
18
  value: value )
33
-
34
- res
35
19
  end
36
20
 
37
21
  def time_field_localized(form_object, field_name, value, label, timezone = nil )
38
- res = form_object.label(label,
39
- field_name,
40
- class: 'small form-text text-muted')
41
-
42
- res << form_object.text_field(field_name, class: 'form-control',
22
+ form_object.text_field(field_name, class: 'form-control',
43
23
  type: 'time',
44
- value: date_to_current_timezone(value, timezone))
24
+ value: date_to_current_timezone(value, timezone)) + timezonize(timezone)
45
25
 
46
- res << timezonize(timezone)
47
- res
48
26
  end
49
27
 
50
28
  def current_timezone
@@ -54,40 +32,30 @@ module HotGlue
54
32
  else
55
33
  server_timezone
56
34
  end
57
- elsif true
58
- server_timezone
59
- # elsif defined?(controller) == "method"
60
- # # controller.try(:current_timezone)
61
- # elsif self.class.ancestors.include?(ApplicationController)
62
- # self.try(:current_timezone)
63
35
  else
64
- puts "no method current_user is available; please implement/override the method current_timezone IN YOUR CONTROLLER"
65
- exit
36
+ server_timezone
66
37
  end
67
38
  end
68
39
 
69
- def server_timezone
70
- Time.now.strftime("%z").to_i/100
71
- end
72
-
73
40
  def date_to_current_timezone(date, timezone = nil)
74
41
  # if the timezone is nil, use the server date'
42
+
75
43
  if timezone.nil?
76
44
  timezone = Time.now.strftime("%z").to_i/100
77
45
  end
78
46
 
79
47
  return nil if date.nil?
80
48
 
81
- begin
82
- return date.in_time_zone(timezone).strftime("%Y-%m-%dT%H:%M")
83
- rescue
84
- return nil
85
- end
49
+ return date.in_time_zone(timezone).strftime("%Y-%m-%dT%H:%M")
50
+ # begin
51
+ #
52
+ # rescue
53
+ # return nil
54
+ # end
86
55
  end
87
56
 
88
-
89
-
90
57
  def modify_date_inputs_on_params(modified_params, current_user_object = nil)
58
+
91
59
  use_timezone = (current_user_object.try(:timezone)) || Time.now.strftime("%z")
92
60
 
93
61
  modified_params = modified_params.tap do |params|
@@ -104,5 +72,27 @@ module HotGlue
104
72
  end
105
73
  modified_params
106
74
  end
75
+
76
+
77
+ def hawk_params(hawk_schema, modified_params)
78
+ @hawk_alarm = ""
79
+ hawk_schema.each do |hawk_key,hawk_definition|
80
+ hawk_root = hawk_definition[0]
81
+ hawk_scope = hawk_definition[1]
82
+ begin
83
+ eval("hawk_root.#{hawk_scope}").find(modified_params[hawk_key.to_s])
84
+ rescue ActiveRecord::RecordNotFound => e
85
+ @hawk_alarm << "You aren't allowed to set #{hawk_key.to_s} to #{modified_params[hawk_key.to_s]}. "
86
+ modified_params.tap { |hs| hs.delete(hawk_key.to_s) }
87
+ end
88
+ end
89
+ modified_params
90
+ end
91
+
92
+ private
93
+
94
+ def server_timezone
95
+ Time.now.strftime("%z").to_i/100
96
+ end
107
97
  end
108
98
  end
data/config/database.yml CHANGED
@@ -1,11 +1,11 @@
1
1
  development:
2
- adapter: sqlite3
3
- database: ../spec/dummy/db/development.sqlite3
2
+ adapter: postgresql
3
+ database: dummy_dev
4
4
  pool: 5
5
5
  timeout: 5000
6
6
 
7
7
  test:
8
- adapter: sqlite3
9
- database: ../spec/dummy/db/test.sqlite3
8
+ adapter: postgresql
9
+ database: dummy_test
10
10
  pool: 5
11
11
  timeout: 5000
@@ -87,11 +87,6 @@ module HotGlue
87
87
 
88
88
  end
89
89
 
90
- if Rails.version.split(".")[0].to_i >= 7
91
- copy_file "confirmable.js", "#{'spec/dummy/' if Rails.env.test?}app/javascript/controllers/confirmable.js"
92
- end
93
-
94
-
95
90
  begin
96
91
  if Rails.version.split(".")[0].to_i == 6
97
92
  app_js_contents = File.read("app/javascript/packs/application.js")