b4um_generators 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4554ba68c9377451369455eee637d0ebf9b05926d17f1cca4e7846ed9a3e7ffe
4
- data.tar.gz: 52c056de9b177de1f0e790ede1d7c13fcd5888c18eb95e02d5e93895c2827040
3
+ metadata.gz: fe62953ac32b6c0aa41af6886b6d6c97d1446ef4ae92177a4c200faee03dc9ff
4
+ data.tar.gz: 4b08b040919c741f57374a9f572268265b2405180af4a5958659da3232ada073
5
5
  SHA512:
6
- metadata.gz: c2758a16ff6d6fdfc220c7c49c8c698d09628ba53ecf45054f446bf062d291dfed85c5ca2a31d50e69e3d6a77521500d01805eaa21ff07cc8bf1adabe6ec0566
7
- data.tar.gz: 22027e9c4911cbc9b16f8ad15132ff9681c32eaa4b53760c4e7c5838f7ff86e609879d94450bf19e975a105a48c196864d7c5bdcbea351266901c109563399e8
6
+ metadata.gz: 54fb5d2d124addb3063a2e0ab1540ff6327b9fa624d41f6a9e0197e6012fa5a1fd5edaf26356f3b59d7ec4d36a2d3a3ab993a4b0f59d65cf50ade4adb65b9a20
7
+ data.tar.gz: adea210e1f9eec24d763c9084be55aec061bb9d568caf7be9c68c2a539e8b65ac45e8066fa75c9baae2721f8f1d6d20b8d7396612ec9fa955e9b7370f5d3b0a2
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module B4umGenerators
4
- VERSION = "0.2.9"
4
+ VERSION = "0.2.11"
5
5
  end
@@ -110,13 +110,18 @@ module B4um
110
110
  def update_single_attachment_params
111
111
  content = File.read(controller_path)
112
112
 
113
- return if attachment_permitted?(content)
113
+ update_single_permitted_params(content)
114
+ update_single_attachment_action
115
+ end
116
+
117
+ def update_single_permitted_params(content)
118
+ return if single_attachment_permitted?(content)
114
119
 
115
120
  pattern = /
116
121
  params\.expect\(
117
122
  #{Regexp.escape(file_name)}:\s*
118
123
  \[
119
- (?<attributes>[^\]]*)
124
+ (?<attributes>.*?)
120
125
  \]
121
126
  \)
122
127
  /mx
@@ -124,9 +129,83 @@ module B4um
124
129
  return unless content.match?(pattern)
125
130
 
126
131
  gsub_file(controller_path, pattern) do |match|
132
+ match_data = pattern.match(match)
133
+ attributes = match_data[:attributes]
134
+
135
+ insertion = ":#{attachment}, :remove_#{attachment}"
136
+
137
+ updated_attributes =
138
+ if attributes.match?(/\w+:\s*\[/)
139
+ attributes.sub(
140
+ /(?=\w+:\s*\[)/,
141
+ "#{insertion}, "
142
+ )
143
+ else
144
+ "#{attributes}, #{insertion}"
145
+ end
146
+
127
147
  match.sub(
128
- /\]\)$/,
129
- ", :#{attachment}])"
148
+ attributes,
149
+ updated_attributes
150
+ )
151
+ end
152
+ end
153
+
154
+ def single_attachment_permitted?(content)
155
+ content.include?(
156
+ ":#{attachment}, :remove_#{attachment}"
157
+ )
158
+ end
159
+
160
+ def update_single_attachment_action
161
+ content = File.read(controller_path)
162
+
163
+ return if content.include?(
164
+ "remove_#{attachment} = update_params.delete(\"remove_#{attachment}\")"
165
+ )
166
+
167
+ if content.include?(" update_params = #{file_name}_params\n")
168
+ insert_into_file(
169
+ controller_path,
170
+ " remove_#{attachment} = update_params.delete(\"remove_#{attachment}\")\n",
171
+ after: " update_params = #{file_name}_params\n"
172
+ )
173
+ else
174
+ setup = [
175
+ " def update",
176
+ " update_params = #{file_name}_params",
177
+ " remove_#{attachment} = update_params.delete(\"remove_#{attachment}\")",
178
+ "",
179
+ " respond_to do |format|",
180
+ ""
181
+ ].join("\n")
182
+
183
+ gsub_file(
184
+ controller_path,
185
+ " def update\n respond_to do |format|\n",
186
+ setup
187
+ )
188
+ end
189
+
190
+ content = File.read(controller_path)
191
+
192
+ if content.include?(" if @#{file_name}.update(update_params)\n")
193
+ insert_into_file(
194
+ controller_path,
195
+ " @#{file_name}.#{attachment}.purge if remove_#{attachment} == \"1\"\n",
196
+ after: " if @#{file_name}.update(update_params)\n"
197
+ )
198
+ else
199
+ attachment_handling = [
200
+ " if @#{file_name}.update(update_params)",
201
+ " @#{file_name}.#{attachment}.purge if remove_#{attachment} == \"1\"",
202
+ ""
203
+ ].join("\n")
204
+
205
+ gsub_file(
206
+ controller_path,
207
+ " if @#{file_name}.update(#{file_name}_params)\n",
208
+ attachment_handling
130
209
  )
131
210
  end
132
211
  end
@@ -299,6 +378,9 @@ module B4um
299
378
  alt="">
300
379
  </div>
301
380
 
381
+ <div class="image-lightbox__thumbnails"
382
+ data-image-lightbox-target="thumbnails"></div>
383
+
302
384
  <div class="image-lightbox__caption"
303
385
  data-image-lightbox-target="caption"></div>
304
386
  </div>
@@ -354,8 +436,9 @@ module B4um
354
436
  </button>
355
437
 
356
438
  <button type="button"
357
- class="image-lightbox__previous"
439
+ class="image-lightbox__navigation image-lightbox__navigation--previous"
358
440
  aria-label="Previous image"
441
+ data-image-lightbox-target="previousButton"
359
442
  data-action="click->image-lightbox#previous">
360
443
  &#8249;
361
444
  </button>
@@ -369,12 +452,16 @@ module B4um
369
452
  </div>
370
453
 
371
454
  <button type="button"
372
- class="image-lightbox__next"
455
+ class="image-lightbox__navigation image-lightbox__navigation--next"
373
456
  aria-label="Next image"
457
+ data-image-lightbox-target="nextButton"
374
458
  data-action="click->image-lightbox#next">
375
459
  &#8250;
376
460
  </button>
377
461
 
462
+ <div class="image-lightbox__thumbnails"
463
+ data-image-lightbox-target="thumbnails"></div>
464
+
378
465
  <div class="image-lightbox__caption"
379
466
  data-image-lightbox-target="caption"></div>
380
467
  </div>
@@ -431,12 +518,34 @@ module B4um
431
518
  <%= "hidden" unless #{file_name}.#{attachment}.attached? %>>
432
519
 
433
520
  <% if #{file_name}.#{attachment}.attached? %>
434
- <%= image_tag #{file_name}.#{attachment},
435
- class: "form-image-preview__image",
436
- alt: #{file_name}.#{attachment}.filename.to_s,
437
- data: {
438
- image_preview_target: "image"
439
- } %>
521
+ <div class="form-image-preview__item"
522
+ role="button"
523
+ tabindex="0"
524
+ aria-pressed="false"
525
+ data-image-preview-target="existingItem"
526
+ data-action="click->image-preview#toggleRemoval keydown->image-preview#toggleRemovalWithKeyboard">
527
+
528
+ <%= image_tag #{file_name}.#{attachment},
529
+ class: "form-image-preview__image",
530
+ alt: #{file_name}.#{attachment}.filename.to_s,
531
+ data: {
532
+ image_preview_target: "image"
533
+ } %>
534
+
535
+ <%= check_box_tag(
536
+ "#{file_name}[remove_#{attachment}]",
537
+ "1",
538
+ false,
539
+ class: "form-image-preview__remove-checkbox",
540
+ data: {
541
+ image_preview_target: "removeCheckbox"
542
+ }
543
+ ) %>
544
+
545
+ <div class="form-image-preview__remove-status">
546
+ Will be removed
547
+ </div>
548
+ </div>
440
549
  <% else %>
441
550
  <img class="form-image-preview__image"
442
551
  data-image-preview-target="image"
@@ -259,6 +259,8 @@ module B4um
259
259
  data-action="click->image-lightbox#next">
260
260
  &#8250;
261
261
  </button>
262
+ <div class="image-lightbox__thumbnails"
263
+ data-image-lightbox-target="thumbnails"></div>
262
264
 
263
265
  <div class="image-lightbox__caption"
264
266
  data-image-lightbox-target="caption"></div>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: b4um_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Baum
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-10-04 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: railties
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.6.2
150
+ rubygems_version: 3.6.9
151
151
  specification_version: 4
152
152
  summary: Rails generators for b4um applications
153
153
  test_files: []