my_admin 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0076e65765943afe3323f0cccf1e1ea692a0035b
4
- data.tar.gz: 30ea921e81f540abb18ab272b8defe3f43c40535
2
+ SHA256:
3
+ metadata.gz: c6672c539d3f0782734ac9251757116955dfc6ab86645903902a5024852164c8
4
+ data.tar.gz: 33434b0ab286815b08953e2898a4b1360d35a6b114741e46164fe29e6d096d8e
5
5
  SHA512:
6
- metadata.gz: 98a53655fe79f1e5e3f703fd0b50cba1cfb01583cc3e94c4c4caabee0ba28f6d599a27a75378d0fafc64ea919bd7b4b8f46bcc6a3b30ec041d8f1bf96b7bcc94
7
- data.tar.gz: 72e279033951de71e0d8b44b02dcf561e04eee54446bcdd4665a26d2dc517ab330d851881815d508d5870dd0409a1fe7306d4c8a279dcfa490bd3f56deacbb98
6
+ metadata.gz: 180a03b3e2c48c652e37be6ff63966ecc32d87ae62c503a0afc6a106b327e6c0ed1905a9fca2251df09c79ecabcf63ee7f7935539367e7f6ec0dc769695d18bd
7
+ data.tar.gz: a1c4bea3590c39d4e0f79cb9d6a6bd37a92820d8e8e74deb575653f7e33209093b7637c2cb8fce33cb0e11a72613e7d108650b7e0f2ebdead46fa385ba5efff9
@@ -28,8 +28,8 @@ class MyAdmin::ModelsController < MyAdmin::MyAdminController
28
28
  only.each do |field|
29
29
  headers << field_title(@model, field)
30
30
  end
31
-
32
- send_data @objects.to_xls({:only => only, :header_columns => headers}), :filename => "#{@model.title_plural}.xls"
31
+
32
+ send_data @objects.to_csv({:only => only, :header_columns => headers}), :type => 'text/csv; charset=utf-8; header=present', :disposition => "attachment", :filename => "#{@model.title_plural}.csv"
33
33
  return
34
34
  end
35
35
  end
@@ -37,7 +37,7 @@
37
37
  </div>
38
38
  <div class="actions pull-right">
39
39
  <div class="input-medium per_page">
40
- <%= select_tag :per_page, options_for_select([10,20,50,100].map { |i| ["#{i} por página", model_link(@application, @model, params.clone.update({:per_page => i}))]}, model_link(@application, @model, params.clone.update({:per_page => params[:per_page]}))), :class => 'chosen-select', "data-nosearch" => true %>
40
+ <%= select_tag :per_page, options_for_select([10,20,50,100,@model.all.count].map { |i| [ i == @model.all.count ? "Todos" : "#{i} por página", model_link(@application, @model, params.clone.update({:per_page => i}))]}, model_link(@application, @model, params.clone.update({:per_page => params[:per_page]}))), :class => 'chosen-select', "data-nosearch" => true %>
41
41
  </div>
42
42
  </div>
43
43
 
data/lib/my_admin.rb CHANGED
@@ -5,6 +5,7 @@ require "dynamic_form"
5
5
  require "breadcrumbs"
6
6
  require "paperclip"
7
7
  require "ckeditor"
8
+ require "csv"
8
9
 
9
10
  require "my_admin/engine"
10
11
  require "my_admin/active_record"
@@ -12,6 +13,7 @@ require "my_admin/string"
12
13
  require "my_admin/application"
13
14
  require "my_admin/locales"
14
15
  require "my_admin/to_xls"
16
+ require "my_admin/to_csv"
15
17
  require "my_admin/breadcrumbs/my_admin"
16
18
  require "my_admin/paperclip"
17
19
  require "my_admin/ckeditor"
@@ -0,0 +1,23 @@
1
+ class Array
2
+
3
+ def to_csv(options = {})
4
+ options.reverse_merge!(:header => true)
5
+
6
+ csv_data = CSV.generate do |csv|
7
+
8
+ if options[:header]
9
+ csv << options[:header_columns]
10
+ self.each do |model|
11
+ row = []
12
+ options[:only].each do |column|
13
+ row.push(model[column])
14
+ end
15
+ csv << row
16
+ end
17
+ end
18
+
19
+ end
20
+ return csv_data
21
+ end
22
+
23
+ end
@@ -1,3 +1,3 @@
1
1
  module MyAdmin
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Vinicius von Gal dos Santos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-13 00:00:00.000000000 Z
11
+ date: 2018-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -960,6 +960,7 @@ files:
960
960
  - lib/my_admin/model_configuration.rb
961
961
  - lib/my_admin/paperclip.rb
962
962
  - lib/my_admin/string.rb
963
+ - lib/my_admin/to_csv.rb
963
964
  - lib/my_admin/to_xls.rb
964
965
  - lib/my_admin/version.rb
965
966
  - lib/my_admin/will_paginate/bootstrap_link_renderer.rb
@@ -984,7 +985,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
984
985
  version: '0'
985
986
  requirements: []
986
987
  rubyforge_project: my_admin
987
- rubygems_version: 2.6.7
988
+ rubygems_version: 2.7.7
988
989
  signing_key:
989
990
  specification_version: 4
990
991
  summary: MyAdmin