trek 0.1.19 → 0.1.20
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 +1 -1
- 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/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/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/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/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: 8836f5f71ee9aeae0475df30e1e941038aeac1d3ba5a1f0a8bc548ddf87cedff
|
|
4
|
+
data.tar.gz: 2b07e244708e2e9a6258d9d352f04fc03bba3777e11b2a6ae3a7ad7e0e100fd5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 568c5f70e0482e4ef6c86e66d4ffe46bc5828848c28ec8646129468bbc4db60c362fb3ddd4bee9ba9e747fffc5d24385f3198876bc8a3dc9031658c3eb1dc380
|
|
7
|
+
data.tar.gz: 322f0ab2ab3fc8d3bef7cabc8fadbd750b43b790163e9abf915c7bb8766c594bec7161980695e020e6d0e8b7a3e8e4a6c47309edefea2a2df72bd1918a8ffe77
|
data/Gemfile.lock
CHANGED
|
@@ -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
|
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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.20
|
|
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
|