trek 0.1.19 → 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/analytics_component/analytics_component.css +4 -0
- data/app/components/trek/dashboard/analytics_component/analytics_component.html.slim +2 -0
- data/app/components/trek/dashboard/analytics_component/analytics_component.js +1 -0
- data/app/components/trek/dashboard/analytics_component.rb +7 -0
- 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/actions_component.rb +1 -1
- data/app/components/trek/form/content_editor_component/extensions/image_block.js +1 -8
- data/app/components/trek/form/content_editor_component/extensions/prompts_block.js +1 -8
- 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/app/components/trek/list/item_component.rb +2 -1
- data/app/controllers/concerns/trek/model.rb +15 -1
- data/app/controllers/concerns/trek/redirections.rb +1 -1
- data/app/controllers/concerns/trek/reorderable.rb +2 -2
- data/app/controllers/concerns/trek/scopes.rb +55 -0
- data/app/views/trek/shared/_resource_heading.html.slim +1 -1
- data/app/views/trek/shared/_resource_index_heading.html.slim +1 -1
- data/config/locales/trek.en.yml +1 -0
- data/config/locales/trek.fr.yml +1 -0
- data/lib/generators/trek/scaffold_generator.rb +24 -6
- data/lib/generators/trek/templates/controllers/admin/scaffold_controller.rb.tt +6 -0
- data/lib/generators/trek/templates/controllers/admin/users_controller.rb +1 -1
- data/lib/generators/trek/templates/initializers/shrine.rb +1 -0
- data/lib/generators/trek/templates/locales/scaffold/admin.en.yml.tt +1 -1
- data/lib/generators/trek/templates/locales/scaffold/admin.other.yml.tt +1 -1
- data/lib/generators/trek/templates/locales/scaffold/model.en.yml.tt +2 -2
- data/lib/generators/trek/templates/locales/scaffold/model.other.yml.tt +2 -2
- data/lib/generators/trek/templates/policies/admin/scaffold_policy.rb.tt +7 -1
- data/lib/generators/trek/templates/views/admin/fragments/_form.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin/fragments/index.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin/menu_nodes/_form.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin/pages/_form.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin/pages/index.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin/scaffold/_form.html.slim.tt +1 -1
- data/lib/generators/trek/templates/views/admin/users/index.html.slim +1 -1
- data/lib/trek/version.rb +1 -1
- data/package.json +1 -1
- metadata +6 -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./analytics_component.css";
|
|
@@ -14,7 +14,7 @@ module Trek
|
|
|
14
14
|
|
|
15
15
|
with_button(
|
|
16
16
|
text: helpers.t("admin.actions.delete"),
|
|
17
|
-
to: [:admin, object],
|
|
17
|
+
to: [:admin, *helpers.model_element_route[0...-1], object],
|
|
18
18
|
method: :delete,
|
|
19
19
|
data: {
|
|
20
20
|
turbo_confirm: helpers.t("admin.#{model_collection}.destroy.confirm")
|
|
@@ -48,14 +48,7 @@ export default Node.create({
|
|
|
48
48
|
},
|
|
49
49
|
|
|
50
50
|
addNodeView() {
|
|
51
|
-
return ({
|
|
52
|
-
editor,
|
|
53
|
-
node,
|
|
54
|
-
getPos,
|
|
55
|
-
HTMLAttributes,
|
|
56
|
-
decorations,
|
|
57
|
-
extension,
|
|
58
|
-
}) => {
|
|
51
|
+
return ({ node }) => {
|
|
59
52
|
const dom = document.createElement("image-block");
|
|
60
53
|
const params = attributesToParams(node.attrs);
|
|
61
54
|
|
|
@@ -45,14 +45,7 @@ export default Node.create({
|
|
|
45
45
|
},
|
|
46
46
|
|
|
47
47
|
addNodeView() {
|
|
48
|
-
return ({
|
|
49
|
-
editor,
|
|
50
|
-
node,
|
|
51
|
-
getPos,
|
|
52
|
-
HTMLAttributes,
|
|
53
|
-
decorations,
|
|
54
|
-
extension,
|
|
55
|
-
}) => {
|
|
48
|
+
return ({ node }) => {
|
|
56
49
|
const dom = document.createElement("prompts-block");
|
|
57
50
|
const params = attributesToParams(node.attrs);
|
|
58
51
|
|
|
@@ -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
|
|
@@ -5,7 +5,7 @@ module Trek
|
|
|
5
5
|
included do
|
|
6
6
|
delegate :model_name, to: :model
|
|
7
7
|
|
|
8
|
-
helper_attr :model, :model_name, :model_collection, :model_element, :model_intro
|
|
8
|
+
helper_attr :model, :model_name, :model_collection, :model_collection_route, :model_element, :model_element_route, :model_intro
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def model
|
|
@@ -20,10 +20,24 @@ module Trek
|
|
|
20
20
|
model_name.collection.to_sym
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# Returns model collection as an array of symbols for route building.
|
|
24
|
+
# For namespaced models like Missive::List, returns [:missive, :lists].
|
|
25
|
+
# For non-namespaced models like Page, returns [:pages].
|
|
26
|
+
def model_collection_route
|
|
27
|
+
model_name.collection.split("/").map(&:to_sym)
|
|
28
|
+
end
|
|
29
|
+
|
|
23
30
|
def model_element
|
|
24
31
|
model_name.element.to_sym
|
|
25
32
|
end
|
|
26
33
|
|
|
34
|
+
# Returns model element as an array of symbols for route building.
|
|
35
|
+
# For namespaced models like Missive::List, returns [:missive, :list].
|
|
36
|
+
# For non-namespaced models like Page, returns [:page].
|
|
37
|
+
def model_element_route
|
|
38
|
+
model_name.element.split("/").map(&:to_sym)
|
|
39
|
+
end
|
|
40
|
+
|
|
27
41
|
def model_intro(action: nil)
|
|
28
42
|
action ||= @object&.new_record? ? "new" : "edit"
|
|
29
43
|
t("admin.#{model_collection}.#{action}.intro")
|
|
@@ -31,7 +31,7 @@ module Trek
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def reorder_path
|
|
34
|
-
[:reorder, :admin,
|
|
34
|
+
[:reorder, :admin, *model_collection_route]
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def reorder_params
|
|
@@ -39,7 +39,7 @@ module Trek
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def reorder_success_redirect
|
|
42
|
-
[:admin,
|
|
42
|
+
[:admin, *model_collection_route]
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def reorder_notice
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Trek
|
|
4
|
+
module Scopes
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
def apply_scopes(scope, filters)
|
|
8
|
+
return scope if filters.blank?
|
|
9
|
+
|
|
10
|
+
filters.each do |filter, value|
|
|
11
|
+
next if value.blank?
|
|
12
|
+
|
|
13
|
+
scope = scope.public_send(filter) if scope.respond_to?(filter)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
scope
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def apply_scopes!
|
|
20
|
+
@unscoped_objects = @objects
|
|
21
|
+
@objects = apply_scopes(@objects, params[:scopes])
|
|
22
|
+
scope_counts
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
included do
|
|
26
|
+
helper_method :available_scopes
|
|
27
|
+
helper_method :scope_params
|
|
28
|
+
helper_method :unscoped_objects
|
|
29
|
+
helper_method :scope_counts
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def unscoped_objects
|
|
33
|
+
@unscoped_objects || @objects
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def scope_counts
|
|
37
|
+
@scope_counts ||= begin
|
|
38
|
+
Prosopite.pause if defined?(Prosopite)
|
|
39
|
+
available_scopes.index_with do |scope|
|
|
40
|
+
unscoped_objects.except(:limit, :offset).public_send(scope).count
|
|
41
|
+
end
|
|
42
|
+
ensure
|
|
43
|
+
Prosopite.resume if defined?(Prosopite)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def available_scopes
|
|
48
|
+
[]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def scope_params
|
|
52
|
+
params[:scopes]&.permit(*available_scopes)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
data/config/locales/trek.en.yml
CHANGED
data/config/locales/trek.fr.yml
CHANGED
|
@@ -32,13 +32,13 @@ module Trek
|
|
|
32
32
|
|
|
33
33
|
def create_controller
|
|
34
34
|
template "controllers/admin/scaffold_controller.rb",
|
|
35
|
-
"app/controllers/admin/#{
|
|
35
|
+
"app/controllers/admin/#{namespaced_plural}_controller.rb"
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def create_views
|
|
39
39
|
%w[index edit new _form show].each do |view|
|
|
40
40
|
template "views/admin/scaffold/#{view}.html.slim",
|
|
41
|
-
"app/views/admin/#{
|
|
41
|
+
"app/views/admin/#{namespaced_plural}/#{view}.html.slim"
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -56,6 +56,12 @@ module Trek
|
|
|
56
56
|
# post :reorder, on: :collection
|
|
57
57
|
end
|
|
58
58
|
RUBY
|
|
59
|
+
|
|
60
|
+
if model_namespaces.any?
|
|
61
|
+
# Wrap resources in nested namespaces for namespaced models
|
|
62
|
+
model_namespaces.each { |ns| route_code = "namespace :#{ns} do\n #{route_code.gsub("\n", "\n ")}\nend" }
|
|
63
|
+
end
|
|
64
|
+
|
|
59
65
|
route route_code, namespace: :admin
|
|
60
66
|
end
|
|
61
67
|
|
|
@@ -94,8 +100,8 @@ module Trek
|
|
|
94
100
|
def cleanup
|
|
95
101
|
return if I18n.available_locales.include?(:en)
|
|
96
102
|
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
FileUtils.rm_f(model_locale_file(:en))
|
|
104
|
+
FileUtils.rm_f(admin_locale_file(:en))
|
|
99
105
|
end
|
|
100
106
|
|
|
101
107
|
private
|
|
@@ -147,11 +153,23 @@ module Trek
|
|
|
147
153
|
end
|
|
148
154
|
|
|
149
155
|
def model_locale_file(locale)
|
|
150
|
-
"config/locales/models/#{
|
|
156
|
+
"config/locales/models/#{file_path}.#{locale}.yml"
|
|
151
157
|
end
|
|
152
158
|
|
|
153
159
|
def admin_locale_file(locale)
|
|
154
|
-
"config/locales/admin/#{
|
|
160
|
+
"config/locales/admin/#{file_path}.#{locale}.yml"
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Returns namespace segments from file_path (e.g., ["missive"] for "missive/list")
|
|
164
|
+
def model_namespaces
|
|
165
|
+
file_path.split("/")[0...-1]
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Returns the pluralized path preserving namespaces (e.g., "missive/lists" for "missive/list")
|
|
169
|
+
def namespaced_plural
|
|
170
|
+
parts = file_path.split("/")
|
|
171
|
+
parts[-1] = parts[-1].pluralize
|
|
172
|
+
parts.join("/")
|
|
155
173
|
end
|
|
156
174
|
end
|
|
157
175
|
end
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
module Admin
|
|
2
|
+
<% model_namespaces.each do |ns| -%>
|
|
3
|
+
module <%= ns.camelize %>
|
|
4
|
+
<% end -%>
|
|
2
5
|
class <%= controller_class_name %>Controller < Trek::ResourceController
|
|
3
6
|
# include Trek::Pagination
|
|
4
7
|
|
|
@@ -8,4 +11,7 @@ module Admin
|
|
|
8
11
|
<%= class_name %>
|
|
9
12
|
end
|
|
10
13
|
end
|
|
14
|
+
<% model_namespaces.each do |_ns| -%>
|
|
15
|
+
end
|
|
16
|
+
<% end -%>
|
|
11
17
|
end
|
|
@@ -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
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
en:
|
|
2
2
|
activerecord:
|
|
3
3
|
models:
|
|
4
|
-
<%=
|
|
4
|
+
<%= file_path %>:
|
|
5
5
|
gender: 'n'
|
|
6
6
|
one: <%= human_name %>
|
|
7
7
|
other: <%= plural_name.humanize %>
|
|
8
8
|
attributes:
|
|
9
|
-
<%=
|
|
9
|
+
<%= file_path %>:<%- attributes.each do |attr| %>
|
|
10
10
|
<%= attr.name %>: <%= attr.name.humanize -%>
|
|
11
11
|
<% end %>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<%= @locale %>:
|
|
2
2
|
activerecord:
|
|
3
3
|
models:
|
|
4
|
-
<%=
|
|
4
|
+
<%= file_path %>:
|
|
5
5
|
gender: # "n", "m", "f"
|
|
6
6
|
one:
|
|
7
7
|
other:
|
|
8
8
|
attributes:
|
|
9
|
-
<%=
|
|
9
|
+
<%= file_path %>:
|
|
10
10
|
<%- attributes.each do |attr| -%>
|
|
11
11
|
<%= attr.name %>:
|
|
12
12
|
<%- end -%>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
module Admin
|
|
2
|
-
|
|
2
|
+
<% model_namespaces.each do |ns| -%>
|
|
3
|
+
module <%= ns.camelize %>
|
|
4
|
+
<% end -%>
|
|
5
|
+
class <%= class_name.demodulize %>Policy < Trek::ResourcePolicy
|
|
3
6
|
def index?
|
|
4
7
|
user.privileged?
|
|
5
8
|
end
|
|
@@ -36,4 +39,7 @@ module Admin
|
|
|
36
39
|
relation.none
|
|
37
40
|
end
|
|
38
41
|
end
|
|
42
|
+
<% model_namespaces.each do |_ns| -%>
|
|
43
|
+
end
|
|
44
|
+
<% end -%>
|
|
39
45
|
end
|
data/lib/trek/version.rb
CHANGED
data/package.json
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trek
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.21
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mohamed Bengrich
|
|
@@ -503,6 +503,10 @@ files:
|
|
|
503
503
|
- app/components/trek/button_group_component/button_group_component.css
|
|
504
504
|
- app/components/trek/button_group_component/button_group_component.js
|
|
505
505
|
- app/components/trek/component.rb
|
|
506
|
+
- app/components/trek/dashboard/analytics_component.rb
|
|
507
|
+
- app/components/trek/dashboard/analytics_component/analytics_component.css
|
|
508
|
+
- app/components/trek/dashboard/analytics_component/analytics_component.html.slim
|
|
509
|
+
- app/components/trek/dashboard/analytics_component/analytics_component.js
|
|
506
510
|
- app/components/trek/dashboard/section_component.rb
|
|
507
511
|
- app/components/trek/dashboard/section_component/section_component.css
|
|
508
512
|
- app/components/trek/dashboard/section_component/section_component.html.slim
|
|
@@ -638,6 +642,7 @@ files:
|
|
|
638
642
|
- app/controllers/concerns/trek/pagination.rb
|
|
639
643
|
- app/controllers/concerns/trek/redirections.rb
|
|
640
644
|
- app/controllers/concerns/trek/reorderable.rb
|
|
645
|
+
- app/controllers/concerns/trek/scopes.rb
|
|
641
646
|
- app/controllers/trek/base_controller.rb
|
|
642
647
|
- app/controllers/trek/panels/base_controller.rb
|
|
643
648
|
- app/controllers/trek/panels/images_controller.rb
|