tramway-export 0.1.0.3 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9ff476d80bb0e6c0d3169ae79cc36a8310eab02aff7f59ac66a54efaa2c4497
|
4
|
+
data.tar.gz: 98a38ab02ee16f7bd30305e4adedbc4dfbe956d496ade6f0176a425b682b819b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 054f373a769da7f602a92ff1f9ece42e52628f083b5e969ff71df9201c9e16b2fe3f9fad8e992acb2b635394f1d10b6206232d8c8c95810fb9285d07b5c224f0
|
7
|
+
data.tar.gz: 2ac3d9481e935acf14cb13b22f57d54e20428b9ba3f5bf141869680d02c0df9dd394128dda9382c26ecbb2352c3f35281e2ac8d681389cfb8fa82ab2428d7e0a
|
@@ -2,26 +2,28 @@
|
|
2
2
|
|
3
3
|
require 'xls_exporter'
|
4
4
|
|
5
|
-
class Tramway::Export::ExportsController < Tramway::
|
5
|
+
class Tramway::Export::ExportsController < Tramway::Admin::ApplicationController
|
6
6
|
def show
|
7
7
|
scope = params[:scope].present? ? params[:scope] : :all
|
8
8
|
model_class = model_class_name(params[:model])
|
9
|
-
|
10
|
-
records =
|
9
|
+
xls_decorator_class = xls_decorator_class_name(params[:model])
|
10
|
+
records = model_class.active.order(id: :desc).send scope
|
11
|
+
records = records.send "#{current_user.role}_scope", current_user.id
|
12
|
+
records = xls_decorator_class.decorate records
|
11
13
|
|
12
14
|
book = ::XlsExporter.export do
|
13
15
|
add_sheet 'List'
|
14
16
|
|
15
|
-
export_models records, *
|
17
|
+
export_models records, *xls_decorator_class.columns
|
16
18
|
end
|
17
19
|
stream = StringIO.new
|
18
20
|
book.write stream
|
19
|
-
send_data stream.string, content_type: 'application/
|
21
|
+
send_data stream.string, content_type: 'application/xls', filename: xls_decorator_class.filename
|
20
22
|
end
|
21
23
|
|
22
24
|
private
|
23
25
|
|
24
|
-
def
|
25
|
-
"#{model_name}
|
26
|
+
def xls_decorator_class_name(model_name)
|
27
|
+
"#{model_name}XlsDecorator".constantize
|
26
28
|
end
|
27
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xls_exporter
|
@@ -37,10 +37,9 @@ files:
|
|
37
37
|
- app/assets/config/tramway_export_manifest.js
|
38
38
|
- app/assets/javascripts/tramway/export/application.js
|
39
39
|
- app/assets/stylesheets/tramway/export/application.css
|
40
|
-
- app/controllers/tramway/export/application_controller.rb
|
41
40
|
- app/controllers/tramway/export/exports_controller.rb
|
42
41
|
- app/decorators/tramway/export/application_decorator.rb
|
43
|
-
- app/decorators/tramway/export/
|
42
|
+
- app/decorators/tramway/export/xls/application_decorator.rb
|
44
43
|
- app/helpers/tramway/export/application_helper.rb
|
45
44
|
- app/jobs/tramway/export/application_job.rb
|
46
45
|
- app/mailers/tramway/export/application_mailer.rb
|