trek 0.1.20 → 0.1.21
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/Gemfile.lock +17 -15
- data/app/components/trek/dashboard/tile_component/tile_component.html.slim +1 -1
- data/app/components/trek/dashboard/tile_component.rb +2 -0
- data/app/components/trek/form/image_field_component/image_field_component.css +8 -0
- data/app/components/trek/form/image_field_component/image_field_component.html.slim +20 -8
- data/app/components/trek/form/image_field_component/image_field_component.js +23 -1
- data/app/components/trek/form/image_field_component.rb +13 -0
- data/config/locales/trek.en.yml +1 -0
- data/config/locales/trek.fr.yml +1 -0
- data/lib/generators/trek/templates/initializers/shrine.rb +1 -0
- data/lib/trek/version.rb +1 -1
- data/package.json +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5cea2a831c71a33aa66c06d9c482aaa195a32eab3d15036892d42b7ad780d896
|
|
4
|
+
data.tar.gz: 8589d77eec5df070bea04c13fea05a46e7b516533e3a044f5bbf10a1551dda27
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0d9a672bbf54060d276ae97b2897b5fb5769d15ab3a64ad8cda2fedfe7875395d89a04bc0116100ee667b195197d1ba610a2e3ff5180492a7743ff8294877d44
|
|
7
|
+
data.tar.gz: df786a478a60fa19944403b15bf41d2c2c9eef5f25e1d5ed638ae2a8be7a8bcf8d33482cec0a1c68254a6424668ad0ac3afc472b49da85882cb2250cd70a7a90
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
trek (0.1.
|
|
4
|
+
trek (0.1.21)
|
|
5
5
|
action_policy (~> 0.6)
|
|
6
6
|
actioncable
|
|
7
7
|
acts_as_list (~> 1.1)
|
|
@@ -37,7 +37,7 @@ GEM
|
|
|
37
37
|
specs:
|
|
38
38
|
action_policy (0.7.5)
|
|
39
39
|
ruby-next-core (>= 1.0)
|
|
40
|
-
action_text-trix (2.1.
|
|
40
|
+
action_text-trix (2.1.17)
|
|
41
41
|
railties
|
|
42
42
|
actioncable (8.1.1)
|
|
43
43
|
actionpack (= 8.1.1)
|
|
@@ -200,7 +200,7 @@ GEM
|
|
|
200
200
|
dry-inflector (~> 1.0)
|
|
201
201
|
dry-logic (~> 1.4)
|
|
202
202
|
zeitwerk (~> 2.6)
|
|
203
|
-
erb (6.0.
|
|
203
|
+
erb (6.0.2)
|
|
204
204
|
erubi (1.13.1)
|
|
205
205
|
fastimage (2.4.0)
|
|
206
206
|
ffi (1.17.3-arm64-darwin)
|
|
@@ -230,12 +230,13 @@ GEM
|
|
|
230
230
|
mini_magick (>= 4.9.5, < 6)
|
|
231
231
|
ruby-vips (>= 2.0.17, < 3)
|
|
232
232
|
io-console (0.8.2)
|
|
233
|
-
irb (1.
|
|
233
|
+
irb (1.17.0)
|
|
234
234
|
pp (>= 0.6.0)
|
|
235
|
+
prism (>= 1.3.0)
|
|
235
236
|
rdoc (>= 4.0.0)
|
|
236
237
|
reline (>= 0.4.2)
|
|
237
238
|
jmespath (1.6.2)
|
|
238
|
-
json (2.
|
|
239
|
+
json (2.19.2)
|
|
239
240
|
kaminari (1.2.2)
|
|
240
241
|
activesupport (>= 4.1.0)
|
|
241
242
|
kaminari-actionview (= 1.2.2)
|
|
@@ -254,7 +255,7 @@ GEM
|
|
|
254
255
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
255
256
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
256
257
|
logger (1.7.0)
|
|
257
|
-
loofah (2.25.
|
|
258
|
+
loofah (2.25.1)
|
|
258
259
|
crass (~> 1.0.2)
|
|
259
260
|
nokogiri (>= 1.12.0)
|
|
260
261
|
lookbook (2.3.14)
|
|
@@ -280,7 +281,8 @@ GEM
|
|
|
280
281
|
mini_magick (5.3.1)
|
|
281
282
|
logger
|
|
282
283
|
mini_mime (1.1.5)
|
|
283
|
-
minitest (6.0.
|
|
284
|
+
minitest (6.0.2)
|
|
285
|
+
drb (~> 2.0)
|
|
284
286
|
prism (~> 1.5)
|
|
285
287
|
mobility (1.3.2)
|
|
286
288
|
i18n (>= 0.6.10, < 2)
|
|
@@ -295,9 +297,9 @@ GEM
|
|
|
295
297
|
net-smtp (0.5.1)
|
|
296
298
|
net-protocol
|
|
297
299
|
nio4r (2.7.5)
|
|
298
|
-
nokogiri (1.19.
|
|
300
|
+
nokogiri (1.19.2-arm64-darwin)
|
|
299
301
|
racc (~> 1.4)
|
|
300
|
-
nokogiri (1.19.
|
|
302
|
+
nokogiri (1.19.2-x86_64-darwin)
|
|
301
303
|
racc (~> 1.4)
|
|
302
304
|
parallel (1.27.0)
|
|
303
305
|
parser (3.3.10.0)
|
|
@@ -312,7 +314,7 @@ GEM
|
|
|
312
314
|
pp (0.6.3)
|
|
313
315
|
prettyprint
|
|
314
316
|
prettyprint (0.2.0)
|
|
315
|
-
prism (1.
|
|
317
|
+
prism (1.9.0)
|
|
316
318
|
prosemirror_to_html (0.3.0)
|
|
317
319
|
nokogiri
|
|
318
320
|
psych (5.3.1)
|
|
@@ -349,8 +351,8 @@ GEM
|
|
|
349
351
|
rails-healthcheck (1.4.0)
|
|
350
352
|
actionpack
|
|
351
353
|
railties
|
|
352
|
-
rails-html-sanitizer (1.
|
|
353
|
-
loofah (~> 2.
|
|
354
|
+
rails-html-sanitizer (1.7.0)
|
|
355
|
+
loofah (~> 2.25)
|
|
354
356
|
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
|
355
357
|
rails-i18n (8.1.0)
|
|
356
358
|
i18n (>= 0.7, < 2)
|
|
@@ -369,7 +371,7 @@ GEM
|
|
|
369
371
|
rb-fsevent (0.11.2)
|
|
370
372
|
rb-inotify (0.11.1)
|
|
371
373
|
ffi (~> 1.0)
|
|
372
|
-
rdoc (7.0
|
|
374
|
+
rdoc (7.2.0)
|
|
373
375
|
erb
|
|
374
376
|
psych (>= 4.0.0)
|
|
375
377
|
tsort
|
|
@@ -483,7 +485,7 @@ GEM
|
|
|
483
485
|
temple (0.10.4)
|
|
484
486
|
terminal-table (4.0.0)
|
|
485
487
|
unicode-display_width (>= 1.1.1, < 4)
|
|
486
|
-
thor (1.
|
|
488
|
+
thor (1.5.0)
|
|
487
489
|
tilt (2.6.1)
|
|
488
490
|
timeout (0.6.0)
|
|
489
491
|
tsort (0.2.0)
|
|
@@ -513,7 +515,7 @@ GEM
|
|
|
513
515
|
xpath (3.2.0)
|
|
514
516
|
nokogiri (~> 1.8)
|
|
515
517
|
yard (0.9.38)
|
|
516
|
-
zeitwerk (2.7.
|
|
518
|
+
zeitwerk (2.7.5)
|
|
517
519
|
|
|
518
520
|
PLATFORMS
|
|
519
521
|
arm64-darwin-24
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
align-items: center;
|
|
11
11
|
background-color: var(--slate-4);
|
|
12
|
+
flex-shrink: 0;
|
|
12
13
|
border: 1px solid var(--slate-a6);
|
|
13
14
|
border-radius: 0.2rem;
|
|
14
15
|
color: var(--slate-8);
|
|
@@ -29,3 +30,10 @@
|
|
|
29
30
|
.preview img {
|
|
30
31
|
object-fit: contain;
|
|
31
32
|
}
|
|
33
|
+
|
|
34
|
+
.actions {
|
|
35
|
+
align-items: flex-start;
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
gap: 0.8rem;
|
|
39
|
+
}
|
|
@@ -10,12 +10,24 @@
|
|
|
10
10
|
value: cached_data,
|
|
11
11
|
id: nil,
|
|
12
12
|
data: stimulus_target_hash("hiddenInput")
|
|
13
|
+
= form.hidden_field "remove_#{method_name}",
|
|
14
|
+
value: nil,
|
|
15
|
+
id: nil,
|
|
16
|
+
data: stimulus_target_hash("removeInput")
|
|
17
|
+
|
|
18
|
+
div(class=class_for("actions"))
|
|
19
|
+
= render Trek::ButtonComponent.new( \
|
|
20
|
+
tag: :label,
|
|
21
|
+
text: button_text,
|
|
22
|
+
size: :narrow,
|
|
23
|
+
)
|
|
24
|
+
= form.file_field method_name,
|
|
25
|
+
class: "sr-only",
|
|
26
|
+
data: file_field_data_attributes
|
|
13
27
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class: "sr-only",
|
|
21
|
-
data: file_field_data_attributes
|
|
28
|
+
- if image&.exists?
|
|
29
|
+
= render Trek::ButtonComponent.new( \
|
|
30
|
+
text: t("admin.actions.remove"),
|
|
31
|
+
size: :narrow,
|
|
32
|
+
data: remove_button_data_attributes,
|
|
33
|
+
)
|
|
@@ -8,7 +8,13 @@ import French from "@uppy/locales/lib/fr_FR";
|
|
|
8
8
|
import "@uppy/core/dist/style.css";
|
|
9
9
|
|
|
10
10
|
export class Controller extends BaseController {
|
|
11
|
-
static targets = [
|
|
11
|
+
static targets = [
|
|
12
|
+
"content",
|
|
13
|
+
"fileInput",
|
|
14
|
+
"hiddenInput",
|
|
15
|
+
"preview",
|
|
16
|
+
"removeInput",
|
|
17
|
+
];
|
|
12
18
|
|
|
13
19
|
connect() {
|
|
14
20
|
this.uppy = new Uppy({
|
|
@@ -48,6 +54,9 @@ export class Controller extends BaseController {
|
|
|
48
54
|
const uploadedFileData = response.body["data"];
|
|
49
55
|
|
|
50
56
|
this.hiddenInputTarget.value = JSON.stringify(uploadedFileData);
|
|
57
|
+
|
|
58
|
+
// Clear the remove flag when a new file is uploaded
|
|
59
|
+
this.removeInputTarget.value = "";
|
|
51
60
|
});
|
|
52
61
|
|
|
53
62
|
this.uppy.on("file-removed", () => {
|
|
@@ -64,6 +73,19 @@ export class Controller extends BaseController {
|
|
|
64
73
|
this.uppy = null;
|
|
65
74
|
}
|
|
66
75
|
|
|
76
|
+
removeImage() {
|
|
77
|
+
// Clear the cached upload data
|
|
78
|
+
this.hiddenInputTarget.value = "";
|
|
79
|
+
|
|
80
|
+
// Set the remove flag so Shrine deletes the attachment on save
|
|
81
|
+
this.removeInputTarget.value = "1";
|
|
82
|
+
|
|
83
|
+
// Reset preview to placeholder icon
|
|
84
|
+
this.previewTarget.innerHTML = `<svg class="c-trek--icon-root c-trek--icon-trek--pic" role="img" focusable="false">
|
|
85
|
+
<use xlink:href="#c-icon-trek--pic"></use>
|
|
86
|
+
</svg>`;
|
|
87
|
+
}
|
|
88
|
+
|
|
67
89
|
addFiles(event) {
|
|
68
90
|
const files = Array.from(event.target.files);
|
|
69
91
|
|
|
@@ -7,6 +7,13 @@ module Trek
|
|
|
7
7
|
include StimulusHelpers
|
|
8
8
|
include Turbo::FramesHelper
|
|
9
9
|
|
|
10
|
+
# Ensure the placeholder icon is in the sprite even when an image exists,
|
|
11
|
+
# because the JS removeImage action needs it.
|
|
12
|
+
def before_render
|
|
13
|
+
Current.icons ||= []
|
|
14
|
+
Current.icons << "trek--pic" unless Current.icons.include?("trek--pic")
|
|
15
|
+
end
|
|
16
|
+
|
|
10
17
|
private
|
|
11
18
|
|
|
12
19
|
def preview
|
|
@@ -48,6 +55,12 @@ module Trek
|
|
|
48
55
|
}.merge(stimulus_target_hash("fileInput"))
|
|
49
56
|
end
|
|
50
57
|
|
|
58
|
+
def remove_button_data_attributes
|
|
59
|
+
{
|
|
60
|
+
action: stimulus_action("removeImage")
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
|
|
51
64
|
def button_text
|
|
52
65
|
image&.exists? ? t("admin.actions.replace") : t("admin.actions.browse")
|
|
53
66
|
end
|
data/config/locales/trek.en.yml
CHANGED
data/config/locales/trek.fr.yml
CHANGED
|
@@ -35,6 +35,7 @@ end
|
|
|
35
35
|
|
|
36
36
|
Shrine.plugin :activerecord
|
|
37
37
|
Shrine.plugin :cached_attachment_data # for retaining the cached file across form redisplays
|
|
38
|
+
Shrine.plugin :remove_attachment
|
|
38
39
|
Shrine.plugin :restore_cached_data # re-extract metadata when attaching a cached file
|
|
39
40
|
Shrine.plugin :determine_mime_type, analyzer: :marcel
|
|
40
41
|
Shrine.plugin :pretty_location
|
data/lib/trek/version.rb
CHANGED
data/package.json
CHANGED