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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +17 -15
  3. data/app/components/trek/dashboard/analytics_component/analytics_component.css +4 -0
  4. data/app/components/trek/dashboard/analytics_component/analytics_component.html.slim +2 -0
  5. data/app/components/trek/dashboard/analytics_component/analytics_component.js +1 -0
  6. data/app/components/trek/dashboard/analytics_component.rb +7 -0
  7. data/app/components/trek/dashboard/tile_component/tile_component.html.slim +1 -1
  8. data/app/components/trek/dashboard/tile_component.rb +2 -0
  9. data/app/components/trek/form/actions_component.rb +1 -1
  10. data/app/components/trek/form/content_editor_component/extensions/image_block.js +1 -8
  11. data/app/components/trek/form/content_editor_component/extensions/prompts_block.js +1 -8
  12. data/app/components/trek/form/image_field_component/image_field_component.css +8 -0
  13. data/app/components/trek/form/image_field_component/image_field_component.html.slim +20 -8
  14. data/app/components/trek/form/image_field_component/image_field_component.js +23 -1
  15. data/app/components/trek/form/image_field_component.rb +13 -0
  16. data/app/components/trek/list/item_component.rb +2 -1
  17. data/app/controllers/concerns/trek/model.rb +15 -1
  18. data/app/controllers/concerns/trek/redirections.rb +1 -1
  19. data/app/controllers/concerns/trek/reorderable.rb +2 -2
  20. data/app/controllers/concerns/trek/scopes.rb +55 -0
  21. data/app/views/trek/shared/_resource_heading.html.slim +1 -1
  22. data/app/views/trek/shared/_resource_index_heading.html.slim +1 -1
  23. data/config/locales/trek.en.yml +1 -0
  24. data/config/locales/trek.fr.yml +1 -0
  25. data/lib/generators/trek/scaffold_generator.rb +24 -6
  26. data/lib/generators/trek/templates/controllers/admin/scaffold_controller.rb.tt +6 -0
  27. data/lib/generators/trek/templates/controllers/admin/users_controller.rb +1 -1
  28. data/lib/generators/trek/templates/initializers/shrine.rb +1 -0
  29. data/lib/generators/trek/templates/locales/scaffold/admin.en.yml.tt +1 -1
  30. data/lib/generators/trek/templates/locales/scaffold/admin.other.yml.tt +1 -1
  31. data/lib/generators/trek/templates/locales/scaffold/model.en.yml.tt +2 -2
  32. data/lib/generators/trek/templates/locales/scaffold/model.other.yml.tt +2 -2
  33. data/lib/generators/trek/templates/policies/admin/scaffold_policy.rb.tt +7 -1
  34. data/lib/generators/trek/templates/views/admin/fragments/_form.html.slim +1 -1
  35. data/lib/generators/trek/templates/views/admin/fragments/index.html.slim +1 -1
  36. data/lib/generators/trek/templates/views/admin/menu_nodes/_form.html.slim +1 -1
  37. data/lib/generators/trek/templates/views/admin/pages/_form.html.slim +1 -1
  38. data/lib/generators/trek/templates/views/admin/pages/index.html.slim +1 -1
  39. data/lib/generators/trek/templates/views/admin/scaffold/_form.html.slim.tt +1 -1
  40. data/lib/generators/trek/templates/views/admin/users/index.html.slim +1 -1
  41. data/lib/trek/version.rb +1 -1
  42. data/package.json +1 -1
  43. metadata +6 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c361aedf0c96319053cdbb1e2d80ac77248791c84fedd2f0bb49e89b3d6afa7f
4
- data.tar.gz: 40fd5afd6fa1cd82f8095e2164d46f5943c0a723fe79878e4046cb576bb3eba0
3
+ metadata.gz: 5cea2a831c71a33aa66c06d9c482aaa195a32eab3d15036892d42b7ad780d896
4
+ data.tar.gz: 8589d77eec5df070bea04c13fea05a46e7b516533e3a044f5bbf10a1551dda27
5
5
  SHA512:
6
- metadata.gz: 37c0db5305f16dfc336b2e9383bb03997dc6613c77a0c797648dd3a77ed2f0300028330b4eae72d2775dbfc407e260b3f8b8877cd3e0c3120b884447b53235cc
7
- data.tar.gz: 7a7d98baf92ad4bed55736607976a73af61696381b90252e3f0f63a691dfb31f5b959982c5570a452ec004199c92ea344a12116904049d7dba315c57c6d3b9ff
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.19)
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.16)
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.1)
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.16.0)
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.18.0)
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.0)
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.1)
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.1-arm64-darwin)
300
+ nokogiri (1.19.2-arm64-darwin)
299
301
  racc (~> 1.4)
300
- nokogiri (1.19.1-x86_64-darwin)
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.7.0)
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.6.2)
353
- loofah (~> 2.21)
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.3)
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.4.0)
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.4)
518
+ zeitwerk (2.7.5)
517
519
 
518
520
  PLATFORMS
519
521
  arm64-darwin-24
@@ -0,0 +1,4 @@
1
+ .root {
2
+ display: block;
3
+ max-width: 120rem;
4
+ }
@@ -0,0 +1,2 @@
1
+ div(class=root_class)
2
+ div(class=class_for("info")) = section
@@ -0,0 +1 @@
1
+ import "./analytics_component.css";
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trek
4
+ class Dashboard::AnalyticsComponent < Trek::Component
5
+ renders_one :section, Trek::Dashboard::SectionComponent
6
+ end
7
+ end
@@ -1,4 +1,4 @@
1
- = link_to href, class: classes
1
+ = link_to href, class: classes, rel: rel, target: target
2
2
  - if icon
3
3
  = render Trek::IconComponent.new(icon, classnames: class_for("icon"))
4
4
  span(class=class_for("text")) = formatted_text
@@ -5,6 +5,8 @@ module Trek
5
5
  option :color, default: proc { :slate }
6
6
  option :href
7
7
  option :icon, optional: true
8
+ option :rel, optional: true
9
+ option :target, optional: true
8
10
  option :text
9
11
  option :allowed_to, default: -> { true }
10
12
 
@@ -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
- = render Trek::ButtonComponent.new( \
15
- tag: :label,
16
- text: button_text,
17
- size: :narrow,
18
- )
19
- = form.file_field method_name,
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 = ["content", "fileInput", "hiddenInput", "preview"];
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
@@ -27,8 +27,9 @@ module Trek
27
27
 
28
28
  def item_link
29
29
  [
30
- (action == :show) ? nil : action,
30
+ ((action == :show) ? nil : action),
31
31
  :admin,
32
+ *helpers.model_element_route[0...-1],
32
33
  item
33
34
  ].compact
34
35
  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")
@@ -17,7 +17,7 @@ module Trek
17
17
  end
18
18
 
19
19
  def success_redirect
20
- [:admin, model_collection]
20
+ [:admin, *model_collection_route]
21
21
  end
22
22
  end
23
23
  end
@@ -31,7 +31,7 @@ module Trek
31
31
  end
32
32
 
33
33
  def reorder_path
34
- [:reorder, :admin, model_collection]
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, model_collection]
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
@@ -4,7 +4,7 @@
4
4
  ) do |c|
5
5
  ruby:
6
6
  c.with_button(
7
- href: [:admin, model_collection],
7
+ href: [:admin, *model_collection_route],
8
8
  text: t("admin.actions.cancel"),
9
9
  )
10
10
 
@@ -27,7 +27,7 @@
27
27
 
28
28
  if allowed_to?(:new?, model)
29
29
  c.with_button(
30
- href: [:new, :admin, model_element],
30
+ href: [:new, :admin, *model_element_route],
31
31
  text: i18n_resource_label(:new, model),
32
32
  ) do |b|
33
33
  b.with_icon("trek/add")
@@ -43,6 +43,7 @@ en:
43
43
  n: New %{resource}
44
44
  reorder_resource:
45
45
  n: Reorder %{resources}
46
+ remove: Remove
46
47
  replace: Replace
47
48
  search_resource:
48
49
  n: Search for a %{resource}
@@ -49,6 +49,7 @@ fr:
49
49
  f: Réorganiser les %{resources}
50
50
  m: Réorganiser les %{resources}
51
51
  m_alt: Réorganiser les %{resources}
52
+ remove: Enlever
52
53
  replace: Remplacer
53
54
  search_resource:
54
55
  "n": Rechercher un·e %{resources}
@@ -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/#{plural_name}_controller.rb"
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/#{plural_name}/#{view}.html.slim"
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
- File.delete(model_locale_file(:en))
98
- File.delete(admin_locale_file(:en))
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/#{singular_name}.#{locale}.yml"
156
+ "config/locales/models/#{file_path}.#{locale}.yml"
151
157
  end
152
158
 
153
159
  def admin_locale_file(locale)
154
- "config/locales/admin/#{singular_name}.#{locale}.yml"
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
@@ -13,7 +13,7 @@ module Admin
13
13
 
14
14
  def success_redirect
15
15
  if allowed_to?(:index?, @object)
16
- [:admin, model_collection]
16
+ [:admin, *model_collection_route]
17
17
  elsif allowed_to?(:show?, @object)
18
18
  [:admin, @object]
19
19
  else
@@ -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,6 +1,6 @@
1
1
  en:
2
2
  admin:
3
- <%= plural_name %>:
3
+ <%= namespaced_plural %>:
4
4
  create:
5
5
  success: <%= human_name %> added
6
6
  destroy:
@@ -1,6 +1,6 @@
1
1
  <%= @locale %>:
2
2
  admin:
3
- <%= plural_name %>:
3
+ <%= namespaced_plural %>:
4
4
  create:
5
5
  success:
6
6
  destroy:
@@ -1,11 +1,11 @@
1
1
  en:
2
2
  activerecord:
3
3
  models:
4
- <%= singular_name %>:
4
+ <%= file_path %>:
5
5
  gender: 'n'
6
6
  one: <%= human_name %>
7
7
  other: <%= plural_name.humanize %>
8
8
  attributes:
9
- <%= singular_name %>:<%- attributes.each do |attr| %>
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
- <%= singular_name %>:
4
+ <%= file_path %>:
5
5
  gender: # "n", "m", "f"
6
6
  one:
7
7
  other:
8
8
  attributes:
9
- <%= singular_name %>:
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
- class <%= class_name %>Policy < Trek::ResourcePolicy
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
@@ -19,7 +19,7 @@
19
19
  = render Trek::Form::ActionsComponent.new do |c|
20
20
  ruby:
21
21
  c.with_button(
22
- href: [:admin, model_collection],
22
+ href: [:admin, *model_collection_route],
23
23
  text: t("admin.actions.cancel"),
24
24
  )
25
25
 
@@ -5,7 +5,7 @@
5
5
  ruby:
6
6
  if allowed_to?(:new?, model)
7
7
  c.with_button(
8
- href: [:new, :admin, model_element],
8
+ href: [:new, :admin, *model_element_route],
9
9
  text: i18n_resource_label(:new, model),
10
10
  ) do |b|
11
11
  b.with_icon("trek/add")
@@ -8,7 +8,7 @@
8
8
  = render Trek::Form::ActionsComponent.new do |c|
9
9
  ruby:
10
10
  c.with_button(
11
- href: [:admin, model_collection],
11
+ href: [:admin, *model_collection_route],
12
12
  text: t("admin.actions.cancel"),
13
13
  )
14
14
 
@@ -92,7 +92,7 @@
92
92
  = render Trek::Form::ActionsComponent.new do |c|
93
93
  ruby:
94
94
  c.with_button(
95
- href: [:admin, model_collection],
95
+ href: [:admin, *model_collection_route],
96
96
  text: t("admin.actions.cancel"),
97
97
  )
98
98
 
@@ -26,7 +26,7 @@
26
26
 
27
27
  if allowed_to?(:new?, model)
28
28
  c.with_button(
29
- href: [:new, :admin, model_element],
29
+ href: [:new, :admin, *model_element_route],
30
30
  text: i18n_resource_label(:new, model),
31
31
  ) do |b|
32
32
  b.with_icon("trek/add")
@@ -11,7 +11,7 @@
11
11
  = render Trek::Form::ActionsComponent.new do |c|
12
12
  ruby:
13
13
  c.with_button(
14
- href: [:admin, model_collection],
14
+ href: [:admin, *model_collection_route],
15
15
  text: t("admin.actions.cancel"),
16
16
  )
17
17
 
@@ -5,7 +5,7 @@
5
5
  ruby:
6
6
  if allowed_to?(:new?, model)
7
7
  c.with_button(
8
- href: [:new, :admin, model_element],
8
+ href: [:new, :admin, *model_element_route],
9
9
  text: i18n_resource_label(:new, model),
10
10
  ) do |b|
11
11
  b.with_icon("trek/add")
data/lib/trek/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trek
4
- VERSION = "0.1.19"
4
+ VERSION = "0.1.21"
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etaminstudio/trek",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "A modern CMS for Ruby on Rails",
5
5
  "main": "app/javascript/trek.js",
6
6
  "repository": {
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.19
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