listings 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/listings/listings_controller.rb +1 -4
- data/app/views/listings/export.xls.erb +1 -1
- data/lib/listings/base.rb +12 -1
- data/lib/listings/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22306e285b8f18877c6d47cc742bfa3cb284c4ac
|
4
|
+
data.tar.gz: f402374e22a72800dfef55e6a8d65fabc2c17a69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0dac07fedd6ef74330151646a991720ded9b0ff2cdb8f7059cfcf0d0d3e62a8a44176a95a9abee7a37e2665662a071670aedf1e7358066fdcdc90858d9248a6
|
7
|
+
data.tar.gz: bf3482c5505d5bce1c903e65cb29dace7917f8fbf60f4629ded558e24cab4d2a2b14a352b8d29f9d9f2d624324254e9be50caf8c34424acf03f3107bdf2fbc80
|
@@ -21,10 +21,7 @@ module Listings
|
|
21
21
|
|
22
22
|
respond_to do |format|
|
23
23
|
format.csv { @listing.send_csv(self) }
|
24
|
-
format.xls
|
25
|
-
headers["Content-Disposition"] = "attachment; filename=\"#{@listing.export_filename(:xls)}\""
|
26
|
-
render 'listings/export'
|
27
|
-
end
|
24
|
+
format.xls { @listing.send_xls(self) }
|
28
25
|
end
|
29
26
|
ensure
|
30
27
|
Kaminari::Helpers::Tag.paginate_with_listings(nil)
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<Cell><Data ss:Type="String"><%= col.human_name %></Data></Cell>
|
12
12
|
<% end %>
|
13
13
|
</Row>
|
14
|
-
<% @listing.
|
14
|
+
<% @listing.export_each do |item| %>
|
15
15
|
<Row>
|
16
16
|
<% @listing.columns.each do |col| %>
|
17
17
|
<% col.value_for(item).tap do |value| %>
|
data/lib/listings/base.rb
CHANGED
@@ -177,6 +177,12 @@ module Listings
|
|
177
177
|
(params[:format] || :html).to_sym
|
178
178
|
end
|
179
179
|
|
180
|
+
def export_each
|
181
|
+
self.items.each do |item|
|
182
|
+
yield item
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
180
186
|
def send_csv(controller)
|
181
187
|
csv_filename = self.export_filename(:csv)
|
182
188
|
|
@@ -190,7 +196,7 @@ module Listings
|
|
190
196
|
controller.response_body = Enumerator.new do |lines|
|
191
197
|
lines << self.columns.map { |c| c.human_name }.to_csv
|
192
198
|
|
193
|
-
self.
|
199
|
+
self.export_each do |item|
|
194
200
|
row = []
|
195
201
|
self.columns.each do |col|
|
196
202
|
row << col.value_for(item)
|
@@ -200,6 +206,11 @@ module Listings
|
|
200
206
|
end
|
201
207
|
end
|
202
208
|
|
209
|
+
def send_xls(controller)
|
210
|
+
controller.headers["Content-Disposition"] = %(attachment; filename="#{self.export_filename(:xls)}")
|
211
|
+
controller.render 'listings/export'
|
212
|
+
end
|
213
|
+
|
203
214
|
def method_missing(m, *args, &block)
|
204
215
|
view_context.send(m, *args, &block)
|
205
216
|
end
|
data/lib/listings/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: listings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian J. Cardiff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|