-
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
feat(Admin): Add links to download CSV in EN and FR #374
Conversation
@tsubik I finished this one late and didn't check if all the specs are passing. |
@@ -0,0 +1,25 @@ | |||
# frozen_string_literal: true | |||
|
|||
module Translatable |
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 a fan of this as we're moving away from the default way of adding extra includes in Active Admin which is overriding scoped_collection
method. If I want to add extra includes I would not know what translate method stands for I would probably just add scoped_collection
as in AA docs.
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.
@tsubik what you're suggesting is not to have the scoped_collection
there?
It's a bunch of repeated code in most AA resources.
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 think more code but easier to undestand could be beneficial, as when someone looks at scoped_collection
then it's obvious what it does as this is default mechanism of AA. In comparison API translate([[operator: :translations], [fmu: :translations]], false)
is very criptic.
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 just not sure if it's worth it to DRY it, as it is making this more complex and harder to customize scoped collection later, let's say we want to sideload different relations if it's CSV download vs HTML page as I did many times.
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.
Also includes could be optimized further to only load I18n.locale
.
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.
Actually, it could be not worth it to try sideload only I18n.locale
translations with custom where
or some joins
.
controller do | ||
before_action :set_locale, only: :index | ||
|
||
def set_locale |
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 think we could move setting this before_action to active admin initializers as this only works when you provide locale param explicit so we can make this work for all resources, and I would keep scoped_collection
as there were before.
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.
Mmmm.. let me check it
@@ -307,3 +292,21 @@ | |||
# Add Filters Extensions | |||
ActiveAdmin::BaseController.include ActiveAdmin::FilterSaver::Controller | |||
end | |||
|
|||
# Modifies the display of the CSVs so that it shows on to download an English and a French versions. | |||
module ActiveAdmin::ViewHelpers::DownloadFormatLinksHelper |
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.
Nice 👍
3a9003d
to
1b1db05
Compare
@tsubik I changed it no to have the |
Great. All look good except a couple of failing specs. I don't know why those are failing (checked them briefly). Please make sure all tests are passing and we can merge this. |
It was late and I forgot to check it. I'll do it now. |
1b1db05
to
79d010f
Compare
The specs are failing because of the batch actions in observations. |
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.
Alright, let's wait for other PR to be merged and see if all specs are passing then this is good to merge 👍
79d010f
to
d41c52e
Compare
Rebased |
It still has failing specs. I'm going to check it. |
d41c52e
to
7e310c6
Compare
Ok, it was because the observations didn't have translations and didn't load in the AA page. |
Task
Pull request checklist
Please check if your PR fulfills the following requirements:
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: 181285671
What is the new behavior?
Does this introduce a breaking change?
Other information