hot-glue 0.5.6 → 0.5.7

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: 61b8c21f0bf630a68d9861b8bb70141ce7fe0da0a0f1ae71c3bb4e69da6b081d
4
- data.tar.gz: 865d633fe279b4db0b2927801c82ec6de1ab630b4ffb7d24ffc539dfbb56d44d
3
+ metadata.gz: 542376a38c918a449ff542925f226deccdc53df8c538d01044ac1c48ecd62943
4
+ data.tar.gz: 53f6afd924df425bb32ccd61b9d592a3d21e32ad8af4a71842d8c14539fe6fd0
5
5
  SHA512:
6
- metadata.gz: 26901af291d1db0f028b14e320ed6c66908c90d94777c559bdba508c4e111b651357531f9fffc468cc419fbe16dda1d9bb6b86777c6e8f840631c4dfb7239e3d
7
- data.tar.gz: 69775a6b4a31b142e1683c2017d2b85c1fda1f7350bb4b954948a0b06bfbb990578bed98c0eedce1534e10ad78aa44b87d27deecf027f017184aa731319c62cb
6
+ metadata.gz: 7a3d4402f80c44ec09955aa53a4f9fae2c02567957d0f3f5b174a829728af5e0e57ea6add91fe974c5752eef67826cea3c5d0e1bac42bab8a838a49979f27b8e
7
+ data.tar.gz: da590a33b01a00f798c6db36e2f68289284a2b886e2e92e34eb0dbfe538b515423c95d63732bdabe19c404323d78c88491238c9f591591abbc758bc4f068879d
data/README.md CHANGED
@@ -11,16 +11,16 @@ Alternatively, you can use this tool to create a Turbo-backed *section* of your
11
11
 
12
12
  It will read your relationships and field types to generate your code for you, leaving you with a 'sourdough starter' to work from. If you modify the generated code, you're on your own if you want to preserve your changes and also re-generate scaffolding after adding fields.
13
13
 
14
- By default, it generates code that gives users full control over objects they 'own' and by default it spits out functionality giving access to all fields.
14
+ By default, it generates code that gives users full control over objects they 'own' and by default it spits out functionality giving access to all fields. (Handily, Hot Glue leaves the command you used in a comment at the top of your generated controller so you can regenerate it again in the future.)
15
15
 
16
16
  Hot Glue generates functionality that is quick and dirty. It lets you be crafty. As with a real glue gun, use it with caution.
17
17
 
18
18
  * Build plug-and-play scaffolding mixing generated ERB with the power of Hotwire and Turbo-Rails
19
19
  * Everything edits-in-place (unless you use `--big-edit`)
20
- * Automatically reads your models (make them AND migrate your database before building your scaffolding!)
20
+ * Automatically reads your models (make them, add relationships, **and** migrate your database before building your scaffolding!)
21
21
  * Excellent for CREATE-READ-UPDATE-DELETE (CRUD), lists with pagination
22
22
  * Great for prototyping, but you should learn Rails fundamentals first.
23
- * 'Packaged' with Devise, Kaminari, Rspec, FontAwesome
23
+ * 'Packaged' with Devise, Kaminari, Rspec, FontAwesome (optional)
24
24
  * Create system specs automatically along with the generated code.
25
25
  * Nest your routes model-by-model for built-in poor man's authentication.
26
26
  * Throw the scaffolding away when your app is ready to graduate to its next phase.
@@ -29,12 +29,12 @@ How is it different than Rails scaffolding?
29
29
 
30
30
  Although inspired by the Rails scaffold generators (built-in to Rails), Hot Glue does something similiar but has made opinionated decisions that deviate from the normal Rails scaffold:
31
31
 
32
- 1. The Hot Glue scaffolds are complete packages and pre-optimized for 'edit-in-place.' (the Rails scaffolds still generates views that make you flip between pages to do create/update operations)
32
+ 1. The Hot Glue scaffolds are complete packages and pre-optimized for 'edit-in-place.' (the Rails scaffolding still generates views that make you flip between pages to do create/update operations)
33
33
  2. Hot Glue does not create your models along with your scaffolding. Instead, create them first using `rails generate model X`
34
- 3. Hot Glue *reads* the fields on your database *and* the relationships defined on your models. Unlike the Rails scaffolding you must add relationships and migration your DB before building your scaffolding.
34
+ 3. Hot Glue *reads* the fields on your database *and* the relationships defined on your models. Unlike the Rails scaffolding you must add relationships and migrate your DB before building your scaffolding.
35
35
  4. Hot Glue has many more features for building layouts quickly, like choosing which fields to include or exclude and how to lay them out on the page, for stitching together related objects (nesting and child portals), and more.
36
36
 
37
- Other than the opinionated differences and additional features, Hot Glue produces code that is fundamentally very similiar and works consistent with the Rails 7 ways of working.
37
+ Other than the opinionated differences and additional features, Hot Glue produces code that is fundamentally very similiar and works consistent with the Rails 7 Hotwire & Turbo paradigms.
38
38
 
39
39
  # Get Hot Glue
40
40
 
@@ -366,13 +366,15 @@ Alternatively, you can define your own driver like so:
366
366
 
367
367
  TitleCase class name of the thing you want to build a scaffoling for.
368
368
 
369
+ ```
369
370
  rails generate hot_glue:scaffold Thing
371
+ ```
370
372
 
371
- (note: Your Thing object must belong_to an authenticated User or alternatively you must create a Gd controller, see below.)
373
+ (note: Your `Thing` object must `belong_to` an authenticated `User` or alternatively you must create a Gd controller, see below.)
372
374
 
373
375
  ## Options With Arguments
374
376
 
375
- All options two dashes (--) and these take an `=` and a value
377
+ All options begin with two dashes (`--`) and a followed by an `=` and a value
376
378
 
377
379
  ### `--namespace=`
378
380
 
@@ -608,10 +610,6 @@ ActiveSupport::Inflector.inflections do |inflect|
608
610
  end
609
611
  ```
610
612
 
611
- ### `--form-labels-position` (default: `after`; options are **before**, **after**, and **omit**)
612
- By default form labels appear after the form inputs. To make them appear before or omit them, use this flag.
613
-
614
- See also `--form-placeholder-labels` to use placeolder labels.
615
613
 
616
614
 
617
615
 
@@ -715,11 +713,31 @@ This is what would happen if 9 fields, specified in the order A,B,C,D,E,F,G,H,I,
715
713
  ### `--show-only=`
716
714
  (separate field names by COMMA)
717
715
 
718
- Any fields only the 'show-only' list will appear as non-editable on the generate form. (visible only)
716
+ Any fields only the 'show-only' list will appear as non-editable on the generated form for both new & edit actions. (visible only)
719
717
 
720
718
  IMPORTANT: By default, all fields that begin with an underscore (`_`) are automatically show-only.
721
719
 
722
- I would recommend this for fields you want globally non-editable by users in your app. For example, a counter cache or other field set only by a backend mechanism.
720
+ This is for fields you want globally non-editable by users in your app. For example, a counter cache or other field set only by a backend mechanism.
721
+
722
+
723
+ ### `--update-show-only`
724
+ (separate field names by COMMA)
725
+
726
+ Fields on the `update show only` (and not on the `show only` list) will appear as non-editible only for the **edit** action, but will still allow entry for the **create** action.
727
+
728
+ Note that Hot Glue still generates a singular partial (`_form`) for both actions, but your form will now contain statements like:
729
+
730
+ ```
731
+ <% if action_name == 'edit' %>
732
+ <%= xyz.name %><
733
+ <% else %>
734
+ <%= f.text_field :name %>
735
+ <% end %>
736
+ ```
737
+
738
+ This works for both regular fields, association fields, and alt lookup fields.
739
+
740
+
723
741
 
724
742
  ### `--ujs_syntax=true` (Default is set automatically based on whether you have turbo-rails installed)
725
743
 
@@ -812,15 +830,106 @@ Omits pagination. (All list views have pagination by default.)
812
830
  Omits list action. Only makes sense to use this if want to create a view where you only want the create button or to navigate to the update screen alternative ways. (The new/create still appears, as well the edit, update & destroy actions are still created even though there is no natural way to navigate to them.)
813
831
 
814
832
 
815
- ### `--no-list-label`
816
833
 
817
- Omits list LABEL itself above the list. (Do not confuse with the list heading which contains the field labels.)
834
+ ### `--no-create`
835
+
836
+ Omits new & create actions.
837
+
838
+ ### `--no-delete`
839
+
840
+ Omits delete button & destroy action.
841
+
842
+ ### `--big-edit`
843
+
844
+ If you do not want inline editing of your list items but instead want to fall back to full page style behavior for your edit views, use `--big-edit`. Turbo still handles the page interactions, but the user is taken to a full-screen edit page instead of an edit-in-place interaction.
845
+
846
+ ### `--display-list-after-update`
847
+
848
+ After an update-in-place normally only the edit view is swapped out for the show view of the record you just edited.
849
+
850
+ Sometimes you might want to redisplay the entire list after you make an update (for example, if your action removes that record from the result set).
851
+
852
+ To do this, use flag `--display-list-after-update`. The update will behave like delete and re-fetch all the records in the result and tell Turbo to swap out the entire list.
853
+
854
+ ### `--with-turbo-streams`
855
+
856
+ If and only if you specify `--with-turbo-streams`, your views will contain `turbo_stream_from` directives. Whereas your views will always contain `turbo_frame_tags` (wether or not this flag is specified) and will use the Turbo stream replacement mechanism for non-idempotent actions (create & update). This flag just brings the magic of live-reload to the scaffold interfaces themselves.
857
+
858
+ **_To test_**: Open the same interface in two separate browser windows. Make an edit in one window and watch your edit appear in the other window instantly.
859
+
860
+ This happens using two interconnected mechanisms:
861
+
862
+ 1) by default, all Hot Glue scaffold is wrapped in `turbo_frame_tag`s. The id of these tags is your namespace + the Rails dom_id(...). That means all Hot Glue scaffold is namespaced to the namespaces you use and won't collide with other turbo_frame_tag you might be using elsewhere
863
+
864
+ 2) by appending **model callbacks**, we can automatically broadcast updates to the users who are using the Hot Glue scaffold. The model callbacks (after_update_commit and after_destroy_commit) get appended automatically to the top of your model file. Each model callback targets the scaffold being built (so just this scaffold), using its namespace, and renders the line partial (or destroys the content in the case of delete) from the scaffolding.
865
+
866
+ please note that *creating* and *deleting* do not yet have a full & complete implementation: Your pages won't re-render the pages being viewed cross-peer (that is, between two users using the app at the same time) if the insertion or deletion causes the pagination to be off for another user.
867
+
868
+
869
+ ### `--alt-foreign-key-lookup` (Foreign Key Lookups)
870
+
871
+ `--alt-foreign-key-lookup=user_id{email}`
872
+
873
+ Let's assume a `Company` `has_many :company_users` and also a `Company` `has_many :users, through: :company_users`
874
+
875
+ Normally, you would be constructing a CompanyUsers downnest portal on the Company page. (Showing you only CompanyUsers associated with that company.)
876
+
877
+ A drop down of _all users in the_ database will be display on the screen where you create a new CompanyUser (join) record.
878
+
879
+ Let's say instead you don't want to expose the full list of all users to this controller, but instead make your user enter the full email address of the user to identify them.
880
+
881
+ Instead of a drop-down, the interface will present an input box for the user to supply an *search by* email.
882
+
883
+ ** Note: Current implementation does not work in conjunction with hawked associations to protect against users from accessing associated records not within scope.**
884
+ TODO: make it work with hawked associations to protect against users from accessing associated records not within scope
885
+
886
+
887
+ ## "Thing" Label
888
+
889
+ Note that on a per model basis, you can also globally omit the label or set a unique label value using
890
+ `@@table_label_singular` and `@@table_label_plural` on your model objects.
891
+
892
+ You have three options to specify labels explicitly with a string, and 1 option to specify a global name for which the words "Delete ___" and "New ___" will be added.
893
+
894
+ If no `--label` is specified, it will be inferred to be the Capitalized version of the name of the thing you are building, with spaces for two or more words.
818
895
 
819
- (Note that on a per model basis, you can also globally omit the label or set a unique label value using
820
- `@@table_label_singular` and `@@table_label_plural` on your model objects.)
896
+ ### `--label`
897
+
898
+ The general name of the thing, will be applied as "New ___" for the new button & form. Will be *pluralized* for list label heading, so if the word has a non-standard pluralization, be sure to specify it in `config/inflictions.rb`
899
+
900
+ If you specify anything explicitly, it will be used.
901
+ If not, a specification that exists as `@@tabel_label_singular` from the Model will be used.
902
+ If this does not exist, the Titleized (capitalized) version of the model name.
903
+
904
+ ### `--list-label-heading`
905
+ The plural of the list of things at the top of the list.
906
+ If not, a specification that exists as `@@tabel_label_plural` from the Model will be used.
907
+ If this does not exist, the UPCASE (all-uppercase) version of the model name.
908
+
909
+ ### `--new-button-label`
910
+ The button on the list that the user clicks onto to create a new record.
911
+ (Follows same rules described in the `--label` option but with the word "New" prepended.)
912
+
913
+ ### `--new-form-heading`
914
+ The text at the top of the new form that appears when the new input entry is displayed.
915
+ (Follows same rules described in the `--label` option but with the word "New" prepended.)
916
+
917
+ ### `--no-list-label`
918
+ Omits list LABEL itself above the list. (Do not confuse with the list heading which contains the field labels.)
821
919
 
822
920
  Note that list labels may be automatically omitted on downnested scaffolds.
823
921
 
922
+
923
+
924
+
925
+ ## Field Labels
926
+
927
+ ### `--form-labels-position` (default: `after`; options are **before**, **after**, and **omit**)
928
+ By default form labels appear after the form inputs. To make them appear before or omit them, use this flag.
929
+
930
+ See also `--form-placeholder-labels` to use placeolder labels.
931
+
932
+
824
933
  ### `--form-placeholder-labels` (default: false)
825
934
 
826
935
  When set to true, fields, numbers, and text areas will have placeholder labels.
@@ -841,39 +950,56 @@ Use `before` to make the labels come before or `after` to make them come after.
841
950
 
842
951
  Omits the heading of column names that appears above the 1st row of data.
843
952
 
844
- ### `--no-create`
845
953
 
846
- Omits new & create actions.
847
954
 
848
- ### `--no-delete`
849
955
 
850
- Omits delete button & destroy action.
851
956
 
852
- ### `--big-edit`
957
+ ## Special Features
853
958
 
854
- If you do not want inline editing of your list items but instead want to fall back to full page style behavior for your edit views, use `--big-edit`. Turbo still handles the page interactions, but the user is taken to a full-screen edit page instead of an edit-in-place interaction.
855
959
 
856
- ### `--display-list-after-update`
960
+ ### `--factory-creation={ ... }`
857
961
 
858
- After an update-in-place normally only the edit view is swapped out for the show view of the record you just edited.
962
+ The code you specify inside of `{` and `}` will be used to generate a new object. The factory should instantiate with any arguments (I suggest Ruby keyword arguments) and must provide a method that is the name of the thing.
859
963
 
860
- Sometimes you might want to redisplay the entire list after you make an update (for example, if your action removes that record from the result set).
964
+ For example, a user Factory might be called like so:
861
965
 
862
- To do this, use flag `--display-list-after-update`. The update will behave like delete and re-fetch all the records in the result and tell Turbo to swap out the entire list.
966
+ `rails generate hot_glue:scaffold User --factory-creation={factory = UserFactory.new(params: user_params)} --gd`
863
967
 
864
- ### `--with-turbo-streams`
968
+ (Note we are relying on the `user_params` method provided by the controller.)
865
969
 
866
- If and only if you specify `--with-turbo-streams`, your views will contain `turbo_stream_from` directives. Whereas your views will always contain `turbo_frame_tags` (wether or not this flag is specified) and will use the Turbo stream replacement mechanism for non-idempotent actions (create & update). This flag just brings the magic of live-reload to the scaffold interfaces themselves.
970
+ You must do one of two things:
971
+ 1) In the code you specify, set an instance variable `@user` to be the newly created thing. (Your code should contain something like `@thing = ` to trigger this option.)
972
+ 2) Make a local variable called `factory` **and** have a method of the name of the object (`user`) on a local variable called `factory` that your code created
867
973
 
868
- **_To test_**: Open the same interface in two separate browser windows. Make an edit in one window and watch your edit appear in the other window instantly.
974
+ (The code example above is the option for #2 because it does not contain `@user =`)
869
975
 
870
- This happens using two interconnected mechanisms:
976
+ If using number #2, Hot Glue will append this to the code specified:
977
+ ```
978
+ @user = factory.user
979
+ ```
980
+
981
+
982
+ Here's a sample UserFactory that will create a new user only if one with a matching email address doesn't exist. (Otherwise, it will update the existing record.)
983
+ Your initialize method can take any params you need it to, and using this pattern your business logic is applied consistently throughout your app. (You must, of course, use your Factory everywhere else in your app too.)
984
+
985
+ ```
986
+ class UserFactory
987
+ attr_reader :user
988
+ attr_accessor :email
989
+
990
+ def initialize(params: {})
991
+ user = User.find_or_create_by(email: params[:email])
992
+
993
+ user.update(params)
994
+ if user.new_record?
995
+ # do special new user logic here, like sending an email
996
+ end
997
+ end
998
+ end
999
+ ```
871
1000
 
872
- 1) by default, all Hot Glue scaffold is wrapped in `turbo_frame_tag`s. The id of these tags is your namespace + the Rails dom_id(...). That means all Hot Glue scaffold is namespaced to the namespaces you use and won't collide with other turbo_frame_tag you might be using elsewhere
873
1001
 
874
- 2) by appending **model callbacks**, we can automatically broadcast updates to the users who are using the Hot Glue scaffold. The model callbacks (after_update_commit and after_destroy_commit) get appended automatically to the top of your model file. Each model callback targets the scaffold being built (so just this scaffold), using its namespace, and renders the line partial (or destroys the content in the case of delete) from the scaffolding.
875
1002
 
876
- please note that *creating* and *deleting* do not yet have a full & complete implementation: Your pages won't re-render the pages being viewed cross-peer (that is, between two users using the app at the same time) if the insertion or deletion causes the pagination to be off for another user.
877
1003
 
878
1004
 
879
1005
  ## Automatic Base Controller
@@ -897,8 +1023,10 @@ Child portals have the headings omitted automatically (there is a heading identi
897
1023
  ## Field Types Supported
898
1024
 
899
1025
  - Integers that don't end with `_id`: displayed as input fields with type="number"
900
- - Foreign keys: Integers that do end with `_id` will be treated automatically as associations. You should have a Rails association defined. (Hot Glue will warn you if it can't find one.)
1026
+ - Foreign key integers: Integers that do end with `_id` will be treated automatically as associations. You should have a Rails association defined. (Hot Glue will warn you if it can't find one.)
901
1027
  - Note: if your foreign key has a nonusual class name, it should be using the `class_name:` in the model definition
1028
+ - UUIDs (as primary key): Works seamlessly for the `id` field to make your primary key a UUID (Be sure to specify UUID in your model's migration).
1029
+ - UUIDs (as foreign key): All UUIDs that are not named `id` are assumed to be foreign keys and will be treated as associations.
902
1030
  - String: displayed as small input box
903
1031
  - Text: displayed as large textarea
904
1032
  - Float: displayed as input box
@@ -908,11 +1036,68 @@ Child portals have the headings omitted automatically (there is a heading identi
908
1036
  - Boolean: displayed radio buttons yes/ no
909
1037
  - Enum - displayed as a drop-down list (defined the enum values on your model).
910
1038
  - For Rails 6 see https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
911
- - AFAIK, you must specify the enum definition both in your model and also in your database migration for both Rails 6 + Rails 7
1039
+ - You must specify the enum definition both in your model and also in your database migration for both Rails 6 + Rails 7
1040
+
1041
+ # Note about enums
1042
+
1043
+ The Rails 7 enum implementation for Postgres is very slick but has a counter-intuitive facet.
1044
+ Define your Enums in Postgres as strings:
1045
+ (database migration)
1046
+ ```
1047
+ create_enum :status, ["pending", "active", "archived"]
1048
+
1049
+ create_table :users, force: true do |t|
1050
+ t.enum :status, enum_type: "status", default: "pending", null: false
1051
+ t.timestamps
1052
+ end
1053
+ ```
1054
+
1055
+ Then define your `enum` ActiveRecord declaration with duplicate keys & strings:
1056
+ (model definition)
1057
+ ```
1058
+ enum status: {
1059
+ pending: "pending",
1060
+ active: "active",
1061
+ archived: "archived",
1062
+ disabled: "disabled",
1063
+ waiting: "waiting"
1064
+ }
1065
+ ```
1066
+
1067
+ To set the labels, use another class-level method that is a hash of keys-to-labels using a method named the same name as the enum method but with `_labels`
1068
+
1069
+ If no `_labels` method exists, Hot Glue will fallback to using the Postgres-defined names.
1070
+ ```
1071
+ def self.status_labels
1072
+ {
1073
+ pending: 'Is Pending',
1074
+ active: 'Is active',
1075
+ archived: 'Is Archived',
1076
+ disabled: 'Is Disabled',
1077
+ waiting: 'Is Waiting'
1078
+ }
1079
+ ```
1080
+
1081
+ Now, your labels will show up as defined in the `_labels` ("Is Pending", etc) instead of the database-values.
912
1082
 
913
1083
 
914
1084
  # VERSION HISTORY
915
1085
 
1086
+ #### 2023-02-13 - v0.5.7 - factory-creation, alt lookups, update show only, fixes to Enums, support for Ruby 3.2
1087
+ • See `--factory-creation` section.
1088
+
1089
+ • `--alt-lookup-foreign-keys`
1090
+ Allows you to specify that a foreign key should act as a search field, allowing the user to input a unique value (like an email) to search for a related record.
1091
+
1092
+ • `--update-show-only`
1093
+ Allows you to specify a list fields that should be show-only (non-editable) on the **edit** page but remain inputable on the **create** page.
1094
+ Note that a singular partial `_form` is still used for new & edit, but now contains `if` statements that check the action and display the show-only version only on the edit action.
1095
+
1096
+ • Syntax fix to support Ruby 3.2.0 (the installer was broken if you used Ruby 3.2)
1097
+
1098
+ • Tweaks to how Enums are display (see "Note about Enums")
1099
+
1100
+
916
1101
  #### 2023-01-02 - v0.5.6
917
1102
  - Changes the long-form of the hawk specifier to require you to use the has_many of the relationship you are hawking (previously, it was assumed). See Hawk for details
918
1103
  - Adds "Regenerate me" comment to top of all generated controllers
@@ -1133,9 +1318,9 @@ This runs both the **generated specs** and also the **internal specs**. Examine
1133
1318
 
1134
1319
  To run only the internal specs, use
1135
1320
 
1136
- `COVERGE=on rspec spec`
1321
+ `rspec spec`
1137
1322
 
1138
- Internal Test coverage as of 2022-03-23 (v0.5.2)
1323
+ Internal Test coverage as of 2023-02-10 (v0.5.7)
1139
1324
 
1140
- ![HG 84 89 coverage report](https://user-images.githubusercontent.com/59002/159719583-a956cfb3-1797-4186-b32c-237ed19e8e2b.png)
1325
+ <img width="1202" alt="Screen Shot 2023-02-10 at 4 43 59 PM" src="https://user-images.githubusercontent.com/59002/218204736-5740505b-1ec8-456f-b0fb-9c359f6f7037.png">
1141
1326
 
@@ -119,7 +119,7 @@ module HotGlue
119
119
 
120
120
 
121
121
  begin
122
- if !File.exists?("#{'spec/dummy/' if Rails.env.test?}config/hot_glue.yml")
122
+ if !File.exist?("#{'spec/dummy/' if Rails.env.test?}config/hot_glue.yml")
123
123
  yaml = {layout: layout,
124
124
  markup: @markup}.to_yaml
125
125
  File.write("#{'spec/dummy/' if Rails.env.test?}config/hot_glue.yml", yaml)
@@ -131,7 +131,7 @@ module HotGlue
131
131
 
132
132
 
133
133
  begin
134
- if !File.exists?("#{'spec/dummy/' if Rails.env.test?}spec/support/capybara_login.rb")
134
+ if !File.exist?("#{'spec/dummy/' if Rails.env.test?}spec/support/capybara_login.rb")
135
135
  copy_file "capybara_login.rb", "#{'spec/dummy/' if Rails.env.test?}spec/support/capybara_login.rb"
136
136
  end
137
137
  rescue StandardError => e
@@ -62,6 +62,7 @@ module HotGlue
62
62
  if smart_layout
63
63
  # automatic control
64
64
  #
65
+ layout_object[:columns][:button_columns] = 2
65
66
 
66
67
  if columns.size > available_columns
67
68
  if available_columns == 0
@@ -79,14 +80,18 @@ module HotGlue
79
80
  layout_object[:columns][:container] = (0..available_columns-1).collect { |x|
80
81
  [ columns[x]]
81
82
  }
83
+ layout_object[:columns][:container] = (0..available_columns-1).collect { |x| [columns[x]] }
82
84
  layout_object[:columns][:container].reject!{|x| x == [nil]}
85
+ layout_object[:columns][:size_each] = 2
83
86
  end
84
87
  elsif ! specified_grouping_mode
85
88
  # not smart and no specified grouping
86
- #
89
+ layout_object[:columns][:button_columns] = 2
90
+
87
91
  layout_object[:columns][:container] = columns.collect{|col| [col]}
88
92
 
89
93
  else # specified grouping mode -- the builder is given control
94
+ layout_object[:columns][:button_columns] = 2
90
95
 
91
96
  (0..available_columns-1).each do |int|
92
97
  layout_object[:columns][:container][int] = []
@@ -129,7 +134,7 @@ module HotGlue
129
134
  # # give some space back to the downnest
130
135
  # end
131
136
 
132
- puts "*** constructed layout columns #{layout_object.inspect}"
137
+ puts "*** constructed smart layout columns #{layout_object.inspect}"
133
138
  layout_object
134
139
  end
135
140
 
@@ -5,6 +5,7 @@ module LayoutStrategy
5
5
  @builder = scaffold_builder
6
6
  end
7
7
 
8
+ def column_classes_for_button_column; ""; end
8
9
  def button_classes; ""; end
9
10
  def button_column_style; "" ; end
10
11
  def button_style ; ""; end
@@ -1,8 +1,13 @@
1
1
  class LayoutStrategy::Bootstrap < LayoutStrategy::Base
2
2
  def button_classes
3
- " " + column_classes_for_line_fields
3
+ " " + "col-sm-#{builder.layout_object[:columns][:button_columns]}"
4
4
  end
5
5
 
6
+ def column_classes_for_button_column
7
+ "col-md-#{builder.layout_object[:columns][:button_columns]}"
8
+ end
9
+
10
+
6
11
  def column_classes_for_form_fields
7
12
  "col-md-#{builder.layout_object[:columns][:size_each]}"
8
13
  end