yummy-guide-generic-administrate 0.8.11 → 0.8.13
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 +19 -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 +11 -5
- 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: f39b663ae3463f915b180637532395e54c341dafac50ad331dbb600ab7e275ab
|
|
4
|
+
data.tar.gz: c690e6ccabd5efdb8a31b74b8c6b3ff0cebe8c54e694bba11725c663108ed84d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff05d854eaa89f3110eec3936ea31ee769c14a6787ca3dad63070957b38ebc9e185a9a36536f7fcfe86bba2525e15d3ea9929caf16416534b609ab371be07238
|
|
7
|
+
data.tar.gz: 436be499cc212d05255da8a299ca251a50390199ba73bcd9de6c560e614e3d173df728dd9910e27a25c430fed4e729f190ed74187fda3047e1b45ae3446aa93f
|
|
@@ -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;
|
|
@@ -378,6 +382,21 @@
|
|
|
378
382
|
margin-left: auto;
|
|
379
383
|
}
|
|
380
384
|
|
|
385
|
+
td.cell-data > .admin-copy-cell {
|
|
386
|
+
box-sizing: border-box;
|
|
387
|
+
width: 100%;
|
|
388
|
+
min-width: 0;
|
|
389
|
+
max-width: 100%;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
td.cell-data > .admin-copy-cell > .admin-copy-cell__content {
|
|
393
|
+
min-width: 0;
|
|
394
|
+
flex: 1 1 auto;
|
|
395
|
+
white-space: inherit;
|
|
396
|
+
overflow-wrap: anywhere;
|
|
397
|
+
word-break: break-word;
|
|
398
|
+
}
|
|
399
|
+
|
|
381
400
|
.attribute-data .admin-copy-cell {
|
|
382
401
|
display: inline-flex;
|
|
383
402
|
width: auto;
|
|
@@ -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
|
|
|
@@ -416,12 +416,18 @@ RSpec.describe "column resizer assets" do
|
|
|
416
416
|
expect(javascript_source).not_to include("initializeAdjustedColumnWidths")
|
|
417
417
|
end
|
|
418
418
|
|
|
419
|
-
#
|
|
420
|
-
it "
|
|
419
|
+
# 未調整のコピーセルもテーブルセル幅の中で縮み、必要に応じて折り返されることを静的に確認する
|
|
420
|
+
it "allows table copy cells to wrap before a column width is adjusted" do
|
|
421
421
|
expect(components_source).to include("display: inline-flex")
|
|
422
|
-
expect(components_source).to include("
|
|
423
|
-
expect(components_source).to include("
|
|
424
|
-
expect(components_source).to include("
|
|
422
|
+
expect(components_source).to include("td.cell-data > .admin-copy-cell")
|
|
423
|
+
expect(components_source).to include("width: 100%;")
|
|
424
|
+
expect(components_source).to include("min-width: 0;")
|
|
425
|
+
expect(components_source).to include("max-width: 100%;")
|
|
426
|
+
expect(components_source).to include("td.cell-data > .admin-copy-cell > .admin-copy-cell__content")
|
|
427
|
+
expect(components_source).to include("white-space: inherit;")
|
|
428
|
+
expect(components_source).to include("overflow-wrap: anywhere;")
|
|
429
|
+
expect(components_source).to include("word-break: break-word;")
|
|
430
|
+
expect(components_source).to include("--admin-copy-cell-width-offset: 1.85rem")
|
|
425
431
|
expect(stylesheet_source).to include("> .admin-copy-cell")
|
|
426
432
|
expect(stylesheet_source).to include("width: 100% !important")
|
|
427
433
|
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.13
|
|
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-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: administrate
|