thambley / activeadmin-xls Goto Github PK
View Code? Open in Web Editor NEWActiveAdmin plugin for adding Excel (xls) download links for your resources
License: MIT License
ActiveAdmin plugin for adding Excel (xls) download links for your resources
License: MIT License
gem 'activeadmin-xls', github: 'thambley/activeadmin-xls'
A nice feature would be the abilty to name the columns in the order they should appear in the file. As I understand it, it is only possible to delete columns, eg:
config.xls_builder.delete_columns :id, :created_at, :updated_at, :category_name, :epfl_id_inst, :epfl_id_transact, :epfl_result, :epfl_date_cr, :epfl_payment_cd, :epfl_paymode, :epfl_payment_status_cd, :
It would be nice to be able to also do this
config.xls_builder.only_columns :first_name, :last_name, :organization, :email, :payment
The code at https://github.com/thambley/activeadmin-xls/blob/master/lib/active_admin/xls/builder.rb#L217 is trying to connect to the database even in situations where it isn't advisable (example: assets:precompile, db:migrate, db:schema:load)
Surrounding the corresponding part of the configuration (both with the DSL and with the explicit builder methods) and rescueing a ActiveRecord::StatementInvalid
exception is a temporary workaround but it might be a problem in production.
This issue in ActiveAdmin is similar: activeadmin/activeadmin#2342
I ran into a limitation with the way localising column names is implemented in the gem, as you can only decide to use, or dismiss localisation for the whole DSL block. My use case is mixed, requiring localising regular model attributes, and using key/value pairs that have been saved to the db directly for custom columns (skipping localisation for the key columns).
I did a quick patch that works for my needs, opting to only localise the columns if passed as a symbol, and when a scope exists. Strings are always titleized.
module ActiveAdmin
module Xls
class Builder
class Column
def localized_name(i18n_scope = nil)
return name.to_s.titleize unless i18n_scope && (name.is_a? Symbol)
I18n.t name, scope: i18n_scope
end
end
end
end
end
Hesitating to do a PR for this though, as it is in essence a breaking change to the way column localisation is handled. Perhaps a passable option for the column helper would be a better approach?
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from included at /bundle/bundler/gems/activeadmin-xls-a5a70018c626/lib/active_admin/xls/resource_controller_extension.rb:5)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from included at /bundle/bundler/gems/activeadmin-xls-a5a70018c626/lib/active_admin/xls/resource_controller_extension.rb:6)
Gemfile.lock
GIT
remote: git://github.com/thambley/activeadmin-xls.git
revision: a5a70018c626d1ad3cde9f763bad3d10fa68867a
specs:
activeadmin-xls (1.0.3)
activeadmin
spreadsheet
sprockets-rails says:
Expected to find a manifest file in app/assets/config/manifest.js
(Sprockets::Railtie::ManifestNeededError)
There seems to be a possibly high impact issue with the way the xls_builder handles rendering the column contents. Steps to reproduce:
xls do
whitelist
column :name do |key|
custom_helper_that_raises_exception(key)
end
end
Observed: viewA.xls contains data from viewB
Expected: Every export should be from a clean slate, so viewA.xls should only contain data from viewA.
Haven't had the chance to see if the issue is with my versions, this gem, or the underlying spreadsheet gem. This does pose a security issue with using custom helpers that might throw an uncaught error, thus leaking data between exports.
Versions used:
Ruby 2.3.7p456, Rails 5.0.7.1, ActiveAdmin 1.2.1, ActiveAdmin-xls 2.0.0, Spreadsheet 1.1.7
Hi, I am receiving the next error:
NameError (undefined local variable or method
max_per_page' for #Admin::UsersController:0x000000065f4cd0):
vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-xls-87675360866b/lib/active_admin/xls/resource_controller_extension.rb:26:in per_page_with_xls'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.