avo 1.4.4.pre.1 → 1.4.4

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.

Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -2
  3. data/Gemfile.lock +1 -7
  4. data/README.md +4 -4
  5. data/app/components/avo/views/resource_index_component.html.erb +3 -3
  6. data/app/controllers/avo/application_controller.rb +7 -14
  7. data/app/controllers/avo/relations_controller.rb +1 -1
  8. data/app/controllers/avo/search_controller.rb +35 -50
  9. data/app/packs/entrypoints/application.css +1 -2
  10. data/app/packs/entrypoints/application.js +0 -3
  11. data/app/views/avo/partials/_profile_dropdown.html.erb +12 -8
  12. data/app/views/layouts/avo/application.html.erb +4 -2
  13. data/avo.gemspec +0 -1
  14. data/config/routes.rb +6 -2
  15. data/lib/avo/app.rb +1 -3
  16. data/lib/avo/base_resource.rb +7 -83
  17. data/lib/avo/configuration.rb +0 -2
  18. data/lib/avo/fields/base_field.rb +0 -6
  19. data/lib/avo/fields/file_field.rb +0 -4
  20. data/lib/avo/licensing/license.rb +0 -10
  21. data/lib/avo/licensing/pro_license.rb +1 -3
  22. data/lib/avo/services/authorization_service.rb +1 -1
  23. data/lib/avo/version.rb +1 -1
  24. data/lib/generators/avo/templates/initializer/avo.tt +0 -1
  25. data/lib/generators/avo/templates/resource/resource.tt +0 -3
  26. data/lib/generators/avo/templates/tool/sidebar_item.tt +1 -1
  27. data/public/avo-packs/css/{application-d69fe930.css → application-68691c73.css} +6 -183
  28. data/public/avo-packs/css/application-68691c73.css.br +0 -0
  29. data/public/avo-packs/css/application-68691c73.css.gz +0 -0
  30. data/public/avo-packs/css/application-68691c73.css.map +1 -0
  31. data/public/avo-packs/css/application-68691c73.css.map.br +0 -0
  32. data/public/avo-packs/css/application-68691c73.css.map.gz +0 -0
  33. data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js +26 -0
  34. data/public/avo-packs/js/{application-7b3d507875f4bc1f6677.js.LICENSE.txt → application-6a0b9e58526ae6bef242.js.LICENSE.txt} +0 -0
  35. data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js.br +0 -0
  36. data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js.gz +0 -0
  37. data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js.map +1 -0
  38. data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js.map.br +0 -0
  39. data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js.map.gz +0 -0
  40. data/public/avo-packs/manifest.json +15 -15
  41. metadata +17 -36
  42. data/app/packs/js/controllers/search_controller.js +0 -120
  43. data/app/packs/js/helpers/debounce_promise.js +0 -13
  44. data/app/packs/stylesheets/search.css +0 -79
  45. data/app/views/avo/partials/_global_search.html.erb +0 -17
  46. data/app/views/avo/partials/_resource_search.html.erb +0 -10
  47. data/public/avo-packs/css/application-d69fe930.css.br +0 -0
  48. data/public/avo-packs/css/application-d69fe930.css.gz +0 -0
  49. data/public/avo-packs/css/application-d69fe930.css.map +0 -1
  50. data/public/avo-packs/css/application-d69fe930.css.map.br +0 -0
  51. data/public/avo-packs/css/application-d69fe930.css.map.gz +0 -0
  52. data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js +0 -26
  53. data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js.br +0 -0
  54. data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js.gz +0 -0
  55. data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js.map +0 -1
  56. data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js.map.br +0 -0
  57. data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js.map.gz +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6f0c2d5d6e682ac63dd8df4b1ab8abc4044d8108790ae9e99df9b045b6a300d
4
- data.tar.gz: a57bd4485774a118a2856bd6507ff16e55552b62dfa1d8818c4764d93ed119dc
3
+ metadata.gz: 4ab528ed4c8361ffed46892c8e838897c9f834a6bba2ad4d5c2134a33381bcb0
4
+ data.tar.gz: 6a01552f743f231a4e1de2a81a85814b9a5e4708a22c514f54e1f48df37b9319
5
5
  SHA512:
6
- metadata.gz: 67738924720441151703681c6638a773bb4ce0c666b9ff21cecf719b5dce767fa816f9a5a63776aaf298da63466a59ace314cef70cb067da89081ee7074d4d70
7
- data.tar.gz: 34f5f367d6f2b5da48a481ab1f3e4e3e448d68ffba91d44a510c639e496d44de876f3b39ffdb43540aee0ca2354c7f479f47ca4957b20e6e376c8d2e7579ab01
6
+ metadata.gz: 2d46d15e71d47b3eaf1f698572aa9f5edb2de0a5699926ef57373bce6f45b00afded60f8cf74016a1d393cadddf3aa807ea16fe7a6e4f3812f44b04ac9ce2bb7
7
+ data.tar.gz: 8d62dfe3b1e41ee0a91281b848eb5a5af48738d5c85bd25c94c0167813df1a5378b3b9393d7d0778630757ccb336801382e8b59d8769b790825138699ddbff32
data/Gemfile CHANGED
@@ -125,5 +125,3 @@ gem 'meta-tags'
125
125
  gem 'breadcrumbs_on_rails'
126
126
 
127
127
  gem 'manifester'
128
-
129
- gem 'ransack'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (1.4.4.pre.1)
4
+ avo (1.4.4)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -14,7 +14,6 @@ PATH
14
14
  pagy
15
15
  pundit
16
16
  rails (>= 6.0)
17
- ransack
18
17
  view_component
19
18
  zeitwerk
20
19
 
@@ -236,10 +235,6 @@ GEM
236
235
  thor (>= 0.20.3, < 2.0)
237
236
  rainbow (3.0.0)
238
237
  rake (13.0.3)
239
- ransack (2.4.2)
240
- activerecord (>= 5.2.4)
241
- activesupport (>= 5.2.4)
242
- i18n
243
238
  rb-fsevent (0.10.4)
244
239
  rb-inotify (0.10.1)
245
240
  ffi (~> 1.0)
@@ -395,7 +390,6 @@ DEPENDENCIES
395
390
  pundit
396
391
  rails (~> 6.0.2, >= 6.0.2.2)
397
392
  rails-controller-testing
398
- ransack
399
393
  rspec-rails (~> 4.0.0)
400
394
  ruby-debug-ide
401
395
  sass-rails (>= 6)
data/README.md CHANGED
@@ -29,13 +29,13 @@ Avo is a beautiful next-generation framework that empowers you, the developer, t
29
29
  - **Actions** - Run custom actions to one or more of your resources with as little as pressing a button 💪
30
30
  - **Filters** - Write your own custom filters to quickly segment your data.
31
31
  - **Keeps your app clean** - You don't need to change your app to use Avo. Drop it in your existing app or add it to a new one and you're done 🙌
32
- - **Custom fields**- No worries if we missed a field you need. Generate a custom field in a jiffy.
32
+ - **Custom fields***- No worries if we missed a field you need. Generate a custom field in a jiffy.
33
+ - **Dashboard widgets and metrics*** - Customize your dashboard with the tools and analytics you need.
33
34
  - **Custom tools** - You need to add a page with something completely new, you've got it!
34
35
  - **Authorization** - Leverage Pundit policies to build a robust and scalable authorization system.
35
- - **Localization** - Have it available in any language you need.
36
- - **No asset pipeline pollution** - Bring your own asset pipeline.
37
- - **Dashboard widgets and metrics*** - Customize your dashboard with the tools and analytics you need.
38
36
  - **Themable*** - Dress it up into your own colors.
37
+ - **Localization*** - Have it available in any language you need.
38
+ - **No asset pipeline pollution** - Bring your own asset pipeline.
39
39
 
40
40
  *Features still under development
41
41
 
@@ -22,12 +22,12 @@
22
22
  <% end %>
23
23
 
24
24
  <% c.body do %>
25
- <div class="flex justify-between pt-2 pb-2 min-h-16"
25
+ <div class="flex justify-between py-6 min-h-24"
26
26
  data-selected-resources-name="<%= @resource.plural_name.downcase %>"
27
27
  data-selected-resources="[]"
28
28
  >
29
29
  <div class="flex items-center px-6 w-64">
30
- <%= render partial: 'avo/partials/resource_search', locals: {resource: @resource.route_key} if @resource.search_query.present? %>
30
+ <%# search %>
31
31
  </div>
32
32
  <div class="flex justify-end items-center px-6 space-x-3">
33
33
  <%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: view_type, turbo_frame: @turbo_frame } if @models.present? %>
@@ -36,7 +36,7 @@
36
36
  </div>
37
37
 
38
38
  <% if view_type.to_sym == :table %>
39
- <div class="w-full overflow-auto flex flex-col mt-4">
39
+ <div class="w-full overflow-auto flex flex-col">
40
40
  <div class="relative flex-1 flex">
41
41
  <%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model)) %>
42
42
  </div>
@@ -17,7 +17,7 @@ module Avo
17
17
  add_flash_types :info, :warning, :success, :error
18
18
 
19
19
  def init_app
20
- Avo::App.init request: request, context: context, current_user: _current_user
20
+ Avo::App.init request: request, context: context
21
21
 
22
22
  @license = Avo::App.license
23
23
  end
@@ -38,25 +38,18 @@ module Avo
38
38
  def render(*args)
39
39
  raise Avo::LicenseVerificationTemperedError, "License verification mechanism tempered with." unless method(:check_avo_license).source_location.first.match?(/.*\/app\/controllers\/avo\/application_controller\.rb/)
40
40
 
41
- if params[:controller] == "avo/search" && params[:action] == "index"
42
- raise Avo::LicenseVerificationTemperedError, "License verification mechanism tempered with." unless method(:index).source_location.first.match?(/.*\/app\/controllers\/avo\/search_controller\.rb/)
43
- end
44
-
45
41
  super(*args)
46
42
  end
47
43
 
48
44
  def check_avo_license
49
- # Check to see if the path is on a custom tool
50
45
  unless on_root_path || on_resources_path || on_api_path
51
- # Display alert on custom tool page if in development.
52
- if @license.lacks(:custom_tools) || @license.invalid?
53
- if Rails.env.development? || Rails.env.test?
46
+ if @license.invalid? || @license.lacks(:custom_tools)
47
+ if Rails.env.development?
54
48
  @custom_tools_alert_visible = true
49
+ else
50
+ raise Avo::LicenseInvalidError, "Your license is invalid or doesn't support custom tools."
55
51
  end
56
52
  end
57
-
58
- # Raise error in non-development environments.
59
- raise Avo::LicenseInvalidError, "Your license is invalid or doesn't support custom tools." if @license.lacks_with_trial(:custom_tools)
60
53
  end
61
54
  end
62
55
 
@@ -164,9 +157,9 @@ module Avo
164
157
 
165
158
  def authorize_action
166
159
  if @model.present?
167
- @authorization.set_record(@model).authorize_action action_name.to_sym
160
+ @authorization.set_record(@model).authorize_action :index
168
161
  else
169
- @authorization.set_record(@resource.model_class).authorize_action action_name.to_sym
162
+ @authorization.set_record(@resource.model_class).authorize_action :index
170
163
  end
171
164
  end
172
165
 
@@ -17,7 +17,7 @@ module Avo
17
17
  @resource = @related_resource
18
18
  @parent_model = @parent_resource.model_class.find(params[:id])
19
19
  @parent_resource.hydrate(model: @parent_model)
20
- @query = @authorization.apply_policy @parent_model.public_send(params[:related_name])
20
+ @query = @parent_model.public_send(params[:related_name])
21
21
 
22
22
  super
23
23
  end
@@ -2,71 +2,56 @@ require_dependency "avo/application_controller"
2
2
 
3
3
  module Avo
4
4
  class SearchController < ApplicationController
5
- before_action :set_resource_name, only: [:show]
6
- before_action :set_resource, only: [:show]
5
+ # before_action :authorize_user
7
6
 
8
7
  def index
9
- raise ActionController::BadRequest.new("This feature requires the pro license https://avohq.io/purchase/pro") if App.license.lacks_with_trial(:global_search)
8
+ @authorization.set_record(resource_model).authorize_action :index
9
+ resources = []
10
+
11
+ App.resources
12
+ .select { |resource| resource.search.present? }
13
+ .select { |resource| AuthorizationService.authorize_action _current_user, resource.model, "index" }
14
+ .each do |resource_model|
15
+ found_resources = add_link_to_search_results(search_resource(resource_model), resource_model)
16
+ resources.push({
17
+ label: resource_model.name,
18
+ resources: found_resources
19
+ })
20
+ end
10
21
 
11
- render json: search_resources(Avo::App.resources)
22
+ render json: {
23
+ resources: resources
24
+ }
12
25
  end
13
26
 
14
- def show
15
- render json: search_resources([resource])
27
+ def resource
28
+ render json: {
29
+ resources: add_link_to_search_results(search_resource(avo_resource), avo_resource)
30
+ }
16
31
  end
17
32
 
18
33
  private
19
34
 
20
- def search_resources(resources)
21
- resources.map do |resource|
22
- # Apply authorization
23
- next unless @authorization.set_record(resource.model_class).authorize_action(:index, raise_exception: false)
24
- # Filter out the models without a search_query
25
- next if resource.search_query.nil?
26
-
27
- search_resource resource
35
+ def add_link_to_search_results(resources, avo_resource)
36
+ resources.map do |model|
37
+ {
38
+ id: model.id,
39
+ search_label: model.send(avo_resource.class.title),
40
+ link: "/resources/#{model.class.to_s.singularize.underscore}/#{model.id}"
41
+ }
28
42
  end
29
- .select do |payload|
30
- payload.present?
31
- end
32
- .sort do |payload|
33
- payload.last[:count]
34
- end
35
- .reverse
36
- .to_h
37
43
  end
38
44
 
39
- def search_resource(resource)
40
- results = apply_search_metadata(resource.search_query.call(params: params).limit(8), resource)
41
-
42
- result_object = {
43
- header: resource.name.pluralize,
44
- results: results,
45
- count: results.length
46
- }
47
-
48
- [resource.name.pluralize.downcase, result_object]
45
+ def search_resource(avo_resource)
46
+ avo_resource.query_search(query: params[:q], via_resource_name: params[:via_resource_name], via_resource_id: params[:via_resource_id], user: _current_user)
49
47
  end
50
48
 
51
- def apply_search_metadata(models, avo_resource)
52
- models.map do |model|
53
- resource = avo_resource.dup.hydrate(model: model).hydrate_fields(model: model)
49
+ # def authorize_user
50
+ # return if params[:action] == 'index'
54
51
 
55
- result = {
56
- _id: model.id,
57
- _label: resource.label,
58
- _url: resource.avo_path,
59
- model: model
60
- }
52
+ # action = params[:action] == 'resource' ? :index : params[:action]
61
53
 
62
- if App.license.has_with_trial(:enhanced_search_results)
63
- result[:_description] = resource.description
64
- result[:_avatar] = resource.avatar
65
- result[:_avatar_type] = resource.avatar_type
66
- end
67
-
68
- result
69
- end
70
- end
54
+ # return render_unauthorized unless AuthorizationService::authorize_action _current_user, avo_resource.model, action
55
+ # end
71
56
  end
72
57
  end
@@ -4,7 +4,7 @@
4
4
  @import './../../../node_modules/tippy.js/themes/light.css';
5
5
  @import './../../../node_modules/trix/dist/trix.css';
6
6
  @import './../../../node_modules/flatpickr/dist/flatpickr.css';
7
- @import './../../../node_modules/@algolia/autocomplete-theme-classic/dist/theme.css';
7
+
8
8
 
9
9
  @import './../stylesheets/tailwindcss/base.css';
10
10
 
@@ -15,7 +15,6 @@
15
15
  @import './../stylesheets/loader.css';
16
16
  @import './../stylesheets/pagination.css';
17
17
  @import './../stylesheets/breadcrumbs.css';
18
- @import './../stylesheets/search.css';
19
18
 
20
19
  @import './../stylesheets/components/status.css';
21
20
  @import './../stylesheets/components/code.css';
@@ -45,9 +45,6 @@ document.addEventListener('turbo:load', () => {
45
45
  })
46
46
  document.addEventListener('turbo:visit', () => document.body.classList.add('turbo-loading'))
47
47
  document.addEventListener('turbo:submit-start', () => document.body.classList.add('turbo-loading'))
48
- document.addEventListener('turbo:before-cache', () => {
49
- document.querySelectorAll('[data-turbo-remove-before-cache]').forEach((element) => element.remove())
50
- })
51
48
 
52
49
  // Uncomment to copy all static images under ../images to the output folder and reference
53
50
  // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
@@ -1,19 +1,23 @@
1
1
  <div data-controller="toggle-panel">
2
2
  <a href="javascript:void(0);" class="flex items-center cursor-pointer font-semibold text-gray-700" data-action="click->toggle-panel#togglePanel">
3
- <% if _current_user.respond_to? 'avatar' %>
4
- <%= image_tag _current_user.avatar, class: "h-12 rounded-full border-4 border-white mr-1" if _current_user.avatar.present? %>
3
+ <% if _current_user.respond_to?(:avatar) && _current_user.avatar.present? %>
4
+ <%= image_tag _current_user.avatar, class: "h-12 rounded-full border-4 border-white mr-1" %>
5
5
  <% end %>
6
- <% if _current_user.name.present? %>
6
+ <% if _current_user.respond_to?(:name) && _current_user.name.present? %>
7
7
  <%= _current_user.name %>
8
- <% elsif _current_user.email.present? %>
8
+ <% elsif _current_user.respond_to?(:email) && _current_user.email.present? %>
9
9
  <%= _current_user.email %>
10
10
  <% else %>
11
11
  Avo user
12
12
  <% end %>
13
- <%= svg 'chevron-down', class: "ml-1 h-4" %>
13
+ <% if main_app.respond_to?(:destroy_user_session_path) %>
14
+ <%= svg 'chevron-down', class: "ml-1 h-4" %>
15
+ <% end %>
14
16
  </a>
15
17
 
16
- <div class="hidden absolute inset-auto inset-auto right-0 mr-6 mt-0 py-4 bg-white rounded-xl min-w-[200px] shadow-context" data-toggle-panel-target="panel">
17
- <%= button_to "Sign out", main_app.destroy_user_session_path, method: :delete, form: { "data-turbo" => "false" }, class: "appearance-none bg-white text-left cursor-pointer text-green-600 font-semibold hover:text-white hover:bg-green-500 block px-4 py-1 w-full" %>
18
- </div>
18
+ <% if main_app.respond_to?(:destroy_user_session_path) %>
19
+ <div class="hidden absolute inset-auto inset-auto right-0 mr-6 mt-0 py-4 bg-white rounded-xl min-w-[200px] shadow-context" data-toggle-panel-target="panel">
20
+ <%= button_to "Sign out", main_app.destroy_user_session_path, method: :delete, form: { "data-turbo" => "false" }, class: "appearance-none bg-white text-left cursor-pointer text-green-600 font-semibold hover:text-white hover:bg-green-500 block px-4 py-1 w-full" %>
21
+ </div>
22
+ <% end %>
19
23
  </div>
@@ -23,8 +23,10 @@
23
23
  <div>
24
24
  <%= render partial: "avo/partials/header" %>
25
25
  </div>
26
- <div class="flex-1 flex ml-4 pl-4">
27
- <%= render partial: "avo/partials/global_search" if ::Avo::App.license.has_with_trial(:global_search) %>
26
+ <div class="flex-1 flex justify-center">
27
+ <div class="w-64 flex">
28
+ <%# <resources-search :global="true"> %>
29
+ </div>
28
30
  </div>
29
31
  <div class="align-end">
30
32
  <%= render partial: "avo/partials/profile_dropdown" %>
data/avo.gemspec CHANGED
@@ -45,5 +45,4 @@ Gem::Specification.new do |spec|
45
45
  spec.add_dependency "meta-tags"
46
46
  spec.add_dependency "breadcrumbs_on_rails"
47
47
  spec.add_dependency "manifester"
48
- spec.add_dependency "ransack"
49
48
  end
data/config/routes.rb CHANGED
@@ -4,8 +4,6 @@ Avo::Engine.routes.draw do
4
4
  get "resources", to: redirect("/avo")
5
5
 
6
6
  scope "avo_api", as: "avo_api" do
7
- get "/search", to: "search#index"
8
- get "/:resource_name/search", to: "search#show"
9
7
  post "/resources/:resource_name/:id/attachments/", to: "attachments#create"
10
8
  end
11
9
 
@@ -29,4 +27,10 @@ Avo::Engine.routes.draw do
29
27
  post "/:resource_name/:id/:related_name", to: "relations#create"
30
28
  delete "/:resource_name/:id/:related_name/:related_id", to: "relations#destroy"
31
29
  end
30
+
31
+ # get '/avo-api/search', to: 'search#index'
32
+ # get '/avo-api/:resource_name/search', to: 'search#resource'
33
+
34
+ # Tools
35
+ # get '/avo-tools/resource-overview', to: 'resource_overview#index'
32
36
  end
data/lib/avo/app.rb CHANGED
@@ -6,7 +6,6 @@ module Avo
6
6
  class_attribute :request, default: nil
7
7
  class_attribute :context, default: nil
8
8
  class_attribute :license, default: nil
9
- class_attribute :current_user, default: nil
10
9
 
11
10
  class << self
12
11
  def boot
@@ -21,10 +20,9 @@ module Avo
21
20
  end
22
21
  end
23
22
 
24
- def init(request:, context:, current_user:)
23
+ def init(request:, context:)
25
24
  self.request = request
26
25
  self.context = context
27
- self.current_user = current_user
28
26
 
29
27
  self.license = Licensing::LicenseManager.new(Licensing::HQ.new(request).response).license
30
28
 
@@ -11,7 +11,7 @@ module Avo
11
11
 
12
12
  class_attribute :id, default: :id
13
13
  class_attribute :title, default: :id
14
- class_attribute :search_query, default: nil
14
+ class_attribute :search, default: [:id]
15
15
  class_attribute :includes, default: []
16
16
  class_attribute :model_class
17
17
  class_attribute :translation_key
@@ -42,18 +42,6 @@ module Avo
42
42
 
43
43
  self.filters_loader.use filter_class
44
44
  end
45
-
46
- def scope
47
- authorization.apply_policy model_class
48
- end
49
-
50
- def authorization
51
- Avo::Services::AuthorizationService.new Avo::App.current_user
52
- end
53
- end
54
-
55
- def initialize
56
- self.class.model_class = model_class
57
45
  end
58
46
 
59
47
  def hydrate(model: nil, view: nil, user: nil, params: nil)
@@ -77,7 +65,7 @@ module Avo
77
65
  field.hydrate(resource: self, panel_name: default_panel_name, user: user)
78
66
  end
79
67
 
80
- if Avo::App.license.has_with_trial(:custom_fields)
68
+ if Avo::App.license.invalid? || Avo::App.license.lacks(:custom_fields)
81
69
  fields = fields.reject do |field|
82
70
  field.custom?
83
71
  end
@@ -108,9 +96,9 @@ module Avo
108
96
  end
109
97
  end
110
98
 
111
- hydrate_fields(model: @model, view: @view)
112
-
113
- fields
99
+ fields.map do |field|
100
+ field.hydrate(model: @model, view: @view, resource: self)
101
+ end
114
102
  end
115
103
 
116
104
  def get_grid_fields
@@ -131,16 +119,8 @@ module Avo
131
119
  self.class.actions_loader.bag
132
120
  end
133
121
 
134
- def hydrate_fields(model: nil, view: nil)
135
- fields.map do |field|
136
- field.hydrate(model: @model, view: @view, resource: self)
137
- end
138
-
139
- self
140
- end
141
-
142
122
  def default_panel_name
143
- return @params[:related_name].capitalize if @params.present? && @params[:related_name].present?
123
+ return @params[:related_name].capitalize if @params[:related_name].present?
144
124
 
145
125
  case @view
146
126
  when :show
@@ -246,11 +226,7 @@ module Avo
246
226
 
247
227
  def fill_model(model, params)
248
228
  # Map the received params to their actual fields
249
- fields_by_database_id = get_field_definitions
250
- .reject do |field|
251
- field.computed
252
- end
253
- .map { |field| [field.database_id(model).to_s, field] }.to_h
229
+ fields_by_database_id = get_field_definitions.map { |field| [field.database_id(model).to_s, field] }.to_h
254
230
 
255
231
  params.each do |key, value|
256
232
  field = fields_by_database_id[key]
@@ -325,57 +301,5 @@ module Avo
325
301
  end
326
302
  end
327
303
  end
328
-
329
- def avo_path
330
- "#{Avo.configuration.root_path}/resources/#{model_class.model_name.route_key}/#{model.id}"
331
- end
332
-
333
- def label_field
334
- get_field_definitions.find do |field|
335
- field.as_label.present?
336
- end
337
- rescue
338
- nil
339
- end
340
-
341
- def label
342
- label_field.value || model_title
343
- rescue
344
- model_title
345
- end
346
-
347
- def avatar_field
348
- get_field_definitions.find do |field|
349
- field.as_avatar.present?
350
- end
351
- rescue
352
- nil
353
- end
354
-
355
- def avatar
356
- avatar_field.to_image
357
- rescue
358
- nil
359
- end
360
-
361
- def avatar_type
362
- avatar_field.as_avatar
363
- rescue
364
- nil
365
- end
366
-
367
- def description_field
368
- get_field_definitions.find do |field|
369
- field.as_description.present?
370
- end
371
- rescue
372
- nil
373
- end
374
-
375
- def description
376
- description_field.value
377
- rescue
378
- nil
379
- end
380
304
  end
381
305
  end
@@ -22,7 +22,6 @@ module Avo
22
22
  attr_accessor :display_breadcrumbs
23
23
  attr_accessor :initial_breadcrumbs
24
24
  attr_accessor :home_path
25
- attr_accessor :search_debounce
26
25
 
27
26
  def initialize
28
27
  @root_path = "/avo"
@@ -57,7 +56,6 @@ module Avo
57
56
  }
58
57
  @display_breadcrumbs = true
59
58
  @home_path = nil
60
- @search_debounce = 300
61
59
  end
62
60
 
63
61
  def locale_tag
@@ -19,9 +19,6 @@ module Avo
19
19
  attr_reader :help
20
20
  attr_reader :default
21
21
  attr_reader :visible
22
- attr_reader :as_label
23
- attr_reader :as_avatar
24
- attr_reader :as_description
25
22
 
26
23
  # Private options
27
24
  attr_reader :updatable
@@ -56,9 +53,6 @@ module Avo
56
53
  @help = args[:help] || nil
57
54
  @default = args[:default] || nil
58
55
  @visible = args[:visible] || true
59
- @as_label = args[:as_label] || false
60
- @as_avatar = args[:as_avatar] || false
61
- @as_description = args[:as_description] || false
62
56
 
63
57
  @updatable = true
64
58
  @computable = true
@@ -20,10 +20,6 @@ module Avo
20
20
  def variant(resize_to_limit: [128, 128])
21
21
  value.variant(resize_to_limit: resize_to_limit).processed.service_url
22
22
  end
23
-
24
- def to_image
25
- return variant(resize_to_limit: [320, 320]) if is_image
26
- end
27
23
  end
28
24
  end
29
25
  end
@@ -47,16 +47,6 @@ module Avo
47
47
 
48
48
  alias_method :has, :can
49
49
  alias_method :lacks, :cant
50
-
51
- # Returns if has ability and if is a valid license or app is in development.
52
- def has_with_trial(ability)
53
- can(ability) && (valid? || Rails.env.development? || Rails.env.test?)
54
- end
55
-
56
- # Returns if lacks ability and if is a valid license or app is in development.
57
- def lacks_with_trial(ability)
58
- !can(ability) && (valid? || Rails.env.development? || Rails.env.test?)
59
- end
60
50
  end
61
51
  end
62
52
  end
@@ -5,9 +5,7 @@ module Avo
5
5
  [
6
6
  :authorization,
7
7
  :custom_tools,
8
- :custom_fields,
9
- :global_search,
10
- :enhanced_search_results
8
+ :custom_fields
11
9
  ]
12
10
  end
13
11
  end
@@ -75,7 +75,7 @@ module Avo
75
75
  end
76
76
 
77
77
  def skip_authorization
78
- Avo::App.license.lacks_with_trial :authorization
78
+ Avo::App.license.lacks :authorization
79
79
  end
80
80
 
81
81
  def authorized_methods(user, record)
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "1.4.4.pre.1"
2
+ VERSION = "1.4.4"
3
3
  end
@@ -43,7 +43,6 @@ Avo.configure do |config|
43
43
  # config.full_width_container = false
44
44
  # config.full_width_index_view = false
45
45
  # config.cache_resources_on_index_view = true
46
- # config.search_debounce = 300
47
46
 
48
47
  # Where should the user be redirected when he hits the `/<%= options[:path] %>` url
49
48
  # config.home_path = nil
@@ -1,9 +1,6 @@
1
1
  class <%= resource_class %> < Avo::BaseResource
2
2
  self.title = :id
3
3
  self.includes = []
4
- # self.search_query = ->(params:) do
5
- # scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
6
- # end
7
4
 
8
5
  field :id, as: :id
9
6
  # add fields here
@@ -1 +1 @@
1
- <%%= render Avo::NavigationLinkComponent.new label: '<%= human_name %>', path: '/avo/<%= file_name %>' %>
1
+ <%%= render Avo::NavigationLinkComponent.new label: '<%= human_name %>', path: "#{Avo.configuration.root_path}/<%= file_name %>" %>