-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show deleted #1904
Show deleted #1904
Conversation
5e8411c
to
8eab860
Compare
core/app/models/spree/product.rb
Outdated
@@ -103,6 +103,11 @@ def find_or_build_master | |||
self.whitelisted_ransackable_associations = %w[stores variants_including_master master variants] | |||
self.whitelisted_ransackable_attributes = %w[slug] | |||
|
|||
# This enables "Show Deleted" checkbox feature in admin/products page | |||
def self.ransackable_scopes(auth_object = nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused method argument - auth_object. If it's necessary, use _ or _auth_object as an argument name to indicate that it won't be used. You can also write as ransackable_scopes(*) if you want the method to accept any arguments but don't care about them.
end | ||
|
||
context 'when params[:q][:with_deleted] is set to "true"' do | ||
let(:params) { { q: {with_deleted: 'true' } } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space inside { missing.
b2681e0
to
142618f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think this is a good improvement!
|
||
context 'when params[:q][:with_deleted] is set to "true"' do | ||
let(:params) { { q: { with_deleted: 'true' } } } | ||
it 'includes soft-deleted products' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave an empty line after let
here
core/app/models/spree/product.rb
Outdated
@@ -103,6 +103,11 @@ def find_or_build_master | |||
self.whitelisted_ransackable_associations = %w[stores variants_including_master master variants] | |||
self.whitelisted_ransackable_attributes = %w[slug] | |||
|
|||
# This enables "Show Deleted" checkbox feature in admin/products page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this comment line. If we'll add other scopes later this line had to be removed/changed in something more generic. I'm for removing it since we can understand why this code is here by using git history.
@@ -34,7 +34,7 @@ | |||
<div class="col-2"> | |||
<div class="field checkbox"> | |||
<label> | |||
<%= f.check_box :deleted_at_null, {checked: params[:q][:deleted_at_null] == '0'}, '0', '1' %> | |||
<%= f.check_box :with_deleted, {checked: params[:q][:with_deleted] == 'true'}, 'true', 'false' %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd take advantage of this change to add spaces inside {}
to be consistent with the rest of the code .
The "Show Deleted" checkbox param was removed in the controller, so it didn't stay checked. This also affected pagination (deleted products could be seen only on first page). The use of ransackable scopes to manage products.deleted_at field allows some code cleanup.
142618f
to
0240914
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better, thanks 👍
Thank you! |
Fix for issue #1903