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 +4 -4
- data/app/assets/stylesheets/yummy_guide_administrate/components.scss +4 -0
- data/app/helpers/yummy_guide/administrate/collection_helper.rb +28 -5
- data/lib/yummy_guide/administrate/version.rb +1 -1
- data/spec/yummy_guide/administrate/collection_helper_spec.rb +22 -13
- data/spec/yummy_guide/administrate/column_resizer_asset_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ba6a92509f2b98a13491fb25f85808f471dc3ffaf53d5c3d4a4d5c1b06da3b3
|
|
4
|
+
data.tar.gz: 3990affb7c42115e6a7c07f987d895c2bd2ddfc5f82be2e79c71eb1d3a34854e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1000b82bf41b9b4169a30b049d4e53faa1f3fcd3e0c7643619682cb6bbc03fdab1a077637f233545299e18c6e639f838677205a5a3b70ec3f7a4830e8a34403
|
|
7
|
+
data.tar.gz: 4f0abf3d64dedab0a39a3a51964cca2d98d8703e2fa2dcd98e7bd4368503534ce5b1330ac2463f8fdb901658cafb72cfcce383fd430d49d89e9e4a2b7736a922
|
|
@@ -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,
|
|
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,
|
|
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,
|
|
501
|
+
current_parts << widths.fetch(name, yummy_guide_administrate_collection_default_fixed_column_width)
|
|
479
502
|
end
|
|
480
503
|
end
|
|
481
504
|
|
|
@@ -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:
|
|
141
|
+
style: "--sticky-left: #{id_width}; --sticky-width: #{customer_width}"
|
|
140
142
|
)
|
|
141
|
-
expect(definition.table_style).to include("--admin-sticky-col-2-width:
|
|
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("
|
|
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
|
|
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
|
-
|
|
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,
|
|
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:
|
|
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:
|
|
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
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
expect(style).to include("--admin-sticky-col-
|
|
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.
|
|
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-
|
|
11
|
+
date: 2026-06-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: administrate
|