templus_models 3.0.13 → 3.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/crud_controller.rb +24 -3
- data/app/helpers/search_helper.rb +3 -1
- data/lib/templus_models/version.rb +1 -1
- metadata +615 -615
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d430cf39c020a63c9cf7e16b248a1ee4c71c040
|
4
|
+
data.tar.gz: cf28b29eb8f4d46fa53a1cd6cf84663f3b1f94d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fb6d1d75db08aa1656e3d8ed3216a3b0a85180fc83319e018f1da91f60b5380ad0b0b30ba61b6d9c1c1fedad6c3a23a18bd5668bd2cd9b3a469442aa7fb9b82
|
7
|
+
data.tar.gz: 12aa1d2ad34d7d1c8c7374571edadf76d78488542748beb085c6bc3a0e6d392f5f66b351d237df669ad0b2fd2bf1d02dcb951249d52831ecc33ef85e8944e850
|
@@ -10,8 +10,8 @@ class CrudController < ApplicationController
|
|
10
10
|
@q = @model.search(params[:q])
|
11
11
|
end
|
12
12
|
if @q.sorts.empty?
|
13
|
-
if
|
14
|
-
@q.sorts =
|
13
|
+
if @crud_helper.order_field.to_s.include?("desc") || @crud_helper.order_field.to_s.include?("asc")
|
14
|
+
@q.sorts = @crud_helper.order_field.to_s
|
15
15
|
else
|
16
16
|
@q.sorts = "#{@crud_helper.order_field} asc"
|
17
17
|
end
|
@@ -159,7 +159,18 @@ class CrudController < ApplicationController
|
|
159
159
|
|
160
160
|
def listing
|
161
161
|
authorize! :read, @model_permission if respond_to?(:current_usuario)
|
162
|
-
|
162
|
+
if params[:scope].present? && valid_method?(params[:scope])
|
163
|
+
@q = @model.send(params[:scope]).search(params[:q])
|
164
|
+
else
|
165
|
+
@q = @model.search(params[:q])
|
166
|
+
end
|
167
|
+
if @q.sorts.empty?
|
168
|
+
if @crud_helper.order_field.to_s.include?("desc") || @crud_helper.order_field.to_s.include?("asc")
|
169
|
+
@q.sorts = @crud_helper.order_field.to_s
|
170
|
+
else
|
171
|
+
@q.sorts = "#{@crud_helper.order_field} asc"
|
172
|
+
end
|
173
|
+
end
|
163
174
|
if respond_to?(:current_usuario)
|
164
175
|
@records = @q.result.accessible_by(current_ability)
|
165
176
|
else
|
@@ -168,6 +179,16 @@ class CrudController < ApplicationController
|
|
168
179
|
report_name = "#{@crud_helper.title}_#{DateTime.now.strftime('%Y%m%d')}"
|
169
180
|
respond_to do |format|
|
170
181
|
format.xls { headers["Content-Disposition"] = "attachment; filename=#{report_name}.xls" }
|
182
|
+
format.pdf do
|
183
|
+
pdf = WickedPdf.new.pdf_from_string(
|
184
|
+
render_to_string('crud/listing.pdf.erb'),
|
185
|
+
encoding: 'UTF-8',
|
186
|
+
page_size: 'A4',
|
187
|
+
show_as_html: params[:debug],
|
188
|
+
margin: { top: 20, bottom: 20 }
|
189
|
+
)
|
190
|
+
send_data(pdf, filename: "#{report_name}.pdf", type: "application/pdf", disposition: "inline")
|
191
|
+
end
|
171
192
|
end
|
172
193
|
end
|
173
194
|
|
@@ -134,7 +134,9 @@ module SearchHelper
|
|
134
134
|
else
|
135
135
|
buf << "<select name=#{name} class='form-control'>"
|
136
136
|
end
|
137
|
-
|
137
|
+
if opts[:include_blank].nil? || (!opts[:include_blank].nil? && ActiveRecord::Type::Boolean.new.type_cast_from_user(opts[:include_blank]))
|
138
|
+
buf << "<option value='' selected>#{I18n.t('search')}</option>"
|
139
|
+
end
|
138
140
|
collection.each do |e|
|
139
141
|
buf << "<option value=#{e[0]}>#{e[1]}</option>"
|
140
142
|
end
|