avo 2.13.0 → 2.13.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: 16af345f63f08dc026b6c1a29ce0938d7a0aad278a53884e542b8f31a17c34fa
4
- data.tar.gz: ed4abef748fbe4e8e22edecd85ea70f361875e30f28ffdbddfb648fbf9cde226
3
+ metadata.gz: 6b921afbe3cb5f55ee67ac20bb21d65dffa91b2b3608dddf1c21b6f9fa5a686e
4
+ data.tar.gz: 5a7d24f4c324b1109717321b3200c41f6b61470fabc915fe41c662fb3858a108
5
5
  SHA512:
6
- metadata.gz: 98d1460f53524d1747ac7db6a85c1c3e0e033d6ad42f624d699865500fa34079f30ea08d0a698ee756771269fb1b6d6e51d30a7663b008366a860dad6b1b6ed2
7
- data.tar.gz: df8cd199ec20e5cf1f17a407ebcd6aa0d020254eedaf8b514a517d4c800d2a923bc4bd131aec1d1967b713be49f12d56167fc69efa4b638a17570967a568f312
6
+ metadata.gz: 0e740c3c1eb71a50fe32bf7856b993e8921c6891e16a09341d636fbcaa32faf8564fd417efc8c914573d959364d573851faaf1b943a5314f7aab78f8c752758f
7
+ data.tar.gz: 7d66c540afb965ac2a07e0a2d88fe811cd6c035cee7a0ce88e8cc926c53f2dd186cabf69fb69946becec707711edb49033cf2c4d6952cdfc13894302554fc1ac
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.13.0)
4
+ avo (2.13.1)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -146,16 +146,14 @@ module Avo
146
146
  end
147
147
  end
148
148
 
149
- respond_to do |format|
150
- if saved
151
- format.html { redirect_to after_create_path, notice: "#{@resource.name} #{t("avo.was_successfully_created")}." }
152
- else
153
- add_breadcrumb @resource.plural_name.humanize, resources_path(resource: @resource)
154
- add_breadcrumb t("avo.new").humanize
155
- set_actions
156
- flash.now[:error] = t "avo.you_missed_something_check_form"
157
- format.html { render :new, status: :unprocessable_entity }
158
- end
149
+ add_breadcrumb @resource.plural_name.humanize, resources_path(resource: @resource)
150
+ add_breadcrumb t("avo.new").humanize
151
+ set_actions
152
+
153
+ if saved
154
+ create_success_action
155
+ else
156
+ create_fail_action
159
157
  end
160
158
  end
161
159
 
@@ -167,27 +165,20 @@ module Avo
167
165
  # model gets instantiated and filled in the fill_model method
168
166
  saved = save_model
169
167
  @resource = @resource.hydrate(model: @model, view: :edit, user: _current_user)
168
+ set_actions
170
169
 
171
- respond_to do |format|
172
- if saved
173
- format.html { redirect_to after_update_path, notice: "#{@resource.name} #{t("avo.was_successfully_updated")}." }
174
- else
175
- set_actions
176
- flash.now[:error] = t "avo.you_missed_something_check_form"
177
- format.html { render :edit, status: :unprocessable_entity }
178
- end
170
+ if saved
171
+ update_success_action
172
+ else
173
+ update_fail_action
179
174
  end
180
175
  end
181
176
 
182
177
  def destroy
183
- respond_to do |format|
184
- if destroy_model
185
- format.html { redirect_to params[:referrer] || resources_path(resource: @resource, turbo_frame: params[:turbo_frame], view_type: params[:view_type]), notice: t("avo.resource_destroyed", attachment_class: @attachment_class) }
186
- else
187
- error_message = @errors.present? ? @errors.first : t("avo.failed")
188
-
189
- format.html { redirect_back fallback_location: params[:referrer] || resources_path(resource: @resource, turbo_frame: params[:turbo_frame], view_type: params[:view_type]), error: error_message }
190
- end
178
+ if destroy_model
179
+ destroy_success_action
180
+ else
181
+ destroy_fail_action
191
182
  end
192
183
  end
193
184
 
@@ -398,6 +389,27 @@ module Avo
398
389
  add_breadcrumb t("avo.edit").humanize
399
390
  end
400
391
 
392
+ def create_success_action
393
+ respond_to do |format|
394
+ format.html { redirect_to after_create_path, notice: create_success_message}
395
+ end
396
+ end
397
+
398
+ def create_fail_action
399
+ respond_to do |format|
400
+ flash.now[:error] = create_fail_message
401
+ format.html { render :new, status: :unprocessable_entity }
402
+ end
403
+ end
404
+
405
+ def create_success_message
406
+ "#{@resource.name} #{t("avo.was_successfully_created")}."
407
+ end
408
+
409
+ def create_fail_message
410
+ t "avo.you_missed_something_check_form"
411
+ end
412
+
401
413
  def after_create_path
402
414
  # If this is an associated record return to the association show page
403
415
  if params[:via_relation_class].present? && params[:via_resource_id].present?
@@ -409,12 +421,57 @@ module Avo
409
421
  redirect_path_from_resource_option(:after_create_path) || resource_path(model: @model, resource: @resource)
410
422
  end
411
423
 
424
+ def update_success_action
425
+ respond_to do |format|
426
+ format.html { redirect_to after_update_path, notice: update_success_message }
427
+ end
428
+ end
429
+
430
+ def update_fail_action
431
+ respond_to do |format|
432
+ flash.now[:error] = update_fail_message
433
+ format.html { render :edit, status: :unprocessable_entity }
434
+ end
435
+ end
436
+
437
+ def update_success_message
438
+ "#{@resource.name} #{t("avo.was_successfully_updated")}."
439
+ end
440
+
441
+ def update_fail_message
442
+ t "avo.you_missed_something_check_form"
443
+ end
444
+
412
445
  def after_update_path
413
446
  return params[:referrer] if params[:referrer].present?
414
447
 
415
448
  redirect_path_from_resource_option(:after_update_path) || resource_path(model: @model, resource: @resource)
416
449
  end
417
450
 
451
+ def destroy_success_action
452
+ respond_to do |format|
453
+ format.html { redirect_to after_destroy_path, notice: destroy_success_message }
454
+ end
455
+ end
456
+
457
+ def destroy_fail_action
458
+ respond_to do |format|
459
+ format.html { redirect_back fallback_location: params[:referrer] || resources_path(resource: @resource, turbo_frame: params[:turbo_frame], view_type: params[:view_type]), error: destroy_fail_message }
460
+ end
461
+ end
462
+
463
+ def destroy_success_message
464
+ t("avo.resource_destroyed", attachment_class: @attachment_class)
465
+ end
466
+
467
+ def destroy_fail_message
468
+ @errors.present? ? @errors.first : t("avo.failed")
469
+ end
470
+
471
+ def after_destroy_path
472
+ params[:referrer] || resources_path(resource: @resource, turbo_frame: params[:turbo_frame], view_type: params[:view_type])
473
+ end
474
+
418
475
  def redirect_path_from_resource_option(action = :after_update_path)
419
476
  return nil if @resource.class.send(action).blank?
420
477
 
@@ -47,7 +47,7 @@ module Avo
47
47
  query = Avo::Hosts::SearchScopeHost.new(
48
48
  block: resource.search_query,
49
49
  params: params,
50
- scope: resource.class.scope
50
+ scope: resource.class.scope.limit(8)
51
51
  ).handle
52
52
 
53
53
  query = apply_scope(query) if should_apply_any_scope?
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.13.0" unless const_defined?(:VERSION)
2
+ VERSION = "2.13.1" unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.0
4
+ version: 2.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-08-17 00:00:00.000000000 Z
12
+ date: 2022-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails