avo 3.0.1.beta7 → 3.0.1.beta9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +23 -25
- data/{public/avo-assets/avo.css → app/assets/builds/avo.base.css} +1943 -1552
- data/app/assets/builds/avo.base.js +124556 -0
- data/app/assets/builds/avo.base.js.map +7 -0
- data/app/assets/builds/avo.custom.js +6 -0
- data/app/assets/builds/avo.custom.js.map +7 -0
- data/app/assets/stylesheets/avo.base.css +1 -0
- data/app/assets/stylesheets/css/fields/tags.css +32 -0
- data/app/components/avo/actions_component.rb +1 -1
- data/app/components/avo/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/field_wrapper_component.rb +1 -7
- data/app/components/avo/fields/boolean_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/common/badge_viewer_component.html.erb +1 -24
- data/app/components/avo/fields/common/badge_viewer_component.rb +24 -0
- data/app/components/avo/fields/common/boolean_check_component.html.erb +1 -12
- data/app/components/avo/fields/common/boolean_check_component.rb +2 -1
- data/app/components/avo/fields/common/gravatar_viewer_component.html.erb +1 -1
- data/app/components/avo/fields/common/gravatar_viewer_component.rb +2 -2
- data/app/components/avo/fields/common/heading_component.html.erb +3 -8
- data/app/components/avo/fields/common/heading_component.rb +1 -3
- data/app/components/avo/fields/common/key_value_component.html.erb +2 -2
- data/app/components/avo/fields/common/key_value_component.rb +2 -2
- data/app/components/avo/fields/common/progress_bar_component.rb +3 -9
- data/app/components/avo/fields/edit_component.rb +1 -1
- data/app/components/avo/fields/external_image_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/file_field/index_component.html.erb +2 -2
- data/app/components/avo/fields/gravatar_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/heading_field/edit_component.html.erb +1 -1
- data/app/components/avo/fields/heading_field/show_component.html.erb +1 -1
- data/app/components/avo/fields/id_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/index_component.rb +1 -1
- data/app/components/avo/fields/show_component.rb +1 -1
- data/app/components/avo/fields/text_field/index_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.rb +1 -1
- data/app/components/avo/index/resource_controls_component.rb +1 -1
- data/app/components/avo/index/resource_table_component.rb +3 -9
- data/app/components/avo/resource_component.rb +9 -4
- data/app/components/avo/sidebar_profile_component.html.erb +4 -4
- data/app/components/avo/tab_group_component.html.erb +1 -1
- data/app/components/avo/tab_switcher_component.rb +2 -2
- data/app/components/avo/views/resource_edit_component.html.erb +9 -20
- data/app/components/avo/views/resource_edit_component.rb +5 -5
- data/app/components/avo/views/resource_index_component.rb +1 -1
- data/app/components/avo/views/resource_show_component.rb +1 -1
- data/app/controllers/avo/actions_controller.rb +9 -20
- data/app/controllers/avo/application_controller.rb +5 -5
- data/app/controllers/avo/base_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +19 -2
- data/app/controllers/concerns/avo/initializes_avo.rb +1 -0
- data/app/helpers/avo/url_helpers.rb +1 -1
- data/app/views/avo/actions/show.html.erb +1 -1
- data/config/routes.rb +4 -3
- data/db/factories.rb +1 -1
- data/lib/avo/base_action.rb +20 -25
- data/lib/avo/base_resource.rb +7 -6
- data/lib/avo/concerns/filters_session_handler.rb +3 -3
- data/lib/avo/concerns/has_helpers.rb +18 -0
- data/lib/avo/concerns/has_items.rb +1 -5
- data/lib/avo/concerns/visible_in_different_views.rb +7 -1
- data/lib/avo/concerns/visible_items.rb +43 -0
- data/lib/avo/configuration.rb +8 -2
- data/lib/avo/current.rb +1 -0
- data/lib/avo/execution_context.rb +4 -1
- data/lib/avo/fields/badge_field.rb +1 -1
- data/lib/avo/fields/base_field.rb +21 -44
- data/lib/avo/fields/belongs_to_field.rb +1 -1
- data/lib/avo/fields/concerns/has_html_attributes.rb +2 -0
- data/lib/avo/fields/concerns/use_view_components.rb +45 -0
- data/lib/avo/fields/external_image_field.rb +2 -2
- data/lib/avo/fields/file_field.rb +2 -2
- data/lib/avo/fields/gravatar_field.rb +2 -2
- data/lib/avo/fields/has_base_field.rb +2 -2
- data/lib/avo/fields/heading_field.rb +5 -13
- data/lib/avo/fields/id_field.rb +2 -2
- data/lib/avo/fields/text_field.rb +2 -2
- data/lib/avo/resources/items/holder.rb +0 -6
- data/lib/avo/resources/items/item_group.rb +2 -2
- data/lib/avo/resources/items/row.rb +3 -3
- data/lib/avo/resources/items/sidebar.rb +1 -1
- data/lib/avo/resources/items/tab.rb +2 -2
- data/lib/avo/resources/items/tab_group.rb +1 -1
- data/lib/avo/resources/resource_manager.rb +6 -1
- data/lib/avo/version.rb +1 -1
- data/lib/avo/view_inquirer.rb +36 -0
- data/lib/avo.rb +9 -0
- data/lib/generators/avo/eject_generator.rb +93 -16
- data/lib/generators/avo/js/install_generator.rb +2 -2
- data/lib/generators/avo/resource_generator.rb +5 -5
- data/lib/generators/avo/tailwindcss/install_generator.rb +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +5 -0
- data/public/avo-assets/avo.base.css +54 -219
- metadata +12 -6
- data/config/master.key +0 -1
- data/public/avo-assets/avo.js +0 -513
- data/public/avo-assets/avo.js.map +0 -7
data/lib/avo/fields/id_field.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Avo
|
2
2
|
module Fields
|
3
3
|
class IdField < BaseField
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :link_to_record
|
5
5
|
|
6
6
|
def initialize(id, **args, &block)
|
7
7
|
args[:readonly] = true
|
@@ -12,7 +12,7 @@ module Avo
|
|
12
12
|
|
13
13
|
add_boolean_prop args, :sortable, true
|
14
14
|
|
15
|
-
@
|
15
|
+
@link_to_record = args[:link_to_record].present? ? args[:link_to_record] : false
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Avo
|
2
2
|
module Fields
|
3
3
|
class TextField < BaseField
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :link_to_record
|
5
5
|
attr_reader :as_html
|
6
6
|
attr_reader :protocol
|
7
7
|
|
8
8
|
def initialize(id, **args, &block)
|
9
9
|
super(id, **args, &block)
|
10
10
|
|
11
|
-
add_boolean_prop args, :
|
11
|
+
add_boolean_prop args, :link_to_record
|
12
12
|
add_boolean_prop args, :as_html
|
13
13
|
add_string_prop args, :protocol
|
14
14
|
end
|
@@ -56,12 +56,6 @@ class Avo::Resources::Items::Holder
|
|
56
56
|
add_item panel
|
57
57
|
end
|
58
58
|
|
59
|
-
def heading(body = nil, **args, &block)
|
60
|
-
field = Avo::Fields::HeadingField.new(body, **args)
|
61
|
-
|
62
|
-
add_item field
|
63
|
-
end
|
64
|
-
|
65
59
|
def sidebar(**args, &block)
|
66
60
|
add_item Avo::Resources::Items::Sidebar::Builder.parse_block(**args, &block)
|
67
61
|
end
|
@@ -3,7 +3,7 @@ class Avo::Resources::Items::ItemGroup
|
|
3
3
|
|
4
4
|
include Avo::Concerns::HasItems
|
5
5
|
include Avo::Concerns::HasItemType
|
6
|
-
include Avo::Concerns::
|
6
|
+
include Avo::Concerns::VisibleItems
|
7
7
|
include Avo::Concerns::VisibleInDifferentViews
|
8
8
|
|
9
9
|
attr_reader :name
|
@@ -13,7 +13,7 @@ class Avo::Resources::Items::ItemGroup
|
|
13
13
|
|
14
14
|
def initialize(name: nil, description: nil, view: nil, **args)
|
15
15
|
@name = name
|
16
|
-
@view = view
|
16
|
+
@view = Avo::ViewInquirer.new view
|
17
17
|
@description = description
|
18
18
|
@items_holder = Avo::Resources::Items::Holder.new
|
19
19
|
@args = args
|
@@ -2,7 +2,7 @@ class Avo::Resources::Items::Row
|
|
2
2
|
include Avo::Concerns::IsResourceItem
|
3
3
|
include Avo::Concerns::HasItems
|
4
4
|
include Avo::Concerns::HasItemType
|
5
|
-
include Avo::Concerns::
|
5
|
+
include Avo::Concerns::VisibleItems
|
6
6
|
|
7
7
|
class_attribute :item_type, default: :row
|
8
8
|
|
@@ -12,12 +12,12 @@ class Avo::Resources::Items::Row
|
|
12
12
|
delegate :items, :add_item, to: :items_holder
|
13
13
|
|
14
14
|
def initialize(view: nil)
|
15
|
-
@view = view
|
15
|
+
@view = Avo::ViewInquirer.new view
|
16
16
|
@items_holder = Avo::Resources::Items::Holder.new
|
17
17
|
end
|
18
18
|
|
19
19
|
def hydrate(view: nil, resource: nil, **args)
|
20
|
-
@view = view
|
20
|
+
@view = Avo::ViewInquirer.new view
|
21
21
|
@resource = resource
|
22
22
|
|
23
23
|
self
|
@@ -13,7 +13,7 @@ class Avo::Resources::Items::Sidebar
|
|
13
13
|
def initialize(name: nil, view: nil, **args)
|
14
14
|
@name = name
|
15
15
|
@items_holder = Avo::Resources::Items::Holder.new
|
16
|
-
@view = view
|
16
|
+
@view = Avo::ViewInquirer.new view
|
17
17
|
@args = args
|
18
18
|
|
19
19
|
post_initialize if respond_to?(:post_initialize)
|
@@ -3,7 +3,7 @@ class Avo::Resources::Items::Tab
|
|
3
3
|
|
4
4
|
include Avo::Concerns::HasItems
|
5
5
|
include Avo::Concerns::HasItemType
|
6
|
-
include Avo::Concerns::
|
6
|
+
include Avo::Concerns::VisibleItems
|
7
7
|
include Avo::Concerns::VisibleInDifferentViews
|
8
8
|
|
9
9
|
delegate :items, :add_item, to: :items_holder
|
@@ -14,7 +14,7 @@ class Avo::Resources::Items::Tab
|
|
14
14
|
@name = name
|
15
15
|
@description = description
|
16
16
|
@items_holder = Avo::Resources::Items::Holder.new
|
17
|
-
@view = view
|
17
|
+
@view = Avo::ViewInquirer.new view
|
18
18
|
@args = args
|
19
19
|
|
20
20
|
post_initialize if respond_to?(:post_initialize)
|
@@ -152,7 +152,12 @@ module Avo
|
|
152
152
|
def get_available_resources(user = nil)
|
153
153
|
valid_resources
|
154
154
|
.select do |resource|
|
155
|
-
|
155
|
+
resource.authorization.class.authorize(
|
156
|
+
user,
|
157
|
+
resource.model_class,
|
158
|
+
Avo.configuration.authorization_methods.stringify_keys["index"],
|
159
|
+
raise_exception: false
|
160
|
+
)
|
156
161
|
end
|
157
162
|
.sort_by { |r| r.name }
|
158
163
|
end
|
data/lib/avo/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Allows to check the the view type by using `view.index?` or `view.edit?` etc...
|
2
|
+
# It also allows to check if the view is a form or a display view by using `view.form?` or `view.display?`
|
3
|
+
module Avo
|
4
|
+
class ViewInquirer < ActiveSupport::StringInquirer
|
5
|
+
DISPLAY_VIEWS = %w[index show]
|
6
|
+
FORM_VIEWS = %w[new edit]
|
7
|
+
|
8
|
+
def initialize(view)
|
9
|
+
super(view.to_s)
|
10
|
+
|
11
|
+
@display = in? DISPLAY_VIEWS
|
12
|
+
@form = in? FORM_VIEWS
|
13
|
+
end
|
14
|
+
|
15
|
+
def display?
|
16
|
+
@display
|
17
|
+
end
|
18
|
+
|
19
|
+
def form?
|
20
|
+
@form
|
21
|
+
end
|
22
|
+
|
23
|
+
# To avoid breaking changes we allow the comparison with symbols
|
24
|
+
def ==(other)
|
25
|
+
if other.is_a? Symbol
|
26
|
+
to_sym == other
|
27
|
+
else
|
28
|
+
super(other)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def in?(another_object)
|
33
|
+
super another_object.map(&:to_s)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/avo.rb
CHANGED
@@ -116,6 +116,15 @@ module Avo
|
|
116
116
|
true
|
117
117
|
end
|
118
118
|
|
119
|
+
# Mount all Avo engines
|
120
|
+
def mount_engines
|
121
|
+
-> {
|
122
|
+
mount Avo::DynamicFilters::Engine, at: "/avo-dynamic_filters" if defined?(Avo::DynamicFilters::Engine)
|
123
|
+
mount Avo::Dashboards::Engine, at: "/dashboards" if defined?(Avo::Dashboards::Engine)
|
124
|
+
mount Avo::Pro::Engine, at: "/avo-pro" if defined?(Avo::Pro::Engine)
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
119
128
|
private
|
120
129
|
|
121
130
|
def boot_logger
|
@@ -18,6 +18,16 @@ module Generators
|
|
18
18
|
type: :string,
|
19
19
|
required: false
|
20
20
|
|
21
|
+
class_option "field-components",
|
22
|
+
desc: "The field components to eject. Example: 'trix', 'text'",
|
23
|
+
type: :string,
|
24
|
+
required: false
|
25
|
+
|
26
|
+
class_option :view,
|
27
|
+
desc: "The view of the component to eject when using --field-component option. Example: 'index', 'show'",
|
28
|
+
type: :string,
|
29
|
+
required: false
|
30
|
+
|
21
31
|
source_root ::Avo::Engine.root
|
22
32
|
|
23
33
|
namespace "avo:eject"
|
@@ -38,12 +48,17 @@ module Generators
|
|
38
48
|
eject_partial
|
39
49
|
elsif options[:component].present?
|
40
50
|
eject_component
|
51
|
+
elsif options["field-components"].present?
|
52
|
+
eject_field_components
|
41
53
|
else
|
42
54
|
say "Please specify a partial or a component to eject.\n" \
|
43
55
|
"Examples: rails g avo:eject --partial :logo\n" \
|
44
56
|
" rails g avo:eject --partial app/views/layouts/avo/application.html.erb\n" \
|
45
57
|
" rails g avo:eject --component Avo::Index::TableRowComponent\n" \
|
46
58
|
" rails g avo:eject --component avo/index/table_row_component\n" \
|
59
|
+
" rails g avo:eject --field-components trix\n" \
|
60
|
+
" rails g avo:eject --field-components trix --scope users\n" \
|
61
|
+
" rails g avo:eject --field-components text --scope users --view edit\n" \
|
47
62
|
" rails g avo:eject --component Avo::Views::ResourceIndexComponent --scope users\n" \
|
48
63
|
" rails g avo:eject --component avo/views/resource_index_component --scope users", :yellow
|
49
64
|
end
|
@@ -60,8 +75,14 @@ module Generators
|
|
60
75
|
path.present? && File.file?(::Avo::Engine.root.join(path))
|
61
76
|
end
|
62
77
|
|
63
|
-
def
|
64
|
-
|
78
|
+
def dir_exists?(path)
|
79
|
+
path.present? && Dir.exist?(::Avo::Engine.root.join(path))
|
80
|
+
end
|
81
|
+
|
82
|
+
def eject(path, dest_path = nil, is_directory: false)
|
83
|
+
method = is_directory ? :directory : :copy_file
|
84
|
+
|
85
|
+
send method, ::Avo::Engine.root.join(path), ::Rails.root.join(dest_path || path)
|
65
86
|
end
|
66
87
|
|
67
88
|
def eject_partial
|
@@ -83,27 +104,33 @@ module Generators
|
|
83
104
|
end
|
84
105
|
end
|
85
106
|
|
86
|
-
def eject_component
|
107
|
+
def eject_component(component_to_eject = options[:component], confirmation: true)
|
87
108
|
# Underscore the component name
|
88
109
|
# Example: Avo::Views::ResourceIndexComponent => avo/views/resource_index_component
|
89
|
-
component =
|
110
|
+
component = component_to_eject.underscore
|
90
111
|
|
91
112
|
# Get the component path for both, the rb and erb files
|
92
113
|
rb, erb = ["app/components/#{component}.rb", "app/components/#{component}.html.erb"]
|
93
114
|
|
94
115
|
# Return if one of the components doesn't exist
|
95
116
|
if !path_exists?(rb) || !path_exists?(erb)
|
96
|
-
return say("Failed to find the `#{
|
117
|
+
return say("Failed to find the `#{component_to_eject}` component.", :yellow)
|
97
118
|
end
|
98
119
|
|
99
120
|
# Add the scope to the component if it's possible
|
100
121
|
if add_scope? component
|
101
|
-
component = component.
|
122
|
+
component = if component.starts_with?("avo/views/")
|
123
|
+
component.gsub("avo/views/", "avo/views/#{options[:scope].underscore}/")
|
124
|
+
elsif component.starts_with?("avo/fields/")
|
125
|
+
component.gsub("avo/fields/", "avo/fields/#{options[:scope].underscore}/")
|
126
|
+
end
|
102
127
|
added_scope = true
|
103
128
|
end
|
104
129
|
|
105
130
|
# Confirm the ejection
|
106
|
-
|
131
|
+
if confirmation
|
132
|
+
return if !confirm_ejection_on(component.camelize)
|
133
|
+
end
|
107
134
|
|
108
135
|
# Get the destination path for both, the rb and erb files
|
109
136
|
dest_rb = "#{::Avo.configuration.view_component_path}/#{component}.rb"
|
@@ -117,27 +144,77 @@ module Generators
|
|
117
144
|
# Example: Avo::Views::ResourceIndexComponent => Avo::Views::Admins::ResourceIndexComponent
|
118
145
|
if added_scope
|
119
146
|
[dest_rb, dest_erb].each do |path|
|
120
|
-
|
147
|
+
if component.starts_with?("avo/views/")
|
148
|
+
modified_content = File.read(path).gsub("Avo::Views::", "Avo::Views::#{options[:scope].camelize}::")
|
149
|
+
elsif component.starts_with?("avo/fields/")
|
150
|
+
modified_content = File.read(path).gsub("#{options["field-components"].camelize}Field", "#{options[:scope].camelize}::#{options["field-components"].camelize}Field")
|
151
|
+
end
|
121
152
|
|
122
153
|
File.open(path, "w") do |file|
|
123
154
|
file.puts modified_content
|
124
155
|
end
|
125
156
|
end
|
126
157
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
158
|
+
if component.starts_with?("avo/views/")
|
159
|
+
say "You can now use this component on any resource by configuring the 'self.components' option.\n" \
|
160
|
+
" self.components = {\n" \
|
161
|
+
" #{component.split("/").last}: #{component.camelize}\n" \
|
162
|
+
" }", :green
|
163
|
+
elsif component.starts_with?("avo/fields/")
|
164
|
+
say "You can now use this component on any field by configuring the 'components' option.\n" \
|
165
|
+
" field :name, as: :#{options["field-components"]}, components: {\n" \
|
166
|
+
" #{component.split("/").last}: #{component.camelize}\n" \
|
167
|
+
" }", :green
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def eject_field_components
|
173
|
+
# Check if the field exists
|
174
|
+
field_path = "lib/avo/fields/#{options["field-components"]}_field.rb"
|
175
|
+
return say("Failed to find the `#{options["field-components"]}` field.", :yellow) if !path_exists?(field_path)
|
176
|
+
|
177
|
+
# Eject single component if view is specified
|
178
|
+
if options[:view].present?
|
179
|
+
return eject_component "Avo::Fields::#{options["field-components"].camelize}Field::#{options[:view].camelize}Component"
|
180
|
+
end
|
181
|
+
|
182
|
+
# Check if the field components directory exist
|
183
|
+
components_path = "app/components/avo/fields/#{options["field-components"]}_field"
|
184
|
+
return say("Failed to find the `#{options["field-components"]}` field components.", :yellow) if !dir_exists?(components_path)
|
185
|
+
|
186
|
+
# Build the destination path for the components directory add the scope
|
187
|
+
destination_components_path = "#{::Avo.configuration.view_component_path}/#{components_path.gsub("app/components/", "")}"
|
188
|
+
|
189
|
+
if options[:scope].present?
|
190
|
+
destination_components_path = destination_components_path.gsub("avo/fields/", "avo/fields/#{options[:scope].underscore}/")
|
191
|
+
end
|
192
|
+
|
193
|
+
# Confirm the ejection
|
194
|
+
confirm_ejection_on destination_components_path, is_directory: true
|
195
|
+
|
196
|
+
# Eject the components directory
|
197
|
+
eject components_path, destination_components_path, is_directory: true
|
198
|
+
|
199
|
+
# Rename the component classes if scope was added
|
200
|
+
if options[:scope].present?
|
201
|
+
Dir.glob("#{destination_components_path}/*").each do |file|
|
202
|
+
modified_content = File.read(file).gsub("#{options["field-components"].camelize}Field", "#{options[:scope].camelize}::#{options["field-components"].camelize}Field")
|
203
|
+
|
204
|
+
File.open(file, "w") do |open_file|
|
205
|
+
open_file.puts modified_content
|
206
|
+
end
|
207
|
+
end
|
131
208
|
end
|
132
209
|
end
|
133
210
|
|
134
|
-
def confirm_ejection_on(path)
|
135
|
-
say("By ejecting the '#{path}' \033[1myou'll take on the responsibility for maintain it.", :yellow)
|
136
|
-
yes?("Are you sure you want to eject the '#{path}'? [y/N]", :yellow)
|
211
|
+
def confirm_ejection_on(path, is_directory: false)
|
212
|
+
say("By ejecting the '#{path}'#{" directory" if is_directory} \033[1myou'll take on the responsibility for maintain it.", :yellow)
|
213
|
+
yes?("Are you sure you want to eject the '#{path}'#{" directory" if is_directory}? [y/N]", :yellow)
|
137
214
|
end
|
138
215
|
|
139
216
|
def add_scope?(component)
|
140
|
-
component.starts_with?("avo/views/") && options[:scope].present?
|
217
|
+
(component.starts_with?("avo/views/") || component.starts_with?("avo/fields/")) && options[:scope].present?
|
141
218
|
end
|
142
219
|
end
|
143
220
|
end
|
@@ -31,7 +31,7 @@ module Generators
|
|
31
31
|
end
|
32
32
|
|
33
33
|
say "Ejecting the _head.html.erb partial"
|
34
|
-
Rails::Generators.invoke("avo:eject", [":head", "--skip-avo-version"], {destination_root: Rails.root})
|
34
|
+
Rails::Generators.invoke("avo:eject", ["--partial", ":head", "--skip-avo-version"], {destination_root: Rails.root})
|
35
35
|
|
36
36
|
say "Adding the JS asset to the partial"
|
37
37
|
append_to_file Rails.root.join("app", "views", "avo", "partials", "_head.html.erb"), "<%= javascript_importmap_tags \"avo.custom\" %>"
|
@@ -48,7 +48,7 @@ module Generators
|
|
48
48
|
end
|
49
49
|
|
50
50
|
say "Ejecting the _head.html.erb partial"
|
51
|
-
Rails::Generators.invoke("avo:eject", [":head", "--skip-avo-version"], {destination_root: Rails.root})
|
51
|
+
Rails::Generators.invoke("avo:eject", ["--partial", ":head", "--skip-avo-version"], {destination_root: Rails.root})
|
52
52
|
|
53
53
|
say "Adding the JS asset to the partial"
|
54
54
|
append_to_file Rails.root.join("app", "views", "avo", "partials", "_head.html.erb"), "<%= javascript_include_tag \"avo.custom\", \"data-turbo-track\": \"reload\", defer: true %>"
|
@@ -21,7 +21,7 @@ module Generators
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def resource_class
|
24
|
-
|
24
|
+
class_name.remove(":").to_s
|
25
25
|
end
|
26
26
|
|
27
27
|
def controller_class
|
@@ -29,7 +29,7 @@ module Generators
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def resource_name
|
32
|
-
|
32
|
+
model_resource_name.to_s
|
33
33
|
end
|
34
34
|
|
35
35
|
def controller_name
|
@@ -139,12 +139,12 @@ module Generators
|
|
139
139
|
|
140
140
|
fields.each do |field_name, field_options|
|
141
141
|
# if field_options are not available (likely a missing resource for an association), skip the field
|
142
|
-
fields_string += "\n
|
142
|
+
fields_string += "\n # Could not generate a field for #{field_name}" and next unless field_options
|
143
143
|
|
144
144
|
options = ""
|
145
145
|
field_options[:options].each { |k, v| options += ", #{k}: #{v}" } if field_options[:options].present?
|
146
146
|
|
147
|
-
fields_string += "\n
|
147
|
+
fields_string += "\n #{field_string field_name, field_options[:field], options}"
|
148
148
|
end
|
149
149
|
|
150
150
|
fields_string
|
@@ -166,7 +166,7 @@ module Generators
|
|
166
166
|
|
167
167
|
def fields_from_model_rich_texts
|
168
168
|
rich_texts.each do |name, _|
|
169
|
-
fields[
|
169
|
+
fields[name.delete_prefix("rich_text_")] = {field: "trix"}
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
@@ -33,7 +33,7 @@ module Generators
|
|
33
33
|
# Ensure that the _pre_head.html.erb template is available
|
34
34
|
unless Rails.root.join("app", "views", "avo", "partials", "_pre_head.html.erb").exist?
|
35
35
|
say "Ejecting the _pre_head.html.erb partial"
|
36
|
-
Rails::Generators.invoke("avo:eject", [":pre_head", "--skip-avo-version"], {destination_root: Rails.root})
|
36
|
+
Rails::Generators.invoke("avo:eject", ["--partial", ":pre_head", "--skip-avo-version"], {destination_root: Rails.root})
|
37
37
|
end
|
38
38
|
|
39
39
|
say "Adding the CSS asset to the partial"
|
@@ -1,10 +1,15 @@
|
|
1
1
|
# For more information regarding these settings check out our docs https://docs.avohq.io
|
2
|
+
# The values disaplayed here are the default ones. Uncomment and change them to fit your needs.
|
2
3
|
Avo.configure do |config|
|
3
4
|
## == Routing ==
|
4
5
|
config.root_path = '/<%= options[:path] %>'
|
5
6
|
# used only when you have custom `map` configuration in your config.ru
|
6
7
|
# config.prefix_path = "/internal"
|
7
8
|
|
9
|
+
# Sometimes you migth want to mount Avo's engines yourself.
|
10
|
+
# https://docs.avohq.io/3.0/routing.html
|
11
|
+
# config.mount_avo_engines = true
|
12
|
+
|
8
13
|
# Where should the user be redirected when visting the `/<%= options[:path] %>` url
|
9
14
|
# config.home_path = nil
|
10
15
|
|