-
-
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 only active promotions filter #3595
Conversation
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, left a few comments!
|
||
<div class="col-2"> | ||
<div class="field"> | ||
<%= label_tag :active, 'Show Only Active' %><br> |
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.
Could you add a translation for this?
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.
<div class="col-2"> | ||
<div class="field"> | ||
<%= label_tag :active, 'Show Only Active' %><br> | ||
<%= f.check_box :active, label: false, as: :boolean, inline_label: "#{ t 'spree.active'}", checked_value: 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.
Do we need the inline_label
option here?
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.
And even if we do, we probably just want to pass in t('spree.active')
rather than "#{t 'spree.active'}"
since they should produce the same value.
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.
It is not needed. I stripped it out.
@@ -62,6 +63,10 @@ def promotion_code_batch_params | |||
def promotion_includes | |||
[:promotion_actions] | |||
end | |||
|
|||
def clear_boolean(query_params, condition) | |||
query_params.delete(condition) if query_params[condition] == "0" |
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.
Do we actually need this? The Ransack documentation states that scopes are only applied for true
values (unless the scope accepts arguments), so a value of 0
should cause Ransack to ignore the scope.
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.
You're right! Will make the change
7a3c2d6
to
ce1ed89
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 @wildbillcat, looking great! 🙂
@wildbillcat one last thing before we merge: could you squash the commits together? |
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.
Thank you!
Adding a holding label while waiting for the commits squash, thanks again! |
ce1ed89
to
c09bdfd
Compare
Sorry for the delay, things got a bit crazy at work yesterday. Rewrote history to be 1 commit. |
Description
This adds active as a ransackable scope to be used in the admin search.
Motivation is that for stores that have a large number of promotions build up, and it is helpful to just see what is active. This is helpful to make sure old/test promotions aren't mistakenly enabled, as they can be costly if not monitored closely.
Standard scope:
Active filter enabled:
Checklist: