hot-glue 0.5.14 → 0.5.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +74 -0
  3. data/.github/workflows/test.yml +33 -14
  4. data/.gitignore +0 -2
  5. data/.ruby-version +1 -1
  6. data/Gemfile +4 -2
  7. data/Gemfile.lock +280 -0
  8. data/README.md +9 -1
  9. data/lib/generators/hot_glue/direct_upload_install_generator.rb +1 -1
  10. data/lib/generators/hot_glue/dropzone_install_generator.rb +1 -1
  11. data/lib/generators/hot_glue/field_factory.rb +4 -1
  12. data/lib/generators/hot_glue/fields/association_field.rb +73 -6
  13. data/lib/generators/hot_glue/fields/attachment_field.rb +7 -3
  14. data/lib/generators/hot_glue/fields/boolean_field.rb +21 -0
  15. data/lib/generators/hot_glue/fields/date_field.rb +13 -0
  16. data/lib/generators/hot_glue/fields/date_time_field.rb +13 -2
  17. data/lib/generators/hot_glue/fields/enum_field.rb +39 -6
  18. data/lib/generators/hot_glue/fields/field.rb +43 -3
  19. data/lib/generators/hot_glue/fields/float_field.rb +9 -0
  20. data/lib/generators/hot_glue/fields/integer_field.rb +4 -0
  21. data/lib/generators/hot_glue/fields/string_field.rb +17 -0
  22. data/lib/generators/hot_glue/fields/text_field.rb +17 -0
  23. data/lib/generators/hot_glue/fields/time_field.rb +20 -0
  24. data/lib/generators/hot_glue/fields/uuid_field.rb +1 -1
  25. data/lib/generators/hot_glue/flash_notices_install_generator.rb +1 -1
  26. data/lib/generators/hot_glue/install_generator.rb +15 -9
  27. data/lib/generators/hot_glue/markup_templates/erb.rb +14 -279
  28. data/lib/generators/hot_glue/scaffold_generator.rb +3 -5
  29. data/lib/hotglue/version.rb +1 -1
  30. data/script/test +9 -14
  31. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c93b089a5dfd19941c88d9b330f0305dee83315bf7b8a6af436321dad842ac0b
4
- data.tar.gz: cf17d5a487fdf1ae4230647923b42d344465bf1e81a06eb6eef0caa75282eb2c
3
+ metadata.gz: 1a4b8f9da30750e8df7e69820c0bd934c0f8b16080bb21f5e5412d49c773dd28
4
+ data.tar.gz: 66b8fa328ca3f96f12e13c7df2f6006a730ff635078dd7e109d0d42467985502
5
5
  SHA512:
6
- metadata.gz: f9c6f8fdd02d3cd09e7c9e6a46a5a82c7125475b18f11fafa1cc3c609c4e7376c7c2cfcbc3a18483bd2027a69adfff859b62fa5d2405dabf371f4086247b240d
7
- data.tar.gz: 51b3736cb2715e6387a13a98a4fe12bf450eee827679d80a6079d3b62546d31db234c4a818e03e801f07881ebd45da289b34b7c61dd5821d25db8084c8de6a61
6
+ metadata.gz: 45e3e6d56cf8125b67383f68985888a8d131cf2a68643d41e1015f3298b7a0175ff6752a790daed42db151f59b36f567e53b1f293240f393a64498730ee123bd
7
+ data.tar.gz: 82c3d1439c5333da6f0427994de3d962a0767453432cc1edd25b7df27532c4e264b033421eb2ff8a3bb2885a1882d6495f58141eceafc3ac04848dda4f240f63
@@ -0,0 +1,74 @@
1
+ # more about orbs: https://circleci.com/docs/2.0/using-orbs/
2
+ version: 2.1
3
+
4
+ orbs:
5
+ ruby: circleci/ruby@1.0
6
+ browser-tools: circleci/browser-tools@1.4.1
7
+
8
+ jobs:
9
+ build:
10
+ docker:
11
+ - image: cimg/ruby:3.2.2-browsers
12
+ auth:
13
+ username: mydockerhub-user
14
+ password: $DOCKERHUB_PASSWORD
15
+ - image: redis:6.2.6
16
+
17
+ steps:
18
+ - checkout
19
+ - ruby/install-deps
20
+ - run:
21
+ name: Build assets
22
+ command: bundle exec rails assets:precompile
23
+
24
+ test:
25
+ parallelism: 1
26
+ docker:
27
+ - image: cimg/ruby:3.2.2-browsers
28
+ auth:
29
+ username: mydockerhub-user
30
+ password: $DOCKERHUB_PASSWORD
31
+ - image: redis:6.2.6
32
+ - image: cimg/postgres:13.7
33
+ auth:
34
+ username: mydockerhub-user
35
+ password: $DOCKERHUB_PASSWORD
36
+ environment:
37
+ POSTGRES_USER: circleci-demo-ruby
38
+ POSTGRES_DB: helios-dev-shop-test
39
+ POSTGRES_PASSWORD: ""
40
+
41
+ environment:
42
+ BUNDLE_JOBS: "3"
43
+ BUNDLE_RETRY: "3"
44
+ PGHOST: 127.0.0.1
45
+ PGUSER: circleci-demo-ruby
46
+ PGPASSWORD: ""
47
+ RAILS_ENV: test
48
+
49
+ steps:
50
+ - browser-tools/install-chrome
51
+ - browser-tools/install-chromedriver
52
+ - checkout
53
+ - ruby/install-deps
54
+
55
+ - run:
56
+ name: Wait for DB
57
+ command: dockerize -wait tcp://localhost:5432 -timeout 1m
58
+
59
+ - run:
60
+ name: Run system tests
61
+ command: script/test
62
+
63
+ - run:
64
+ name: Run internal tests
65
+ command: bundle exec rspec
66
+
67
+ workflows:
68
+ version: 2
69
+ build_and_test:
70
+ jobs:
71
+ - build
72
+ - test:
73
+ requires:
74
+ - build
@@ -3,6 +3,24 @@ on: [ push, pull_request ]
3
3
 
4
4
  jobs:
5
5
  internal_tests:
6
+ services:
7
+ # Label used to access the service container
8
+ postgres:
9
+ # Docker Hub image
10
+ image: postgres
11
+ # Provide the password for postgres
12
+ env:
13
+ POSTGRES_USER: postgres
14
+ POSTGRES_PASSWORD: postgres
15
+ POSTGRES_DB: test_database_name
16
+ ports:
17
+ - 5432:5432
18
+ # Set health checks to wait until postgres has started
19
+ options: >-
20
+ --health-cmd pg_isready
21
+ --health-interval 10s
22
+ --health-timeout 5s
23
+ --health-retries 5
6
24
  runs-on: ubuntu-latest
7
25
  steps:
8
26
  - uses: actions/checkout@v3
@@ -12,19 +30,20 @@ jobs:
12
30
  # Not needed with a .ruby-version file
13
31
  # runs 'bundle install' and caches installed gems automatically
14
32
  bundler-cache: true
15
- - run: bundle install
16
- - run: bundle exec rspec
33
+ - name: bundle install
34
+ run: cd dummy && bundle install && cd ..
35
+
36
+ - name: run tests
37
+ env:
38
+ RUBYOPT: "-W:no-deprecated -W:no-experimental" # Suppress Rails 6 deprecation warnings for ruby 2.7
39
+ RAILS_ENV: "test"
40
+ DATABASE_URL: "postgres://postgres:postgres@localhost:5432/test_database_name"
41
+
42
+ run: |
43
+ cd dummy && bin/setup && cd ..
44
+ bundle install
45
+ bundle exec rspec --fail-fast --backtrace
46
+
47
+
17
48
 
18
49
 
19
- system_tests:
20
- runs-on: ubuntu-latest
21
- steps:
22
- - uses: actions/checkout@v3
23
- - name: Set up Ruby
24
- uses: ruby/setup-ruby@v1
25
- with:
26
- # Not needed with a .ruby-version file
27
- # runs 'bundle install' and caches installed gems automatically
28
- bundler-cache: true
29
- - run: bundle install
30
- - run: bundle exec script/test
data/.gitignore CHANGED
@@ -12,8 +12,6 @@ dump.rdb
12
12
  tmp/
13
13
 
14
14
 
15
- Gemfile.lock
16
-
17
15
  db/*.sqlite3
18
16
 
19
17
  dummy/app/views/
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.2
1
+ 3.2.2
data/Gemfile CHANGED
@@ -17,8 +17,8 @@ gem "rspec-rails"
17
17
  gem "factory_bot_rails"
18
18
  gem "ffaker"
19
19
  gem "capybara"
20
- gem "selenium-webdriver"
21
- gem "webdrivers"
20
+ gem "selenium-webdriver", "4.11.0"
21
+ # gem "webdrivers"
22
22
 
23
23
  gem "sprockets-rails"
24
24
  gem "importmap-rails"
@@ -29,3 +29,5 @@ gem "byebug"
29
29
  gem "puma", "~> 5.0"
30
30
 
31
31
  gem "devise"
32
+
33
+ gem "pg", "~> 1.5"
data/Gemfile.lock ADDED
@@ -0,0 +1,280 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hot-glue (0.5.14)
5
+ ffaker (~> 2.16)
6
+ kaminari (~> 1.2)
7
+ rails (> 5.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (7.0.4)
13
+ actionpack (= 7.0.4)
14
+ activesupport (= 7.0.4)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailbox (7.0.4)
18
+ actionpack (= 7.0.4)
19
+ activejob (= 7.0.4)
20
+ activerecord (= 7.0.4)
21
+ activestorage (= 7.0.4)
22
+ activesupport (= 7.0.4)
23
+ mail (>= 2.7.1)
24
+ net-imap
25
+ net-pop
26
+ net-smtp
27
+ actionmailer (7.0.4)
28
+ actionpack (= 7.0.4)
29
+ actionview (= 7.0.4)
30
+ activejob (= 7.0.4)
31
+ activesupport (= 7.0.4)
32
+ mail (~> 2.5, >= 2.5.4)
33
+ net-imap
34
+ net-pop
35
+ net-smtp
36
+ rails-dom-testing (~> 2.0)
37
+ actionpack (7.0.4)
38
+ actionview (= 7.0.4)
39
+ activesupport (= 7.0.4)
40
+ rack (~> 2.0, >= 2.2.0)
41
+ rack-test (>= 0.6.3)
42
+ rails-dom-testing (~> 2.0)
43
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
44
+ actiontext (7.0.4)
45
+ actionpack (= 7.0.4)
46
+ activerecord (= 7.0.4)
47
+ activestorage (= 7.0.4)
48
+ activesupport (= 7.0.4)
49
+ globalid (>= 0.6.0)
50
+ nokogiri (>= 1.8.5)
51
+ actionview (7.0.4)
52
+ activesupport (= 7.0.4)
53
+ builder (~> 3.1)
54
+ erubi (~> 1.4)
55
+ rails-dom-testing (~> 2.0)
56
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
57
+ activejob (7.0.4)
58
+ activesupport (= 7.0.4)
59
+ globalid (>= 0.3.6)
60
+ activemodel (7.0.4)
61
+ activesupport (= 7.0.4)
62
+ activerecord (7.0.4)
63
+ activemodel (= 7.0.4)
64
+ activesupport (= 7.0.4)
65
+ activestorage (7.0.4)
66
+ actionpack (= 7.0.4)
67
+ activejob (= 7.0.4)
68
+ activerecord (= 7.0.4)
69
+ activesupport (= 7.0.4)
70
+ marcel (~> 1.0)
71
+ mini_mime (>= 1.1.0)
72
+ activesupport (7.0.4)
73
+ concurrent-ruby (~> 1.0, >= 1.0.2)
74
+ i18n (>= 1.6, < 2)
75
+ minitest (>= 5.1)
76
+ tzinfo (~> 2.0)
77
+ addressable (2.8.1)
78
+ public_suffix (>= 2.0.2, < 6.0)
79
+ bcrypt (3.1.18)
80
+ builder (3.2.4)
81
+ byebug (11.1.3)
82
+ capybara (3.38.0)
83
+ addressable
84
+ matrix
85
+ mini_mime (>= 0.1.3)
86
+ nokogiri (~> 1.8)
87
+ rack (>= 1.6.0)
88
+ rack-test (>= 0.6.3)
89
+ regexp_parser (>= 1.5, < 3.0)
90
+ xpath (~> 3.2)
91
+ concurrent-ruby (1.1.10)
92
+ crass (1.0.6)
93
+ date (3.3.3)
94
+ devise (4.8.1)
95
+ bcrypt (~> 3.0)
96
+ orm_adapter (~> 0.1)
97
+ railties (>= 4.1.0)
98
+ responders
99
+ warden (~> 1.2.3)
100
+ diff-lcs (1.5.0)
101
+ docile (1.4.0)
102
+ erubi (1.11.0)
103
+ factory_bot (6.2.1)
104
+ activesupport (>= 5.0.0)
105
+ factory_bot_rails (6.2.0)
106
+ factory_bot (~> 6.2.0)
107
+ railties (>= 5.0.0)
108
+ ffaker (2.21.0)
109
+ globalid (1.0.0)
110
+ activesupport (>= 5.0)
111
+ i18n (1.12.0)
112
+ concurrent-ruby (~> 1.0)
113
+ importmap-rails (1.1.5)
114
+ actionpack (>= 6.0.0)
115
+ railties (>= 6.0.0)
116
+ kaminari (1.2.2)
117
+ activesupport (>= 4.1.0)
118
+ kaminari-actionview (= 1.2.2)
119
+ kaminari-activerecord (= 1.2.2)
120
+ kaminari-core (= 1.2.2)
121
+ kaminari-actionview (1.2.2)
122
+ actionview
123
+ kaminari-core (= 1.2.2)
124
+ kaminari-activerecord (1.2.2)
125
+ activerecord
126
+ kaminari-core (= 1.2.2)
127
+ kaminari-core (1.2.2)
128
+ loofah (2.19.0)
129
+ crass (~> 1.0.2)
130
+ nokogiri (>= 1.5.9)
131
+ mail (2.8.1)
132
+ mini_mime (>= 0.1.1)
133
+ net-imap
134
+ net-pop
135
+ net-smtp
136
+ marcel (1.0.2)
137
+ matrix (0.4.2)
138
+ method_source (1.0.0)
139
+ mini_mime (1.1.2)
140
+ mini_portile2 (2.8.4)
141
+ minitest (5.16.3)
142
+ net-imap (0.3.4)
143
+ date
144
+ net-protocol
145
+ net-pop (0.1.2)
146
+ net-protocol
147
+ net-protocol (0.2.1)
148
+ timeout
149
+ net-smtp (0.3.3)
150
+ net-protocol
151
+ nio4r (2.5.8)
152
+ nokogiri (1.13.9)
153
+ mini_portile2 (~> 2.8.0)
154
+ racc (~> 1.4)
155
+ orm_adapter (0.5.0)
156
+ pg (1.5.3)
157
+ public_suffix (5.0.0)
158
+ puma (5.6.5)
159
+ nio4r (~> 2.0)
160
+ racc (1.6.0)
161
+ rack (2.2.4)
162
+ rack-test (2.0.2)
163
+ rack (>= 1.3)
164
+ rails (7.0.4)
165
+ actioncable (= 7.0.4)
166
+ actionmailbox (= 7.0.4)
167
+ actionmailer (= 7.0.4)
168
+ actionpack (= 7.0.4)
169
+ actiontext (= 7.0.4)
170
+ actionview (= 7.0.4)
171
+ activejob (= 7.0.4)
172
+ activemodel (= 7.0.4)
173
+ activerecord (= 7.0.4)
174
+ activestorage (= 7.0.4)
175
+ activesupport (= 7.0.4)
176
+ bundler (>= 1.15.0)
177
+ railties (= 7.0.4)
178
+ rails-dom-testing (2.0.3)
179
+ activesupport (>= 4.2.0)
180
+ nokogiri (>= 1.6)
181
+ rails-html-sanitizer (1.4.3)
182
+ loofah (~> 2.3)
183
+ railties (7.0.4)
184
+ actionpack (= 7.0.4)
185
+ activesupport (= 7.0.4)
186
+ method_source
187
+ rake (>= 12.2)
188
+ thor (~> 1.0)
189
+ zeitwerk (~> 2.5)
190
+ rake (13.0.6)
191
+ regexp_parser (2.6.0)
192
+ responders (3.0.1)
193
+ actionpack (>= 5.0)
194
+ railties (>= 5.0)
195
+ rexml (3.2.6)
196
+ rspec-core (3.12.0)
197
+ rspec-support (~> 3.12.0)
198
+ rspec-expectations (3.12.0)
199
+ diff-lcs (>= 1.2.0, < 2.0)
200
+ rspec-support (~> 3.12.0)
201
+ rspec-mocks (3.12.0)
202
+ diff-lcs (>= 1.2.0, < 2.0)
203
+ rspec-support (~> 3.12.0)
204
+ rspec-rails (6.0.1)
205
+ actionpack (>= 6.1)
206
+ activesupport (>= 6.1)
207
+ railties (>= 6.1)
208
+ rspec-core (~> 3.11)
209
+ rspec-expectations (~> 3.11)
210
+ rspec-mocks (~> 3.11)
211
+ rspec-support (~> 3.11)
212
+ rspec-support (3.12.0)
213
+ rubyzip (2.3.2)
214
+ selenium-webdriver (4.11.0)
215
+ rexml (~> 3.2, >= 3.2.5)
216
+ rubyzip (>= 1.2.2, < 3.0)
217
+ websocket (~> 1.0)
218
+ simplecov (0.22.0)
219
+ docile (~> 1.1)
220
+ simplecov-html (~> 0.11)
221
+ simplecov_json_formatter (~> 0.1)
222
+ simplecov-html (0.12.3)
223
+ simplecov-rcov (0.3.1)
224
+ simplecov (>= 0.4.1)
225
+ simplecov_json_formatter (0.1.4)
226
+ sprockets (4.1.1)
227
+ concurrent-ruby (~> 1.0)
228
+ rack (> 1, < 3)
229
+ sprockets-rails (3.4.2)
230
+ actionpack (>= 5.2)
231
+ activesupport (>= 5.2)
232
+ sprockets (>= 3.0.0)
233
+ sqlite3 (1.5.3)
234
+ mini_portile2 (~> 2.8.0)
235
+ stimulus-rails (1.1.1)
236
+ railties (>= 6.0.0)
237
+ thor (1.2.1)
238
+ timeout (0.3.2)
239
+ turbo-rails (1.3.2)
240
+ actionpack (>= 6.0.0)
241
+ activejob (>= 6.0.0)
242
+ railties (>= 6.0.0)
243
+ tzinfo (2.0.5)
244
+ concurrent-ruby (~> 1.0)
245
+ warden (1.2.9)
246
+ rack (>= 2.0.9)
247
+ websocket (1.2.9)
248
+ websocket-driver (0.7.5)
249
+ websocket-extensions (>= 0.1.0)
250
+ websocket-extensions (0.1.5)
251
+ xpath (3.2.0)
252
+ nokogiri (~> 1.8)
253
+ zeitwerk (2.6.6)
254
+
255
+ PLATFORMS
256
+ arm64-darwin-21
257
+ arm64-darwin-22
258
+ x86_64-linux
259
+
260
+ DEPENDENCIES
261
+ byebug
262
+ capybara
263
+ devise
264
+ factory_bot_rails
265
+ ffaker
266
+ hot-glue!
267
+ importmap-rails
268
+ pg (~> 1.5)
269
+ puma (~> 5.0)
270
+ rake
271
+ rspec-rails
272
+ selenium-webdriver (= 4.11.0)
273
+ simplecov-rcov
274
+ sprockets-rails
275
+ sqlite3
276
+ stimulus-rails
277
+ turbo-rails
278
+
279
+ BUNDLED WITH
280
+ 2.3.22
data/README.md CHANGED
@@ -1253,14 +1253,22 @@ end
1253
1253
 
1254
1254
  # VERSION HISTORY
1255
1255
 
1256
- #### TBR
1256
+ #### 2023-08-11 - v0.5.15
1257
+
1257
1258
  - When using big edit, updating a child will now re-render the parent EDIT record automatically.
1258
1259
 
1259
1260
  For example
1261
+ `rails generate hot_glue:scafold Invoice --big-edit`
1260
1262
  `rails generate hot_glue:scafold LineItem --nested=invioce`
1261
1263
 
1262
1264
  Whenever the line item is created, updated, or destroyed, the parent invoice record gets (edit action) re-rendered automatically. This happens for the big edit screen of the invoice.
1263
1265
 
1266
+
1267
+ - Refactors fields into polymoric objects
1268
+
1269
+ - Adds test coverage for Postgres Enums
1270
+
1271
+
1264
1272
  #### 2023-05-14 - v0.5.14 Delete message flash notice and new flash notice partial
1265
1273
 
1266
1274
  - This changes to how flash_notices work.
@@ -6,7 +6,7 @@ module HotGlue
6
6
 
7
7
  def filepath_prefix
8
8
  # todo: inject the context
9
- 'spec/dummy/' if Rails.env.test?
9
+ 'spec/dummy/' if $INTERNAL_SPECS
10
10
  end
11
11
 
12
12
  def initialize(*args) #:nodoc:
@@ -4,7 +4,7 @@ module HotGlue
4
4
 
5
5
  def filepath_prefix
6
6
  # todo: inject the context
7
- 'spec/dummy/' if Rails.env.test?
7
+ 'spec/dummy/' if $INTERNAL_SPECS
8
8
  end
9
9
 
10
10
 
@@ -45,8 +45,11 @@ class FieldFactory
45
45
  end
46
46
  @class_name = class_name
47
47
 
48
-
49
48
  @field = field_class.new(name: name,
49
+ layout_strategy: generator.layout_strategy,
50
+ form_placeholder_labels: generator.form_placeholder_labels,
51
+ form_labels_position: generator.form_labels_position,
52
+ ownership_field: generator.ownership_field,
50
53
  hawk_keys: generator.hawk_keys,
51
54
  auth: generator.auth,
52
55
  class_name: generator.singular_class,
@@ -3,10 +3,15 @@ require_relative './field.rb'
3
3
 
4
4
  class AssociationField < Field
5
5
 
6
+ attr_accessor :assoc_name, :assoc_class, :assoc
7
+
6
8
  def initialize(name: , class_name: , alt_lookups: , singular: , update_show_only: ,
7
- hawk_keys: , auth: , sample_file_path:, attachment_data: nil )
9
+ hawk_keys: , auth: , sample_file_path:, ownership_field: ,
10
+ attachment_data: nil , layout_strategy: , form_placeholder_labels: nil,
11
+ form_labels_position: )
8
12
  super
9
- assoc_model = eval("#{class_name}.reflect_on_association(:#{assoc})")
13
+
14
+ @assoc_model = eval("#{class_name}.reflect_on_association(:#{assoc})")
10
15
 
11
16
  if assoc_model.nil?
12
17
  exit_message = "*** Oops: The model #{class_name} is missing an association for :#{assoc_name} or the model #{assoc_name.titlecase} doesn't exist. TODO: Please implement a model for #{assoc_name.titlecase}; or add to #{class_name} `belongs_to :#{assoc_name}`. To make a controller that can read all records, specify with --god."
@@ -14,9 +19,7 @@ class AssociationField < Field
14
19
  raise(HotGlue::Error, exit_message)
15
20
  end
16
21
 
17
- begin
18
- assoc_class = eval(assoc_model.try(:class_name))
19
- end
22
+ @assoc_class = eval(assoc_model.try(:class_name))
20
23
 
21
24
  name_list = [:name, :to_label, :full_name, :display_name, :email]
22
25
 
@@ -27,7 +30,6 @@ class AssociationField < Field
27
30
  raise(HotGlue::Error, exit_message)
28
31
  end
29
32
 
30
- # set teh assoc label
31
33
  end
32
34
 
33
35
  def assoc_label
@@ -73,4 +75,69 @@ class AssociationField < Field
73
75
 
74
76
  " let!(:#{assoc}1) {create(:#{the_foreign_class}" + hawk_keys_on_lets + ")}"
75
77
  end
78
+
79
+ def form_field_output
80
+ assoc_name = name.to_s.gsub("_id","")
81
+ assoc = eval("#{class_name}.reflect_on_association(:#{assoc_name})")
82
+
83
+
84
+ if @alt_lookups.keys.include?(name.to_s)
85
+ alt = @alt_lookups[name.to_s][:lookup_as]
86
+ "<%= f.text_field :__lookup_#{alt}, value: @#{singular}.#{assoc_name}.try(:#{alt}), placeholder: \"search by #{alt}\" %>"
87
+ else
88
+ if assoc.nil?
89
+ exit_message = "*** Oops. on the #{class_name} object, there doesn't seem to be an association called '#{assoc_name}'"
90
+ exit
91
+ end
92
+
93
+ is_owner = name == ownership_field
94
+ assoc_class_name = assoc.class_name.to_s
95
+ display_column = HotGlue.derrive_reference_name(assoc_class_name)
96
+
97
+ if hawk_keys[assoc.foreign_key.to_sym]
98
+ hawk_definition = hawk_keys[assoc.foreign_key.to_sym]
99
+ hawked_association = hawk_definition[:bind_to].join(".")
100
+ else
101
+ hawked_association = "#{assoc.class_name}.all"
102
+ end
103
+
104
+ (is_owner ? "<% unless @#{assoc_name} %>\n" : "") +
105
+ " <%= f.collection_select(:#{name}, #{hawked_association}, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{name} }, class: 'form-control') %>\n" +
106
+ (is_owner ? "<% else %>\n <%= @#{assoc_name}.#{display_column} %>" : "") +
107
+ (is_owner ? "\n<% end %>" : "")
108
+ end
109
+ end
110
+
111
+ def field_error_name
112
+ name
113
+ end
114
+
115
+ def form_show_only_output
116
+ assoc_name = name.to_s.gsub("_id","")
117
+ assoc = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
118
+ if assoc.nil?
119
+ exit_message = "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
120
+ exit
121
+ end
122
+
123
+ is_owner = name == ownership_field
124
+ assoc_class_name = assoc.class_name.to_s
125
+ display_column = HotGlue.derrive_reference_name(assoc_class_name)
126
+
127
+ if hawk_keys[assoc.foreign_key.to_sym]
128
+ hawk_definition = hawk_keys[assoc.foreign_key.to_sym]
129
+ hawked_association = hawk_definition.join(".")
130
+ else
131
+ hawked_association = "#{assoc.class_name}.all"
132
+ end
133
+ "<%= #{singular}.#{assoc_name}.#{display_column} %>"
134
+
135
+ end
136
+
137
+ def line_field_output
138
+
139
+ display_column = HotGlue.derrive_reference_name(assoc_class.to_s)
140
+
141
+ "<%= #{singular}.#{assoc}.try(:#{display_column}) || '<span class=\"content alert-danger\">MISSING</span>'.html_safe %>"
142
+ end
76
143
  end
@@ -1,8 +1,10 @@
1
1
  class AttachmentField < Field
2
2
  attr_accessor :attachment_data
3
3
  def initialize(name:, class_name:, alt_lookups:, singular:, update_show_only:, hawk_keys:, auth:,
4
- sample_file_path: nil, attachment_data: )
4
+ sample_file_path: nil, attachment_data:, ownership_field:, layout_strategy: ,
5
+ form_placeholder_labels: , form_labels_position:)
5
6
  super
7
+
6
8
  @attachment_data = attachment_data
7
9
  end
8
10
 
@@ -30,7 +32,9 @@ class AttachmentField < Field
30
32
  return field_result
31
33
  end
32
34
 
33
- def field_error_name
34
- name
35
+ def line_field_output
36
+ thumbnail = attachment_data[:thumbnail]
37
+
38
+ (thumbnail ? "<%= #{singular}.#{name}.attached? ? image_tag(#{singular}.#{name}.variant(:#{thumbnail})) : '' %>" : "")
35
39
  end
36
40
  end
@@ -15,4 +15,25 @@ class BooleanField < Field
15
15
  def spec_list_view_assertion
16
16
  " " + ["expect(page).to have_content(#{singular}#{1}.#{name} ? 'YES' : 'NO')"].join("\n ")
17
17
  end
18
+
19
+
20
+ def form_field_output
21
+ (form_labels_position == 'before' ? " <br />" : "") +
22
+ " <%= f.radio_button(:#{name}, '0', checked: #{singular}.#{name} ? '' : 'checked') %>\n" +
23
+ " <%= f.label(:#{name}, value: 'No', for: '#{singular}_#{name}_0') %>\n" +
24
+ " <%= f.radio_button(:#{name}, '1', checked: #{singular}.#{name} ? 'checked' : '') %>\n" +
25
+ " <%= f.label(:#{name}, value: 'Yes', for: '#{singular}_#{name}_1') %>\n" +
26
+ (form_labels_position == 'after' ? " <br />" : "")
27
+ end
28
+
29
+ def line_field_output
30
+ "
31
+ <% if #{singular}.#{name}.nil? %>
32
+ <span class='alert-danger'>MISSING</span>
33
+ <% elsif #{singular}.#{name} %>
34
+ YES
35
+ <% else %>
36
+ NO
37
+ <% end %>"
38
+ end
18
39
  end
@@ -7,4 +7,17 @@ class DateField < Field
7
7
  def spec_setup_let_arg
8
8
  "#{name}: Date.current + rand(50).days"
9
9
  end
10
+
11
+
12
+ def form_field_output
13
+ "<%= date_field_localized(f, :#{name}, #{singular}.#{name}, '#{ name.to_s.humanize }', #{auth ? auth+'.timezone' : 'nil'}) %>"
14
+ end
15
+
16
+ def line_field_output
17
+ "<% unless #{singular}.#{name}.nil? %>
18
+ <%= #{singular}.#{name} %>
19
+ <% else %>
20
+ <span class='alert-danger'>MISSING</span>
21
+ <% end %>"
22
+ end
10
23
  end