yummy-guide-generic-administrate 0.8.11 → 0.8.12

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: 010d1c2fe4f859c1888130041b8b6f9e6031c4950ac8951992cb787e9ad99f10
4
- data.tar.gz: cea0d9110b7208f632e421d7275f75f34f36d1b5114855b1d74812158eaa04ab
3
+ metadata.gz: 5ba6a92509f2b98a13491fb25f85808f471dc3ffaf53d5c3d4a4d5c1b06da3b3
4
+ data.tar.gz: 3990affb7c42115e6a7c07f987d895c2bd2ddfc5f82be2e79c71eb1d3a34854e
5
5
  SHA512:
6
- metadata.gz: 86ffba95443e2a3537b8ee0343c31cccca6fbdb23f1b577b552d5812da2e6058e0c602b8f4e6097714301b8c773d29e3927c2b6cb1ac03be012fe936dedd9811
7
- data.tar.gz: 07d92c76ea5b17277640a67a9952ef5b19d22b9507bd5ef62f2967bd567832d04b87d1c30358b3941346f16f9926b4bb3e5c6cce2fd29121fa70ce02c976cf9e
6
+ metadata.gz: e1000b82bf41b9b4169a30b049d4e53faa1f3fcd3e0c7643619682cb6bbc03fdab1a077637f233545299e18c6e639f838677205a5a3b70ec3f7a4830e8a34403
7
+ data.tar.gz: 4f0abf3d64dedab0a39a3a51964cca2d98d8703e2fa2dcd98e7bd4368503534ce5b1330ac2463f8fdb901658cafb72cfcce383fd430d49d89e9e4a2b7736a922
@@ -344,6 +344,10 @@
344
344
  vertical-align: middle;
345
345
  }
346
346
 
347
+ body {
348
+ --admin-copy-cell-width-offset: 1.85rem;
349
+ }
350
+
347
351
  .admin-copy-cell {
348
352
  position: relative;
349
353
  display: inline-flex;
@@ -17,6 +17,7 @@ module YummyGuide
17
17
  }.freeze
18
18
  DEFAULT_FIXED_COLUMN_WIDTH = "8rem"
19
19
  CONTENT_WIDTH_VALUE = "max-content"
20
+ COPY_CELL_ACTION_WIDTH_OFFSET = "var(--admin-copy-cell-width-offset, 1.85rem)"
20
21
  MAX_MOBILE_FIXED_COLUMNS_COUNT = 1
21
22
 
22
23
  CollectionTableDefinition = Struct.new(
@@ -174,7 +175,7 @@ module YummyGuide
174
175
  names.first(max_count).each_with_index.each_with_object({}) do |(name, index), sticky_columns|
175
176
  classes = []
176
177
  styles = []
177
- width = widths.fetch(name, DEFAULT_FIXED_COLUMN_WIDTH)
178
+ width = widths.fetch(name, yummy_guide_administrate_collection_default_fixed_column_width)
178
179
 
179
180
  if index < fixed_count
180
181
  classes << "sticky-left"
@@ -210,7 +211,7 @@ module YummyGuide
210
211
  )
211
212
 
212
213
  names.first(6).each_with_index.flat_map do |name, index|
213
- width = widths.fetch(name, DEFAULT_FIXED_COLUMN_WIDTH)
214
+ width = widths.fetch(name, yummy_guide_administrate_collection_default_fixed_column_width)
214
215
  column_number = index + 1
215
216
 
216
217
  [
@@ -349,13 +350,17 @@ module YummyGuide
349
350
  dashboard.class.index_fixed_column_widths if dashboard&.class&.respond_to?(:index_fixed_column_widths)
350
351
  end
351
352
 
352
- DEFAULT_FIXED_COLUMN_WIDTHS.merge(
353
+ raw_widths = DEFAULT_FIXED_COLUMN_WIDTHS.merge(
353
354
  (configured_widths || {}).to_h.each_with_object({}) do |(name, width), widths|
354
355
  next if width.nil?
355
356
 
356
357
  widths[name.to_sym] = yummy_guide_administrate_collection_column_width_value(width)
357
358
  end
358
359
  )
360
+
361
+ raw_widths.transform_values do |width|
362
+ yummy_guide_administrate_collection_fixed_column_width_value(width)
363
+ end
359
364
  end
360
365
 
361
366
  def yummy_guide_administrate_collection_default_column_widths(page:)
@@ -371,7 +376,7 @@ module YummyGuide
371
376
  value = yummy_guide_administrate_collection_column_width_value(width)
372
377
  next if value == CONTENT_WIDTH_VALUE
373
378
 
374
- widths[name.to_sym] = value
379
+ widths[name.to_sym] = yummy_guide_administrate_collection_default_column_width_value(value)
375
380
  end
376
381
  end
377
382
 
@@ -470,12 +475,30 @@ module YummyGuide
470
475
  width.to_s
471
476
  end
472
477
 
478
+ def yummy_guide_administrate_collection_default_column_width_value(width)
479
+ yummy_guide_administrate_collection_column_width_value_with_copy_action(width)
480
+ end
481
+
482
+ def yummy_guide_administrate_collection_fixed_column_width_value(width)
483
+ yummy_guide_administrate_collection_column_width_value_with_copy_action(width)
484
+ end
485
+
486
+ def yummy_guide_administrate_collection_column_width_value_with_copy_action(width)
487
+ return width if width == CONTENT_WIDTH_VALUE
488
+
489
+ "calc(#{width} + #{COPY_CELL_ACTION_WIDTH_OFFSET})"
490
+ end
491
+
492
+ def yummy_guide_administrate_collection_default_fixed_column_width
493
+ yummy_guide_administrate_collection_fixed_column_width_value(DEFAULT_FIXED_COLUMN_WIDTH)
494
+ end
495
+
473
496
  def yummy_guide_administrate_collection_sticky_lefts(column_names, widths)
474
497
  current_parts = []
475
498
 
476
499
  column_names.each_with_object({}) do |name, lefts|
477
500
  lefts[name] = yummy_guide_administrate_collection_css_sum(current_parts)
478
- current_parts << widths.fetch(name, DEFAULT_FIXED_COLUMN_WIDTH)
501
+ current_parts << widths.fetch(name, yummy_guide_administrate_collection_default_fixed_column_width)
479
502
  end
480
503
  end
481
504
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module YummyGuide
4
4
  module Administrate
5
- VERSION = "0.8.11"
5
+ VERSION = "0.8.12"
6
6
  end
7
7
  end
@@ -131,21 +131,23 @@ RSpec.describe YummyGuide::Administrate::CollectionHelper do
131
131
  collection_presenter: collection_presenter,
132
132
  column_names: %i[id customer note]
133
133
  )
134
+ id_width = "calc(4rem + var(--admin-copy-cell-width-offset, 1.85rem))"
135
+ customer_width = "calc(14rem + var(--admin-copy-cell-width-offset, 1.85rem))"
134
136
 
135
137
  expect(definition.fixed_columns_count).to eq(2)
136
138
  expect(definition.mobile_fixed_columns_count).to eq(1)
137
139
  expect(definition.sticky_column(:customer)).to include(
138
140
  class: "sticky-left sticky-left--last",
139
- style: "--sticky-left: 4rem; --sticky-width: 14rem"
141
+ style: "--sticky-left: #{id_width}; --sticky-width: #{customer_width}"
140
142
  )
141
- expect(definition.table_style).to include("--admin-sticky-col-2-width: 14rem")
143
+ expect(definition.table_style).to include("--admin-sticky-col-2-width: #{customer_width}")
142
144
  expect(definition.table_style).to include("--admin-sticky-col-3-width: max-content")
143
- expect(definition.grid_template_columns).to eq("4rem 14rem max-content")
145
+ expect(definition.grid_template_columns).to eq("#{id_width} #{customer_width} max-content")
144
146
  expect(definition.column_id(:customer)).to eq("reservation.customer")
145
147
  expect(definition.actions_column_id).to eq("reservation.actions")
146
148
  end
147
149
 
148
- # Dashboard のデフォルト幅とブラウザ別の保存幅がCSS変数として同じテーブル定義へ反映されることを確認する
150
+ # Dashboard のデフォルト幅にはコピー操作幅を含め、ブラウザ別の保存幅はそのまま反映されることを確認する
149
151
  it "builds resizable width variables from default and saved column widths" do
150
152
  dashboard_class = Class.new do
151
153
  def self.index_default_column_widths
@@ -170,12 +172,14 @@ RSpec.describe YummyGuide::Administrate::CollectionHelper do
170
172
  column_names: %i[name interview_summary memo]
171
173
  )
172
174
 
173
- expect(definition.table_style).to include("--admin-column-resizer-default-col-2: 800px")
175
+ default_width = "calc(800px + var(--admin-copy-cell-width-offset, 1.85rem))"
176
+
177
+ expect(definition.table_style).to include("--admin-column-resizer-default-col-2: #{default_width}")
174
178
  expect(definition.table_style).to include("--admin-column-resizer-user-col-3: 320px")
175
179
  expect(definition.table_style).to include("--admin-column-resizer-col-2: var(--admin-column-resizer-user-col-2, var(--admin-column-resizer-default-col-2))")
176
180
  expect(definition.table_style).to include("--admin-column-resizer-col-3: var(--admin-column-resizer-user-col-3)")
177
181
  expect(definition.adjusted_column_indexes).to eq([2, 3])
178
- expect(definition.colgroup_widths).to eq([nil, "800px", "320px"])
182
+ expect(definition.colgroup_widths).to eq([nil, default_width, "320px"])
179
183
  end
180
184
  end
181
185
 
@@ -205,14 +209,16 @@ RSpec.describe YummyGuide::Administrate::CollectionHelper do
205
209
  collection_presenter: collection_presenter,
206
210
  column_names: %i[id customer note]
207
211
  )
212
+ id_width = "calc(4rem + var(--admin-copy-cell-width-offset, 1.85rem))"
213
+ customer_width = "calc(14rem + var(--admin-copy-cell-width-offset, 1.85rem))"
208
214
 
209
215
  expect(sticky_columns[:id]).to eq(
210
216
  class: "sticky-left sticky-left-mobile sticky-left-mobile--last",
211
- style: "--sticky-left: 0px; --sticky-width: 4rem; --sticky-mobile-left: 0px; --sticky-mobile-width: 4rem"
217
+ style: "--sticky-left: 0px; --sticky-width: #{id_width}; --sticky-mobile-left: 0px; --sticky-mobile-width: #{id_width}"
212
218
  )
213
219
  expect(sticky_columns[:customer]).to eq(
214
220
  class: "sticky-left sticky-left--last",
215
- style: "--sticky-left: 4rem; --sticky-width: 14rem"
221
+ style: "--sticky-left: #{id_width}; --sticky-width: #{customer_width}"
216
222
  )
217
223
  expect(sticky_columns).not_to have_key(:note)
218
224
  end
@@ -291,11 +297,14 @@ RSpec.describe YummyGuide::Administrate::CollectionHelper do
291
297
  page: page,
292
298
  column_names: %i[id customer note]
293
299
  )
294
-
295
- expect(style).to include("--admin-sticky-col-1-width: 4rem")
296
- expect(style).to include("--admin-sticky-mobile-col-1-width: 4rem")
297
- expect(style).to include("--admin-sticky-col-2-width: 14rem")
298
- expect(style).to include("--admin-sticky-col-3-width: 8rem")
300
+ id_width = "calc(4rem + var(--admin-copy-cell-width-offset, 1.85rem))"
301
+ customer_width = "calc(14rem + var(--admin-copy-cell-width-offset, 1.85rem))"
302
+ fallback_width = "calc(8rem + var(--admin-copy-cell-width-offset, 1.85rem))"
303
+
304
+ expect(style).to include("--admin-sticky-col-1-width: #{id_width}")
305
+ expect(style).to include("--admin-sticky-mobile-col-1-width: #{id_width}")
306
+ expect(style).to include("--admin-sticky-col-2-width: #{customer_width}")
307
+ expect(style).to include("--admin-sticky-col-3-width: #{fallback_width}")
299
308
  end
300
309
  end
301
310
 
@@ -422,6 +422,7 @@ RSpec.describe "column resizer assets" do
422
422
  expect(components_source).to include("width: max-content")
423
423
  expect(components_source).to include("min-width: max-content")
424
424
  expect(components_source).to include("white-space: nowrap")
425
+ expect(components_source).to include("--admin-copy-cell-width-offset: 1.85rem")
425
426
  expect(stylesheet_source).to include("> .admin-copy-cell")
426
427
  expect(stylesheet_source).to include("width: 100% !important")
427
428
  expect(stylesheet_source).to include("flex: 1 1 auto !important")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yummy-guide-generic-administrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.11
4
+ version: 0.8.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - akatsuki-kk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-18 00:00:00.000000000 Z
11
+ date: 2026-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate