Giter Club home page Giter Club logo

activeadmin-axlsx's Introduction

Hi there ๐Ÿ‘‹

activeadmin-axlsx's People

Contributors

randym avatar steveltn avatar zevgeniy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

activeadmin-axlsx's Issues

Break rails custom helpers

I got a register_page Dashboard:

ActiveAdmin.register_page "Dashboard" do
  content :title => proc{ I18n.t("active_admin.dashboard")  } do
    columns do
      column do
        panel "ๆœ€่ฟ‘่ฟ›ๆฅ็š„่ฎขๅ•" do
          table_for Order.order('id desc').limit(10) do
            column("็Šถๆ€")  { |order| status_tag t('models.order.state.' + order.state), order_state(order) }
            ...
          end
        end
      end
    end
  end
end

The order_state is a custom helper in app/helpers/orders_helper.rb. It would not work after I added this gem to Gemfile. I checked the activeadmin repo and found it's use method_missing to find a helper, but It just can't find out the helper from @helpers in pry debugging. More seriously, it cause infinit loop, which means the server stucked and cpu/memory is in high usage.

Using only filtered elements in the excel download

I have used activeadmin-axslx for excel download in active admin rails 4.
When I use the filters to fetch only few records based on some condition and try to download the excel with this fetched data, the excel shows all the data irrespective of the filters.

I only need that data in the excel that I have filtered.

Can any body help me achieve this?

Thanks in advance!

required)>': undefined method `xlsx' for #<ActiveAdmin::ResourceDSL:0x007fca01d1fdd0> (NoMethodError)

Hi!

Thanks for usefull gem and your work.

I have some strange problem with gem. I install it, it work. I customize xlsx for own needs and it work without problem when application run in devel mode. But if stop application and try to start it: i get such error:

 app/admin/orders.rb:55:in `block in <top (required)>': undefined method `xlsx' for #      <ActiveAdmin::ResourceDSL:0x007fca01d1fdd0> (NoMethodError)
 gems/activeadmin-0.5.1/lib/active_admin/dsl.rb:16:in `instance_eval'
 gems/activeadmin-0.5.1/lib/active_admin/dsl.rb:16:in `run_registration_block'
 gems/activeadmin-0.5.1/lib/active_admin/namespace.rb:175:in `parse_registration_block'

Any idea how fix it?

rails (3.2.12), activeadmin (0.5.1), activeadmin-axlsx (2.0.0)

Filter suddenly not respected anymore

Hi,

this is me reaching out if someone else has the issue that the filter is not respected anymore, meaning all the records of the resource end up in the excel file. For the life of me I can't tie it to any change in our application, neither to an upgrade of this extension or activeadmin itself. Also it doesn't matter if a custom configuration is in play or not. Furthermore I couldn't find any indicator that the behaviour I suddenly seem to be missing was supported in the first place, but I am pretty sure it was! :) So yeah, pretty lame error report from my side. Just wondering if someone has similar troubles or can point in the right direction for further research.

Thanks, much appreciated.

Add config.xlsx_builder.output_header

Hi,

It'd be great if the header row can be omitted by configuration. For example, setting true/false to config.xlsx_builder.output_header.

At the moment disabling header seems not possible so I simply add an after_filter to the xslx block:

after_filter do |sheet|
  sheet.rows.delete_at 0
end

dsl method xlsx fails

I tried t o configure xlsx format with code:

xlsx do
column :id
end

But got an error:
uninitialized constant ActiveAdmin::Axlsx::DSL::XlsxBuilder

I tried restarting server and oops I got another error:
undefined method `xlsx' for #ActiveAdmin::ResourceDSL:0xafaef38 (NoMethodError)

Thanks.

index_without_xlsx(options) fails with wrong number of arguments (1 for 0)

lib/active_admin/axlsx/resource_controller_extension.rb

index_without_xlsx(options) fails with:

wrong number of arguments (1 for 0)

      def index_with_xlsx(options={}, &block)
        index_without_xlsx(options) do |format|
           format.xlsx do
            xlsx = active_admin_config.xlsx_builder.serialize(collection)
            send_data xlsx.to_stream.read, :filename => "#{xlsx_filename}", :type => Mime::Type.lookup_by_extension(:xlsx)
          end
        end

All my active admin index pages fail with the same error

axlsx and assets:precompile doesnt work !

I have issue to precompile assets with axlsx active admin gem, without having it in gem everything works fine

i do have meta_search and inherited_resources in gemfile

rake aborted!
uninitialized constant InheritedResources::Base
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activeadmin-0.6.0/lib/active_admin/base_controller/authorization.rb:21:in `<module:ActiveAdmin>'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activeadmin-0.6.0/lib/active_admin/base_controller/authorization.rb:1:in `<top (required)>'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activeadmin-0.6.0/lib/active_admin/base_controller.rb:3:in `<top (required)>'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activeadmin-0.6.0/lib/active_admin/resource_controller/actions.rb:2:in `<module:ActiveAdmin>'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activeadmin-0.6.0/lib/active_admin/resource_controller/actions.rb:1:in `<top (required)>'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activeadmin-0.6.0/lib/active_admin/resource_controller.rb:2:in `<top (required)>'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activeadmin-axlsx-2.1.2/lib/active_admin/axlsx.rb:21:in `block in <class:Railtie>'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.5/lib/active_support/lazy_load_hooks.rb:34:in `call'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.5/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.5/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.5/lib/active_support/lazy_load_hooks.rb:42:in `each'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.5/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.5/lib/rails/application/bootstrap.rb:69:in `block in <module:Bootstrap>'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.5/lib/rails/initializable.rb:30:in `instance_exec'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.5/lib/rails/initializable.rb:30:in `run'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.5/lib/rails/initializable.rb:54:in `each'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.5/lib/rails/initializable.rb:54:in `run_initializers'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.5/lib/rails/application.rb:136:in `initialize!'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.5/lib/sprockets/assets.rake:95:in `block (2 levels) in <top (required)>'
Tasks: TOP => assets:clean:all => assets:environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/home/martin/.rvm/rubies/ruby-1.9.3-p392/b...]
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.5/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.5/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/home/martin/.rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.5/lib/sprockets/assets.rake:80:in `block (2 levels) in <top (required)>'
/home/martin/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `eval'
/home/martin/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => assets:clean
(See full trace by running task with --trace)

Not working with AA 1.0.0.pre

I'm trying to get the gem working with current AA master, 1.0.0.pre and after I made a few tiny fixes I got my Rails project booted. But ActiveAdmin resources that use xlsx DSL produces this error:

undefined method `xlsx' for #<ActiveAdmin::ResourceDSL:0x007fc4e3294e10> (NoMethodError)

And my patch is https://github.com/stripeskr/activeadmin-axlsx/commit/59ea1ff5631c3f277125e4f0115d1b357f7f3bcb

Not sure if it is happening because any recent change of AA, but I can't figure it out. Can anybody help me solving it?

Gemfile incompatible with activeadmin master/pre branch

In my Gemfile where I have

gem 'activeadmin', github: 'gregbell/active_admin'

I added

gem 'activeadmin-axlsx', github: 'randym/activeadmin-axlsx'

but at

bundle install

I receive

Bundler could not find compatible versions for gem "activeadmin":
    In snapshot (Gemfile.lock):
    activeadmin (1.0.0.pre)

In Gemfile:
    activeadmin-axlsx (>= 0) x86-mingw32 depends on
    activeadmin (~> 0.6.0) x86-mingw32

Running `bundle update` will rebuild your snapshot from scratch,
using only the gems in your Gemfile, which may resolve the conflict.

Is actual master branch really incompatible with activeadmin master/pre branch or only Gemfile need fix?

The way to make activeadmin-axlsx work with newest ActiveAdmin 1.0 Rails4 (Tested)

first download it from github to change something.
git clone https://github.com/randym/activeadmin-axlsx
git clone https://github.com/ywencn/active_admin

make path correct.
gem 'activeadmin-axlsx', path: '../activeadmin-axlsx'
gem 'activeadmin', path: '../activeadmin'

change all below:

for undefined method `xlsx' for #ActiveAdmin::ResourceDSL:0x (NoMethodError)
yourproject/config/environments/production.rb
set
config.eager_load = false

for `require': cannot load such file -- activeadmin/axlsx (LoadError)
activeadmin-axlsx/activeadmin-axlsx.gemspec
s.add_runtime_dependency 'activeadmin', "~> 0.6.0"
to
s.add_runtime_dependency 'activeadmin', "> 0.6.0"

for ArgumentError (wrong number of arguments (1 for 0)):
activeadmin/lib/active_admin/resource_controller/streaming.rb:11:in `index'
Change line 11
def index
to
def index(arg=nil)

for undefined local variable or method max_csv_records': activeadmin-axlsx/lib/active_admin/axlsx/resource_controller_extension.rb:11:inper_page_with_xlsx'
add max_csv_records = 1000 # some num which result in db query as limit 1000 in the end of select * query.

  def per_page_with_xlsx
      max_csv_records = 1000   #add
      if request.format ==  Mime::Type.lookup_by_extension(:xlsx)
        return max_csv_records
      end
      per_page_without_xlsx
  end

mangle values for specific columns without deleting and re-adding.

Hi,

i was wondering if it would be possible to add some sort of
column_replace(:column_name { |resource| some_helper_function(resource.title) } )

to replace the value of a column.

this would be extremely helpful if one only wants to 'mangle' a few columns.
This way one wouldn't have to do all columns manually.

Active Admin scoped_collection

When using a "scoped_collection" to limit the columns returned in an activerecord query you will get the error "ActiveModel::MissingAttributeError".

`require': cannot load such file -- activeadmin/axlsx (LoadError)

Hi,

In my gem file
gem 'activeadmin'
gem 'activeadmin-axlsx'

When I run bundle install, all the required gems got installed. But when I start the run "rails s" I am getting below error.

/home/rails/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in require': cannot load such file -- activeadmin/axlsx (LoadError) from /home/user1/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:inrescue in block in require'
from /home/user1/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:62:in block in require' from /home/user1/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:ineach'
from /home/user1/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in require' from /home/user1/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler.rb:119:inrequire'
from /home/user1/Workspace/audit_management/with_admin/audit/config/application.rb:7:in <top (required)>' from /home/user1/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.13/lib/rails/commands.rb:53:inrequire'
from /home/user1/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.13/lib/rails/commands.rb:53:in block in <top (required)>' from /home/user1/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.13/lib/rails/commands.rb:50:intap'
from /home/user1/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.13/lib/rails/commands.rb:50:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

'

Can any one help me on this?

Export all records without pagination

Hi! I couldn't find it anywhere, is there a way to export all records without pagination getting involved? E.g. I'm in the active admin index view of Users and when i export as xlsx only the current page is exported. How can i export ALL records?

column proc'ing helper method bad output

when i do this:
column(:attending) { |resource| proc { _yesno(resource.attending) } }

where _yesno() is a helper function in the ApplicationHelper module:

def _yesno(object)
case object
when nil
""
when true
"Yes"
when false
"No"
end
end

i get the following output:

Proc:0x007f8945098ff0@/srv/my/blah/path/app/admin/registrations.rb:44

if i don't use proc {} it doesn't seem to find _yesno() which is defined in applicationHelper and

in the active_admin initializer i do:

module ActiveAdmin::ViewsHelpers
include ApplicationHelper
end

any idea?

Access to the collection object in the DSL

Any chance we can get access to the collection object in the DSL vs rebuilding the query via model as shown? Params don't appear to be available in the DSL so rebuilding the users query will be kind of a pain.
Maybe something like this?
lib/active_admin/axlsx/builder.rb

      def sheet_collection
        @sheet_collection
      end

      def sheet_collection=(collection)
        @sheet_collection = collection
      end

      def serialize(collection)
        self.sheet_collection = collection
        apply_filter @before_filter
        export_collection(collection)
        apply_filter @after_filter
        to_stream
      end

Repeated exports contain duplicate data

I'm seeing an issue where repeated exports results in XLSX sheets with all rows and headers repeated several times (the number of repetitions being equal to the number of times the export is run).

The cause of the problem seems to be that the ActiveAdmin::Axlsx::Builder provided by ActiveAdmin::Axlsx::ResourceExtension is shared across requests. For each request, the serialize method of the builder simply adds more rows to the existing sheet and returns it.

First of all, I would like to provide a test case for the bug. It wasn't obvious to be where to put it. What would you advice? My first hunch was to add a test case to resource_controller_spec.rb, and simply parse the response, but perhaps you have a better idea.

Secondly, I have a crude fix:

--- a/lib/active_admin/axlsx/resource_extension.rb
+++ b/lib/active_admin/axlsx/resource_extension.rb
@@ -2,11 +2,11 @@ module ActiveAdmin
   module Axlsx
     module ResourceExtension
       def xlsx_builder=(builder)
-        @xlsx_builder = builder
+        @configured_xlsx_builder = builder
       end

       def xlsx_builder
-        @xlsx_builder ||= ActiveAdmin::Axlsx::Builder.new(resource_class)
+        @configured_xlsx_builder || ActiveAdmin::Axlsx::Builder.new(resource_class)
       end

This makes sure that every request gets a fresh builder, but it doesn't do so for a custom builder. What are your thoughts on this?

I'd be happy to submit a pull request pending your feedback.

Custom helpers not being included, compass watch produces an error.

Hi,

First of all, thanks for this gem. It has saved hours of my time.

After installing gem 'activeadmin-axlsx' to my Rails project, I have two issues.

I already explained that the gem seems to prevent helpers being included in controllers in #14.

The other issue that I found today is bin/compass watch was not running properly and produced an error:

$ bin/compass compile
NameError on line ["21"] of /Users/shpark/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activeadmin-0.6.0/lib/active_admin/base_controller/authorization.rb: uninitialized constant InheritedResources::Base
Run with --trace to see the full backtrace

I'm not sure why this is happening but removing the gem from Gemfile simply solves the problem. Running bundle exec compass watch results the same.

Any help?

Breaking Routes

By adding the gem to my project with Rails 3.2.13 and activeadmin 0.6.2 all my routes breaks. They only way to put the routes back on track is by changing a file on my rails project so they're loaded again and everything works.

Excel cant open this file format error

i like to download for each index or show page
here in my code look like

collection_action :download_xlsx, method: :get do
project = Project.find(params[:id])
send_data(filename: "#{project.project_name}.xlsx", type: "application/xlsx")
end

index do
column 'Download Links' do |c|
link_to 'Download', download_xlsx_admin_projects_path(id: c.id, format: :xlsx)
end
end

http://prntscr.com/bxrumt

Trailing zeros in column values

Is there a configuration option which we can use to ensure that the trailing zeros will be stored in the xlsx file ?

My database field is a string field.

Installation dependency axlsx is not recognized

I have axlsx-3.0.0.pre.gem installed yet I continue to receive missing dependency error while attempting to install activeadmin-axlsx-2.1.2.gem

ERROR: Could not find a valid gem 'axlsx' (<=0) in any repository

Unfortunately I cannot paste any sort of screen shot, I hope this is enough information.

get data for pivot table from another sheet in after_filter hook

my code:

after_filter { |sheet|
  new_sheet = sheet.workbook.add_worksheet(:name => 'Pivot Table')
  new_sheet.add_pivot_table "A1:B2", "'Sheet1'!A1:M15" do |pivot_table|
    pivot_table.rows = ['Month', 'Year']
    pivot_table.columns = ['Type']
    pivot_table.data = ['Sales']
  end
}

but i receive

undefined method `row' for nil:NilClass

do i miss something or is this a bug?

two issues with devise

I got this method (device_error_messages) in other views but the edit profile view is the only one that makes the error.

First error:

undefined methoddevise_error_messages!' for #<#Class:0x007f981c25bf50:0x005556aef0e290>`

app/views/my_profiles/edit.html.slim


    .row
      .small-12.large-8.large-offset-2.columns
        h2.section-title.text-center.section-title--margin = t('.edit_profile')

        = simple_form_for user, url: my_profile_path(id: user), wrapper: :vertical_form do |f|

          - if user.traveler_type.nil? or user.traveler_type.blank?
            .panel.warning-message
              p = t('.fill_traveler_type_field')

          .panel
            = devise_error_messages!

            h3.sub-section-title = t('.general')

            = f.input :email, label: t('.email_label')
            = f.input :password, input_html: { autocomplete: "off" }, label: t('.password_label')
            = f.input :name, label: t('.name_label')
            = f.input :age, label: t('.age_label')
            = f.input :traveler_type, collection: user.available_traveler_type_options, label: t('.traveler_type_label')



          .panel
            .sub-section-title = t('.notifications')

            = f.input :receive_push, input_html: {class: 'push_checkbox'}, label: t('.mobile_notifications')
            = f.input :receive_email_notifications, input_html: {class: 'push_checkbox'}, label: t('.email_notifications')

            = f.input :urban_airship_platform, disabled: true, as: :hidden
            = f.input :urban_airship_channel_id, disabled: true, as: :hidden

          .panel
            .sub-section-title = t('.sncf')

            = f.input :sncf_card_type, collection: user.available_sncf_card_types, label: t('.sncf_card_type_label')
            = f.input :sncf_fidelity_card_type, collection: user.available_sncf_fidelity_card_types,  label: t('.sncf_fidelity_card_type_label')
            = f.input :sncf_fidelity_card_code,  label: t('.sncf_fidelity_card_code_label')




          .panel
            .actions
              = f.button :submit, t('shared.actions.update'), class: 'button tiny expand no-margin'

What I've tried and didn't make any difference:

  1. Adding the devise helper method for devise_error_messages
  2. Rails.application.config.action_controller.include_all_helpers
    variable was nil. Setting it to true on app initialization didn't
    work either.

Second Error, happens when I try to export the users table to xls,
other tables are exported fine

undefined methodto_i' for #`

app/admin/user.rb

   ActiveAdmin.register User do
      actions :index, :show, :destroy, :edit, :update

      permit_params :email, :admin

      index do
        selectable_column
        column :email
        column :registration_platform
        column :admin
        column :confirmed_at
        actions
      end


      form do |f|
        f.semantic_errors
        f.inputs :email, :admin
        f.actions
      end


      filter :email
      filter :admin

    end

Maybe those errors are related.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.