-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/backoffice smart filters #426
Conversation
…r new dependent input
9118dfa
to
e5a3200
Compare
85eed81
to
9b608f6
Compare
073c5c1
to
1a366c5
Compare
1a366c5
to
30997c2
Compare
df15f40
to
ce5be5f
Compare
f9bf158
to
8c495d4
Compare
8c495d4
to
d02b627
Compare
…ot change selection if no parent selection
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.
Looks great!
But we will lose some dependencies on the observation page. Is that ok?
app/admin/law.rb
Outdated
as: :select, | ||
collection: -> { Subcategory.joins(:laws).with_translations(I18n.locale).order('subcategory_translations.name') } | ||
filter :written_infraction_cont, label: I18n.t('active_admin.laws_page.written_infraction') | ||
filter :infraction_cont, label: I18n.t('active_admin.laws_page.infraction') |
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.
what's cont
? So that the field is not prepopulated? Wasn't it enough not to make the fields text fields?
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's ransack contains
so checking if text contains a string. It's a simple text field without any autocompletion now.
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 will ask Sophie again what is more desired, as we can change as you said to look by law id for selected infraction text which will help, but I think they wanted simple text field here.
{ | ||
country_id: { | ||
operator_id: Operator.pluck(:country_id, :id), | ||
fmu_id: Fmu.pluck(:country_id, :id), |
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.
mmm.. but this way the fmu does not depend on the operator.
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.
In this case, that was strictly requested.
app/admin/observation_report.rb
Outdated
collection: -> { Country.with_translations(I18n.locale).order('country_translations.name') } | ||
filter :observers, label: I18n.t('activerecord.attributes.observation.observers'), as: :select, | ||
collection: -> { Observer.with_translations(I18n.locale).order('observer_translations.name') } | ||
label: I18n.t('activerecord.models.country.one'), |
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.
We no longer want the user? I thought this was a useful field
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.
Yes, I removed all filters Sophie doesn't want there anymore.
collection: -> { Operator.order(:name) } | ||
filter :fmu, label: I18n.t('activerecord.models.fmu.other'), as: :select, | ||
collection: -> { Fmu.with_translations(I18n.locale).order('fmu_translations.name') } | ||
collection: -> { RequiredOperatorDocument.with_generic.map { |r| [r.name_with_country, r.id] } } |
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.
❤️
end | ||
end | ||
result | ||
array.group_by(&:first).transform_values { |v| v.map(&:last) }.delete_if { |k, _v| k.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.
👍
# Configure Capybara to use :cuprite driver by default | ||
Capybara.default_driver = Capybara.javascript_driver = :cuprite | ||
|
||
RSpec.configure do |config| |
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.
mmm.. what does this change in the rspec execution?
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.
We did not have any system spec before, so we do now. System specs are run along the rest when executing rspec spec
.
@tsubik maybe before merging it would be a good idea to squash most of the commits :) |
Don't want to squash them as I want to have that other solution (using
dependent ajax select) in git history. There are many commits as I changed
my mind how I will implement this.
|
filter_tree = block.call | ||
filter_tree.each_value { |v| v.transform_values! { |collection| HashHelper.aggregate(collection) } } | ||
|
||
# div class: 'dependent-filters', data: { filters: filter_tree } |
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.
upps I see I forgot to remove this comment here.
Adding more dependent filters by using filter trees. (https://www.pivotaltracker.com/story/show/181286870)