avo 0.5.0.beta2 → 0.5.0.beta7
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 +4 -4
- data/Gemfile.lock +1 -5
- data/app/components/avo/index/grid_item_component.html.erb +8 -8
- data/app/components/avo/index/grid_item_component.rb +6 -12
- data/app/components/avo/index/resource_grid_component.html.erb +1 -1
- data/app/components/avo/index/resource_table_component.html.erb +2 -2
- data/app/components/avo/index/table_row_component.html.erb +1 -1
- data/app/controllers/avo/actions_controller.rb +2 -5
- data/app/controllers/avo/application_controller.rb +12 -4
- data/app/controllers/avo/base_controller.rb +1 -9
- data/app/controllers/avo/relations_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +1 -1
- data/app/frontend/packs/application.js +1 -1
- data/app/views/avo/base/_actions.html.erb +0 -6
- data/app/views/avo/base/_boolean_filter.html.erb +1 -1
- data/app/views/avo/base/_filters.html.erb +3 -11
- data/app/views/avo/base/_select_filter.html.erb +1 -1
- data/app/views/avo/home/_resources.html.erb +0 -1
- data/app/views/avo/partials/_table_header.html.erb +1 -1
- data/app/views/layouts/avo/_filter_wrapper.html.erb +1 -1
- data/app/views/layouts/avo/application.html.erb +5 -0
- data/avo.gemspec +0 -1
- data/config/webpacker.yml +10 -23
- data/lib/avo.rb +5 -16
- data/lib/avo/app.rb +204 -0
- data/lib/avo/base_action.rb +123 -0
- data/lib/avo/base_resource.rb +326 -0
- data/lib/avo/configuration.rb +8 -0
- data/lib/avo/engine.rb +12 -31
- data/lib/avo/{app/fields → fields}/badge_field.rb +1 -1
- data/lib/avo/{app/fields/field.rb → fields/base_field.rb} +3 -7
- data/lib/avo/{app/fields/belongs_to.rb → fields/belongs_to_field.rb} +3 -3
- data/lib/avo/{app/fields → fields}/boolean_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/boolean_group_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/code_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/country_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/currency_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/date_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/date_time_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/external_image_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/field_extensions/has_field_name.rb +0 -0
- data/lib/avo/{app/fields → fields}/field_extensions/visible_in_different_views.rb +1 -1
- data/lib/avo/{app/fields → fields}/file_field.rb +1 -2
- data/lib/avo/{app/fields → fields}/files_field.rb +1 -2
- data/lib/avo/{app/fields → fields}/gravatar_field.rb +1 -1
- data/lib/avo/{app/fields/has_and_belongs_to_many.rb → fields/has_and_belongs_to_many_field.rb} +1 -1
- data/lib/avo/{app/fields/has_many.rb → fields/has_many_field.rb} +1 -1
- data/lib/avo/{app/fields/has_one.rb → fields/has_one_field.rb} +1 -1
- data/lib/avo/{app/fields → fields}/heading_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/hidden_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/id_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/key_value_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/markdown_field.rb +1 -3
- data/lib/avo/{app/fields → fields}/number_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/password_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/select_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/status_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/text_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/textarea_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/trix_field.rb +1 -3
- data/lib/avo/filters/base_filter.rb +20 -0
- data/lib/avo/filters/boolean_filter.rb +7 -0
- data/lib/avo/filters/select_filter.rb +7 -0
- data/lib/avo/{app/grid_fields → grid_fields}/body_field.rb +0 -2
- data/lib/avo/{app/grid_fields → grid_fields}/grid_field.rb +0 -0
- data/lib/avo/{app/grid_fields → grid_fields}/preview_field.rb +0 -2
- data/lib/avo/{app/grid_fields → grid_fields}/title_field.rb +0 -2
- data/lib/avo/licensing/community_license.rb +6 -0
- data/lib/avo/licensing/h_q.rb +88 -0
- data/lib/avo/licensing/license.rb +50 -0
- data/lib/avo/licensing/license_manager.rb +22 -0
- data/lib/avo/licensing/null_license.rb +14 -0
- data/lib/avo/licensing/pro_license.rb +11 -0
- data/lib/avo/loaders/actions_loader.rb +6 -0
- data/lib/avo/loaders/fields_loader.rb +27 -0
- data/lib/avo/loaders/filters_loader.rb +6 -0
- data/lib/avo/loaders/loader.rb +15 -0
- data/lib/avo/services/authorization_service.rb +93 -0
- data/lib/avo/services/panel_service.rb +27 -0
- data/lib/avo/{app/tools_manager.rb → tools_manager.rb} +0 -0
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/action_generator.rb +11 -5
- data/lib/generators/avo/controller_generator.rb +14 -8
- data/lib/generators/avo/filter_generator.rb +14 -8
- data/lib/generators/avo/install_generator.rb +14 -10
- data/lib/generators/avo/locales_generator.rb +11 -7
- data/lib/generators/avo/partials_generator.rb +11 -5
- data/lib/generators/avo/resource_generator.rb +33 -15
- data/lib/generators/avo/templates/{action.rb → action.tt} +2 -4
- data/lib/generators/avo/templates/filters/boolean_filter.tt +11 -0
- data/lib/generators/avo/templates/filters/select_filter.tt +11 -0
- data/lib/generators/avo/templates/initializer/{avo.rb → avo.tt} +6 -0
- data/lib/generators/avo/templates/resource/controller.tt +2 -0
- data/lib/generators/avo/templates/resource/resource.tt +17 -0
- data/public/avo-packs/css/{application-3598cfbb.css → application-c75ac28c.css} +1 -1
- data/public/avo-packs/css/application-c75ac28c.css.br +0 -0
- data/public/avo-packs/css/{application-3598cfbb.css.gz → application-c75ac28c.css.gz} +0 -0
- data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js → application-8849c6e2c8f75d55c666.js} +3 -3
- data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js.LICENSE.txt → application-8849c6e2c8f75d55c666.js.LICENSE.txt} +0 -0
- data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.br +0 -0
- data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.gz +0 -0
- data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js.map → application-8849c6e2c8f75d55c666.js.map} +1 -1
- data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.map.br +0 -0
- data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js.map.gz → application-8849c6e2c8f75d55c666.js.map.gz} +0 -0
- data/public/avo-packs/manifest.json +6 -6
- data/public/avo-packs/manifest.json.br +0 -0
- data/public/avo-packs/manifest.json.gz +0 -0
- metadata +72 -87
- data/config/webpacker_packed.yml +0 -86
- data/lib/avo/app/action.rb +0 -145
- data/lib/avo/app/actions_loader.rb +0 -11
- data/lib/avo/app/app.rb +0 -181
- data/lib/avo/app/fields_loader.rb +0 -29
- data/lib/avo/app/filter.rb +0 -23
- data/lib/avo/app/filters/boolean_filter.rb +0 -13
- data/lib/avo/app/filters/select_filter.rb +0 -13
- data/lib/avo/app/licensing/community_license.rb +0 -4
- data/lib/avo/app/licensing/hq.rb +0 -86
- data/lib/avo/app/licensing/license.rb +0 -48
- data/lib/avo/app/licensing/license_manager.rb +0 -25
- data/lib/avo/app/licensing/null_license.rb +0 -12
- data/lib/avo/app/licensing/pro_license.rb +0 -9
- data/lib/avo/app/resource.rb +0 -291
- data/lib/avo/app/resource_grid_fields.rb +0 -30
- data/lib/avo/app/services/authorization_service.rb +0 -110
- data/lib/avo/app/services/panel_service.rb +0 -25
- data/lib/avo/app/tool.rb +0 -5
- data/lib/generators/avo/templates/filters/boolean_filter.rb +0 -17
- data/lib/generators/avo/templates/filters/select_filter.rb +0 -17
- data/lib/generators/avo/templates/resource/%plural_name%_controller.tt +0 -2
- data/lib/generators/avo/templates/resource/%singular_name%.tt +0 -20
- data/public/avo-packs/css/application-3598cfbb.css.br +0 -0
- data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.br +0 -0
- data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.gz +0 -0
- data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map.br +0 -0
data/lib/avo/configuration.rb
CHANGED
@@ -19,6 +19,8 @@ module Avo
|
|
19
19
|
attr_accessor :id_links_to_resource
|
20
20
|
attr_accessor :full_width_container
|
21
21
|
attr_accessor :full_width_index_view
|
22
|
+
attr_accessor :cache_resources_on_index_view
|
23
|
+
attr_accessor :context
|
22
24
|
|
23
25
|
def initialize
|
24
26
|
@root_path = '/avo'
|
@@ -48,6 +50,8 @@ module Avo
|
|
48
50
|
@id_links_to_resource = false
|
49
51
|
@full_width_container = false
|
50
52
|
@full_width_index_view = false
|
53
|
+
@cache_resources_on_index_view = Avo::PACKED
|
54
|
+
@context = proc {}
|
51
55
|
end
|
52
56
|
|
53
57
|
def locale_tag
|
@@ -69,6 +73,10 @@ module Avo
|
|
69
73
|
def authenticate_with(&block)
|
70
74
|
@authenticate = block if block.present?
|
71
75
|
end
|
76
|
+
|
77
|
+
def set_context(&block)
|
78
|
+
@context = block if block.present?
|
79
|
+
end
|
72
80
|
end
|
73
81
|
|
74
82
|
def self.configuration
|
data/lib/avo/engine.rb
CHANGED
@@ -8,44 +8,25 @@ module Avo
|
|
8
8
|
class Engine < ::Rails::Engine
|
9
9
|
isolate_namespace Avo
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
'Avo::Filters': ['app', 'avo', 'filters'],
|
15
|
-
'Avo::Actions': ['app', 'avo', 'actions'],
|
16
|
-
}.each do |namespace, path|
|
17
|
-
next unless Rails.root.join(*path).exist?
|
18
|
-
|
19
|
-
Rails.autoloaders.main.push_dir(Rails.root.join(*path), namespace: namespace.to_s.safe_constantize)
|
20
|
-
end
|
11
|
+
config.after_initialize do
|
12
|
+
# Boot Avo
|
13
|
+
::Avo::App.boot
|
21
14
|
end
|
22
15
|
|
23
|
-
initializer 'avo.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
if Avo::IN_DEVELOPMENT
|
29
|
-
# Register reloader
|
30
|
-
app.reloaders << app.config.file_watcher.new([], {
|
31
|
-
Avo::Engine.root.join('lib', 'avo').to_s => ['rb'],
|
32
|
-
}) {}
|
33
|
-
|
34
|
-
# What to do on file change
|
35
|
-
config.to_prepare do
|
36
|
-
Dir.glob(avo_root_path + '/lib/avo/app/**/*.rb'.to_s).each { |c| load c }
|
37
|
-
Avo::App.boot
|
38
|
-
end
|
39
|
-
else
|
40
|
-
Dir.glob(avo_root_path + '/lib/avo/app/**/*.rb'.to_s).each { |c| require c }
|
16
|
+
initializer 'avo.autoload', before: :set_autoload_paths do |app|
|
17
|
+
Rails.autoloaders.main.push_dir(Rails.root.join('app', 'avo', 'filters'))
|
18
|
+
Rails.autoloaders.main.push_dir(Rails.root.join('app', 'avo', 'actions'))
|
19
|
+
Rails.autoloaders.main.push_dir(Rails.root.join('app', 'avo', 'resources'))
|
20
|
+
end
|
41
21
|
|
42
|
-
|
43
|
-
|
22
|
+
initializer 'avo.init_fields' do |app|
|
23
|
+
# Init the fields
|
24
|
+
::Avo::App.init_fields
|
44
25
|
end
|
45
26
|
|
46
27
|
initializer 'webpacker.proxy' do |app|
|
47
28
|
app.config.debug_exception_response_format = :api
|
48
|
-
app.config.logger = ::Logger.new(STDOUT)
|
29
|
+
# app.config.logger = ::Logger.new(STDOUT)
|
49
30
|
|
50
31
|
insert_middleware = begin
|
51
32
|
Avo.webpacker.config.dev_server.present?
|
@@ -1,11 +1,9 @@
|
|
1
|
-
require_relative 'field_extensions/visible_in_different_views'
|
2
|
-
require_relative 'field_extensions/has_field_name'
|
3
|
-
|
4
1
|
module Avo
|
5
2
|
module Fields
|
6
|
-
class
|
7
|
-
|
3
|
+
class BaseField
|
4
|
+
extend ActiveSupport::DescendantsTracker
|
8
5
|
extend Avo::Fields::FieldExtensions::HasFieldName
|
6
|
+
include Avo::Fields::FieldExtensions::VisibleInDifferentViews
|
9
7
|
|
10
8
|
attr_accessor :id
|
11
9
|
attr_accessor :name
|
@@ -32,7 +30,6 @@ module Avo
|
|
32
30
|
attr_accessor :view
|
33
31
|
attr_accessor :user
|
34
32
|
attr_accessor :action
|
35
|
-
attr_accessor :grid_position
|
36
33
|
attr_accessor :meta
|
37
34
|
attr_accessor :panel_name
|
38
35
|
attr_accessor :link_to_resource
|
@@ -67,7 +64,6 @@ module Avo
|
|
67
64
|
help: nil,
|
68
65
|
default: nil,
|
69
66
|
can_see: nil,
|
70
|
-
grid_position: false,
|
71
67
|
meta: {},
|
72
68
|
panel_name: nil,
|
73
69
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Avo
|
2
2
|
module Fields
|
3
|
-
class BelongsToField <
|
3
|
+
class BelongsToField < BaseField
|
4
4
|
def initialize(name, **args, &block)
|
5
5
|
@defaults = {
|
6
6
|
partial_name: 'belongs-to-field',
|
@@ -17,7 +17,7 @@ module Avo
|
|
17
17
|
target_resource.model_class.all.map do |model|
|
18
18
|
{
|
19
19
|
value: model.id,
|
20
|
-
label: model.send(target_resource.title)
|
20
|
+
label: model.send(target_resource.class.title)
|
21
21
|
}
|
22
22
|
end
|
23
23
|
end
|
@@ -43,7 +43,7 @@ module Avo
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def label
|
46
|
-
value.send(target_resource.title)
|
46
|
+
value.send(target_resource.class.title)
|
47
47
|
end
|
48
48
|
|
49
49
|
def to_permitted_param
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Avo
|
2
|
+
module Filters
|
3
|
+
class BaseFilter
|
4
|
+
class_attribute :name, default: 'Filter'
|
5
|
+
class_attribute :component, default: 'boolean-filter'
|
6
|
+
class_attribute :default, default: ''
|
7
|
+
class_attribute :template, default: 'avo/base/select_filter'
|
8
|
+
|
9
|
+
def apply_query(request, query, value)
|
10
|
+
value.symbolize_keys! if value.is_a? Hash
|
11
|
+
|
12
|
+
self.apply(request, query, value)
|
13
|
+
end
|
14
|
+
|
15
|
+
def id
|
16
|
+
self.class.name.underscore.gsub('/', '_')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|