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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 599fc4c702a8e03706fe1237d7596a252b23e1c1
4
- data.tar.gz: 54c5350bc61712bd5b981bda2a8edfd1818ea8a1
3
+ metadata.gz: 5d430cf39c020a63c9cf7e16b248a1ee4c71c040
4
+ data.tar.gz: cf28b29eb8f4d46fa53a1cd6cf84663f3b1f94d1
5
5
  SHA512:
6
- metadata.gz: 3d76b7da4125981bf52c8cb402889e25eacca4886dc1dc1457d4cbde8acbd31f7ca92c3acb9fe3a08a74a88cbfd38a34f3f46b9d6a68df0c5e8892d785ce2dcf
7
- data.tar.gz: 4c184c1a561e0a59b14a40ef4187d9f248b39ecb76d2b321f10be1993a1f35d5cccf98ff5feecb7ff2b7bad6553c016c0a96f3f902543128786bf5c07d86b32f
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 "#{@crud_helper.order_field}".include?("desc") or "#{@crud_helper.order_field}".include?("asc")
14
- @q.sorts = "#{@crud_helper.order_field}"
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
- @q = @model.search(params[:q])
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
- buf <<"<option value ='' selected>#{I18n.t('search')}</option>"
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
@@ -1,3 +1,3 @@
1
1
  module TemplusModels
2
- VERSION = "3.0.13"
2
+ VERSION = "3.0.14"
3
3
  end