avo 0.5.0.beta9 → 0.5.0.beta10
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 +47 -48
- data/Gemfile.lock +1 -1
- data/Rakefile +14 -14
- data/app/components/avo/common/multiple_file_viewer_component.rb +1 -1
- data/app/components/avo/common/single_file_viewer_component.rb +1 -1
- data/app/components/avo/edit/field_wrapper_component.rb +3 -3
- data/app/components/avo/index/field_wrapper_component.rb +1 -1
- data/app/components/avo/index/grid_item_component.rb +10 -9
- data/app/components/avo/index/resource_controls_component.rb +2 -2
- data/app/components/avo/panel_component.rb +7 -6
- data/app/components/avo/resource_component.rb +4 -3
- data/app/components/avo/show/field_wrapper_component.rb +3 -3
- data/app/components/avo/views/resource_edit_component.rb +4 -3
- data/app/components/avo/views/resource_index_component.rb +8 -7
- data/app/components/avo/views/resource_new_component.rb +4 -3
- data/app/components/avo/views/resource_show_component.rb +21 -21
- data/app/controllers/avo/actions_controller.rb +30 -29
- data/app/controllers/avo/application_controller.rb +113 -126
- data/app/controllers/avo/attachments_controller.rb +3 -3
- data/app/controllers/avo/base_controller.rb +81 -80
- data/app/controllers/avo/home_controller.rb +2 -2
- data/app/controllers/avo/relations_controller.rb +29 -28
- data/app/controllers/avo/resources_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +20 -19
- data/app/helpers/avo/application_helper.rb +48 -42
- data/app/helpers/avo/resources_helper.rb +11 -11
- data/app/mailers/avo/application_mailer.rb +2 -2
- data/app/packs/entrypoints/application.js +9 -7
- data/app/packs/js/controllers/fields/code_field_controller.js +14 -14
- data/app/packs/js/controllers/filter_controller.js +9 -8
- data/app/packs/js/toastr.js +1 -0
- data/avo.gemspec +31 -31
- data/config/initializers/inline_svg.rb +1 -1
- data/config/initializers/pagy.rb +1 -1
- data/config/routes.rb +12 -12
- data/config/spring.rb +5 -5
- data/db/factories.rb +3 -5
- data/lib/avo.rb +6 -6
- data/lib/avo/app.rb +18 -18
- data/lib/avo/base_action.rb +20 -20
- data/lib/avo/base_resource.rb +41 -45
- data/lib/avo/configuration.rb +16 -18
- data/lib/avo/engine.rb +18 -18
- data/lib/avo/fields/badge_field.rb +2 -2
- data/lib/avo/fields/base_field.rb +24 -25
- data/lib/avo/fields/belongs_to_field.rb +13 -12
- data/lib/avo/fields/boolean_field.rb +4 -4
- data/lib/avo/fields/boolean_group_field.rb +3 -3
- data/lib/avo/fields/code_field.rb +4 -4
- data/lib/avo/fields/country_field.rb +2 -2
- data/lib/avo/fields/currency_field.rb +3 -3
- data/lib/avo/fields/date_field.rb +3 -3
- data/lib/avo/fields/date_time_field.rb +2 -2
- data/lib/avo/fields/external_image_field.rb +2 -2
- data/lib/avo/fields/field_extensions/has_field_name.rb +2 -2
- data/lib/avo/fields/field_extensions/visible_in_different_views.rb +34 -33
- data/lib/avo/fields/file_field.rb +1 -1
- data/lib/avo/fields/files_field.rb +2 -2
- data/lib/avo/fields/gravatar_field.rb +9 -9
- data/lib/avo/fields/has_and_belongs_to_many_field.rb +1 -1
- data/lib/avo/fields/has_many_field.rb +1 -1
- data/lib/avo/fields/has_one_field.rb +2 -2
- data/lib/avo/fields/heading_field.rb +2 -2
- data/lib/avo/fields/hidden_field.rb +1 -1
- data/lib/avo/fields/id_field.rb +3 -3
- data/lib/avo/fields/key_value_field.rb +12 -12
- data/lib/avo/fields/markdown_field.rb +2 -2
- data/lib/avo/fields/number_field.rb +3 -3
- data/lib/avo/fields/password_field.rb +1 -1
- data/lib/avo/fields/select_field.rb +8 -12
- data/lib/avo/fields/status_field.rb +4 -4
- data/lib/avo/fields/text_field.rb +2 -2
- data/lib/avo/fields/textarea_field.rb +2 -2
- data/lib/avo/fields/trix_field.rb +1 -1
- data/lib/avo/fields_collector.rb +4 -5
- data/lib/avo/filters/base_filter.rb +6 -6
- data/lib/avo/filters/boolean_filter.rb +1 -1
- data/lib/avo/filters/select_filter.rb +1 -1
- data/lib/avo/licensing/h_q.rb +56 -55
- data/lib/avo/licensing/license.rb +5 -5
- data/lib/avo/licensing/license_manager.rb +4 -4
- data/lib/avo/licensing/null_license.rb +2 -2
- data/lib/avo/licensing/pro_license.rb +1 -1
- data/lib/avo/loaders/fields_loader.rb +4 -4
- data/lib/avo/services/authorization_service.rb +2 -2
- data/lib/avo/services/panel_service.rb +4 -4
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/action_generator.rb +4 -4
- data/lib/generators/avo/controller_generator.rb +4 -4
- data/lib/generators/avo/filter_generator.rb +5 -5
- data/lib/generators/avo/install_generator.rb +8 -8
- data/lib/generators/avo/locales_generator.rb +5 -5
- data/lib/generators/avo/partials_generator.rb +4 -4
- data/lib/generators/avo/resource_generator.rb +5 -5
- data/lib/tasks/avo_tasks.rake +52 -53
- data/public/avo-packs/css/{application-38e7e91b.css → application-4e16d6a6.css} +4 -4
- data/public/avo-packs/css/application-4e16d6a6.css.br +0 -0
- data/public/avo-packs/css/{application-38e7e91b.css.gz → application-4e16d6a6.css.gz} +0 -0
- data/public/avo-packs/css/{application-38e7e91b.css.map → application-4e16d6a6.css.map} +1 -1
- data/public/avo-packs/css/application-4e16d6a6.css.map.br +0 -0
- data/public/avo-packs/css/application-4e16d6a6.css.map.gz +0 -0
- data/public/avo-packs/js/{application-2b90fe889f7d6df1ad92.js → application-8eb130a4688f2c667703.js} +4 -4
- data/public/avo-packs/js/{application-2b90fe889f7d6df1ad92.js.LICENSE.txt → application-8eb130a4688f2c667703.js.LICENSE.txt} +0 -0
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js.br +0 -0
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js.gz +0 -0
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map +1 -0
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map.br +0 -0
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map.gz +0 -0
- data/public/avo-packs/manifest.json +15 -15
- metadata +15 -15
- data/public/avo-packs/css/application-38e7e91b.css.br +0 -0
- data/public/avo-packs/css/application-38e7e91b.css.map.br +0 -0
- data/public/avo-packs/css/application-38e7e91b.css.map.gz +0 -0
- data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.br +0 -0
- data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.gz +0 -0
- data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map +0 -1
- data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map.br +0 -0
- data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbc5163742282b121c065a97fc808446b8d7e1dfe05ff3a85eb46c86bc0e5794
|
4
|
+
data.tar.gz: 5ee2eba0895df8227d2ab6630e50759f177c291efe672b79a1dedf143e5ad25d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bfbe17a6b34aa4fd206ca6688fdca752e0fdebf6fcfcc38945af4b0e9cbe48a468b6643124cd0d65f9a7cfe0f2376f4a00271eeb8bcbf7346a0c6b12f5ccce4
|
7
|
+
data.tar.gz: 17dd64588f184560a367f54f29b40a802ab1dc530fb8ccae5785be415a1fd8ff10ea1a37aac3597690cb525eac78c28f2c86d9103dacb786197057b9b12a3716
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
3
|
|
4
4
|
# Declare your gem's dependencies in avo.gemspec.
|
@@ -15,113 +15,112 @@ gemspec
|
|
15
15
|
# gem 'byebug', group: [:development, :test]
|
16
16
|
|
17
17
|
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
|
18
|
-
gem
|
18
|
+
gem "webpacker", "6.0.0.beta.6"
|
19
19
|
|
20
20
|
# SVGs
|
21
|
-
gem
|
21
|
+
gem "inline_svg"
|
22
22
|
|
23
|
-
gem
|
23
|
+
gem "countries"
|
24
24
|
|
25
25
|
# Authorization
|
26
|
-
gem
|
26
|
+
gem "pundit"
|
27
27
|
|
28
28
|
#
|
29
29
|
# Dependencies for dummy_app
|
30
30
|
#
|
31
31
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
32
|
-
gem
|
32
|
+
gem "rails", "~> 6.0.2", ">= 6.0.2.2"
|
33
33
|
# Use postgresql as the database for Active Record
|
34
|
-
gem
|
34
|
+
gem "pg", ">= 0.18", "< 2.0"
|
35
35
|
# Use Puma as the app server
|
36
|
-
gem
|
36
|
+
gem "puma", "~> 4.3.5"
|
37
37
|
# Use SCSS for stylesheets
|
38
|
-
gem
|
38
|
+
gem "sass-rails", ">= 6"
|
39
39
|
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
|
40
40
|
# gem 'turbolinks', '~> 5'
|
41
41
|
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
42
|
-
gem
|
42
|
+
gem "jbuilder", "~> 2.7"
|
43
43
|
# Use Redis adapter to run Action Cable in production
|
44
44
|
# gem 'redis', '~> 4.0'
|
45
45
|
# Use Active Model has_secure_password
|
46
46
|
# gem 'bcrypt', '~> 3.1.7'
|
47
47
|
|
48
48
|
# Use Active Storage variant
|
49
|
-
gem
|
49
|
+
gem "image_processing", "~> 1.2"
|
50
50
|
|
51
51
|
# Reduces boot times through caching; required in config/boot.rb
|
52
|
-
gem
|
52
|
+
gem "bootsnap", ">= 1.4.2", require: false
|
53
53
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
54
|
-
gem
|
55
|
-
gem
|
54
|
+
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
|
55
|
+
gem "dotenv-rails"
|
56
56
|
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
|
57
|
-
gem
|
58
|
-
gem
|
57
|
+
gem "web-console", ">= 3.3.0"
|
58
|
+
gem "listen", ">= 3.0.5", "< 3.2"
|
59
59
|
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
60
|
-
gem
|
60
|
+
gem "spring"
|
61
61
|
|
62
|
-
gem
|
62
|
+
gem "factory_bot_rails"
|
63
63
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
64
|
-
gem
|
64
|
+
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
65
65
|
|
66
|
-
gem
|
67
|
-
gem
|
66
|
+
gem "devise"
|
67
|
+
gem "database_cleaner"
|
68
68
|
|
69
|
-
gem
|
70
|
-
gem
|
69
|
+
gem "ruby-debug-ide", require: false
|
70
|
+
gem "debase"
|
71
71
|
#
|
72
72
|
# END Dependencies for dummy_app
|
73
73
|
#
|
74
74
|
|
75
75
|
group :development do
|
76
|
-
gem
|
76
|
+
gem "standard"
|
77
77
|
|
78
78
|
# Release helper
|
79
|
-
gem
|
80
|
-
gem
|
79
|
+
gem "bump", require: false
|
80
|
+
gem "gem-release", require: false
|
81
81
|
|
82
82
|
# gem 'rack-mini-profiler'
|
83
83
|
# gem 'memory_profiler'
|
84
84
|
# gem 'stackprof'
|
85
85
|
# gem 'ruby-prof'
|
86
86
|
|
87
|
-
|
88
87
|
# gem 'pry-rails'
|
89
88
|
end
|
90
89
|
|
91
90
|
group :development, :test do
|
92
|
-
gem
|
91
|
+
gem "faker", require: false
|
93
92
|
end
|
94
93
|
|
95
94
|
group :test do
|
96
|
-
gem
|
97
|
-
gem
|
95
|
+
gem "rspec-rails", "~> 4.0.0"
|
96
|
+
gem "rails-controller-testing"
|
98
97
|
# Adds support for Capybara system testing and selenium driver
|
99
|
-
gem
|
100
|
-
gem
|
98
|
+
gem "capybara", ">= 2.15"
|
99
|
+
gem "selenium-webdriver"
|
101
100
|
# Easy installation and use of web drivers to run system tests with browsers
|
102
|
-
gem
|
103
|
-
gem
|
104
|
-
gem
|
105
|
-
gem
|
106
|
-
gem
|
107
|
-
gem
|
108
|
-
|
109
|
-
gem
|
101
|
+
gem "webdrivers"
|
102
|
+
gem "fuubar"
|
103
|
+
gem "simplecov", require: false
|
104
|
+
gem "simplecov-cobertura"
|
105
|
+
gem "webmock"
|
106
|
+
gem "spring-commands-rspec"
|
107
|
+
|
108
|
+
gem "test-prof"
|
110
109
|
end
|
111
110
|
|
112
|
-
gem
|
111
|
+
gem "zeitwerk", "~> 2.3"
|
113
112
|
|
114
113
|
# Pagination
|
115
|
-
gem
|
114
|
+
gem "pagy"
|
116
115
|
|
117
|
-
gem
|
116
|
+
gem "httparty"
|
118
117
|
|
119
|
-
gem
|
118
|
+
gem "iso"
|
120
119
|
|
121
|
-
gem
|
120
|
+
gem "hotwire-rails"
|
122
121
|
|
123
|
-
gem
|
122
|
+
gem "active_link_to"
|
124
123
|
|
125
|
-
gem
|
124
|
+
gem "view_component", require: "view_component/engine"
|
126
125
|
|
127
|
-
gem
|
126
|
+
gem "addressable"
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "bundler/setup"
|
3
3
|
rescue LoadError
|
4
|
-
puts
|
4
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
5
5
|
end
|
6
6
|
|
7
|
-
require
|
7
|
+
require "rdoc/task"
|
8
8
|
|
9
9
|
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir =
|
11
|
-
rdoc.title
|
12
|
-
rdoc.options <<
|
13
|
-
rdoc.rdoc_files.include(
|
14
|
-
rdoc.rdoc_files.include(
|
10
|
+
rdoc.rdoc_dir = "rdoc"
|
11
|
+
rdoc.title = "Avo"
|
12
|
+
rdoc.options << "--line-numbers"
|
13
|
+
rdoc.rdoc_files.include("README.md")
|
14
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
15
15
|
end
|
16
16
|
|
17
17
|
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
|
18
|
-
load
|
18
|
+
load "rails/tasks/engine.rake"
|
19
19
|
|
20
|
-
load
|
20
|
+
load "rails/tasks/statistics.rake"
|
21
21
|
|
22
|
-
require
|
22
|
+
require "bundler/gem_tasks"
|
23
23
|
|
24
|
-
require
|
24
|
+
require "rake/testtask"
|
25
25
|
|
26
26
|
Rake::TestTask.new(:test) do |t|
|
27
|
-
t.libs <<
|
28
|
-
t.pattern =
|
27
|
+
t.libs << "test"
|
28
|
+
t.pattern = "test/**/*_test.rb"
|
29
29
|
t.verbose = false
|
30
30
|
end
|
31
31
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class Avo::Common::MultipleFileViewerComponent < ViewComponent::Base
|
4
4
|
include Avo::ApplicationHelper
|
5
5
|
|
6
|
-
def initialize(id:, file:, is_image:, button_size: :md
|
6
|
+
def initialize(id:, file:, is_image:, resource:, button_size: :md)
|
7
7
|
@id = id
|
8
8
|
@file = file
|
9
9
|
@is_image = is_image
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class Avo::Common::SingleFileViewerComponent < ViewComponent::Base
|
4
4
|
include Avo::ApplicationHelper
|
5
5
|
|
6
|
-
def initialize(id:, file:, is_image:, button_size: :md
|
6
|
+
def initialize(id:, file:, is_image:, resource:, button_size: :md)
|
7
7
|
@id = id
|
8
8
|
@file = file
|
9
9
|
@is_image = is_image
|
@@ -4,7 +4,7 @@ class Avo::Edit::FieldWrapperComponent < ViewComponent::Base
|
|
4
4
|
def initialize(field: nil, dash_if_blank: true, full_width: false, displayed_in_modal: false, form: nil, resource: {}, **args)
|
5
5
|
@field = field
|
6
6
|
@dash_if_blank = dash_if_blank
|
7
|
-
@classes = args[:class].present? ? args[:class] :
|
7
|
+
@classes = args[:class].present? ? args[:class] : ""
|
8
8
|
@args = args
|
9
9
|
@displayed_in_modal = displayed_in_modal
|
10
10
|
@form = form
|
@@ -12,8 +12,8 @@ class Avo::Edit::FieldWrapperComponent < ViewComponent::Base
|
|
12
12
|
@model = resource.present? ? resource.model : nil
|
13
13
|
@full_width = full_width
|
14
14
|
|
15
|
-
if @index != 0
|
16
|
-
@classes +=
|
15
|
+
if (@index != 0) || @displayed_in_modal
|
16
|
+
@classes += " border-t"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -4,7 +4,7 @@ class Avo::Index::FieldWrapperComponent < ViewComponent::Base
|
|
4
4
|
def initialize(field: nil, dash_if_blank: true, **args)
|
5
5
|
@field = field
|
6
6
|
@dash_if_blank = dash_if_blank
|
7
|
-
@classes = args[:class].present? ? args[:class] :
|
7
|
+
@classes = args[:class].present? ? args[:class] : ""
|
8
8
|
@args = args
|
9
9
|
end
|
10
10
|
end
|
@@ -11,15 +11,16 @@ class Avo::Index::GridItemComponent < ViewComponent::Base
|
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
|
-
def cover
|
15
|
-
@grid_fields.cover_field
|
16
|
-
end
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
def cover
|
16
|
+
@grid_fields.cover_field
|
17
|
+
end
|
18
|
+
|
19
|
+
def title
|
20
|
+
@grid_fields.title_field
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
def body
|
24
|
+
@grid_fields.body_field
|
25
|
+
end
|
25
26
|
end
|
@@ -9,8 +9,8 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
9
9
|
|
10
10
|
def can_detach?
|
11
11
|
@reflection.present? &&
|
12
|
-
|
13
|
-
|
12
|
+
@resource.model.present? &&
|
13
|
+
(@reflection.is_a?(::ActiveRecord::Reflection::HasManyReflection) || @reflection.is_a?(::ActiveRecord::Reflection::ThroughReflection))
|
14
14
|
end
|
15
15
|
|
16
16
|
def can_edit?
|
@@ -10,11 +10,12 @@ class Avo::PanelComponent < ViewComponent::Base
|
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
|
-
def data_attributes
|
14
|
-
return if @data.blank?
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
def data_attributes
|
15
|
+
return if @data.blank?
|
16
|
+
|
17
|
+
@data.map do |key, value|
|
18
|
+
" data-#{key}=\"#{value}\""
|
19
|
+
end.join
|
20
|
+
end
|
20
21
|
end
|
@@ -8,7 +8,8 @@ class Avo::ResourceComponent < ViewComponent::Base
|
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
|
12
|
+
def simple_relation?
|
13
|
+
@reflection.is_a? ::ActiveRecord::Reflection::HasManyReflection
|
14
|
+
end
|
14
15
|
end
|
@@ -4,12 +4,12 @@ class Avo::Show::FieldWrapperComponent < ViewComponent::Base
|
|
4
4
|
def initialize(field: nil, dash_if_blank: true, full_width: false, **args)
|
5
5
|
@field = field
|
6
6
|
@dash_if_blank = dash_if_blank
|
7
|
-
@classes = args[:class].present? ? args[:class] :
|
7
|
+
@classes = args[:class].present? ? args[:class] : ""
|
8
8
|
@args = args
|
9
9
|
@full_width = full_width
|
10
10
|
|
11
|
-
if @index != 0
|
12
|
-
@classes +=
|
11
|
+
if (@index != 0) || @displayed_in_modal
|
12
|
+
@classes += " border-t"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -17,7 +17,8 @@ class Avo::Views::ResourceEditComponent < ViewComponent::Base
|
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
|
21
|
+
def via_resource?
|
22
|
+
params[:via_resource_class].present? && params[:via_resource_id].present?
|
23
|
+
end
|
23
24
|
end
|
@@ -13,7 +13,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
13
13
|
filters: [],
|
14
14
|
actions: [],
|
15
15
|
reflection: nil,
|
16
|
-
turbo_frame:
|
16
|
+
turbo_frame: "",
|
17
17
|
parent_model: nil
|
18
18
|
)
|
19
19
|
@resource = resource
|
@@ -63,7 +63,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
63
63
|
if @reflection.present?
|
64
64
|
path_args = {
|
65
65
|
via_relation_class: @parent_model.model_name,
|
66
|
-
via_resource_id: @parent_model.id
|
66
|
+
via_resource_id: @parent_model.id
|
67
67
|
}
|
68
68
|
|
69
69
|
if @reflection.inverse_of.present?
|
@@ -77,7 +77,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def attach_path
|
80
|
-
"#{Avo.configuration.root_path}#{request.env[
|
80
|
+
"#{Avo.configuration.root_path}#{request.env["PATH_INFO"]}/new"
|
81
81
|
end
|
82
82
|
|
83
83
|
def detach_path
|
@@ -85,9 +85,10 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
85
85
|
end
|
86
86
|
|
87
87
|
private
|
88
|
-
def simple_relation?
|
89
|
-
return @reflection.is_a? ::ActiveRecord::Reflection::HasManyReflection if @reflection.present?
|
90
88
|
|
91
|
-
|
92
|
-
|
89
|
+
def simple_relation?
|
90
|
+
return @reflection.is_a? ::ActiveRecord::Reflection::HasManyReflection if @reflection.present?
|
91
|
+
|
92
|
+
true
|
93
|
+
end
|
93
94
|
end
|
@@ -21,7 +21,8 @@ class Avo::Views::ResourceNewComponent < ViewComponent::Base
|
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
|
25
|
+
def via_resource?
|
26
|
+
params[:via_relation_class].present? && params[:via_resource_id].present?
|
27
|
+
end
|
27
28
|
end
|
@@ -38,29 +38,29 @@ class Avo::Views::ResourceShowComponent < Avo::ResourceComponent
|
|
38
38
|
end
|
39
39
|
|
40
40
|
private
|
41
|
-
def via_resource?
|
42
|
-
params[:via_resource_class].present? and params[:via_resource_id].present?
|
43
|
-
end
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@has_many_panels = []
|
49
|
-
@has_as_belongs_to_many_panels = []
|
42
|
+
def via_resource?
|
43
|
+
params[:via_resource_class].present? && params[:via_resource_id].present?
|
44
|
+
end
|
50
45
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
@has_many_panels << field
|
57
|
-
when 'Avo::Fields::HasAndBelongsToManyField'
|
58
|
-
@has_as_belongs_to_many_panels << field
|
59
|
-
else
|
60
|
-
@fields_by_panel[field.panel_name] ||= []
|
61
|
-
@fields_by_panel[field.panel_name] << field
|
62
|
-
end
|
63
|
-
end
|
46
|
+
def split_panel_fields
|
47
|
+
@fields_by_panel = {}
|
48
|
+
@has_one_panels = []
|
49
|
+
@has_many_panels = []
|
50
|
+
@has_as_belongs_to_many_panels = []
|
64
51
|
|
52
|
+
@resource.get_fields.each do |field|
|
53
|
+
case field.class.to_s
|
54
|
+
when "Avo::Fields::HasOneField"
|
55
|
+
@has_one_panels << field
|
56
|
+
when "Avo::Fields::HasManyField"
|
57
|
+
@has_many_panels << field
|
58
|
+
when "Avo::Fields::HasAndBelongsToManyField"
|
59
|
+
@has_as_belongs_to_many_panels << field
|
60
|
+
else
|
61
|
+
@fields_by_panel[field.panel_name] ||= []
|
62
|
+
@fields_by_panel[field.panel_name] << field
|
63
|
+
end
|
65
64
|
end
|
65
|
+
end
|
66
66
|
end
|