templus_models 2.0.3 → 2.0.4

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: 4ce817cc08c43cd412a30b093e5bc9f00fb4f38c
4
- data.tar.gz: 0c6303bc7d12e48ee80af6888d52fc4b9042e25b
3
+ metadata.gz: 7fb0cc95c5bfa019c9542e783b7f340cc2d732f0
4
+ data.tar.gz: 175ca61205b9b4f4588c8994538977c241af5029
5
5
  SHA512:
6
- metadata.gz: 05618d4dd8a1388fb9c63edde0ed6f91616221e8a570ecf307227883f785415d416462874b6235919e76a66055ed220f15d9c1ba24594b85075c70d98de9329e
7
- data.tar.gz: 2b8df5f12fe2597c8c94332a6880b63dd75a348f895e6cd6674ca2dd2ae9a0923e62fdea1357d5f1a1520d0c342bb94599668649edaf2fc1ec9e6d953bf55877
6
+ metadata.gz: f46f9241987ea445ae2fafc85872f74d3bc46a4a784e1edb73d5b757def6c2570eb2e45191a49331a70d9ae85b271d803d14e74e6fd88f26a9213b6a21d61bf9
7
+ data.tar.gz: 1fdb2615e5d8772e7dc1aa07f198ae8bca1c8479a96a77ed4327e839918903190a31975feb8bb73566ac829e32fe2362964e5637c977596e4800c1199583316f
@@ -160,6 +160,18 @@ class CrudController < ApplicationController
160
160
  report_name = "#{@crud_helper.title}_#{DateTime.now.strftime('%Y%m%d')}"
161
161
  respond_to do |format|
162
162
  format.xls { headers["Content-Disposition"] = "attachment; filename=#{report_name}.xls" }
163
+ format.pdf do
164
+ html = render_to_string('crud/listing.pdf.erb')
165
+ File.write('/Users/pedropires/Desktop/test.html', html)
166
+ options = {
167
+ encoding: 'UTF-8',
168
+ page_size: 'A4',
169
+ show_as_html: params[:debug],
170
+ margin: { top: 20, bottom: 20 }
171
+ }
172
+ pdf = WickedPdf.new.pdf_from_string(html, options)
173
+ send_data(pdf, filename: "#{report_name}.pdf", type: "application/pdf", disposition: "inline")
174
+ end
163
175
  end
164
176
  end
165
177
 
@@ -175,7 +175,7 @@ module CrudHelper
175
175
 
176
176
  def render_field_file(field)
177
177
  if imagem?(field) && field.respond_to?(:thumb)
178
- if is_active_action("printing")
178
+ if is_active_action("printing") || is_active_action("listing")
179
179
  pdf_image_tag(field, width: '100px')
180
180
  else
181
181
  image_tag(field.url(:thumb), width: '100px')
@@ -226,6 +226,12 @@ module CrudHelper
226
226
  crud_helper.condition_listing_excel.call(model)
227
227
  end
228
228
 
229
+ def should_listing_pdf?(crud_helper, model)
230
+ return false unless can?(:read, model)
231
+ return true if crud_helper.condition_listing_pdf.nil?
232
+ crud_helper.condition_listing_pdf.call(model)
233
+ end
234
+
229
235
  def can_print_pdf?(crud_helper, record)
230
236
  return false unless can?(:read, record)
231
237
  return true if crud_helper.condition_printing_action.nil?
@@ -7,6 +7,8 @@ class RaroCrud
7
7
  @@form_scripts = {}
8
8
  @@view_fields = {}
9
9
  @@listing_fields = {}
10
+ @@logo_listing_field = {}
11
+ @@titulo_listing_field = {}
10
12
  @@printing_fields = {}
11
13
  @@logo_printing_field = {}
12
14
  @@titulo_printing_field = {}
@@ -27,7 +29,7 @@ class RaroCrud
27
29
  @@condition_listing_action = {}
28
30
  @@condition_listing_excel = {}
29
31
  @@condition_listing_pdf = {}
30
- @@condition_printing_action = {}
32
+ @@condition_printing_action = {}
31
33
  @@options_link = {}
32
34
  @@scopes = {}
33
35
  @@menus = []
@@ -177,6 +179,14 @@ class RaroCrud
177
179
  @@listing_fields[self.to_s.to_sym] || []
178
180
  end
179
181
 
182
+ def self.logo_listing_field
183
+ @@logo_listing_field[self.to_s.to_sym]
184
+ end
185
+
186
+ def self.titulo_listing_field
187
+ @@titulo_listing_field[self.to_s.to_sym]
188
+ end
189
+
180
190
  def self.printing_fields
181
191
  @@printing_fields[self.to_s.to_sym] || []
182
192
  end
@@ -211,157 +221,64 @@ class RaroCrud
211
221
 
212
222
 
213
223
 
214
- private
215
-
216
- def self.modelo
217
- self.to_s.underscore.gsub("_crud", "")
218
- end
219
-
220
- def self.titulo str
221
- @@title[self.to_s.to_sym] = str
222
- end
223
-
224
- def self.subtitulo(str,type)
225
- case type
226
- when :index
227
- @@subtitle_index[self.to_s.to_sym] = str
228
- end
229
- end
230
-
231
- def self.descricao(str,type)
232
- case type
233
- when :index
234
- @@description_index[self.to_s.to_sym] = str
235
- end
236
- end
237
224
 
238
- def self.link_superior opts={}
239
- @@top_links[self.to_s.to_sym] = [] unless @@top_links[self.to_s.to_sym]
240
- @@top_links[self.to_s.to_sym].push(
241
- {
242
- text: opts[:nome],
243
- modelo: self.modelo,
244
- id: opts[:id],
245
- data: {push: 'partial', target: '#form'},
246
- icon: "fa fa-#{opts[:icon]}",
247
- class: 'btn btn-small btn-primary btn-rounded',
248
- link: opts[:link],
249
- url: opts[:url],
250
- can: opts[:can],
251
- partial: opts[:partial]
252
- }
253
- )
254
- end
255
-
256
- def self.campo_tabela nome, opts={}
257
- @@index_fields[self.to_s.to_sym] = [] unless @@index_fields[self.to_s.to_sym]
225
+ def self.campo_visualizacao(nome, opts = {})
226
+ @@view_fields[self.to_s.to_sym] ||= []
258
227
  opts = set_default_label nome, opts
259
- @@index_fields[self.to_s.to_sym].push(
260
- {
261
- attribute: nome
262
- }.merge(opts)
263
- )
264
- end
265
-
266
- def self.ordenar_por nome
267
- @@order_field[self.to_s.to_sym] = nome
268
- end
269
-
270
- def self.itens_por_pagina qtd
271
- @@per_page[self.to_s.to_sym] = qtd
228
+ @@view_fields[self.to_s.to_sym].push({
229
+ attribute: nome,
230
+ sf: opts
231
+ })
272
232
  end
273
233
 
274
- def self.campo_teste nome, opts = {}
275
- @@test_fields[self.to_s.to_sym] = [] unless @@test_fields[self.to_s.to_sym]
276
- @@test_fields[self.to_s.to_sym].push(
277
- {
278
- attribute: nome
279
- }.merge({sf: opts})
280
- )
234
+ def self.campo_busca(nome, opts = {})
235
+ @@search_fields[self.to_s.to_sym] ||= []
236
+ opts = set_default_label nome, opts
237
+ @@search_fields[self.to_s.to_sym].push({
238
+ attribute: nome,
239
+ sf: opts
240
+ })
281
241
  end
282
242
 
283
- def self.campo_formulario nome, opts={}
284
- @@form_fields[self.to_s.to_sym] = [] unless @@form_fields[self.to_s.to_sym]
243
+ def self.relatorio_listagem(nome, opts = {})
244
+ @@listing_fields[self.to_s.to_sym] ||= []
285
245
  opts = set_default_label nome, opts
286
- if opts.present? && opts[:autocomplete].present?
287
- opts[:as] = :autocomplete
288
- label_method = opts[:autocomplete][:label_method] || opts[:autocomplete][:campo]
289
- opts[:url] = Rails.application.routes.url_helpers.autocomplete_crud_path(model: opts[:autocomplete][:classe], campo: opts[:autocomplete][:campo], tipo: "start", label: label_method)
290
- name = "#{opts[:autocomplete][:campo]}_#{opts[:autocomplete][:classe]}"
291
- opts[:input_html] = {name: name, id: name}
292
- opts[:id_element] = "##{self.modelo}_#{nome}_id"
293
- end
294
- if opts.present? && opts[:grupo].present?
295
- opts[:fields] = []
296
- opts[:grupo].each do |field|
297
- attribute = field[:campo]
298
- field.delete(:campo)
299
- add_group_formulario(field) if field[:grupo].present?
300
- opts[:fields].push({attribute: attribute,sf: field})
301
- end
302
- opts[:grupo] = true if opts[:grupo].present?
303
- end
304
- @@form_fields[self.to_s.to_sym].push(
305
- {
306
- attribute: nome
307
- }.merge({sf: opts})
308
- )
309
- if opts.present? && opts[:autocomplete].present?
310
- campo_formulario(nome, {as: :hidden})
311
- end
246
+ @@listing_fields[self.to_s.to_sym].push({
247
+ attribute: nome,
248
+ sf: opts
249
+ })
312
250
  end
313
251
 
314
- def self.add_group_formulario(field)
315
- field[:fields] = []
316
- field[:grupo].each do |f|
317
- attribute = f[:campo]
318
- f.delete(:campo)
319
- add_group_formulario(f) if f[:grupo].present?
320
- field[:fields].push({attribute: attribute, sf: f})
252
+ def self.relatorio_listagem_logo(proc = nil, options = {})
253
+ url = nil
254
+ logo_proc = nil
255
+ if proc.respond_to?(:call)
256
+ logo_proc = proc
257
+ else
258
+ url = Templus.logo
321
259
  end
322
- field[:grupo] = true
323
- end
324
260
 
325
- def self.set_default_label nome, opts
326
- unless opts[:label].present?
327
- opts[:label] = "simple_form.labels.#{self.modelo.underscore}.#{nome}"
328
- end
329
- opts
261
+ @@logo_listing_field[self.to_s.to_sym] = {
262
+ url: url,
263
+ logo_proc: logo_proc,
264
+ sf: options
265
+ }
330
266
  end
331
267
 
268
+ def self.relatorio_listagem_titulo(string_or_proc)
269
+ titulo_proc = nil
270
+ titulo = nil
332
271
 
272
+ if string_or_proc.respond_to?(:call)
273
+ titulo_proc = string_or_proc
274
+ elsif string_or_proc.is_a?(String)
275
+ titulo = string_or_proc
276
+ end
333
277
 
334
-
335
- public
336
-
337
- def self.campo_visualizacao(nome, opts = {})
338
- @@view_fields[self.to_s.to_sym] ||= []
339
- opts = set_default_label nome, opts
340
- @@view_fields[self.to_s.to_sym].push(
341
- {
342
- attribute: nome
343
- }.merge({sf: opts})
344
- )
345
- end
346
-
347
- def self.campo_busca(nome, opts = {})
348
- @@search_fields[self.to_s.to_sym] ||= []
349
- opts = set_default_label nome, opts
350
- @@search_fields[self.to_s.to_sym].push(
351
- {
352
- attribute: nome
353
- }.merge({sf: opts})
354
- )
355
- end
356
-
357
- def self.relatorio_listagem(nome, opts = {})
358
- @@listing_fields[self.to_s.to_sym] ||= []
359
- opts = set_default_label nome, opts
360
- @@listing_fields[self.to_s.to_sym].push(
361
- {
362
- attribute: nome
363
- }.merge({sf: opts})
364
- )
278
+ @@titulo_listing_field[self.to_s.to_sym] = {
279
+ titulo_proc: titulo_proc,
280
+ titulo: titulo
281
+ }
365
282
  end
366
283
 
367
284
  def self.relatorio_impressao(nome, opts = {})
@@ -520,4 +437,123 @@ class RaroCrud
520
437
  @@form_scripts[self.to_s.to_sym] << script.to_s
521
438
  end
522
439
 
440
+
441
+
442
+ private
443
+
444
+ def self.modelo
445
+ self.to_s.underscore.gsub("_crud", "")
446
+ end
447
+
448
+ def self.titulo str
449
+ @@title[self.to_s.to_sym] = str
450
+ end
451
+
452
+ def self.subtitulo(str,type)
453
+ case type
454
+ when :index
455
+ @@subtitle_index[self.to_s.to_sym] = str
456
+ end
457
+ end
458
+
459
+ def self.descricao(str,type)
460
+ case type
461
+ when :index
462
+ @@description_index[self.to_s.to_sym] = str
463
+ end
464
+ end
465
+
466
+ def self.link_superior opts={}
467
+ @@top_links[self.to_s.to_sym] = [] unless @@top_links[self.to_s.to_sym]
468
+ @@top_links[self.to_s.to_sym].push(
469
+ {
470
+ text: opts[:nome],
471
+ modelo: self.modelo,
472
+ id: opts[:id],
473
+ data: {push: 'partial', target: '#form'},
474
+ icon: "fa fa-#{opts[:icon]}",
475
+ class: 'btn btn-small btn-primary btn-rounded',
476
+ link: opts[:link],
477
+ url: opts[:url],
478
+ can: opts[:can],
479
+ partial: opts[:partial]
480
+ }
481
+ )
482
+ end
483
+
484
+ def self.campo_tabela nome, opts={}
485
+ @@index_fields[self.to_s.to_sym] = [] unless @@index_fields[self.to_s.to_sym]
486
+ opts = set_default_label nome, opts
487
+ @@index_fields[self.to_s.to_sym].push(
488
+ {
489
+ attribute: nome
490
+ }.merge(opts)
491
+ )
492
+ end
493
+
494
+ def self.ordenar_por nome
495
+ @@order_field[self.to_s.to_sym] = nome
496
+ end
497
+
498
+ def self.itens_por_pagina qtd
499
+ @@per_page[self.to_s.to_sym] = qtd
500
+ end
501
+
502
+ def self.campo_teste nome, opts = {}
503
+ @@test_fields[self.to_s.to_sym] = [] unless @@test_fields[self.to_s.to_sym]
504
+ @@test_fields[self.to_s.to_sym].push(
505
+ {
506
+ attribute: nome
507
+ }.merge({sf: opts})
508
+ )
509
+ end
510
+
511
+ def self.campo_formulario nome, opts={}
512
+ @@form_fields[self.to_s.to_sym] = [] unless @@form_fields[self.to_s.to_sym]
513
+ opts = set_default_label nome, opts
514
+ if opts.present? && opts[:autocomplete].present?
515
+ opts[:as] = :autocomplete
516
+ label_method = opts[:autocomplete][:label_method] || opts[:autocomplete][:campo]
517
+ opts[:url] = Rails.application.routes.url_helpers.autocomplete_crud_path(model: opts[:autocomplete][:classe], campo: opts[:autocomplete][:campo], tipo: "start", label: label_method)
518
+ name = "#{opts[:autocomplete][:campo]}_#{opts[:autocomplete][:classe]}"
519
+ opts[:input_html] = {name: name, id: name}
520
+ opts[:id_element] = "##{self.modelo}_#{nome}_id"
521
+ end
522
+ if opts.present? && opts[:grupo].present?
523
+ opts[:fields] = []
524
+ opts[:grupo].each do |field|
525
+ attribute = field[:campo]
526
+ field.delete(:campo)
527
+ add_group_formulario(field) if field[:grupo].present?
528
+ opts[:fields].push({attribute: attribute,sf: field})
529
+ end
530
+ opts[:grupo] = true if opts[:grupo].present?
531
+ end
532
+ @@form_fields[self.to_s.to_sym].push(
533
+ {
534
+ attribute: nome
535
+ }.merge({sf: opts})
536
+ )
537
+ if opts.present? && opts[:autocomplete].present?
538
+ campo_formulario(nome, {as: :hidden})
539
+ end
540
+ end
541
+
542
+ def self.add_group_formulario(field)
543
+ field[:fields] = []
544
+ field[:grupo].each do |f|
545
+ attribute = f[:campo]
546
+ f.delete(:campo)
547
+ add_group_formulario(f) if f[:grupo].present?
548
+ field[:fields].push({attribute: attribute, sf: f})
549
+ end
550
+ field[:grupo] = true
551
+ end
552
+
553
+ def self.set_default_label nome, opts
554
+ unless opts[:label].present?
555
+ opts[:label] = "simple_form.labels.#{self.modelo.underscore}.#{nome}"
556
+ end
557
+ opts
558
+ end
523
559
  end
@@ -26,30 +26,42 @@
26
26
  <% end %>
27
27
 
28
28
 
29
- <% if (@crud_helper.present? && (is_action_index? || is_action_query?)) %>
29
+ <% if @crud_helper.present? && (is_action_index? || is_action_query?) %>
30
30
  <div class="pull-right actions">
31
31
  <% @crud_helper.top_links.each do |link| %>
32
32
  <% if link[:can].present? %>
33
- <%= render_link(link,@clean_url) if self.instance_eval &link[:can] %>
33
+ <%= render_link(link, @clean_url) if self.instance_eval(&link[:can]) %>
34
34
  <% else %>
35
- <%= render_link(link,@clean_url) %>
35
+ <%= render_link(link, @clean_url) %>
36
36
  <% end %>
37
37
  <% end %>
38
38
  <% if params[:associacao] %>
39
- <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model_permission) && should_listing_excel?(@crud_helper, @model_permission) %>
39
+ <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model_permission) %>
40
+
40
41
  <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
41
42
  <%= I18n.t("devise.reports.excel").html_safe %>
42
- <% end %>
43
+ <% end if should_listing_excel?(@crud_helper, @model_permission) %>
44
+
45
+ <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], q: params[:q], format: :pdf), class: "btn btn-success btn-rounded", target: '_blank' do %>
46
+ <%= I18n.t("devise.reports.pdf").html_safe %>
47
+ <% end if should_listing_pdf?(@crud_helper, @model_permission) %>
48
+
43
49
  <% end %>
44
50
  <% else %>
45
- <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model) && should_listing_excel?(@crud_helper, @model) %>
51
+ <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model) %>
52
+
46
53
  <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
47
54
  <%= I18n.t("devise.reports.excel").html_safe %>
48
- <% end %>
55
+ <% end if should_listing_excel?(@crud_helper, @model) %>
56
+
57
+ <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], target: '_blank', format: :pdf), class: "btn btn-success btn-rounded", target: '_blank' do %>
58
+ <%= I18n.t("devise.reports.pdf").html_safe %>
59
+ <% end if should_listing_pdf?(@crud_helper, @model) %>
60
+
49
61
  <% end %>
50
62
  <% end %>
51
63
  <% if @crud_helper.search_fields.present? %>
52
- <button id="button_search_<%=@model.name.underscore%>" class="btn btn-warning btn-rounded" data-toggle="modal" data-target="#modal_search">
64
+ <button id="button_search_<%= @model.name.underscore %>" class="btn btn-warning btn-rounded" data-toggle="modal" data-target="#modal_search">
53
65
  <i class="fa fa-search"></i>
54
66
  </button>
55
67
  <% end %>
@@ -0,0 +1,118 @@
1
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
2
+
3
+ <div class="widget-box" id="relatorio">
4
+ <div class="widget-body">
5
+ <div class="widget-main">
6
+ <div class="profile-element">
7
+
8
+ <div>
9
+ <div class="row">
10
+ <% if @crud_helper.logo_listing_field.present? %>
11
+ <div class="col-xs-3">
12
+ <% if @crud_helper.logo_listing_field[:logo_proc].present? %>
13
+ <%= render_field_file(@crud_helper.logo_listing_field[:logo_proc].call(@records)) %>
14
+ <% elsif @crud_helper.logo_listing_field[:url].present? %>
15
+ <%= pdf_image_tag(@crud_helper.logo_listing_field[:url], width: '100px') %>
16
+ <% end %>
17
+ </div>
18
+ <% end %>
19
+
20
+ <% if @crud_helper.titulo_listing_field.present? %>
21
+ <div class="col-xs-9">
22
+ <h1>
23
+ <% if @crud_helper.titulo_listing_field[:titulo].present? %>
24
+ <%= t(@crud_helper.titulo_listing_field[:titulo]) %>
25
+ <% elsif @crud_helper.titulo_listing_field[:titulo_proc].present? %>
26
+ <%= @crud_helper.titulo_listing_field[:titulo_proc].call(@records) %>
27
+ <% else %>
28
+ <%= Templus.nome_aplicacao %>
29
+ <% end %>
30
+ </h1>
31
+ </div>
32
+ <% end %>
33
+ </div>
34
+ </div>
35
+ </div>
36
+
37
+ <div style="clear: both;"></div>
38
+
39
+ <div class="row">
40
+ <div class="col-lg-12">
41
+ <h2>
42
+ <small><%= @crud_helper.title %></small><br />
43
+ </h2>
44
+ </div>
45
+ </div>
46
+
47
+
48
+ <table class="table table-bordered table-striped">
49
+ <thead>
50
+ <tr>
51
+ <% @crud_helper.listing_fields.each do |att| %>
52
+ <% next if att[:sf][:only] == :excel %>
53
+
54
+ <% if !att[:visible_if].nil? %>
55
+ <% if ((att[:visible_if].class == Proc && !att[:visible_if].call(att)) || (att[:visible_if].class != Proc && !att[:visible_if])) %>
56
+ <% next %>
57
+ <% end %>
58
+ <% end %>
59
+ <th><%= I18n.t(att[:sf][:label]) %></th>
60
+ <% end %>
61
+ </tr>
62
+ </thead>
63
+ <tbody>
64
+ <% @records.each do |record| %>
65
+ <tr>
66
+ <% @crud_helper.listing_fields.each do |att| %>
67
+ <% next if att[:sf][:only] == :excel %>
68
+
69
+ <% if record.send(att[:attribute]).present? || record.send(att[:attribute]).to_s == "false" %>
70
+ <% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type)%>
71
+ <% if att[:date_format].present?%>
72
+ <td><%= record.send(att[:attribute]).strftime(att[:date_format]) %></td>
73
+ <% else %>
74
+ <td><%= l record.send(att[:attribute]) %></td>
75
+ <% end %>
76
+ <% elsif array?(record, att[:attribute]) || (association?(@model, att[:attribute]) && !belongs_to_association?(@model, att[:attribute]) && !has_one_association?(@model, att[:attribute])) %>
77
+ <td><%= record.send(att[:attribute]).map{|rec| rec.to_s}.join(",") %></td>
78
+ <% elsif boolean?(record, att[:attribute]) %>
79
+ <td><%= I18n.t(record.send(att[:attribute]) ? "shared.sim" : "shared.nao") %></td>
80
+ <% elsif possui_url?(record, att[:attribute]) %>
81
+ <% if deve_renderizar_imagem?(att[:sf]) %>
82
+ <td><%= render_field_file(record.send(att[:attribute])) %></td>
83
+ <% else %>
84
+ <td><%= record.send(att[:attribute]).url %></td>
85
+ <% end %>
86
+ <% elsif att[:sf][:label_method].present? %>
87
+ <td><%= record.send(att[:attribute]).send(att[:sf][:label_method]).to_s %></td>
88
+ <% else %>
89
+ <td><%= record.send(att[:attribute]).to_s %></td>
90
+ <% end %>
91
+ <% else %>
92
+ <td></td>
93
+ <% end %>
94
+ <% end %>
95
+ </tr>
96
+ <% end %>
97
+ </tbody>
98
+ </table>
99
+ </div>
100
+ </div>
101
+ </div>
102
+
103
+ <style>
104
+ #relatorio {
105
+ clear: both;
106
+ page-break-inside: avoid;
107
+ }
108
+ .header {
109
+ float: left;
110
+ }
111
+ table {
112
+ font-size: 0.75em;
113
+ }
114
+ thead { display: table-header-group }
115
+ tfoot { display: table-row-group }
116
+ tr { page-break-inside: avoid }
117
+ h1 { padding-bottom: 20px; }
118
+ </style>
@@ -8,6 +8,8 @@ xmlns:html="http://www.w3.org/TR/REC-html40">
8
8
  <Table>
9
9
  <Row>
10
10
  <% @crud_helper.listing_fields.each do |att| %>
11
+ <% next if att[:sf][:only] == :pdf %>
12
+
11
13
  <% if !att[:visible_if].nil?%>
12
14
  <% if ((att[:visible_if].class == Proc && !att[:visible_if].call(att)) || (att[:visible_if].class != Proc && !att[:visible_if])) %>
13
15
  <% next %>
@@ -19,6 +21,8 @@ xmlns:html="http://www.w3.org/TR/REC-html40">
19
21
  <% @records.each do |record| %>
20
22
  <Row>
21
23
  <% @crud_helper.listing_fields.each do |att| %>
24
+ <% next if att[:sf][:only] == :pdf %>
25
+
22
26
  <% if record.send(att[:attribute]).present? || record.send(att[:attribute]).to_s == "false" %>
23
27
  <% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type) %>
24
28
  <% if att[:date_format].present?%>
@@ -4,6 +4,7 @@
4
4
  <div class="widget-body">
5
5
  <div class="widget-main">
6
6
  <div class="profile-element">
7
+
7
8
  <div>
8
9
  <div class="row">
9
10
  <% if @crud_helper.logo_printing_field.present? %>
@@ -1,3 +1,3 @@
1
1
  module TemplusModels
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: templus_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Sol
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-28 00:00:00.000000000 Z
13
+ date: 2017-04-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -176,6 +176,7 @@ files:
176
176
  - app/views/crud/create.js.erb
177
177
  - app/views/crud/edit.html.erb
178
178
  - app/views/crud/index.html.erb
179
+ - app/views/crud/listing.pdf.erb
179
180
  - app/views/crud/listing.xls.erb
180
181
  - app/views/crud/mensagens/_avisos.html.erb
181
182
  - app/views/crud/mensagens/_erros_formulario.html.erb