avo 2.13.5.pre.2 → 2.13.6.pre.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ac27367850b66ed5118891624a6480086e08d5e781a186cc766af138cff1c77
4
- data.tar.gz: 59c4765ea8e68bbfc5e088c6b9a3bad11c3f8ece23f3090793299ea414094086
3
+ metadata.gz: 5c3d594c867fc840c703aff831b7a39e66ca678d525ce66a698014979197fa8d
4
+ data.tar.gz: c8d325159aadabb979c15df783595b68ad2c1ea5c150779f85de66255b1ba221
5
5
  SHA512:
6
- metadata.gz: ce476b0f388b16f1f27e96e94499a30fe35a59acea7997aa5a72f16ba0e85bf86d1b2f79481b69eb32504bcb58a27f7355a4e004983072e216fd117b9c836e67
7
- data.tar.gz: 413d0a5063903155f3915a309d8291d5cea91192d971b4899b7ed5a8a21eae7f295458aacb34eaa10f2ccea76656a0c9b01393a4048769d9b7587882f3bc6ce2
6
+ metadata.gz: 3abe727bca4823198022bd9e79ccadc9c2b79b1cc8d6ab1070b57e9761e93620ee457dfa45b45a9847258640c551865b9d830bfd73326372a355c7c3fabbaf60
7
+ data.tar.gz: f7107a8cb2b0dbc072a50eaa5faa3b92ad565642c835a11ee30bbcde0f601c94bbc56694f39c4c363592194203144a78215e9bade5c478433a2603a8486f1251
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.13.5.pre.2)
4
+ avo (2.13.6.pre.1)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -9,9 +9,10 @@ class Avo::BaseComponent < ViewComponent::Base
9
9
 
10
10
  private
11
11
 
12
- # Use the @parent_resource to fetch the field using the @reflection name.
12
+ # Figure out what is the corresponding field for this @reflection
13
13
  def field
14
- @parent_resource.get_field_definitions.find { |f| f.id == @reflection.name }
14
+ fields = ::Avo::App.get_resource_by_model_name(@reflection.active_record.name).get_field_definitions
15
+ fields.find { |f| f.id == @reflection.name }
15
16
  rescue
16
17
  nil
17
18
  end
@@ -21,7 +21,7 @@
21
21
  <div class="flex space-x-2">
22
22
  <div class="flex">
23
23
  <% if @resource.authorization.authorize_action(:download_attachments?, raise_exception: false) %>
24
- <%= a_link helpers.main_app.url_for(file),
24
+ <%= a_link file.url(disposition: :attachment),
25
25
  icon: 'heroicons/outline/download',
26
26
  color: :primary,
27
27
  download: true,
@@ -4,7 +4,6 @@ class Avo::ResourceComponent < Avo::BaseComponent
4
4
  attr_reader :has_many_panels
5
5
  attr_reader :has_as_belongs_to_many_panels
6
6
  attr_reader :resource_tools
7
- attr_reader :resource
8
7
  attr_reader :view
9
8
 
10
9
  def can_create?
@@ -20,7 +19,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
20
19
  end
21
20
 
22
21
  def can_detach?
23
- authorize_association_for(:detach)
22
+ authorize_association_for("detach")
24
23
  end
25
24
 
26
25
  def detach_path
@@ -54,7 +53,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
54
53
 
55
54
  if @reflection.present?
56
55
  # Fetch the appropiate resource
57
- reflection_resource = field.resource
56
+ reflection_resource = ::Avo::App.get_resource_by_model_name(@reflection.active_record.name)
58
57
  # Fetch the model
59
58
  # Hydrate the resource with the model if we have one
60
59
  reflection_resource.hydrate(model: @parent_model) if @parent_model.present?
@@ -4,6 +4,8 @@ class Avo::Views::ResourceEditComponent < Avo::ResourceComponent
4
4
  include Avo::ResourcesHelper
5
5
  include Avo::ApplicationHelper
6
6
 
7
+ attr_reader :view
8
+
7
9
  def initialize(resource: nil, model: nil, actions: [], view: :edit)
8
10
  @resource = resource
9
11
  @model = model
@@ -117,7 +117,11 @@ export default class extends Controller {
117
117
 
118
118
  flatpickr(this.fakeInputTarget, options)
119
119
 
120
- this.updateRealInput(this.parsedValue.setZone(this.displayTimezone).toISO())
120
+ if (this.enableTimeValue) {
121
+ this.updateRealInput(this.parsedValue.setZone(this.displayTimezone).toISO())
122
+ } else {
123
+ this.updateRealInput(universalTimestamp(this.initialValue))
124
+ }
121
125
  }
122
126
 
123
127
  onChange(selectedDates) {
@@ -20,6 +20,7 @@ module Avo
20
20
  delegate :context, to: ::Avo::App
21
21
 
22
22
  attr_accessor :view
23
+ attr_accessor :model
23
24
  attr_accessor :reflection
24
25
  attr_accessor :user
25
26
  attr_accessor :params
@@ -110,11 +111,6 @@ module Avo
110
111
  end
111
112
  end
112
113
 
113
- def record
114
- @model
115
- end
116
- alias :model :record
117
-
118
114
  def hydrate(model: nil, view: nil, user: nil, params: nil)
119
115
  @view = view if view.present?
120
116
  @user = user if user.present?
@@ -51,15 +51,10 @@ module Avo
51
51
  #
52
52
  # get_resource_by_name('User') => UserResource
53
53
  # get_resource_by_name(User) => UserResource
54
- def get_resource_by_model_name(klass)
55
- # Fetch the mappings imposed by the user.
56
- # If they are present, use those ones.
57
- mapping = get_mapping_for_model klass
58
- return get_resource(mapping) if mapping.present?
59
-
54
+ def get_resource_by_model_name(name)
60
55
  valid_resources
61
56
  .find do |resource|
62
- resource.model_class.model_name.name == klass.to_s
57
+ resource.model_class.model_name.name == name.to_s
63
58
  end
64
59
  end
65
60
 
@@ -133,12 +128,6 @@ module Avo
133
128
 
134
129
  get_sidebar_partials
135
130
  end
136
-
137
- private
138
-
139
- def get_mapping_for_model(klass)
140
- (Avo.configuration.model_resource_mapping || {}).stringify_keys.transform_values(&:to_s)[klass.to_s]
141
- end
142
131
  end
143
132
  end
144
133
  end
@@ -34,7 +34,6 @@ module Avo
34
34
  attr_accessor :buttons_on_form_footers
35
35
  attr_accessor :main_menu
36
36
  attr_accessor :profile_menu
37
- attr_accessor :model_resource_mapping
38
37
 
39
38
  def initialize
40
39
  @root_path = "/avo"
@@ -79,7 +78,6 @@ module Avo
79
78
  @buttons_on_form_footers = false
80
79
  @main_menu = nil
81
80
  @profile_menu = nil
82
- @model_resource_mapping = {}
83
81
  end
84
82
 
85
83
  def current_user_method(&block)
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.13.5.pre.2" unless const_defined?(:VERSION)
2
+ VERSION = "2.13.6.pre.1" unless const_defined?(:VERSION)
3
3
  end
@@ -34,27 +34,25 @@ Avo.configure do |config|
34
34
  ## == Localization ==
35
35
  # config.locale = 'en-US'
36
36
 
37
- ## == Resource options ==
38
- # config.resource_controls = :right
39
- # config.model_resource_mapping = {}
40
- # config.default_view_type = :table
41
- # config.per_page = 24
42
- # config.per_page_steps = [12, 24, 48, 72]
43
- # config.via_per_page = 8
44
- # config.id_links_to_resource = false
45
- # config.cache_resources_on_index_view = true
46
-
47
37
  ## == Customization ==
48
38
  # config.app_name = 'Avocadelicious'
49
39
  # config.timezone = 'UTC'
50
40
  # config.currency = 'USD'
41
+ # config.per_page = 24
42
+ # config.per_page_steps = [12, 24, 48, 72]
43
+ # config.via_per_page = 8
44
+ # config.default_view_type = :table
51
45
  # config.hide_layout_when_printing = false
46
+ # config.id_links_to_resource = false
52
47
  # config.full_width_container = false
53
48
  # config.full_width_index_view = false
49
+ # config.cache_resources_on_index_view = true
54
50
  # config.search_debounce = 300
55
51
  # config.view_component_path = "app/components"
56
52
  # config.display_license_request_timeout_error = true
57
53
  # config.disabled_features = []
54
+ # config.resource_controls = :right
55
+
58
56
 
59
57
  ## == Breadcrumbs ==
60
58
  # config.display_breadcrumbs = true