rails_admin_next 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a47ededbcad2a173ee6e0d77e581ef0e4e7649458a7bf0e659592726299c6ae2
4
- data.tar.gz: bded3ecf250c69185107635e6877b4d9467f678fb12919b08146a3e67fdb7842
3
+ metadata.gz: a1e669bb86719b972a161917a8f2b88747a6be2e2233ada17c3a437e6dfdeaaf
4
+ data.tar.gz: 66a69ecedbd7e4fdca9991e2044bede57d842f5bc7e1d29159a2fb4ef41a361f
5
5
  SHA512:
6
- metadata.gz: 88379320dc12d64a6311ed451b82a685862b7c7c3ea4449c44fc391a6b1cdad8beed31623a7d4709cc8bef210779cdfe41593e24b7a6688fdf7dcbdd101a6bbb
7
- data.tar.gz: 6baf5beb0080b57a8f1fe08ccd6407872b1bec576fb43a493f58fefc76d5883c04f74c3d66e674756684c224038f6235c6f7e54b97483aa9d073a45c7dde8294
6
+ metadata.gz: 85c4a2ad4d178fee59d393020db78d735c114c8b0bb41cf42f14e70017363edd78bb49e0c461db95e8098901f30bf974a2a93683f70faf3cbb935978468cd24f
7
+ data.tar.gz: 0a60be77736c263a0dabea8abb46f573948b56ee672b0ca75473012feeb5a8889a3d5bac60668a3057602f7c5b51db097f9ff39171e210671a8d16ef3856db99
@@ -144,7 +144,7 @@ module RailsAdminNext
144
144
  content_tag(:li, class: ["breadcrumb-item", current_action?(a, am, o) && "active"]) do
145
145
  if current_action?(a, am, o)
146
146
  wording_for(:breadcrumb, a, am, o)
147
- elsif a.http_methods.include?(:get)
147
+ elsif a.linkable?
148
148
  link_to rails_admin_next.url_for(action: a.action_name, controller: "rails_admin_next/main", model_name: am.try(:to_param), id: o.try(:persisted?) && o.try(:id) || nil) do
149
149
  wording_for(:breadcrumb, a, am, o)
150
150
  end
@@ -159,7 +159,7 @@ module RailsAdminNext
159
159
  # parent => :root, :collection, :member
160
160
  # perf matters here (no action view trickery)
161
161
  def menu_for(parent, abstract_model = nil, object = nil, only_icon = false)
162
- actions = actions(parent, abstract_model, object).select { |a| a.http_methods.include?(:get) && a.show_in_menu }
162
+ actions = actions(parent, abstract_model, object).select { |a| a.linkable? && a.show_in_menu }
163
163
  actions.collect do |action|
164
164
  wording = wording_for(:menu, action)
165
165
  li_class = ["nav-item", "icon", "#{action.key}_#{parent}_link"]
@@ -131,6 +131,17 @@ module RailsAdminNext
131
131
  end
132
132
 
133
133
  def to_statement
134
+ # A multi-select filter submits its values as an array, so the sentinel has to
135
+ # be stripped out of one rather than compared against it. An array emptied by
136
+ # that strip discards the filter, but one that arrived empty does not: a date
137
+ # filter carries its meaning in the operator alone ("today", "this_week").
138
+ #
139
+ # "between" is excluded because it alone reads the array by index, so removing
140
+ # an element would shift the range ends rather than discard anything.
141
+ if @value.is_a?(Array) && @operator != "between" && @value.include?("_discard")
142
+ @value -= ["_discard"]
143
+ return if @value.empty?
144
+ end
134
145
  return if [@operator, @value].any? { |v| v == "_discard" }
135
146
 
136
147
  unary_operators[@operator] || unary_operators[@value] ||
@@ -147,6 +147,13 @@ module RailsAdminNext
147
147
 
148
148
  # Off API.
149
149
 
150
+ # Whether visiting the action's URL performs it, so it can be rendered as a
151
+ # plain link rather than a button. Verbs are host-supplied, so they may be
152
+ # written as :GET or "get".
153
+ def linkable?
154
+ http_methods.include?(:get) || http_methods.any? { |verb| verb.to_s.casecmp?("get") }
155
+ end
156
+
150
157
  def key
151
158
  self.class.key
152
159
  end
@@ -20,9 +20,11 @@ module RailsAdminNext
20
20
 
21
21
  register_instance_option :controller do
22
22
  proc do
23
+ # HTML first: an Accept-less request arrives as */*, which matches every
24
+ # registered type, so Rails falls back to whichever is declared first.
23
25
  respond_to do |format|
24
- format.json { render json: @object }
25
26
  format.html { render @action.template_name }
27
+ format.json { render json: @object }
26
28
  end
27
29
  end
28
30
  end
@@ -16,6 +16,9 @@ module RailsAdminNext
16
16
  include RailsAdminNext::Config::Groupable
17
17
  include RailsAdminNext::Config::Inspectable
18
18
 
19
+ # The length-validation options that are compared against the column limit.
20
+ LENGTH_BOUNDS = %i[is maximum minimum].freeze
21
+
19
22
  attr_reader :name, :properties, :abstract_model, :parent, :root
20
23
  attr_accessor :defined, :order, :section
21
24
 
@@ -196,8 +199,14 @@ module RailsAdminNext
196
199
 
197
200
  # Accessor for field's length restrictions per validations
198
201
  #
202
+ # ActiveModel also accepts a bound as a Proc or a Symbol, which it resolves
203
+ # against the record at validation time. Neither can be compared against the
204
+ # column limit here, so both are dropped. Devise's password length validation
205
+ # declares its bounds as Procs.
199
206
  register_instance_option :valid_length do
200
- @valid_length ||= abstract_model.model.validators_on(name).detect { |v| v.kind == :length }.try(&:options) || {}
207
+ @valid_length ||=
208
+ (abstract_model.model.validators_on(name).detect { |v| v.kind == :length }.try(&:options) || {})
209
+ .reject { |option, bound| LENGTH_BOUNDS.include?(option) && (bound.is_a?(Proc) || bound.is_a?(Symbol)) }
201
210
  end
202
211
 
203
212
  register_instance_option :partial do
@@ -266,8 +275,6 @@ module RailsAdminNext
266
275
  false
267
276
  end
268
277
 
269
- register_deprecated_instance_option :eager_load?, :eager_load
270
-
271
278
  def eager_load_values
272
279
  case eager_load
273
280
  when true
@@ -63,11 +63,6 @@ module RailsAdminNext
63
63
  :form_datetime
64
64
  end
65
65
 
66
- # Picker-only legacy option; native HTML5 inputs render per the browser locale, so it is ignored.
67
- register_deprecated_instance_option :momentjs_format do
68
- RailsAdminNext.deprecator.warn("The momentjs_format configuration option is deprecated and ignored; date/time fields now use native HTML5 inputs.")
69
- end
70
-
71
66
  # The native <input type="datetime-local" step="1"> control accepts and emits ISO 8601 only.
72
67
  def form_value
73
68
  value&.in_time_zone&.strftime("%Y-%m-%dT%H:%M:%S") || form_default_value
@@ -29,8 +29,6 @@ module RailsAdminNext
29
29
  nil
30
30
  end
31
31
 
32
- register_deprecated_instance_option :delete_key, :delete_value
33
-
34
32
  register_instance_option :pretty_value do
35
33
  if value.presence
36
34
  v = bindings[:view]
@@ -46,17 +46,9 @@ module RailsAdminNext
46
46
  ""
47
47
  end
48
48
 
49
- register_deprecated_instance_option :sidescroll do
50
- RailsAdminNext.deprecator.warn("The sidescroll configuration option was removed, it is always enabled now.")
51
- end
52
-
53
49
  def fields_for_table
54
50
  visible_fields.partition(&:sticky?).flatten
55
51
  end
56
-
57
- register_deprecated_instance_option :sort_reverse do
58
- RailsAdminNext.deprecator.warn("The sort_reverse configuration option is deprecated and has no effect.")
59
- end
60
52
  end
61
53
  end
62
54
  end
@@ -316,14 +316,6 @@ module RailsAdminNext
316
316
  end
317
317
  end
318
318
 
319
- def total_columns_width=(_)
320
- RailsAdminNext.deprecator.warn("The total_columns_width configuration option is deprecated and has no effect.")
321
- end
322
-
323
- def sidescroll=(_)
324
- RailsAdminNext.deprecator.warn("The sidescroll configuration option was removed, it is always enabled now.")
325
- end
326
-
327
319
  # Setup actions to be used.
328
320
  def actions(&block)
329
321
  return unless block
@@ -6,8 +6,8 @@ module RailsAdminNext
6
6
  # the tag's version over these constants at build time, so the in-repo values are only
7
7
  # the floor a local `gem build` produces.
8
8
  MAJOR = 1
9
- MINOR = 0
10
- PATCH = 2
9
+ MINOR = 1
10
+ PATCH = 0
11
11
  PRE = nil
12
12
 
13
13
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_next
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel López Prat