Skip to content
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

Merged
merged 1 commit into from
May 27, 2017
Merged

Show deleted #1904

merged 1 commit into from
May 27, 2017

Conversation

spaghetticode
Copy link
Member

Fix for issue #1903

@@ -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)

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' } } }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside { missing.

@spaghetticode spaghetticode force-pushed the show_deleted branch 5 times, most recently from b2681e0 to 142618f Compare May 15, 2017 07:52
Copy link
Member

@kennyadsl kennyadsl left a 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
Copy link
Member

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

@@ -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
Copy link
Member

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' %>
Copy link
Member

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.
Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, thanks 👍

@mamhoff mamhoff merged commit 74f1f6d into solidusio:master May 27, 2017
@mamhoff
Copy link
Contributor

mamhoff commented May 27, 2017

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants